Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
FLP_INFOLOGGER_URL: "${ALI_ECS_GUI_URL:-http://localhost:8081}"
QC_GUI_URL: "${ALI_ECS_GUI_URL:-http://localhost:8082}"
ALI_FLP_INDEX_URL: "${ALI_ECS_GUI_URL:-http://localhost:80}"
ALICE_INSIGHTS_URL: "${ALICE_INSIGHTS_URL:-}"
CCDB_ENABLE_SYNCHRONIZATION: "${CCDB_ENABLE_SYNCHRONIZATION:-false}"
CCDB_RUN_INFO_URL: "${CCDB_RUN_INFO_URL:-}"
links:
Expand Down
12 changes: 12 additions & 0 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ The following configuration items can be set using environment variables, note t
| OPENID_SECRET | Application secret | |
| OPENID_REDIRECT | Authentication callback | |
| OPENID_WELL_KNOWN | So-called "well-known" endpoint defining OpenID configuration. | https://auth.cern.ch/auth/realms/cern/.well-known/openid-configuration |

## Presentations

| Variable name | Description | Default value |
|---------------|-------------|---------------|
| `ALICE_INSIGHTS_URL` | The HTTP(S) origin of the ALICE Insights generation service, reachable from the Bookkeeping backend. Bookkeeping sends generation requests to `/presentations` on this origin. | Unset |

In Docker Compose, set `ALICE_INSIGHTS_URL` in the `.env` file to an origin the `application` container can reach. For a native Bookkeeping process, set it in that process's environment. The browser uses Bookkeeping's API for both templates and downloads.

Open **Presentations** in the Bookkeeping navigation, choose a reporting period and a template, then select **Generate presentation**. The page offers **Download PDF** when the file is ready. Apply Bookkeeping's template migration and seeders for a local installation with example templates.

