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

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e3a78a5
[O2B-532] Create a reusable filtering system and apply it to run tags…
martinboulais Dec 16, 2024
07a4cdc
Minor improvements
martinboulais Dec 16, 2024
4129c8b
Fix reset
martinboulais Dec 17, 2024
f384b7b
Encode URI when it makes sense
martinboulais Dec 19, 2024
ea89858
Minor test refactoring
martinboulais Dec 19, 2024
2c091ce
Fix linter and missing import
martinboulais Dec 19, 2024
54bd5fd
Reformat
martinboulais Dec 19, 2024
85f4b71
Merge branch 'main' into feature/O2B-532/factorize-filtering
martinboulais Dec 20, 2024
4d5dce8
Merge branch 'main' into feature/O2B-532/factorize-filtering
martinboulais Jan 8, 2025
157b8f0
Minor improvement
martinboulais Jan 8, 2025
31e2e97
Merge branch 'main' into feature/O2B-532/factorize-filtering
martinboulais Jan 8, 2025
af69ef1
Merge branch 'main' into feature/O2B-532/factorize-filtering
martinboulais Jan 9, 2025
20dba8f
[O2B-532] Improve runs overview detectors filter
martinboulais Dec 16, 2024
5088d06
[O2B-532] Improve runs overview runs type filter
martinboulais Dec 16, 2024
a450bd8
[O2B-532] Improve runs overview EOR reasons filter
martinboulais Dec 16, 2024
133c73f
[O2B-532] Improve runs overview start/stop filters
martinboulais Dec 16, 2024
1ae5e3a
[O2B-532] Improve runs overview magnets filter
martinboulais Dec 16, 2024
25b4300
BuildURL and dropdown improvements cherry-pick
martinboulais Dec 20, 2024
a8acd00
[O2B-532] Improve runs overview inelastic interaction rates filtering
martinboulais Dec 16, 2024
d020c81
[O2B-532] Improve runs overview run number filter
martinboulais Dec 20, 2024
e7b2c37
[O2B-532] Improve runs overview run definition filter
martinboulais Dec 29, 2024
6c08942
[O2B-532] Improve runs overview fill number filter
martinboulais Jan 6, 2025
2d3c624
[O2B-532] Improve runs overview LHC periods filter
martinboulais Jan 6, 2025
958df49
[O2B-532] Improve runs overview duration filter
martinboulais Jan 7, 2025
09702a6
[O2B-532] Improve runs overview environment ID filter
martinboulais Jan 8, 2025
dbded88
[O2B-532] Improve runs overview run quality filter
martinboulais Jan 8, 2025
a9ff55e
[O2B-532] Improve run overview nFLPs, nEPNs and nDetectors filters
martinboulais Jan 10, 2025
0a27bfa
Clean selection model
martinboulais Jan 15, 2025
7d30630
Fix linter
martinboulais Jan 15, 2025
d94779f
Cleaning
martinboulais Jan 15, 2025
0bd328f
Factorize checkboxes/radio display
martinboulais Jan 15, 2025
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 @@ -59,8 +59,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.

75 changes: 31 additions & 44 deletions lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
* 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';
import { CombinationOperator, CombinationOperatorChoiceModel } from '../common/CombinationOperatorChoiceModel.js';
import { DetectorSelectionDropdownModel } from '../../detector/DetectorSelectionDropdownModel.js';
import { FilterModel } from '../common/FilterModel.js';

