Skip to content

Commit 3d95551

Browse files
authored
[O2B-1071] Improvements on LHC Fills Overview page (#1275)
* small user-interface improvements readibility for the LHC Fill table
1 parent cebb170 commit 3d95551

3 files changed

Lines changed: 52 additions & 9 deletions

File tree

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { frontLink } from '../../../components/common/navigation/frontLink.js';
1818
import { formatPercentage } from '../../../utilities/formatting/formatPercentage.js';
1919
import { h } from '/js/src/index.js';
2020
import { formatRunsList } from '../../Runs/format/formatRunsList.js';
21+
import { formatLhcFillsTimeLoss } from '../format/formatLhcFillsTimeLoss.js';
2122

2223
/**
2324
* List of active columns for a lhc fills table
@@ -31,19 +32,19 @@ export const lhcFillsActiveColumns = {
3132
format: (fillNumber) => frontLink(fillNumber, 'lhc-fill-details', { fillNumber: fillNumber }),
3233
},
3334
stableBeamsStart: {
34-
name: 'Stable beams start',
35+
name: 'SB START',
3536
visible: true,
3637
size: 'w-8',
37-
format: (timestamp) => formatTimestamp(timestamp),
38+
format: (timestamp) => formatTimestamp(timestamp, false),
3839
},
3940
stableBeamsEnd: {
40-
name: 'Stable beams end',
41+
name: 'SB END',
4142
visible: true,
4243
size: 'w-8',
43-
format: (timestamp) => formatTimestamp(timestamp),
44+
format: (timestamp) => formatTimestamp(timestamp, false),
4445
},
4546
stableBeamsDuration: {
46-
name: 'Beams Duration',
47+
name: 'SB Duration',
4748
visible: true,
4849
size: 'w-8',
4950
format: (time, { stableBeamsStart, stableBeamsEnd }) => {
@@ -74,13 +75,13 @@ export const lhcFillsActiveColumns = {
7475
name: 'Before 1st run',
7576
visible: true,
7677
size: 'w-8',
77-
format: (duration, lhcFill) => duration ? `${formatDuration(duration)} (${formatPercentage(lhcFill.efficiencyLossAtStart)})` : '-',
78+
format: (duration, lhcFill) => formatLhcFillsTimeLoss(duration, lhcFill.efficiencyLossAtStart, false),
7879
},
7980
timeLossAtEnd: {
8081
name: 'After last run',
8182
visible: true,
8283
size: 'w-8',
83-
format: (duration, lhcFill) => duration ? `${formatDuration(duration)} (${formatPercentage(lhcFill.efficiencyLossAtEnd)})` : '-',
84+
format: (duration, lhcFill) => formatLhcFillsTimeLoss(duration, lhcFill.efficiencyLossAtEnd, false),
8485
},
8586
meanRunDuration: {
8687
name: 'Mean run duration',
@@ -99,6 +100,7 @@ export const lhcFillsActiveColumns = {
99100
visible: true,
100101
size: 'w-10',
101102
format: (value) => value ? value : '-',
103+
balloon: true,
102104
},
103105
runs: {
104106
name: 'Runs',
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
import { h } from '/js/src/index.js';
15+
import { formatDuration } from '../../../utilities/formatting/formatDuration.mjs';
16+
import { formatPercentage } from '../../../utilities/formatting/formatPercentage.js';
17+
18+
/**
19+
* Formats the duration and loss percentage to display, with the option of
20+
* separating the duration and percentage by a newline or not.
21+
*
22+
* @param {number} duration the duration to display, in milliseconds.
23+
* @param {number} efficiencyLoss the percentage to display, normalized between 0 and 1.
24+
* @param {boolean} [inline] if true, the duration and loss will be returned as a string.
25+
* Else, a component will be returned, where the duration and loss are separated by a newline.
26+
* @returns {vnode|string} the formatted duration and percentage.
27+
*/
28+
export const formatLhcFillsTimeLoss = (duration, efficiencyLoss, inline = true) => {
29+
if (!duration) {
30+
return '-';
31+
}
32+
33+
const formattedDuration = formatDuration(duration);
34+
const formattedEfficiencyLossPercentage = formatPercentage(efficiencyLoss);
35+
36+
if (inline) {
37+
return `${formattedDuration} (${formattedEfficiencyLossPercentage})`;
38+
}
39+
40+
return h('', [formattedDuration, h('br'), `(${formattedEfficiencyLossPercentage})`]);
41+
};

test/public/lhcFills/overview.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ module.exports = () => {
7070
statusMessage: (string) => typeof string == 'string',
7171
efficiency: (efficiency) => efficiency === '-' || efficiency.match(percentageRegex) !== null,
7272
timeLossAtStart: (data) => data === '-'
73-
|| data.match(new RegExp(`${durationRegex.source} \\(${percentageRegex.source}\\)`)) !== null,
73+
|| data.match(new RegExp(`${durationRegex.source}\n\\(${percentageRegex.source}\\)`)) !== null,
7474
timeLossAtEnd: (data) => data === '-'
75-
|| data.match(new RegExp(`${durationRegex.source} \\(${percentageRegex.source}\\)`)) !== null,
75+
|| data.match(new RegExp(`${durationRegex.source}\n\\(${percentageRegex.source}\\)`)) !== null,
7676
meanRunDuration: (duration) => duration === '-' || duration.match(durationRegex) !== null,
7777
runsCoverage: (duration) => duration === '-' || duration.match(durationRegex) !== null,
7878
runs: (string) => typeof string == 'string',

0 commit comments

Comments
 (0)