Skip to content
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

[O2B-643] Run duration accept format HH:MM:SS #1464

Draft
wants to merge 56 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
355ddac
works
xsalonx Mar 14, 2024
9702196
works
xsalonx Mar 14, 2024
4b87ce8
refactor
xsalonx Mar 14, 2024
d436308
add model
xsalonx Mar 14, 2024
eda937b
nEPS filter works
xsalonx Mar 15, 2024
8c18794
filters work
xsalonx Mar 15, 2024
15b5dac
filter works
xsalonx Mar 15, 2024
c3b2f86
pol
xsalonx Mar 15, 2024
e9e7420
pol
xsalonx Mar 15, 2024
5e98f04
linter
xsalonx Mar 15, 2024
3cbb87f
add default
xsalonx Mar 15, 2024
1a61b69
docs
xsalonx Mar 15, 2024
2d1731a
conf min max
xsalonx Mar 15, 2024
2475d19
docs
xsalonx Mar 15, 2024
b37573a
value
xsalonx Mar 15, 2024
78950b5
change default
xsalonx Mar 15, 2024
7f03dff
test WIP
xsalonx Mar 15, 2024
58d31e5
Test
xsalonx Mar 15, 2024
191d434
Merge branch 'main' into xsalonx/misc/O2B-643/run-duration-should-acc…
xsalonx Mar 18, 2024
fbdefc0
Merge branch 'main' into xsalonx/misc/O2B-643/run-duration-should-acc…
xsalonx Mar 25, 2024
3661588
remove override
xsalonx Mar 27, 2024
a06640d
refactor
xsalonx Mar 27, 2024
21c1cf4
use SelectionMode
xsalonx Mar 27, 2024
0ab6860
rename
xsalonx Mar 27, 2024
144317c
rename
xsalonx Mar 27, 2024
40b70e2
bug
xsalonx Mar 27, 2024
68a01d7
simp
xsalonx Mar 27, 2024
ff0da59
cherry-picked
xsalonx Mar 27, 2024
7d57685
cherry -pick
xsalonx Mar 27, 2024
71cb30d
rm
xsalonx Mar 27, 2024
14fc5a8
cleanup
xsalonx Mar 27, 2024
6dda2bc
cl
xsalonx Mar 27, 2024
e639db8
revoke
xsalonx Mar 27, 2024
1d5e0c7
remove
xsalonx Mar 27, 2024
cd9d679
ref
xsalonx May 30, 2024
c4c9fc7
ch
xsalonx May 30, 2024
b59e0d2
add model
xsalonx May 30, 2024
a4933f2
ref WIP
xsalonx May 30, 2024
5d6c941
ref
xsalonx May 30, 2024
fe67005
fix
xsalonx May 30, 2024
f165e23
fix
xsalonx May 30, 2024
52e7bf6
merge main
xsalonx May 30, 2024
318d0a5
cleanup
xsalonx May 30, 2024
7d05396
test WIP
xsalonx May 30, 2024
a4843f3
merge main
xsalonx Jun 3, 2024
6b013dd
fix
xsalonx Jun 3, 2024
c353f54
fix
xsalonx Jun 3, 2024
73425be
fix
xsalonx Jun 4, 2024
c4c70dd
Merge branch 'main' into xsalonx/misc/O2B-643/run-duration-should-acc…
xsalonx Jun 4, 2024
2507a4a
simp
xsalonx Jun 4, 2024
e6763c6
merge main
xsalonx Jun 4, 2024
a908084
Merge branch 'main' into xsalonx/misc/O2B-643/run-duration-should-acc…
xsalonx Jun 4, 2024
bf412c4
add method
xsalonx Jun 4, 2024
2ea7b4a
merge main
xsalonx Jun 10, 2024
76905be
Merge branch 'main' into xsalonx/misc/O2B-643/run-duration-should-acc…
xsalonx Jun 11, 2024
eb7ae9f
merg main
xsalonx Oct 10, 2024
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
74 changes: 58 additions & 16 deletions lib/public/components/Filters/RunsFilter/durationFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,68 @@
* or submit itself to any jurisdiction.
*/

import { amountFilter } from '../common/filters/amountFilter.js';
import { h } from '/js/src/index.js';
import { comparisonOperatorFilter } from '../common/filters/comparisonOperatorFilter.js';

