Skip to content

Commit

Permalink
[O2B-913] Add infologger links (#1196)
Browse files Browse the repository at this point in the history
* [O2B-913] Add infologger links

* Fix linter

* Simplify configuration controller
  • Loading branch information
martinboulais authored Oct 17, 2023
1 parent 03e08cf commit 1a09b57
Show file tree
Hide file tree
Showing 20 changed files with 360 additions and 109 deletions.
4 changes: 2 additions & 2 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const { webUiServer } = require('./server');
const { gRPCServer } = require('./server/index.js');
const { GRPCConfig } = require('./config');
const { handleLostRunsAndEnvironments } = require('./server/services/housekeeping/handleLostRunsAndEnvironments.js');
const { services } = require('./config/services.js');
const { ServicesConfig } = require('./config/index.js');

/**
* Bookkeeping Application
Expand Down Expand Up @@ -57,7 +57,7 @@ class BookkeepingApplication {
await this.gRPCServer.listen(gRPCOrigin);
}

if (services.enableHousekeeping) {
if (ServicesConfig.enableHousekeeping) {
// Start background housekeeping
setInterval(async () => {
try {
Expand Down
2 changes: 2 additions & 0 deletions lib/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const notification = require('./notification');
const httpConfig = require('./httpConfig.js');
const apiConfig = require('./apiConfig.js');
const gRPC = require('./gRPCConfig.js');
const { services } = require('./services.js');

module.exports = {
DatabaseConfig: database,
Expand All @@ -27,4 +28,5 @@ module.exports = {
HttpConfig: httpConfig,
ApiConfig: apiConfig,
GRPCConfig: gRPC,
ServicesConfig: services,
};
19 changes: 18 additions & 1 deletion lib/config/services.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
const { origin } = require('./httpConfig.js');

/**
* Return the given origin with a different port
*
* @param {string} origin the origin to change port from
* @param {number} port the new port to apply
* @return {string} the new URL
*/
const changeOriginPort = (origin, port) => origin.replace(/(\/\/[a-zA-Z0-9-.]+:)\d+/, (_, match) => `${match}${port}`);

exports.services = {
enableHousekeeping: process.env?.ENABLE_HOUSEKEEPING ?? false,
aliEcsGUI: {
url: process.env?.ALI_ECS_GUI_URL || origin.replace(/(\/\/[a-zA-Z0-9-.]+:)\d+/, (_, match) => `${match}8080`),
url: process.env?.ALI_ECS_GUI_URL || changeOriginPort(origin, 8080),
token: process.env?.ALI_ECS_GUI_TOKEN,
},
infologger: {
flp: {
url: process.env?.FLP_INFOLOGGER_URL || changeOriginPort(origin, 8081),
},
epn: {
url: process.env?.EPN_INFOLOGGER_URL || null,
},
},
};
2 changes: 1 addition & 1 deletion lib/presentation/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
*/

/**
* @typedef {(vnode|string|Array<(vnode|string)>|null)} Component
* @typedef {(vnode|string|number|Array<(vnode|string|number)>|null)} Component
*/
4 changes: 4 additions & 0 deletions lib/public/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ html, body {
background-color: rgba(0, 0, 0, 0.075);
}

th.text-center, td.text-center {
text-align: center;
}

/* alerts */

.alert {
Expand Down
1 change: 1 addition & 0 deletions lib/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<link rel="stylesheet" href="/app.css">
</head>

<script src="api/configuration.js" type="module"></script>
<script src="index.js" type="module"></script>
<!-- ----------------------------------------------------------------------------------- -->
<!-- CodeMirror -->
Expand Down
41 changes: 41 additions & 0 deletions lib/public/services/externalRouting/getInfologgerLink.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 { CONFIGURATION: { FLP_INFOLOGGER_URL, EPN_INFOLOGGER_URL } } = window;

/**
* Format the infologger URLs (FLP and EPN) with specific filters
*
* @param {object} filter the filter to apply to infologger
* @param {string} [filter.environmentId] the id of environment to filter on (partition)
* @param {number} [filter.runNumber] the runNumber of the run to filter on
* @return {{flp: (string|null), epn: (string|null)}} the infologger URLs (null if no infologger is configured for the given type)
*/
export const getInfologgerLink = ({ environmentId, runNumber }) => {
const queryObject = {};
if (environmentId) {
queryObject.partition = { match: environmentId };
}

if (runNumber) {
queryObject.run = { match: runNumber };
}

// eslint-disable-next-line require-jsdoc
const formatUrl = (origin) => origin ? `${origin}?q=${JSON.stringify(queryObject)}` : null;

return {
flp: formatUrl(FLP_INFOLOGGER_URL),
epn: formatUrl(EPN_INFOLOGGER_URL),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
*/

import { formatTimestamp } from '../../../utilities/formatting/formatTimestamp.js';
import { frontLink } from '../../../components/common/navigation/frontLink.js';
import { formatRunsList } from '../../Runs/format/formatRunsList.js';
import { displayEnvironmentStatus } from '../format/displayEnvironmentStatus.js';
import { displayEnvironmentInfologgerLinks } from '../format/displayEnvironmentInfologgerLinks.js';
import { frontLink } from '../../../components/common/navigation/frontLink.js';

/**
* List of active columns for a generic Environments component
Expand Down Expand Up @@ -58,8 +59,7 @@ export const environmentsActiveColumns = {
sortable: false,
size: 'w-40',
title: true,
format: (message) =>
message ? message : '-',
format: (message) => message || '-',
balloon: true,
},
runs: {
Expand All @@ -71,4 +71,11 @@ export const environmentsActiveColumns = {
format: formatRunsList,
balloon: true,
},
infologger: {
name: 'Infologger',
visible: true,
sortable: false,
classes: 'w-10 text-center',
format: (_, environment) => displayEnvironmentInfologgerLinks(environment),
},
};
31 changes: 20 additions & 11 deletions lib/public/views/Environments/Details/EnvironmentDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { tabbedPanelComponent } from '../../../components/TabbedPanel/tabbedPane
import { ENVIRONMENT_DETAILS_PANELS_KEYS } from './EnvironmentDetailsModel.js';
import { LHC_FILL_DETAILS_PANELS_KEYS } from '../../LhcFills/Detail/LhcFillDetailsModel.js';
import { logsActiveColumns } from '../../Logs/ActiveColumns/logsActiveColumns.js';
import { getInfologgerLink } from '../../../services/externalRouting/getInfologgerLink.js';

/**
* Returns the environment's detail page
Expand All @@ -42,6 +43,7 @@ export const EnvironmentDetailsPage = ({ envs: { detailsModel } }) => detailsMod
*/
Success: (environment) => {
const { id, status, createdAt, historyItems, runs } = environment;
const { flp: flpInfologger, epn: epnInfologger } = getInfologgerLink({ environmentId: id });

const history = [];
for (const historyIndex in historyItems) {
Expand All @@ -52,19 +54,26 @@ export const EnvironmentDetailsPage = ({ envs: { detailsModel } }) => detailsMod
}

return h('.flex-column.g3', [
h('.flex-row.items-center.justify-between.g3', [
h('.flex-row.items-center.g3', [
h('h2', ['Environment ', h('strong', id)]),
h('#environment-status-badge.f3.badge.bg-primary.white', status),
h('', [
h('.flex-row.items-center.justify-between.g3', [
h('.flex-row.items-center.g3', [
h('h2', ['Environment ', h('strong', id)]),
h('#environment-status-badge.f3.badge.bg-primary.white', status),
]),
frontLink(
'Add log to this environment',
'log-create',
{ environmentIds: [id] },
{ id: 'create-log', class: 'btn btn-primary h2' },
),
]),
frontLink(
'Add log to this environment',
'log-create',
{ environmentIds: [id] },
{ id: 'create-log', class: 'btn btn-primary h2' },
),
h('#environment-creation-date', [h('strong', 'Created at '), formatTimestamp(createdAt)]),
]),
(flpInfologger || epnInfologger) && h('h3.flex-row.w-100.g2.items-baseline.mb3', [
h('', 'Infologger: '),
flpInfologger && h('a', { href: flpInfologger }, 'FLP'),
epnInfologger && h('a', { href: epnInfologger }, 'EPN'),
]),
h('#environment-creation-date', [h('strong', 'Created at '), formatTimestamp(createdAt)]),
h('h3', 'History'),
h('#environment-history.flex-row.g3.flex-wrap.items-center', history),
tabbedPanelComponent(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @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.
*/
import { h } from '/js/src/index.js';
import { getInfologgerLink } from '../../../services/externalRouting/getInfologgerLink.js';

/**
* Display links to infologger for the given environment's
*
* @param {Environment} environment the environment for which links need to be displayed
* @return {vnode} the infologger links
*/
export const displayEnvironmentInfologgerLinks = ({ id }) => {
const { flp, epn } = getInfologgerLink({ environmentId: id });

return h(
'.flex-row.btn-group',
[
flp && h('a.btn', { href: flp }, 'FLP'),
epn && h('a.btn', { href: epn }, 'EPN'),
],
);
};
3 changes: 2 additions & 1 deletion lib/public/views/Runs/ActiveColumns/runsActiveColumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { selectionDropdown } from '../../../components/common/selection/dropdown
import { eorReasonFilter } from '../../../components/Filters/RunsFilter/eorReasonFilter.js';
import { RunDefinition } from '../../../domain/enums/RunDefinition.js';
import { coloredCalibrationStatusComponent } from '../coloredCalibrationStatusComponent.js';
import { displayRunNumber } from '../format/displayRunNumber.js';

/**
* List of active columns for a generic runs table
Expand All @@ -60,7 +61,7 @@ export const runsActiveColumns = {
visible: true,
size: 'w-10 f6 w-wrapped',
filter: runNumberFilter,
format: (text, run) => frontLink(text, 'run-detail', { id: run.id }),
format: (_, run) => displayRunNumber(run),
profiles: {
lhcFill: true,
environment: true,
Expand Down
Loading

0 comments on commit 1a09b57

Please sign in to comment.