Skip to content

Commit f84191f

Browse files
authored
Merge branch 'main' into feature/O2B-1489/Add-filtering-panel-to-environments-page
2 parents 998d076 + 7368f5e commit f84191f

19 files changed

Lines changed: 278 additions & 57 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
/**
15+
* @typedef SequelizeBeamMode
16+
*
17+
* BeamMode is currently a string column in the runs table, but we define this typedef as if it were a full model for future use.
18+
* BeamMode should become independent entity in the future. [O2B-1499]
19+
*
20+
* @property {string} name
21+
*/

lib/database/seeders/20220503120937-lhc-fills.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module.exports = {
6363
},
6464
{
6565
fill_number: 6,
66-
beam_type: 'PROTON-PROTON',
66+
beam_type: ' PROTON-PROTON ',
6767
stable_beams_start: '2019-08-08 11:00:00',
6868
stable_beams_end: '2019-08-08 23:00:00',
6969
stable_beams_duration: 60 * 60 * 12,

lib/public/components/common/selection/infoLoggerButtonGroup/buttonLinkWithDropdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const buttonLinkWithDropdown = (linkContent, page, parameters, dropdownBo
3636
DropdownComponent(
3737
h('.btn.btn-group-item.last-item', iconCaretBottom()),
3838
h(
39-
'.flex-column.p2.g3',
39+
'.flex-column.p2.g2',
4040
dropdownBody,
4141
),
4242
),

lib/public/components/common/table/table.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const parseColumnsConfiguration = (columns, currentProfile) => {
9494
* all predecesors of the node returned by this function must have display property column-flex and height: 100%
9595
* @property {boolean} singleWrapper have effect only when some scroll is enabled.
9696
* If true all divs wrapping table element are merged to single on.
97+
* @property {string} tableClasses The classes for the table, this appends to .freeze-first-column if present.
9798
*/
9899

99100
/**
@@ -137,6 +138,7 @@ export const table = (
137138
freezeFirstColumn = false,
138139
verticalScrollEnabled = false,
139140
singleWrapper = false,
141+
tableClasses = '',
140142
} = tableConfiguration || {};
141143
const { idKey, displayedColumns } = parseColumnsConfiguration(columns, currentProfile);
142144

@@ -150,7 +152,8 @@ export const table = (
150152
}
151153

152154
const scrollEnabled = horizontalScrollEnabled || verticalScrollEnabled;
153-
const optionalTableClassesExpression = freezeFirstColumn && horizontalScrollEnabled ? '.freeze-first-column' : '';
155+
let optionalTableClassesExpression = freezeFirstColumn && horizontalScrollEnabled ? '.freeze-first-column' : '';
156+
optionalTableClassesExpression += tableClasses;
154157

155158
const firstLevelWrapperClasses =
156159
(verticalScrollEnabled ? '.sticky-table-wrapper' : '') +

lib/public/services/lhcFill/LhcFillStatisticsExtractor.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class LhcFillStatisticsExtractor {
3131
* @param {Run[]} [runs=[]] the list of runs to consider to compute statistics (only physics run will be added).
3232
* This is optional and runs can be added independently later on using {@see addRun}, for performances purpose
3333
*/
34-
constructor({ stableBeamsStart, stableBeamsEnd, stableBeamsDuration }, runs = []) {
34+
constructor({ stableBeamsStart, stableBeamsEnd, stableBeamsDuration, collidingBunchesCount }, runs = []) {
3535
this._stableBeamsStart = stableBeamsStart;
3636
this._stableBeamsEnd = stableBeamsEnd;
3737
// Stable beam duration is in seconds in LHC fill
@@ -45,6 +45,8 @@ export class LhcFillStatisticsExtractor {
4545
this._totalCtfFileSize = 0;
4646
this._totalTfFileSize = 0;
4747

48+
this._collidingBunchesCount = collidingBunchesCount;
49+
4850
for (const run of runs) {
4951
this.addRun(run);
5052
}
@@ -151,6 +153,7 @@ export class LhcFillStatisticsExtractor {
151153
efficiencyLossAtEnd,
152154
meanRunDuration: totalRunsDuration / this._rawTimeSegments.length,
153155
runsCoverage,
156+
collidingBunchesCount: this._collidingBunchesCount,
154157
totalCtfFileSize: this._totalCtfFileSize,
155158
totalTfFileSize: this._totalTfFileSize,
156159
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
import { h } from '/js/src/index.js';
14+
15+
/**
16+
* Format the beam type into a formatted string
17+
*
18+
* @param {string|null} beamType the time loss to format
19+
* @return {vnode} the formatted result
20+
*/
21+
export const formatBeamType = (beamType = '') => {
22+
const [beamOneType = '', beamTwoType = ''] = beamType?.split('-') ?? [];
23+
if (beamOneType !== '' && beamTwoType !== '') {
24+
return h('', [beamOneType.trim(), h('br'), beamTwoType.trim()]);
25+
} else {
26+
return h('', '-');
27+
}
28+
};

lib/public/views/LhcFills/ActiveColumns/lhcFillsActiveColumns.js

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ import { formatTimestamp } from '../../../utilities/formatting/formatTimestamp.j
1616
import { formatDuration } from '../../../utilities/formatting/formatDuration.mjs';
1717
import { formatPercentage } from '../../../utilities/formatting/formatPercentage.js';
1818
import { CopyToClipboardComponent, h } from '/js/src/index.js';
19+
import { iconPlus } from '/js/src/icons.js';
1920
import { formatRunsList } from '../../Runs/format/formatRunsList.js';
2021
import { formatLhcFillsTimeLoss } from '../format/formatLhcFillsTimeLoss.js';
2122
import { buttonLinkWithDropdown } from '../../../components/common/selection/infoLoggerButtonGroup/buttonLinkWithDropdown.js';
2223
import { infologgerLinksComponents } from '../../../components/common/externalLinks/infologgerLinksComponents.js';
24+
import { formatBeamType } from '../../../utilities/formatting/formatBeamType.js';
25+
import { frontLink } from '../../../components/common/navigation/frontLink.js';
2326

2427
/**
2528
* List of active columns for a lhc fills table
@@ -37,6 +40,12 @@ export const lhcFillsActiveColumns = {
3740
[
3841
h(CopyToClipboardComponent, { value: fillNumber, id: fillNumber }, 'Copy Fill Number'),
3942
...infologgerLinksComponents({ runNumbers: runs.map(({ runNumber }) => runNumber) }),
43+
frontLink(
44+
[iconPlus(), ' Add log to this fill'],
45+
'log-create',
46+
{ lhcFillNumbers: [fillNumber] },
47+
{ id: 'create-log', class: 'btn btn-primary h2' },
48+
),
4049
],
4150
),
4251
profiles: {
@@ -98,25 +107,6 @@ export const lhcFillsActiveColumns = {
98107
},
99108
},
100109
},
101-
beamType: {
102-
name: 'Beam Type',
103-
visible: true,
104-
size: 'w-8',
105-
format: (value) => value ? value : '-',
106-
},
107-
efficiency: {
108-
name: 'Fill Efficiency',
109-
visible: true,
110-
size: 'w-8',
111-
format: (efficiency) => formatPercentage(efficiency),
112-
profiles: {
113-
lhcFill: true,
114-
environment: true,
115-
home: {
116-
size: 'w-20',
117-
},
118-
},
119-
},
120110
timeLossAtStart: {
121111
name: 'Before 1st run',
122112
visible: true,
@@ -125,7 +115,7 @@ export const lhcFillsActiveColumns = {
125115
},
126116
timeLossAtEnd: {
127117
name: 'After last run',
128-
visible: true,
118+
visible: false,
129119
size: 'w-8',
130120
format: (duration, lhcFill) => formatLhcFillsTimeLoss(duration, lhcFill.efficiencyLossAtEnd, false),
131121
},
@@ -141,6 +131,31 @@ export const lhcFillsActiveColumns = {
141131
size: 'w-8',
142132
format: (duration) => formatDuration(duration),
143133
},
134+
efficiency: {
135+
name: 'Fill Efficiency',
136+
visible: true,
137+
size: 'w-8',
138+
format: (efficiency) => formatPercentage(efficiency),
139+
profiles: {
140+
lhcFill: true,
141+
environment: true,
142+
home: {
143+
size: 'w-20',
144+
},
145+
},
146+
},
147+
beamType: {
148+
name: 'Beam Type',
149+
visible: true,
150+
size: 'w-8',
151+
format: (value) => formatBeamType(value),
152+
},
153+
collidingBunches: {
154+
name: 'Colliding bunches',
155+
visible: true,
156+
size: 'w-8',
157+
format: (duration, lhcFill) => lhcFill.collidingBunchesCount ? lhcFill.collidingBunchesCount : '-',
158+
},
144159
fillingSchemeName: {
145160
name: 'Scheme name',
146161
visible: true,

lib/public/views/LhcFills/LhcFills.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default class LhcFills extends Observable {
2929
this.model = model;
3030

3131
// Sub-models
32-
this._overviewModel = new LhcFillsOverviewModel();
32+
this._overviewModel = new LhcFillsOverviewModel(true);
3333
this._overviewModel.bubbleTo(this);
3434

3535
this._detailsModel = new LhcFillDetailsModel();

lib/public/views/LhcFills/Overview/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const showLhcFillsTable = (lhcFillsOverviewModel) => {
6565
toggleStableBeamOnlyFilter(lhcFillsOverviewModel),
6666
]),
6767
h('.w-100.flex-column', [
68-
table(lhcFillsOverviewModel.items, lhcFillsActiveColumns, { classes: '.table-sm' }),
68+
table(lhcFillsOverviewModel.items, lhcFillsActiveColumns, null, { tableClasses: '.table-sm' }),
6969
paginationComponent(lhcFillsOverviewModel.pagination),
7070
]),
7171
];

lib/server/controllers/runs.controller.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const { dtoValidator } = require('../utilities');
3737
const { ApiConfig } = require('../../config/index.js');
3838
const { DtoFactory } = require('../../domain/dtos/DtoFactory.js');
3939
const { runService } = require('../services/run/RunService.js');
40+
const { getAllBeamModes } = require('../services/beam/getAllBeamModes.js');
4041
const { updateExpressResponseFromNativeError } = require('../express/updateExpressResponseFromNativeError.js');
4142
const { runToHttpView } = require('./runsToHttpView.js');
4243

@@ -278,8 +279,7 @@ const updateRunByRunNumber = async (request, response) => {
278279
* @param {Object} _request The *request* object represents the HTTP request and has properties for the request query
279280
* string, parameters, body, HTTP headers, and so on.
280281
* @param {Object} response The *response* object represents the HTTP response that an Express app sends when it gets
281-
* an
282-
* HTTP request.
282+
* an HTTP request.
283283
* @param {Function} _next The *next* object represents the next middleware function which is used to pass control to
284284
* the next middleware function.
285285
* @returns {undefined}
@@ -297,6 +297,30 @@ const listReasonTypes = async (_request, response, _next) => {
297297
}
298298
};
299299

300+
/**
301+
* Retrieve a list of unique beam modes
302+
*
303+
* @param {Object} _request The *request* object represents the HTTP request and has properties for the request query
304+
* string, parameters, body, HTTP headers, and so on.
305+
* @param {Object} response The *response* object represents the HTTP response that an Express app sends when it gets
306+
* an HTTP request.
307+
* @param {NextFunction} _next The *next* object represents the next middleware function which is used to pass control to
308+
* the next middleware function.
309+
* @returns {undefined}
310+
*/
311+
const listBeamModes = async (_request, response, _next) => {
312+
try {
313+
const beamModes = await getAllBeamModes();
314+
if (beamModes && beamModes.length > 0) {
315+
response.status(200).json({ data: beamModes });
316+
} else {
317+
response.status(204).json({ data: [] });
318+
}
319+
} catch {
320+
response.status(502).json({ errors: ['Unable to retrieve list of beam modes'] });
321+
}
322+
};
323+
300324
// eslint-disable-next-line jsdoc/require-param
301325
/**
302326
* Retrieve distinct combination of levels of alice L3 and dipole current rounded to kilo amperes
@@ -323,6 +347,7 @@ module.exports = {
323347
getLogsByRunNumberHandler,
324348
getFlpsByRunNumberHandler,
325349
listReasonTypes,
350+
listBeamModes,
326351
listRuns,
327352
startRun,
328353
updateRunByRunNumber,

0 commit comments

Comments
 (0)