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 14 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
18 changes: 11 additions & 7 deletions lib/public/components/Filters/RunsFilter/durationFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,46 @@
* Returns the run duration filter component
*
* @param {DurationInputModel} durationFilterModel the duration input model
* @param {NumericComparisonOperatorSelectionModel} operatorSelectionModel the comparison operator selection model
* @param {ComparisonOperatorSelectionModel} operatorSelectionModel the comparison operator selection model
* @return {Component} the duration filter
*/
export const durationFilter = (durationFilterModel, operatorSelectionModel) => {
const { hours, minutes, seconds, secondsMin, minutesMin } = durationFilterModel.raw;
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: minutesMin,
max: 60,
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
},
}, '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: secondsMin,
max: 60,
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,
Expand All @@ -70,5 +70,9 @@
]),
]);

return comparisonOperatorFilter(inputs, operatorSelectionModel);
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
);
};
30 changes: 30 additions & 0 deletions lib/public/components/Filters/RunsFilter/nDetectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @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 { amountFilter } from '../common/filters/amountFilter.js';

/**
* Returns the author filter component
* @param {RunsOverviewModel} runModel the runs model object
* @return {vnode} A text box that lets the user look for logs with a specific author
*/
const nDetectorsFilter = (runModel) => amountFilter(runModel.getNDetectorsFilter(), (filter) => runModel.setNDetectorsFilter(filter), {
operatorAttributes: {
id: 'nDetectors-operator',
},
limitAttributes: {
id: 'nDetectors-limit',
},
});

export default nDetectorsFilter;
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
36 changes: 36 additions & 0 deletions lib/public/components/Filters/RunsFilter/nEpns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @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 { amountFilter } from '../common/filters/amountFilter.js';

/**
* Returns the nEpns filter component
* @param {RunsOverviewModel} runModel The runs model object
* @return {vnode} A text box and operator that lets the user look for logs with a specific number of EPNs
*/
const nEpnsFilter = (runModel) => amountFilter(
runModel.nEpnsFilter,
(filter) => {
runModel.nEpnsFilter = filter;
},
{
operatorAttributes: {
id: 'nEpns-operator',
},
limitAttributes: {
id: 'nEpns-limit',
},
},
);

export default nEpnsFilter;
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
30 changes: 30 additions & 0 deletions lib/public/components/Filters/RunsFilter/nFlps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @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 { amountFilter } from '../common/filters/amountFilter.js';

/**
* Returns the author filter component
* @param {RunsOverviewModel} runModel the run model object
* @return {vnode} A text box that lets the user look for logs with a specific author
*/
const nFlpsFilter = (runModel) => amountFilter(runModel.getNFlpsFilter(), (filter) => runModel.setNFlpsFilter(filter), {
operatorAttributes: {
id: 'nFlps-operator',
},
limitAttributes: {
id: 'nFlps-limit',
},
});

export default nFlpsFilter;
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,22 @@
* or submit itself to any jurisdiction.
*/

import { SelectionDropdownModel } from '../../../common/selection/dropdown/SelectionDropdownModel.js';
import { SelectionModel } from '../../../common/selection/SelectionModel.js';

/**
* Model storing state of a selection of predfined numerical comparison operators
* Model storing state of a selection of predefined comparison operators
*/
export class NumericComparisonOperatorSelectionModel extends SelectionDropdownModel {
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((op) => ({ value: op })),
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 }],
});
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritDoc
*/
get selected() {
return super.selected[0];
}
}
89 changes: 0 additions & 89 deletions lib/public/components/Filters/common/filters/NumericFilterModel.js

This file was deleted.

58 changes: 41 additions & 17 deletions lib/public/components/Filters/common/filters/amountFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,60 @@
import { comparisonOperatorFilter } from './comparisonOperatorFilter.js';
import { h } from '/js/src/index.js';

/**
* @callback filterChangeHandler
* @param {{operator: string, limit: (number|number)}|null} newFilter the new filter value
*/