/**
* Returns the run duration filter component
*
* @param {RunsOverviewModel} runModel the runs model object
*
* @return {vnode} the duration filter
* @param {DurationInputModel} durationFilterModel the duration input model
* @param {ComparisonOperatorSelectionModel} operatorSelectionModel the comparison operator selection model
* @return {Component} the duration filter
*/
export const durationFilter = (runModel) => amountFilter(
runModel.runDurationFilter,
(filter) => {
runModel.runDurationFilter = filter;
},
{
operatorAttributes: {
id: 'duration-operator',
export const durationFilter = (durationFilterModel, operatorSelectionModel) => {
const { hours, minutes, seconds } = durationFilterModel.raw;

Check warning on line 25 in lib/public/components/Filters/RunsFilter/durationFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/durationFilter.js#L24-L25

Added lines #L24 - L25 were not covered by tests

const hoursInput = h('input.flex-grow', {

Check warning on line 27 in lib/public/components/Filters/RunsFilter/durationFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/durationFilter.js#L27

Added line #L27 was not covered by tests
id: 'hours-input',
type: 'number',
min: 0,
value: hours,
oninput: (e) => {
const { value } = e.target;
durationFilterModel.update({ hours: value.length === 0 ? null : Number(value) });

Check warning on line 34 in lib/public/components/Filters/RunsFilter/durationFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/durationFilter.js#L32-L34

Added lines #L32 - L34 were not covered by tests
},
});
const minutesInput = h('input.flex-grow', {

Check warning on line 37 in lib/public/components/Filters/RunsFilter/durationFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/durationFilter.js#L37

Added line #L37 was not covered by tests
id: 'minutes-input',
type: 'number',
min: 0,
max: 59,
value: minutes,
oninput: (e) => {
const { value } = e.target;
durationFilterModel.update({ minutes: value.length === 0 ? null : Number(value) });

Check warning on line 45 in lib/public/components/Filters/RunsFilter/durationFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/durationFilter.js#L43-L45

Added lines #L43 - L45 were not covered by tests
},
limitAttributes: {
id: 'duration-limit',
}, 'm');
const secondsInput = h('input.flex-grow', {

Check warning on line 48 in lib/public/components/Filters/RunsFilter/durationFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/durationFilter.js#L48

Added line #L48 was not covered by tests
id: 'seconds-input',
type: 'number',
min: 0,
max: 59,
value: seconds,
oninput: (e) => {
const { value } = e.target;
durationFilterModel.update({ seconds: value.length === 0 ? null : Number(value) });

Check warning on line 56 in lib/public/components/Filters/RunsFilter/durationFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/durationFilter.js#L54-L56

Added lines #L54 - L56 were not covered by tests
},
},
);
}, 's');

const inputs = h('.flex-row.w-40', [

Check warning on line 60 in lib/public/components/Filters/RunsFilter/durationFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/durationFilter.js#L60

Added line #L60 was not covered by tests
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
hoursInput,
minutesInput,
secondsInput,
h('.flex-row.items-center.p2', [
h('label', { for: 'hours-input' }, 'h'),
':',
h('label', { for: 'minutes-input' }, 'm'),
':',
h('label', { for: 'seconds-input' }, 's'),
]),
]);

return comparisonOperatorFilter(

Check warning on line 73 in lib/public/components/Filters/RunsFilter/durationFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/durationFilter.js#L73

Added line #L73 was not covered by tests
inputs,
operatorSelectionModel.selected[0],
(operator) => operatorSelectionModel.select(operator),

Check warning on line 76 in lib/public/components/Filters/RunsFilter/durationFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/durationFilter.js#L76

Added line #L76 was not covered by tests
);
};
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 { SelectionModel } from '../../../common/selection/SelectionModel.js';

/**
* Model storing state of a selection of predefined comparison operators
*/
export class ComparisonOperatorSelectionModel extends SelectionModel {
/**
* Constructor
* @param {string} [defaultOperator = '='] one of ['<', '<=', '=', '>=', '>'] operators
*/
constructor(defaultOperator = '=') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't override this parameter anywhere, simply don't add it

super({
availableOptions: ['<', '<=', '=', '>=', '>'].map((operator) => ({ value: operator })),

Check warning on line 26 in lib/public/components/Filters/common/filters/ComparisonOperatorSelectionModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/common/filters/ComparisonOperatorSelectionModel.js#L24-L26

Added lines #L24 - L26 were not covered by tests
multiple: false,
allowEmpty: false,
defaultSelection: [{ value: defaultOperator }],
});
}
}
98 changes: 98 additions & 0 deletions lib/public/components/common/form/inputs/DurationInputModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* @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 { Observable } from '/js/src/index.js';

/**
* @typedef DurationInputRawData
* @property {number} hours the number of hours
* @property {number} minutes the number of minutes
* @property {number} seconds the number of seconds
*/

/**
* Store the duration input
*/
export class DurationInputModel extends Observable {
/**
* Constructor
*/
constructor() {
super();

Check warning on line 31 in lib/public/components/common/form/inputs/DurationInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DurationInputModel.js#L30-L31

Added lines #L30 - L31 were not covered by tests

this._raw = {

Check warning on line 33 in lib/public/components/common/form/inputs/DurationInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DurationInputModel.js#L33

Added line #L33 was not covered by tests
hours: null,
minutes: null,
seconds: null,
};

/**
* Timestamp (ms)
* @type {number|null}
* @private
*/
this._value = null;

Check warning on line 44 in lib/public/components/common/form/inputs/DurationInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DurationInputModel.js#L44

Added line #L44 was not covered by tests
}

/**
* Update the inputs raw values
* @param {DurationInputRawData} raw the input raw values
* @return {void}
*/
update(raw) {
try {
this._raw = { ...this._raw, ...raw };
this._value =
(this._raw.hours || 0) * 60 * 60 * 1000 +
(this._raw.minutes || 0) * 60 * 1000 +
(this._raw.seconds || 0) * 1000;

Check warning on line 58 in lib/public/components/common/form/inputs/DurationInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DurationInputModel.js#L52-L58

Added lines #L52 - L58 were not covered by tests

if (this._value === 0) {
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
this.reset();

Check warning on line 61 in lib/public/components/common/form/inputs/DurationInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DurationInputModel.js#L60-L61

Added lines #L60 - L61 were not covered by tests
}
} catch (_) {
this._value = null;

Check warning on line 64 in lib/public/components/common/form/inputs/DurationInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DurationInputModel.js#L64

Added line #L64 was not covered by tests
}

this.notify();

Check warning on line 67 in lib/public/components/common/form/inputs/DurationInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DurationInputModel.js#L67

Added line #L67 was not covered by tests
}

/**
* Reset the inputs to its initial state
* @return {void}
*/
reset() {
this._raw = {

Check warning on line 75 in lib/public/components/common/form/inputs/DurationInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DurationInputModel.js#L74-L75

Added lines #L74 - L75 were not covered by tests
hours: null,
minutes: null,
seconds: null,
};
this._value = null;

Check warning on line 80 in lib/public/components/common/form/inputs/DurationInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DurationInputModel.js#L80

Added line #L80 was not covered by tests
}

/**
* Returns the raw input values
* @return {DurationInputRawData} the raw values
*/
get raw() {
return this._raw;

Check warning on line 88 in lib/public/components/common/form/inputs/DurationInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DurationInputModel.js#L87-L88

Added lines #L87 - L88 were not covered by tests
}

/**
* Returns the current date represented by the inputs (null if no valid value is represented)
* @return {number|null} the current value
*/
get value() {
return this._value;

Check warning on line 96 in lib/public/components/common/form/inputs/DurationInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DurationInputModel.js#L95-L96

Added lines #L95 - L96 were not covered by tests
}
}
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 @@ -262,7 +262,8 @@
noEllipsis: true,
format: (_duration, run) => displayRunDuration(run),
exportFormat: (_duration, run) => formatRunDuration(run),
filter: durationFilter,
filter: ({ runDurationFilterModel, runDurationOperatorSelectionModel }) =>
durationFilter(runDurationFilterModel, runDurationOperatorSelectionModel),

Check warning on line 266 in lib/public/views/Runs/ActiveColumns/runsActiveColumns.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/ActiveColumns/runsActiveColumns.js#L266

Added line #L266 was not covered by tests
},
environmentId: {
name: 'Environment ID',
Expand Down
48 changes: 28 additions & 20 deletions lib/public/views/Runs/Overview/RunsOverviewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import pick from '../../../utilities/pick.js';
import { OverviewPageModel } from '../../../models/OverviewModel.js';
import { getRemoteDataSlice } from '../../../utilities/fetch/getRemoteDataSlice.js';
import { DurationInputModel } from '../../../components/common/form/inputs/DurationInputModel.js';
import { ComparisonOperatorSelectionModel }
from '../../../components/Filters/common/filters/ComparisonOperatorSelectionModel.js';

/**
* Model representing handlers for runs page
Expand Down Expand Up @@ -51,6 +54,15 @@
this._eorReasonsFilterModel.observe(() => this._applyFilters());
this._eorReasonsFilterModel.visualChange$.observe(() => this.notify());

this._runDurationFilterModel = new DurationInputModel();
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
this._runDurationFilterModel.observe(() => this._applyFilters());
this._runDurationOperatorSelectionModel = new ComparisonOperatorSelectionModel();
this._runDurationOperatorSelectionModel.observe(() => {
if (this._runDurationFilterModel.value !== null) {
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
this._applyFilters();

Check warning on line 62 in lib/public/views/Runs/Overview/RunsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/Overview/RunsOverviewModel.js#L57-L62

Added lines #L57 - L62 were not covered by tests
}
});

// Export items
this._allRuns = RemoteData.NotAsked();

Expand Down Expand Up @@ -157,8 +169,6 @@
this.o2endFilterFromTime = '00:00';
this.o2endFilterToTime = '23:59';

this._runDurationFilter = null;

this._lhcPeriodsFilter = null;

this.environmentIdsFilter = '';
Expand All @@ -173,6 +183,9 @@

this.nFlpsFilter = null;

this._runDurationFilterModel.reset();
this._runDurationOperatorSelectionModel.reset();

Check warning on line 187 in lib/public/views/Runs/Overview/RunsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/Overview/RunsOverviewModel.js#L186-L187

Added lines #L186 - L187 were not covered by tests

this.ddflpFilter = '';

this.dcsFilter = '';
Expand Down Expand Up @@ -207,7 +220,7 @@
|| this.o2endFilterTo !== ''
|| this.o2endFilterToTime !== '23:59'
|| this.o2endFilterFromTime !== '00:00'
|| this._runDurationFilter !== null
|| this._runDurationFilterModel.value !== null

Check warning on line 223 in lib/public/views/Runs/Overview/RunsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/Overview/RunsOverviewModel.js#L223

Added line #L223 was not covered by tests
|| this._lhcPeriodsFilter !== null
|| this.environmentIdsFilter !== ''
|| this.runQualitiesFilters.length !== 0
Expand Down Expand Up @@ -262,7 +275,7 @@
if (this.o2endFilterTo !== '') {
this.activeFilters.push('O2 End to');
}
if (this._runDurationFilter !== null) {
if (this._runDurationFilterModel.value !== null) {

Check warning on line 278 in lib/public/views/Runs/Overview/RunsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/Overview/RunsOverviewModel.js#L278

Added line #L278 was not covered by tests
this.activeFilters.push('Run duration');
}
if (this._lhcPeriodsFilter !== null) {
Expand Down Expand Up @@ -512,23 +525,19 @@
}

/**
* Returns the run duration filter (filter is defined in minutes)
* @return {{operator: string, limit: (number|null)}|null} The current run duration filter
* Returns the run duration filter model
* @return {DurationInputModel} The current run duration filter model
*/
get runDurationFilter() {
return this._runDurationFilter;
get runDurationFilterModel() {
return this._runDurationFilterModel;

Check warning on line 532 in lib/public/views/Runs/Overview/RunsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/Overview/RunsOverviewModel.js#L531-L532

Added lines #L531 - L532 were not covered by tests
}

/**
* Sets the limit of duration (in minutes) and the comparison operator to filter
*
* @param {{operator: string, limit: (number|null)}|null} newRunDurationFilter The new filter value
*
* @return {void}
* Returns the run duration filter operator selection model
* @return {ComparisonOperatorSelectionModel} selection model
*/
set runDurationFilter(newRunDurationFilter) {
this._runDurationFilter = newRunDurationFilter;
this._applyFilters();
get runDurationOperatorSelectionModel() {
return this._runDurationOperatorSelectionModel;

Check warning on line 540 in lib/public/views/Runs/Overview/RunsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/Overview/RunsOverviewModel.js#L539-L540

Added lines #L539 - L540 were not covered by tests
}

/**
Expand Down Expand Up @@ -895,10 +904,9 @@
'filter[o2end][to]':
new Date(`${this.o2endFilterTo.replace(/\//g, '-')}T${this.o2endFilterToTime}:59.999`).getTime(),
},
...this._runDurationFilter && this._runDurationFilter.limit !== null && {
'filter[runDuration][operator]': this._runDurationFilter.operator,
// Convert filter to milliseconds
'filter[runDuration][limit]': this._runDurationFilter.limit * 60 * 1000,
...this._runDurationFilterModel.value && {

Check warning on line 907 in lib/public/views/Runs/Overview/RunsOverviewModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/Overview/RunsOverviewModel.js#L907

Added line #L907 was not covered by tests
'filter[runDuration][operator]': this._runDurationOperatorSelectionModel.selected,
'filter[runDuration][limit]': this._runDurationFilterModel.value,
},
...this._lhcPeriodsFilter && {
'filter[lhcPeriods]': this._lhcPeriodsFilter,
Expand Down
5 changes: 5 additions & 0 deletions test/public/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ module.exports.expectInnerTextTo = async (page, selector, validator) => {
expect(validator(actualInnerText), `"${actualInnerText}" is invalid with respect of given validator`).to.be.true;
};

module.exports.expectSelectToBe = async (page, selector, selectedOption) => {
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
await page.waitForSelector(selector);
expect(await (await page.$(selector)).evaluate(({ value }) => value)).to.be.equal(selectedOption);
};

/**
* Evaluate and return the html content of a given element handler
* @param {{evaluate}} elementHandler the puppeteer handler of the element to inspect
Expand Down
Loading