The API tests run Bookkeeping against a loopback stand-in for ALICE Insights and check the forwarded request and download. The browser tests use the seeded template list and simulate successful downloads and generation errors.
3 changes: 3 additions & 0 deletions lib/config/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const {

exports.services = {
enableHousekeeping: process.env?.ENABLE_HOUSEKEEPING?.toLowerCase() === 'true',
aliceInsights: {
url: process.env?.ALICE_INSIGHTS_URL || null,
},
userCertificate: {
path: USER_CERTIFICATE_PATH ?? MONALISA_CERTIFICATE_PATH,
passphrase: USER_CERTIFICATE_PASSPHRASE ?? MONALISA_CERTIFICATE_PASSPHRASE,
Expand Down
51 changes: 51 additions & 0 deletions lib/database/adapters/TemplateAdapter.js
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 templates
*/
class TemplateAdapter {
/**
* Constructor
*/
constructor() {
this.toEntity = this.toEntity.bind(this);

/**
* @type {TemplateModuleAdapter|null}
*/
this.templateModuleAdapter = null;
}

/**
* Converts the given database object to an entity object.
*
* @param {SequelizeTemplate} databaseObject Object to convert.
* @returns {Template} Converted entity object.
*/
toEntity({ id, name, title, description, modules }) {
const entityObject = {
id,
name,
title,
description,
};

if (modules) {
entityObject.modules = modules.map(this.templateModuleAdapter.toEntity);
}

return entityObject;
}
}

module.exports = TemplateAdapter;
40 changes: 40 additions & 0 deletions lib/database/adapters/TemplateModuleAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @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 template modules
*/
class TemplateModuleAdapter {
/**
* Constructor
*/
constructor() {
this.toEntity = this.toEntity.bind(this);
}

/**
* Converts the given database object to an entity object.
*
* @param {SequelizeTemplateModule} databaseObject Object to convert.
* @returns {TemplateModule} Converted entity object.
*/
toEntity({ position, type, title, options }) {
return {
position,
type,
title,
options,
};
}
}

module.exports = TemplateModuleAdapter;
7 changes: 7 additions & 0 deletions lib/database/adapters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const RunTypeAdapter = require('./RunTypeAdapter');
const SimulationPassAdapter = require('./SimulationPassAdapter.js');
const { SimulationPassQcFlagAdapter } = require('./SimulationPassQcFlagAdapter');
const TagAdapter = require('./TagAdapter');
const TemplateAdapter = require('./TemplateAdapter.js');
const TemplateModuleAdapter = require('./TemplateModuleAdapter.js');
const { CtpTriggerCountersAdapter } = require('./CtpTriggerCountersAdapter');
const UserAdapter = require('./UserAdapter');

Expand Down Expand Up @@ -82,6 +84,8 @@ const runTypeAdapter = new RunTypeAdapter();
const simulationPassAdapter = new SimulationPassAdapter();
const simulationPassQcFlagAdapter = new SimulationPassQcFlagAdapter();
const tagAdapter = new TagAdapter();
const templateAdapter = new TemplateAdapter();
const templateModuleAdapter = new TemplateModuleAdapter();
const ctpTriggerCountersAdapter = new CtpTriggerCountersAdapter();
const userAdapter = new UserAdapter();

Expand Down Expand Up @@ -144,6 +148,7 @@ runAdapter.tagAdapter = tagAdapter;
runAdapter.userAdapter = userAdapter;

tagAdapter.userAdapter = userAdapter;
templateAdapter.templateModuleAdapter = templateModuleAdapter;
runAdapter.qcFlagAdapter = qcFlagAdapter;

simulationPassQcFlagAdapter.simulationPassAdapter = simulationPassAdapter;
Expand Down Expand Up @@ -183,6 +188,8 @@ module.exports = {
simulationPassAdapter,
simulationPassQcFlagAdapter,
tagAdapter,
templateAdapter,
templateModuleAdapter,
ctpTriggerCountersAdapter,
userAdapter,
};
105 changes: 105 additions & 0 deletions lib/database/migrations/v1/20261028100000-create-templates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/**
* @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('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('template_modules', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
template_id: {
allowNull: false,
type: Sequelize.INTEGER,
references: { model: '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),
},
options: {
allowNull: false,
type: Sequelize.JSON,
},
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('template_modules', {
fields: ['template_id', 'position'],
type: 'unique',
name: 'template_modules_template_id_position',
transaction,
});
}),

down: async (queryInterface) => queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.dropTable('template_modules', { transaction });
await queryInterface.dropTable('templates', { transaction });
}),
};
4 changes: 4 additions & 0 deletions lib/database/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const SimulationPass = require('./simulationPass.js');
const SimulationPassQcFlag = require('./simulationPassQcFlag.js');
const StableBeamRun = require('./stableBeamsRun.js');
const Tag = require('./tag');
const Template = require('./template.js');
const TemplateModule = require('./templateModule.js');
const CtpTriggerCounters = require('./ctpTriggerCounters');
const User = require('./user');

Expand Down Expand Up @@ -84,6 +86,8 @@ module.exports = (sequelize) => {
SimulationPassQcFlag: SimulationPassQcFlag(sequelize),
StableBeamRun: StableBeamRun(sequelize),
Tag: Tag(sequelize),
Template: Template(sequelize),
TemplateModule: TemplateModule(sequelize),
CtpTriggerCounters: CtpTriggerCounters(sequelize),
User: User(sequelize),
};
Expand Down
41 changes: 41 additions & 0 deletions lib/database/models/template.js
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 Template = sequelize.define('Template', {
name: {
allowNull: false,
unique: true,
type: Sequelize.STRING(64),
},
title: {
allowNull: false,
type: Sequelize.STRING(255),
},
description: {
allowNull: true,
type: Sequelize.TEXT,
},
});

Template.associate = (models) => {
Template.hasMany(models.TemplateModule, {
as: 'modules',
foreignKey: 'templateId',
});
};

return Template;
};
48 changes: 48 additions & 0 deletions lib/database/models/templateModule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* @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 TemplateModule = sequelize.define('TemplateModule', {
templateId: {
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),
},
options: {
allowNull: false,
type: Sequelize.JSON,
},
});

TemplateModule.associate = (models) => {
TemplateModule.belongsTo(models.Template, {
as: 'template',
foreignKey: 'templateId',
});
};

return TemplateModule;
};
Loading