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] Improve runs overview run definition filter #1825

Draft
wants to merge 16 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
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 @@ export class DetectorsFilterModel extends Observable {
constructor(observableDetectors) {
super();
this._dropdownModel = new DetectorSelectionDropdownModel(observableDetectors);
this._dropdownModel.bubbleTo(this);
this._addSubmodel(this._dropdownModel);

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

// 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();
}

// 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();
}

// eslint-disable-next-line valid-jsdoc
/**
* Reset the model to its default state
* @inheritDoc
*/
get normalized() {
const normalized = {
operator: this._combinationOperatorModel.current,
};
if (!this.isNone()) {
normalized.values = this._dropdownModel.selected.join();
}
return normalized;
}

/**
* 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;
}

/**
Expand All @@ -73,13 +85,6 @@ export class DetectorsFilterModel extends Observable {
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 @@ export class DetectorsFilterModel extends Observable {
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();
// TODO this should go into a data provider
this._fetchReasonTypes();

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

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

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

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

if (this._category !== '') {
ret.category = this._category;
}
if (this._title !== '') {
ret.title = this._title;
}
if (this._description !== '') {
ret.description = this._description;
}

return ret;
}

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

/**
* 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();
}

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

/**
* 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();
}

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

/**
* 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();
}

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

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

/**
* 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();

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

this._visualChange$.notify();
}
}
Loading
Loading