/**
* Model to store the state of the filtering on a detectors list
*/
export class DetectorsFilterModel extends Observable {
export class DetectorsFilterModel extends FilterModel {
/**
* Constructor
*
Expand All @@ -26,42 +26,54 @@
constructor(observableDetectors) {
super();
this._dropdownModel = new DetectorSelectionDropdownModel(observableDetectors);
this._dropdownModel.bubbleTo(this);
this._addSubmodel(this._dropdownModel);

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

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js#L29

Added line #L29 was not covered by tests

this._combinationOperatorModel = new CombinationOperatorChoiceModel([
CombinationOperator.AND,
CombinationOperator.OR,
CombinationOperator.NONE,
]);
this._combinationOperatorModel.bubbleTo(this);
this._addSubmodel(this._combinationOperatorModel);

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

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js#L36

Added line #L36 was not covered by tests
}

// eslint-disable-next-line valid-jsdoc
/**
* States if the filter has no tags selected
*
* @return {boolean} true if no tags are selected
* @inheritDoc
*/
isEmpty() {
return this.selected.length === 0 && !this.isNone();
reset() {
this._dropdownModel.reset();
this._combinationOperatorModel.reset();

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L43 - L45 were not covered by tests
}

// eslint-disable-next-line valid-jsdoc
/**
* Return true if the current combination operator is none
*
* @return {boolean} true if the current combination operator is none
* @inheritDoc
*/
isNone() {
return this.combinationOperator === CombinationOperator.NONE.value;
get isEmpty() {
return this._dropdownModel.isEmpty && !this.isNone();

Check warning on line 53 in lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js#L52-L53

Added lines #L52 - L53 were not covered by tests
}

// eslint-disable-next-line valid-jsdoc
/**
* Reset the model to its default state
* @inheritDoc
*/
get normalized() {
const normalized = {

Check warning on line 61 in lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js#L60-L61

Added lines #L60 - L61 were not covered by tests
operator: this._combinationOperatorModel.current,
};
if (!this.isNone()) {
normalized.values = this._dropdownModel.selected.join();

Check warning on line 65 in lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js#L64-L65

Added lines #L64 - L65 were not covered by tests
}
return normalized;

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

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js#L67

Added line #L67 was not covered by tests
}

/**
* Return true if the current combination operator is none
*
* @return {void}
* @return {boolean} true if the current combination operator is none
*/
reset() {
this._dropdownModel.reset();
this._combinationOperatorModel.reset();
isNone() {
return this._combinationOperatorModel.current === CombinationOperator.NONE.value;

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

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js#L75-L76

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

/**
Expand All @@ -73,13 +85,6 @@
return this._dropdownModel;
}

/**
* Shortcut to get the list of selected detectors
*/
get selected() {
return this._dropdownModel.selected;
}

/**
* Return the model storing the combination operator to apply on the list of detectors
*
Expand All @@ -88,22 +93,4 @@
get combinationOperatorModel() {
return this._combinationOperatorModel;
}

/**
* Shortcut to get the current combination operator
*
* @return {string} the current operator
*/
get combinationOperator() {
return this._combinationOperatorModel.current;
}

/**
* Returns an observable notified any time a visual change occurs that has no impact on the actual selection
*
* @return {Observable} the visual change observable
*/
get visualChange$() {
return this._dropdownModel.visualChange$;
}
}
174 changes: 174 additions & 0 deletions lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/**
* @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 { FilterModel } from '../common/FilterModel.js';

/**
* Model storing state of a selection of run types picked from the list of all the existing run types
*/
export class EorReasonFilterModel extends FilterModel {
/**
* Constructor
*/
constructor() {
super();
this._eorReasonTypes = RemoteData.notAsked();

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

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L25-L27

Added lines #L25 - L27 were not covered by tests
// TODO this should go into a data provider
this._fetchReasonTypes();

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

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L29

Added line #L29 was not covered by tests

this._category = '';
this._title = '';
this._rawDescription = '';
this._description = '';

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

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L31-L34

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

// eslint-disable-next-line valid-jsdoc
/**
* @inheritDoc
*/
reset() {
this._category = '';
this._title = '';
this._rawDescription = '';
this._description = '';

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

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L41-L45

Added lines #L41 - L45 were not covered by tests
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritDoc
*/
get isEmpty() {
return this._category === '' && this._title === '' && this._description === '';

Check warning on line 53 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L52-L53

Added lines #L52 - L53 were not covered by tests
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritDoc
*/
get normalized() {
const ret = {};

Check warning on line 61 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L60-L61

Added lines #L60 - L61 were not covered by tests

if (this._category !== '') {
ret.category = this._category;

Check warning on line 64 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L63-L64

Added lines #L63 - L64 were not covered by tests
}
if (this._title !== '') {
ret.title = this._title;

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L66 - L67 were not covered by tests
}
if (this._description !== '') {
ret.description = this._description;

Check warning on line 70 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L69-L70

Added lines #L69 - L70 were not covered by tests
}

return ret;

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L73 was not covered by tests
}

/**
* Returns the EOR reason filter category
*
* @return {string} the category
*/
get category() {
return this._category;

Check warning on line 82 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L81-L82

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

/**
* Sets the category of the EOR reason filter category and reset the title
*
* @param {string} category the category of the new EOR reason filter
* @return {void}
*/
set category(category) {
this._category = category;
this._title = '';
this.notify();

Check warning on line 94 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L91-L94

Added lines #L91 - L94 were not covered by tests
}

/**
* Returns the EOR reason filter title
*
* @return {string} the title
*/
get title() {
return this._title;

Check warning on line 103 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L102-L103

Added lines #L102 - L103 were not covered by tests
}

/**
* Sets the EOR reason filter title
*
* @param {string} title the title of the new EOR reason filter
* @return {void}
*/
set title(title) {
this._title = title;
this.notify();

Check warning on line 114 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L112-L114

Added lines #L112 - L114 were not covered by tests
}

/**
* Returns the raw value of EOR reason filter description
*
* @return {string} the raw description
*/
get rawDescription() {
return this._rawDescription;

Check warning on line 123 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L122-L123

Added lines #L122 - L123 were not covered by tests
}

/**
* Sets the raw value of EOR reason filter description
*
* @param {string} rawDescription the raw description
* @return {void}
*/
set rawDescription(rawDescription) {
this._rawDescription = rawDescription;
this.visualChange$.notify();

Check warning on line 134 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L132-L134

Added lines #L132 - L134 were not covered by tests
}

/**
* Sets the EOR reason filter description
*
* @param {string} description the description
* @return {void}
*/
set description(description) {
this._description = description;
this.notify();

Check warning on line 145 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L143-L145

Added lines #L143 - L145 were not covered by tests
}

/**
* Getter for the EOR reason types
* @return {Object} the EOR reason type
*/
get eorReasonTypes() {
return this._eorReasonTypes;

Check warning on line 153 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L152-L153

Added lines #L152 - L153 were not covered by tests
}

/**
* Retrieve a list of reason types from the API
*
* @return {Promise<void>} resolves once the data has been fetched
*/
async _fetchReasonTypes() {
this._eorReasonTypes = RemoteData.loading();
this._visualChange$.notify();

Check warning on line 163 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L161-L163

Added lines #L161 - L163 were not covered by tests

try {
const { data: reasonTypes } = await getRemoteData('/api/runs/reasonTypes');
this._eorReasonTypes = RemoteData.success(reasonTypes);

Check warning on line 167 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L165-L167

Added lines #L165 - L167 were not covered by tests
} catch (error) {
this._eorReasonTypes = RemoteData.failure(error);

Check warning on line 169 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L169

Added line #L169 was not covered by tests
}

this._visualChange$.notify();

Check warning on line 172 in lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js#L172

Added line #L172 was not covered by tests
}
}
Loading
Loading