Repository navigation
Connect the Presentations page, the presentation templates and the generation service #2322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kaymeer
wants to merge
15
commits into
alice-insights/dev
Choose a base branch
from
alice-insights/connect-presentations
base: alice-insights/dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
aadb067
Add tables and example data for presentation templates
kaymeer 6307710
Add endpoints to read presentation templates
kaymeer 023056d
Document the template endpoints in the HTTP API documentation
kaymeer eb2f389
feat: request presentation PDFs through Bookkeeping
Remzi1993 2a30c9c
feat: add the Bookkeeping Presentations page
Remzi1993 f75345e
test: cover the presentation API and generation client
Remzi1993 ec356a0
test: cover the Presentations page and PDF download
Remzi1993 6fa9162
docs: describe presentation generation and its configuration
Remzi1993 e464333
test: reproduce navbar overflow with the Presentations tab
Remzi1993 a1d99f5
fix: fit the expanded navbar on laptop screens
Remzi1993 162450b
Rename templates to presentation templates and drop the unused module…
kaymeer 641ef65
Start the week of the period picker on the same Monday in every time …
kaymeer 3ef5ece
Read the period as Geneva time and drop a finished download when the …
kaymeer 63a1b29
Show the error sentence of the generation service and log why no pres…
kaymeer 3e9b487
Explain on the Presentations page which fills and runs a presentation…
kaymeer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE O2. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
| /** | ||
| * Adapter for presentation templates | ||
| */ | ||
| class PresentationTemplateAdapter { | ||
| /** | ||
| * Constructor | ||
| */ | ||
| constructor() { | ||
| this.toEntity = this.toEntity.bind(this); | ||
|
|
||
| /** | ||
| * @type {PresentationTemplateModuleAdapter|null} | ||
| */ | ||
| this.presentationTemplateModuleAdapter = null; | ||
| } | ||
|
|
||
| /** | ||
| * Converts the given database object to an entity object. | ||
| * | ||
| * @param {SequelizePresentationTemplate} databaseObject Object to convert. | ||
| * @returns {PresentationTemplate} Converted entity object. | ||
| */ | ||
| toEntity({ id, name, title, description, modules }) { | ||
| const entityObject = { | ||
| id, | ||
| name, | ||
| title, | ||
| description, | ||
| }; | ||
|
|
||
| if (modules) { | ||
| entityObject.modules = modules.map(this.presentationTemplateModuleAdapter.toEntity); | ||
| } | ||
|
|
||
| return entityObject; | ||
| } | ||
| } | ||
|
|
||
| module.exports = PresentationTemplateAdapter; |
39 changes: 39 additions & 0 deletions
39
lib/database/adapters/PresentationTemplateModuleAdapter.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE O2. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
| /** | ||
| * Adapter for the modules of presentation templates | ||
| */ | ||
| class PresentationTemplateModuleAdapter { | ||
| /** | ||
| * Constructor | ||
| */ | ||
| constructor() { | ||
| this.toEntity = this.toEntity.bind(this); | ||
| } | ||
|
|
||
| /** | ||
| * Converts the given database object to an entity object. | ||
| * | ||
| * @param {SequelizePresentationTemplateModule} databaseObject Object to convert. | ||
| * @returns {PresentationTemplateModule} Converted entity object. | ||
| */ | ||
| toEntity({ position, type, title }) { | ||
| return { | ||
| position, | ||
| type, | ||
| title, | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| module.exports = PresentationTemplateModuleAdapter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
lib/database/migrations/v1/20261028100000-create-presentation-templates.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE O2. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| 'use strict'; | ||
|
|
||
| /** @type {import('sequelize-cli').Migration} */ | ||
| module.exports = { | ||
| up: async (queryInterface, Sequelize) => queryInterface.sequelize.transaction(async (transaction) => { | ||
| await queryInterface.createTable('presentation_templates', { | ||
| id: { | ||
| allowNull: false, | ||
| autoIncrement: true, | ||
| primaryKey: true, | ||
| type: Sequelize.INTEGER, | ||
| }, | ||
| name: { | ||
| allowNull: false, | ||
| unique: true, | ||
| type: Sequelize.STRING(64), | ||
| }, | ||
| title: { | ||
| allowNull: false, | ||
| type: Sequelize.STRING(255), | ||
| }, | ||
| description: { | ||
| allowNull: true, | ||
| type: Sequelize.TEXT, | ||
| }, | ||
| created_at: { | ||
| allowNull: false, | ||
| type: Sequelize.DATE, | ||
| defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'), | ||
| }, | ||
| updated_at: { | ||
| allowNull: false, | ||
| type: Sequelize.DATE, | ||
| defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), | ||
| }, | ||
| }, { transaction }); | ||
|
|
||
| await queryInterface.createTable('presentation_template_modules', { | ||
| id: { | ||
| allowNull: false, | ||
| autoIncrement: true, | ||
| primaryKey: true, | ||
| type: Sequelize.INTEGER, | ||
| }, | ||
| presentation_template_id: { | ||
| allowNull: false, | ||
| type: Sequelize.INTEGER, | ||
| references: { model: 'presentation_templates', key: 'id' }, | ||
| onUpdate: 'CASCADE', | ||
| onDelete: 'CASCADE', | ||
| }, | ||
| position: { | ||
| allowNull: false, | ||
| type: Sequelize.INTEGER, | ||
| }, | ||
| type: { | ||
| allowNull: false, | ||
| type: Sequelize.STRING(64), | ||
| }, | ||
| title: { | ||
| allowNull: true, | ||
| type: Sequelize.STRING(255), | ||
| }, | ||
| created_at: { | ||
| allowNull: false, | ||
| type: Sequelize.DATE, | ||
| defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'), | ||
| }, | ||
| updated_at: { | ||
| allowNull: false, | ||
| type: Sequelize.DATE, | ||
| defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), | ||
| }, | ||
| }, { transaction }); | ||
|
|
||
| await queryInterface.addConstraint('presentation_template_modules', { | ||
| fields: ['presentation_template_id', 'position'], | ||
| type: 'unique', | ||
| name: 'presentation_template_modules_position', | ||
| transaction, | ||
| }); | ||
| }), | ||
|
|
||
| down: async (queryInterface) => queryInterface.sequelize.transaction(async (transaction) => { | ||
| await queryInterface.dropTable('presentation_template_modules', { transaction }); | ||
| await queryInterface.dropTable('presentation_templates', { transaction }); | ||
| }), | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE O2. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| const Sequelize = require('sequelize'); | ||
|
|
||
| module.exports = (sequelize) => { | ||
| const PresentationTemplate = sequelize.define('PresentationTemplate', { | ||
| name: { | ||
| allowNull: false, | ||
| unique: true, | ||
| type: Sequelize.STRING(64), | ||
| }, | ||
| title: { | ||
| allowNull: false, | ||
| type: Sequelize.STRING(255), | ||
| }, | ||
| description: { | ||
| allowNull: true, | ||
| type: Sequelize.TEXT, | ||
| }, | ||
| }); | ||
|
|
||
| PresentationTemplate.associate = (models) => { | ||
| PresentationTemplate.hasMany(models.PresentationTemplateModule, { | ||
| as: 'modules', | ||
| foreignKey: 'presentationTemplateId', | ||
| }); | ||
| }; | ||
|
|
||
| return PresentationTemplate; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE O2. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| const Sequelize = require('sequelize'); | ||
|
|
||
| module.exports = (sequelize) => { | ||
| const PresentationTemplateModule = sequelize.define('PresentationTemplateModule', { | ||
| presentationTemplateId: { | ||
| allowNull: false, | ||
| type: Sequelize.INTEGER, | ||
| }, | ||
| position: { | ||
| allowNull: false, | ||
| type: Sequelize.INTEGER, | ||
| }, | ||
| type: { | ||
| allowNull: false, | ||
| type: Sequelize.STRING(64), | ||
| }, | ||
| title: { | ||
| allowNull: true, | ||
| type: Sequelize.STRING(255), | ||
| }, | ||
| }); | ||
|
|
||
| PresentationTemplateModule.associate = (models) => { | ||
| PresentationTemplateModule.belongsTo(models.PresentationTemplate, { | ||
| as: 'presentationTemplate', | ||
| foreignKey: 'presentationTemplateId', | ||
| }); | ||
| }; | ||
|
|
||
| return PresentationTemplateModule; | ||
| }; |
24 changes: 24 additions & 0 deletions
24
lib/database/models/typedefs/SequelizePresentationTemplate.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE O2. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| /** | ||
| * @typedef SequelizePresentationTemplate | ||
| * | ||
| * @property {number} id | ||
| * @property {string} name | ||
| * @property {string} title | ||
| * @property {string|null} description | ||
| * @property {SequelizePresentationTemplateModule[]} [modules] | ||
| * @property {string} createdAt | ||
| * @property {string} updatedAt | ||
| */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we keep the migration from #2308 and add a follow-up migration that renames the existing tables and columns?
I tested the merge order described in this PR with the two seeded templates and a custom template containing two modules. The migration completed successfully, but the template list came back empty. All three templates and their modules were still in the old tables.
Since #2308 is meant to merge first, could we add an upgrade test that verifies the same template IDs, titles and ordered modules are still available afterwards? The fresh-database path already works.
Status: High priority
Reason: After upgrading from #2308, the template picker is empty. Existing templates and their modules remain in the old tables and become inaccessible through the page.