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-536] Clean selection model #1835

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
119 changes: 119 additions & 0 deletions lib/database/seeders/20200508094502-logs.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions lib/domain/dtos/filters/RunFilterDto.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ exports.RunFilterDto = Joi.object({
dataPassIds: Joi.array().items(Joi.number()),
simulationPassIds: Joi.array().items(Joi.number()),
runTypes: CustomJoi.stringArray().items(Joi.string()).single().optional(),
aliceL3Current: Joi.number().integer(),
aliceDipoleCurrent: Joi.number().integer(),
magnets: Joi.object({
l3: Joi.number().integer(),
dipole: Joi.number().integer(),
}),
updatedAt: FromToFilterDto,

muInelasticInteractionRate: FloatComparisonDto,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* @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 { RemoteData } from '/js/src/index.js';
import { getRemoteData } from '../../../utilities/fetch/getRemoteData.js';
import { SelectionDropdownModel } from '../../common/selection/dropdown/SelectionDropdownModel.js';
import { FilterModel } from '../common/FilterModel.js';

/**
* AliceL3AndDipoleFilteringModel
*/
export class MagnetsFilteringModel extends FilterModel {
/**
* Constructor
*/
constructor() {
super();
this._selectionDropdownModel = new SelectionDropdownModel({ multiple: false });
this._addSubmodel(this._selectionDropdownModel);

Check warning on line 29 in lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L26-L29

Added lines #L26 - L29 were not covered by tests

this._valueToFilteringParamsMap = new Map();

Check warning on line 31 in lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L31

Added line #L31 was not covered by tests

getRemoteData('/api/runs/aliceMagnetsCurrentLevels')

Check warning on line 33 in lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L33

Added line #L33 was not covered by tests
.then(
({ data }) => {
data.sort((

Check warning on line 36 in lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L35-L36

Added lines #L35 - L36 were not covered by tests
{ l3Level: l3LevelA, dipoleLevel: dipoleLevelA },
{ l3Level: l3LevelB, dipoleLevel: dipoleLevelB },
) => l3LevelA - l3LevelB || dipoleLevelA - dipoleLevelB);

Check warning on line 39 in lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L39

Added line #L39 was not covered by tests

const options = [];
for (const { l3Level, dipoleLevel } of data) {
const value = `${l3Level}kA/${dipoleLevel}kA`;
options.push({

Check warning on line 44 in lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L41-L44

Added lines #L41 - L44 were not covered by tests
value,

});
this._valueToFilteringParamsMap.set(

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L48 was not covered by tests
value,
{
l3: l3Level,
dipole: dipoleLevel,
},
);
}
this._selectionDropdownModel.setAvailableOptions(RemoteData.success(options));

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

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L56

Added line #L56 was not covered by tests
},
(errors) => this._selectionDropdownModel.setAvailableOptions(RemoteData.failure(errors)),

Check warning on line 58 in lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L58

Added line #L58 was not covered by tests
);
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritDoc
*/
reset() {
this._selectionDropdownModel.reset();

Check warning on line 67 in lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L66-L67

Added lines #L66 - L67 were not covered by tests
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritDoc
*/
get isEmpty() {
return this._selectionDropdownModel.isEmpty;

Check warning on line 75 in lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L74-L75

Added lines #L74 - L75 were not covered by tests
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritDoc
*/
get normalized() {
return this._valueToFilteringParamsMap.get(this._selectionDropdownModel.selected[0]) ?? null;

Check warning on line 83 in lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L82-L83

Added lines #L82 - L83 were not covered by tests
}

/**
* Return the underlying selection dropdown model
*
* @return {SelectionDropdownModel} the dropdown model
*/
get selectionDropdownModel() {
return this._selectionDropdownModel;

Check warning on line 92 in lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/MagnetsFilteringModel.js#L91-L92

Added lines #L91 - L92 were not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { RUN_DEFINITIONS, RunDefinition } from '../../../domain/enums/RunDefinition.js';
import { SelectionFilterModel } from '../common/filters/SelectionFilterModel.js';

/**
* Run definition filter model
*/
export class RunDefinitionFilterModel extends SelectionFilterModel {
/**
* Constructor
*/
constructor() {
super({ availableOptions: RUN_DEFINITIONS.map((definition) => ({ value: definition })) });

Check warning on line 12 in lib/public/components/Filters/RunsFilter/RunDefinitionFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/RunDefinitionFilterModel.js#L11-L12

Added lines #L11 - L12 were not covered by tests
}

/**
* Returns true if the current filter is physics only
*
* @return {boolean} true if filter is physics only
*/
isPhysicsOnly() {
const selectedOptions = this._selectionModel.selected;
return selectedOptions.length === 1 && selectedOptions[0] === RunDefinition.Physics;

Check warning on line 22 in lib/public/components/Filters/RunsFilter/RunDefinitionFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/RunDefinitionFilterModel.js#L20-L22

Added lines #L20 - L22 were not covered by tests
}

/**
* Sets the current filter to physics only
*
* @return {void}
*/
setPhysicsOnly() {
if (!this.isPhysicsOnly()) {
this._selectionModel.selectedOptions = [];
this._selectionModel.select(RunDefinition.Physics);
this.notify();

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

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/RunDefinitionFilterModel.js#L30-L34

Added lines #L30 - L34 were not covered by tests
}
}

/**
* Empty the current filter
*
* @return {void}
*/
setEmpty() {
if (!this.isEmpty) {
this.reset();
this.notify();

Check warning on line 46 in lib/public/components/Filters/RunsFilter/RunDefinitionFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/RunDefinitionFilterModel.js#L43-L46

Added lines #L43 - L46 were not covered by tests
}
}
}
31 changes: 0 additions & 31 deletions lib/public/components/Filters/RunsFilter/definitionFilter.js

This file was deleted.

22 changes: 6 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,16 @@
* or submit itself to any jurisdiction.
*/

import { amountFilter } from '../common/filters/amountFilter.js';
import { numericalComparisonFilter } from '../common/filters/numericalComparisonFilter.js';

/**
* Returns the run duration filter component
* Component to filter on a duration
*
* @param {RunsOverviewModel} runModel the runs model object
* @param {NumericalComparisonFilterModel} numericalComparisonFilterModel the filter model
*
* @return {vnode} the duration filter
*/
export const durationFilter = (runModel) => amountFilter(
runModel.runDurationFilter,
(filter) => {
runModel.runDurationFilter = filter;
},
{
operatorAttributes: {
id: 'duration-operator',
},
limitAttributes: {
id: 'duration-limit',
},
},
export const durationFilter = (numericalComparisonFilterModel) => numericalComparisonFilter(

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L23 was not covered by tests
numericalComparisonFilterModel,
{ selectorPrefix: 'duration' },
);
31 changes: 0 additions & 31 deletions lib/public/components/Filters/RunsFilter/environmentId.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @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 { h } from '/js/src/index.js';

/**
* Returns a filter component to filter on environment ids (comma separated list)
*
* @param {RawTextFilterModel} filterModel the filter model
* @return {Component} the environment ids filter
*/
export const environmentIdsFilter = (filterModel) => h(

Check warning on line 22 in lib/public/components/Filters/RunsFilter/environmentIdsFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/environmentIdsFilter.js#L22

Added line #L22 was not covered by tests
'input.w-75.mt1',
{
type: 'text',
id: 'environment-ids-filter',
value: filterModel.value,
placeholder: 'e.g. Dxi029djX, TDI59So3d...',
onchange: (e) => {
filterModel.value = e.target.value;

Check warning on line 30 in lib/public/components/Filters/RunsFilter/environmentIdsFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/environmentIdsFilter.js#L29-L30

Added lines #L29 - L30 were not covered by tests
},
},
'',
);
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@
/**
* Returns a filter component to filter on a list of fill numbers
*
* @param {RunsOverviewModel} runModel the run model object
*
* @return {vnode} A text box that allows the user to enter a list of fill numbers
* @param {RawTextFilterModel} fillNumbersFilterModel the filter model
* @return {Component} the fill number filter component
*/
const fillNumbers = (runModel) => h('input.w-75.mt1', {
type: 'text',
id: 'fillNumbers',
value: runModel.getFillNumbersFilter(),
placeholder: 'e.g. 7966, 7954, 7948...',
oninput: (e) => runModel.setFillNumbersFilter(e.target.value),
}, '');

export default fillNumbers;
export const fillNumbersFilter = (fillNumbersFilterModel) => h(

Check warning on line 22 in lib/public/components/Filters/RunsFilter/fillNumbersFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/fillNumbersFilter.js#L22

Added line #L22 was not covered by tests
'input.w-75.mt1',
{
type: 'text',
id: 'fillNumbers',
value: fillNumbersFilterModel.value,
placeholder: 'e.g. 7966, 7954, 7948...',
oninput: (e) => {
fillNumbersFilterModel.value = e.target.value;

Check warning on line 30 in lib/public/components/Filters/RunsFilter/fillNumbersFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/fillNumbersFilter.js#L29-L30

Added lines #L29 - L30 were not covered by tests
},
},
'',
);
Loading
Loading