/**
* Returns a component which provide an amount filter, allowing to choose a limit and the comparison operator to apply
*
* @param {NumericFilterModel} numericFilterModel filter model
* @param {{operatorAttributes: (object|undefined), operandAttributes: (object|undefined)}} options eventual options to configure the filter: use
* `operatorAttributes` to define the attributes of the operator selection component and `operandAttributes` to define the attributes of the
* operand input component
* @param {{operator: string, limit: (number|null)}|null} currentValue the operator to use to compare the limit to the actual
* values
* @param {filterChangeHandler} onChange callback called any time the operator OR the limit changes
* @param {{operatorAttributes: (object|undefined), limitAttributes: (object|undefined)}} options eventual options to configure the filter: use
* `operatorAttributes` to define the attributes of the operator selection component and `limitAttributes` to define the attributes of the
* limit input component
*
* @return {Component} the filter component
* @return {vnode} the component
*/
export const amountFilter = (numericFilterModel, options) => {
const { operatorSelectionModel } = numericFilterModel;
export const amountFilter = (currentValue, onChange, options) => {
const { operator, limit } = currentValue || { operator: '=', limit: null };
const { operatorAttributes = {}, limitAttributes = {} } = options;

// eslint-disable-next-line require-jsdoc
const updateFilter = ({ newOperator, newLimit }) => {
onChange({
operator: newOperator || operator,
limit: newLimit !== undefined ? newLimit : limit,
});
};

return comparisonOperatorFilter(
h('input.flex-grow', {
type: 'number',
min: numericFilterModel.minValue,
max: numericFilterModel.maxValue,
value: numericFilterModel.value,
min: 0,
value: limit,
oninput: (e) => {
const { value } = e.target;
if (value === '') {
numericFilterModel.value = null;
let newLimit;

if (e.target.value === '') {
newLimit = null;
} else {
numericFilterModel.value = Number(value);
const value = parseInt(e.target.value, 10);
if (!isNaN(value)) {
newLimit = value;
}
}

if (newLimit !== undefined && newLimit !== limit) {
updateFilter({ newLimit });
}
},
...options.operandAttributes,
...limitAttributes,
}, ''),
operatorSelectionModel,
options.operatorAttributes,
operator,
(newOperator) => updateFilter({ newOperator }),
operatorAttributes,
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,33 @@

import { h } from '/js/src/index.js';

/**
* Handle an operator change event
*
* @callback operatorChangeHandler
*
* @param {string} operator the new operator value
*
* @return {*}
*/

/**
* Wrap a given input inside a comparison operator filter, prefixing the input by an operator selector
*
* @param {Compoenent} operandInput the input for the operand value (the one to wrap)
* @param {NumericComparisonOperatorSelectionModel} operatorSelectionModel the operator selection model
* @param {*} limitInput the input for the limit value (the one to wrap)
* @param {*} currentLimit the current limit value
* @param {operatorChangeHandler} onOperatorChange callback called when the operator changes
* @param {*} [operatorAttributes] the list of attributes to apply on the operator selector (note that value and
* onchange attribute are override)
*
* @return {ComponenT} the filter component
* @return {vnode} the filter component
*/
export const comparisonOperatorFilter = (operandInput, operatorSelectionModel, operatorAttributes = {}) => h('.flex-row.g3', [
export const comparisonOperatorFilter = (limitInput, currentLimit, onOperatorChange, operatorAttributes = {}) => h('.flex-row.g3', [
h('', h('select.form-control', {
...operatorAttributes,
value: operatorSelectionModel.selected,
onchange: (e) => operatorSelectionModel.select(e.target.value),
}, operatorSelectionModel.options?.map(({ value }) => h('option', {
value,
}, value)))), operandInput,
value: currentLimit,
onchange: (e) => onOperatorChange(e.target.value),
}, ['<', '<=', '=', '>=', '>'].map((operator) => h('option', {
value: operator,
}, operator)))), limitInput,
]);
Loading