Skip to content
Draft
Show file tree
Hide file tree
Changes from 20 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
70 changes: 54 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,64 @@
* 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 {NumericComparisonOperatorSelectionModel} 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, secondsMin, minutesMin } = durationFilterModel.raw;

const hoursInput = h('input.flex-grow', {
id: 'hours-input',
type: 'number',
min: 0,
value: hours,
oninput: (e) => {
const { value } = e.target;
durationFilterModel.update({ hours: value.length === 0 ? null : Number(value) });
},
});
const minutesInput = h('input.flex-grow', {
id: 'minutes-input',
type: 'number',
min: minutesMin,
max: 60,
value: minutes,
oninput: (e) => {
const { value } = e.target;
durationFilterModel.update({ minutes: value.length === 0 ? null : Number(value) });
},
limitAttributes: {
id: 'duration-limit',
}, 'm');
const secondsInput = h('input.flex-grow', {
id: 'seconds-input',
type: 'number',
min: secondsMin,
max: 60,
value: seconds,
oninput: (e) => {
const { value } = e.target;
durationFilterModel.update({ seconds: value.length === 0 ? null : Number(value) });
},
},
);
}, 's');

const inputs = h('.flex-row.w-40', [
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(inputs, operatorSelectionModel);
};
30 changes: 0 additions & 30 deletions lib/public/components/Filters/RunsFilter/nDetectors.js

This file was deleted.

36 changes: 0 additions & 36 deletions lib/public/components/Filters/RunsFilter/nEpns.js

This file was deleted.

30 changes: 0 additions & 30 deletions lib/public/components/Filters/RunsFilter/nFlps.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @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 { SelectionDropdownModel } from '../../../common/selection/dropdown/SelectionDropdownModel.js';

/**
* Model storing state of a selection of predfined numerical comparison operators
*/
export class NumericComparisonOperatorSelectionModel extends SelectionDropdownModel {
/**
* Constructor
* @param {string} [defaultOperator = '='] one of ['<', '<=', '=', '>=', '>'] operators
*/
constructor(defaultOperator = '=') {
super({
availableOptions: ['<', '<=', '=', '>=', '>'].map((op) => ({ value: op })),
multiple: false,
allowEmpty: false,
defaultSelection: [{ value: defaultOperator }],
});
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritDoc
*/
get selected() {
return super.selected[0];
}
}
89 changes: 89 additions & 0 deletions lib/public/components/Filters/common/filters/NumericFilterModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* @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 { NumericComparisonOperatorSelectionModel } from './NumericComparisonOperatorSelectionModel.js';
import { Observable } from '/js/src/index.js';

/**
* Model storing state of a expected value of something with respect of comprison operator
*/
export class NumericFilterModel extends Observable {
/**
* Constructor
* @param {object} configuration configration
* @param {number} [configration.minValue] minimal value allowed in model
* @param {number} [configration.maxValue] maximum value allowed in model
* @param {number} [configration.defaultOperator] defaultOperator one of ['<', '<=', '=', '>=', '>'] operators
*/
constructor({ min, max, defaultOperator }) {
super();

this._minValue = min;
this._maxValue = max;

this._operatorSelectionModel = new NumericComparisonOperatorSelectionModel(defaultOperator);
this._operatorSelectionModel.observe(() => {
if (this._value !== null) {
this.notify();
}
});

this._value = null;
}

/**
* Get minimum allowed value
*/
get minValue() {
return this._minValue;
}

/**
* Get maximum allowed value
*/
get maxValue() {
return this._maxValue;
}

/**
* Reset to default
* @return {void}
*/
reset() {
this._value = null;
this._operatorSelectionModel.reset();
}

/**
* Get value - operand to comparison
*/
get value() {
return this._value;
}

/**
* Set current value of operand
* @param {number} value value
*/
set value(value) {
this._value = value;
this.notify();
}

/**
* Get operator selection model
*/
get operatorSelectionModel() {
return this._operatorSelectionModel;
}
}
58 changes: 17 additions & 41 deletions lib/public/components/Filters/common/filters/amountFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,36 @@
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 {{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
* @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
*
* @return {vnode} the component
* @return {Component} the filter component
*/
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,
});
};
export const amountFilter = (numericFilterModel, options) => {
const { operatorSelectionModel } = numericFilterModel;

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

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

if (newLimit !== undefined && newLimit !== limit) {
updateFilter({ newLimit });
numericFilterModel.value = Number(value);
}
},
...limitAttributes,
...options.operandAttributes,
}, ''),
operator,
(newOperator) => updateFilter({ newOperator }),
operatorAttributes,
operatorSelectionModel,
options.operatorAttributes,
);
};
Loading