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-1155] Add QC flag creation panel #1504

Merged
merged 127 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
2a68a96
refactor
xsalonx Apr 9, 2024
9b9438b
typos
xsalonx Apr 9, 2024
ab3a3c6
add testS
xsalonx Apr 9, 2024
ac5ed21
fix
xsalonx Apr 9, 2024
b2e184a
fix
xsalonx Apr 9, 2024
f00bf33
test
xsalonx Apr 9, 2024
77b33f1
refactor'
xsalonx Apr 9, 2024
d2dfc44
fix
xsalonx Apr 9, 2024
c6c840b
refactor
xsalonx Apr 9, 2024
2f1ac2b
refactor
xsalonx Apr 9, 2024
9c31108
add controller
xsalonx Apr 9, 2024
928c23c
test
xsalonx Apr 9, 2024
d0c1d92
test
xsalonx Apr 9, 2024
4fb4c0a
more rigid
xsalonx Apr 9, 2024
b48780c
mr
xsalonx Apr 9, 2024
f4eda9f
cleanup
xsalonx Apr 9, 2024
798d01e
ceanup
xsalonx Apr 9, 2024
175ca10
Merge branch 'main' into xsalonx/QCF/O2B-1120/creation-API
xsalonx Apr 9, 2024
db600b5
refactor
xsalonx Apr 9, 2024
b831876
refactor
xsalonx Apr 9, 2024
de58d97
cleanup
xsalonx Apr 9, 2024
64c80d8
Merge branch 'main' into xsalonx/QCF/O2B-1120/creation-API
xsalonx Apr 9, 2024
7e92023
ref
xsalonx Apr 9, 2024
43bc001
ch err
xsalonx Apr 9, 2024
8d8634c
test
xsalonx Apr 9, 2024
51fd126
use default timestamps
xsalonx Apr 9, 2024
c0d74e4
refactor
xsalonx Apr 10, 2024
fc8b944
refactor
xsalonx Apr 10, 2024
a391574
fix
xsalonx Apr 10, 2024
8454884
docs
xsalonx Apr 10, 2024
0a1740e
handle missing timestamps
xsalonx Apr 10, 2024
d02762f
typo
xsalonx Apr 10, 2024
c62dd0a
dates
xsalonx Apr 10, 2024
8236f4b
test
xsalonx Apr 10, 2024
3b38f1e
test
xsalonx Apr 10, 2024
1977563
test
xsalonx Apr 10, 2024
815cd9f
Merge branch 'main' into xsalonx/QCF/O2B-1120/creation-API
xsalonx Apr 10, 2024
7ac0685
Merge branch 'main' into xsalonx/QCF/O2B-1120/creation-API
xsalonx Apr 10, 2024
069841c
add front model
xsalonx Apr 10, 2024
b840071
add provider
xsalonx Apr 10, 2024
7a8c449
color
xsalonx Apr 10, 2024
3bede36
cleanup
xsalonx Apr 10, 2024
75449c1
add stuff
xsalonx Apr 10, 2024
f37f3a7
refactor
xsalonx Apr 10, 2024
561c8ed
spec
xsalonx Apr 11, 2024
33a2ab2
WIP
xsalonx Apr 11, 2024
cf352e6
add add btn
xsalonx Apr 11, 2024
5d9f785
WIP
xsalonx Apr 11, 2024
bd7fa1c
merge main
xsalonx Apr 11, 2024
a074886
Merge branch 'main' into xsalonx/QCF/O2B-1155/creation-panel
xsalonx Apr 11, 2024
2aa5301
expose WIP
xsalonx Apr 11, 2024
ce9fb74
fiux
xsalonx Apr 11, 2024
272c527
fix
xsalonx Apr 11, 2024
803b387
A
xsalonx Apr 11, 2024
05c267b
breadcrumbs work
xsalonx Apr 11, 2024
950f7c1
fix
xsalonx Apr 11, 2024
202ee8a
WIP
xsalonx Apr 11, 2024
e86fd13
fix
xsalonx Apr 11, 2024
856a5fe
update
xsalonx Apr 11, 2024
fc2245d
fix
xsalonx Apr 11, 2024
d3ea3e1
WI
xsalonx Apr 11, 2024
3b731a9
can send flag
xsalonx Apr 11, 2024
dce70eb
send comment
xsalonx Apr 11, 2024
e7f28ff
simp
xsalonx Apr 11, 2024
99869dc
cleanu
xsalonx Apr 11, 2024
9ceced4
cleanu
xsalonx Apr 11, 2024
e882bef
docs
xsalonx Apr 11, 2024
0550912
add validity cond
xsalonx Apr 11, 2024
ca985eb
fix
xsalonx Apr 11, 2024
fe9aa2f
test
xsalonx Apr 11, 2024
04fc525
cleanup
xsalonx Apr 11, 2024
f47df0c
cleanup
xsalonx Apr 11, 2024
73db2d7
cleanup
xsalonx Apr 11, 2024
67bb32f
ref
xsalonx Apr 11, 2024
c647701
cleanup
xsalonx Apr 11, 2024
4ce2c44
a
xsalonx Apr 11, 2024
ad0cd4d
typo
xsalonx Apr 11, 2024
122d691
a
xsalonx Apr 11, 2024
bb1035a
typo
xsalonx Apr 11, 2024
cd4ecfb
typo
xsalonx Apr 11, 2024
574f8e2
simp
xsalonx Apr 11, 2024
cc24dfd
simp
xsalonx Apr 11, 2024
6300589
ref
xsalonx Apr 11, 2024
590bb80
Update lib/public/views/QcFlags/Create/ForDataPass/QcFlagForDataPassC…
xsalonx Apr 11, 2024
3610be9
Update lib/public/views/QcFlags/Create/ForDataPass/QcFlagForDataPassC…
xsalonx Apr 11, 2024
f7d0963
rename
xsalonx Apr 11, 2024
6f51e5d
refactor
xsalonx Apr 11, 2024
ede2336
refactor
xsalonx Apr 11, 2024
f0db2e7
refactor
xsalonx Apr 11, 2024
82233d4
simp
xsalonx Apr 11, 2024
278e91f
ref
xsalonx Apr 11, 2024
8717bc9
simp
xsalonx Apr 11, 2024
3c2b437
fix
xsalonx Apr 11, 2024
8ce4331
rename
xsalonx Apr 11, 2024
2a58963
refactor
xsalonx Apr 11, 2024
4dda213
refactor
xsalonx Apr 11, 2024
6d82cc5
change order
xsalonx Apr 11, 2024
e16692d
increase timeout
xsalonx Apr 11, 2024
8289e14
rework qc type badge
xsalonx Apr 12, 2024
c04ca28
use rawLabel
xsalonx Apr 12, 2024
28fc31a
fix test
xsalonx Apr 12, 2024
d385910
use badge
xsalonx Apr 12, 2024
f6aad71
cleanup
xsalonx Apr 12, 2024
154ba4e
fix
xsalonx Apr 12, 2024
45a10cf
fix
xsalonx Apr 12, 2024
f64d3b6
fix
xsalonx Apr 12, 2024
8a8a176
test
xsalonx Apr 12, 2024
a12d322
fix test
xsalonx Apr 12, 2024
b73a376
revoke
xsalonx Apr 12, 2024
e9603cc
docs
xsalonx Apr 12, 2024
6e75c9e
fix test
xsalonx Apr 12, 2024
18e3039
refactor
xsalonx Apr 12, 2024
2dc01f2
rename
xsalonx Apr 12, 2024
982fb1a
rename
xsalonx Apr 12, 2024
f3c54e7
rename
xsalonx Apr 12, 2024
170d1fc
use min,max
xsalonx Apr 12, 2024
81eb771
docs
xsalonx Apr 12, 2024
63c1068
simp provider
xsalonx Apr 12, 2024
d41d10a
Merge branch 'main' into xsalonx/QCF/O2B-1155/creation-panel
xsalonx Apr 12, 2024
694851b
rename
xsalonx Apr 12, 2024
9dcb57d
fix
xsalonx Apr 12, 2024
7d7c89b
merge main
xsalonx Apr 12, 2024
ce1ebce
ref
xsalonx Apr 12, 2024
272b67f
switch ifs
xsalonx Apr 12, 2024
197c8e4
fix test
xsalonx Apr 12, 2024
f739d8c
fix test
xsalonx Apr 12, 2024
755f22c
add padding
xsalonx Apr 12, 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
16 changes: 8 additions & 8 deletions lib/database/seeders/20240213120811-quality-control-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@ module.exports = {
queryInterface.bulkInsert('quality_control_flag_types', [
{
id: 2,
name: 'UnknownQuality',
method: 'Unknown Quality',
name: 'Unknown Quality',
method: 'UnknownQuality',
bad: true,
created_by_id: 1,
},
{
id: 3,
name: 'CertifiedByExpert',
method: 'Certified by Expert',
name: 'Certified by Expert',
method: 'CertifiedByExpert',
bad: false,
created_by_id: 1,
},
{
id: 11,
name: 'LimitedAcceptance',
method: 'Limited acceptance',
name: 'Limited acceptance',
method: 'LimitedAcceptance',
bad: true,
color: '#FFFF00',
created_by_id: 1,
},
{
id: 12,
name: 'BadPID',
method: 'Bad PID',
name: 'Bad PID',
method: 'BadPID',
bad: true,
created_by_id: 1,
},
Expand Down
5 changes: 4 additions & 1 deletion lib/public/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
this.dataPasses = new DataPassesModel(this);
this.dataPasses.bubbleTo(this);

this.qcFlags = new QcFlagsModel();
this.qcFlags = new QcFlagsModel(this);

Check warning on line 83 in lib/public/Model.js

View check run for this annotation

Codecov / codecov/patch

lib/public/Model.js#L83

Added line #L83 was not covered by tests
this.qcFlags.bubbleTo(this);

this.simulationPasses = new SimulationPassesModel(this);
Expand Down Expand Up @@ -194,6 +194,9 @@
case 'qc-flags-for-data-pass':
this.qcFlags.loadForDataPassOverview(this.router.params);
break;
case 'qc-flag-creation-for-data-pass':
this.qcFlags.loadCreationForDataPass(this.router.params);
break;

Check warning on line 199 in lib/public/Model.js

View check run for this annotation

Codecov / codecov/patch

lib/public/Model.js#L197-L199

Added lines #L197 - L199 were not covered by tests
case 'qc-flags-for-simulation-pass':
this.qcFlags.loadForSimulationPassOverview(this.router.params);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Model for a date time limits filter
*/
export class TimeRangeFilterModel extends FilterModel {
export class TimeRangeInputModel extends FilterModel {
/**
* Constructor
*
Expand All @@ -33,15 +33,16 @@
* @param {object} [configuration] the inputs configuration
* @param {(boolean|{from: boolean, to: boolean})} [configuration.required] defines if the from/to dates are required (true means both are
* required)
* @property {boolean} [configuration.seconds=false] states if the input has granularity up to seconds (if not, granularity is minutes)
*/
constructor(value, periodLabel, configuration) {
super();

const { required = false } = configuration || {};
const { required = false, seconds } = configuration || {};

Check warning on line 41 in lib/public/components/Filters/common/filters/TimeRangeInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/common/filters/TimeRangeInputModel.js#L41

Added line #L41 was not covered by tests
this._required = required;

this._fromTimeInputModel = new DateTimeInputModel();
this._toTimeInputModel = new DateTimeInputModel();
this._fromTimeInputModel = new DateTimeInputModel({ seconds });
this._toTimeInputModel = new DateTimeInputModel({ seconds });

Check warning on line 45 in lib/public/components/Filters/common/filters/TimeRangeInputModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/common/filters/TimeRangeInputModel.js#L44-L45

Added lines #L44 - L45 were not covered by tests

// eslint-disable-next-line no-return-assign
this._fromTimeInputModel.observe(() => this._periodLabel = null);
Expand Down
36 changes: 6 additions & 30 deletions lib/public/components/Filters/common/filters/timeRangeFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
import { dropdown } from '../../../common/popover/dropdown.js';
import { h } from '/js/src/index.js';
import { DateTimeInputComponent } from '../../../common/form/inputs/DateTimeInputComponent.js';
import {
getLocaleDateAndTime,
getStartOfMonth,
Expand All @@ -22,6 +21,7 @@ import {
MONTH_NAMES,
} from '../../../../utilities/dateUtils.js';
import { formatTimeRange } from '../../../common/formatting/formatTimeRange.js';
import { timeRangeInput } from '../../../common/form/inputs/TimeRangeInputComponent.js';

/**
* Amount of years to display as pre-defined options
Expand All @@ -30,12 +30,6 @@ import { formatTimeRange } from '../../../common/formatting/formatTimeRange.js';
*/
const YEARS_OPTIONS_COUNT = 3;

/**
* Time input step (1 minute, not configurable for now in the dateTimeInput)
* @type {number}
*/
const TIME_STEP = 60 * 1000;

/**
* Returns a pre-defined list of years period selectors
*
Expand Down Expand Up @@ -96,7 +90,7 @@ const monthsOptions = ({ onChange }) => {
/**
* Return a time range filter component
*
* @param {TimeRangeFilterModel} timeRangeFilterModel the model of the filter
* @param {TimeRangeInputModel} timeRangeFilterModel the model of the filter
* @return {Component} the resulting component
*/
export const timeRangeFilter = (timeRangeFilterModel) => dropdown(
Expand All @@ -118,28 +112,10 @@ export const timeRangeFilter = (timeRangeFilterModel) => dropdown(
],
),
h('.flex-row.time-range-selector', [
h('.flex-column.g3.p3', [
h('.flex-column.g1', [
h('label.flex-row.g2', [h('', 'From'), h('.gray-darker', '(Included)')]),
h(DateTimeInputComponent, {
value: timeRangeFilterModel.fromTimeInputModel.raw,
onChange: (value) => timeRangeFilterModel.fromTimeInputModel.update(value),
defaults: { time: '00:00' },
required: timeRangeFilterModel.isRequired(),
max: timeRangeFilterModel.toTimeInputModel.value ? timeRangeFilterModel.toTimeInputModel.value - TIME_STEP : null,
}),
]),
h('.flex-column.g1', [
h('label.flex-row.g2', [h('', 'To'), h('.gray-darker', '(Excluded)')]),
h(DateTimeInputComponent, {
value: timeRangeFilterModel.toTimeInputModel.raw,
onChange: (value) => timeRangeFilterModel.toTimeInputModel.update(value),
defaults: { time: '00:00' },
required: timeRangeFilterModel.isRequired(),
min: timeRangeFilterModel.fromTimeInputModel.value ? timeRangeFilterModel.fromTimeInputModel.value + TIME_STEP : null,
}),
]),
]),
timeRangeInput(timeRangeFilterModel, {
fromInputConfiguration: { label: [h('', 'From'), h('.gray-darker', '(Included)')] },
toInputConfiguration: { label: [h('', 'To'), h('.gray-darker', '(Excluded)')] },
}),
h(
'.flex-column.dropdown-options.text-center',
{ style: { 'border-left': '1px solid var(--color-gray)' } },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* @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';
import { DateTimeInputComponent } from '../../../common/form/inputs/DateTimeInputComponent.js';

/**
* @typedef TimeInputConfiguration
* @property {string|Componenet|null} label label for input, if null default label is rendered
*/

/**
* @typedef TimeRangeInputComponentOptions
* @property {boolean} [seconds=false] states if the input has granularity up to seconds (if not, granularity is minutes)
* @property {number} min minimal timestamp accepted by both inputs
* @property {number} max maximal timestamp accepted by both inputs
* @property {TimeInputConfiguration} fromInputConfiguration `from` input additioal configuration
* @property {TimeInputConfiguration} toInputConfiguration `to` input additional configuration
*/

/**
* Return a time range input component
*
* @param {TimeRangeInputModel} timeRangeInputModel the model of the time range input
* @param {TimeRangeInputComponentOptions} options inputs options
* @return {Component} time range input component
*/
export const timeRangeInput = (timeRangeInputModel, { seconds, min, max, fromInputConfiguration, toInputConfiguration } = {}) => {
const { label: fromLabel = h('', 'From') } = fromInputConfiguration || {};
const { label: toLabel = h('', 'To') } = toInputConfiguration || {};

Check warning on line 39 in lib/public/components/common/form/inputs/TimeRangeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/TimeRangeInputComponent.js#L37-L39

Added lines #L37 - L39 were not covered by tests

const { value: fromValue } = timeRangeInputModel.fromTimeInputModel;
const { value: toValue } = timeRangeInputModel.toTimeInputModel;

Check warning on line 42 in lib/public/components/common/form/inputs/TimeRangeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/TimeRangeInputComponent.js#L41-L42

Added lines #L41 - L42 were not covered by tests

let fromMax;
if (max) {
fromMax = toValue ? Math.min(toValue, max) : max;

Check warning on line 46 in lib/public/components/common/form/inputs/TimeRangeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/TimeRangeInputComponent.js#L45-L46

Added lines #L45 - L46 were not covered by tests
} else {
fromMax = toValue;

Check warning on line 48 in lib/public/components/common/form/inputs/TimeRangeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/TimeRangeInputComponent.js#L48

Added line #L48 was not covered by tests
}

let toMin;
if (min) {
toMin = fromValue ? Math.max(fromValue, min) : min;

Check warning on line 53 in lib/public/components/common/form/inputs/TimeRangeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/TimeRangeInputComponent.js#L52-L53

Added lines #L52 - L53 were not covered by tests
} else {
toMin = fromValue;

Check warning on line 55 in lib/public/components/common/form/inputs/TimeRangeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/TimeRangeInputComponent.js#L55

Added line #L55 was not covered by tests
}

const timeStep = seconds ? 1000 : 60 * 1000;
return h('.flex-column.g3.p3', [

Check warning on line 59 in lib/public/components/common/form/inputs/TimeRangeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/TimeRangeInputComponent.js#L58-L59

Added lines #L58 - L59 were not covered by tests
h('.flex-column.g1', [
h('label.flex-row.g2', fromLabel),
h(DateTimeInputComponent, {
value: timeRangeInputModel.fromTimeInputModel.raw,
onChange: (value) => timeRangeInputModel.fromTimeInputModel.update(value),

Check warning on line 64 in lib/public/components/common/form/inputs/TimeRangeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/TimeRangeInputComponent.js#L64

Added line #L64 was not covered by tests
required: timeRangeInputModel.isRequired(),
seconds,
min,
max: fromMax ? fromMax - timeStep : null,

Check warning on line 68 in lib/public/components/common/form/inputs/TimeRangeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/TimeRangeInputComponent.js#L68

Added line #L68 was not covered by tests
}),
]),
h('.flex-column.g1', [
h('label.flex-row.g2', toLabel),
h(DateTimeInputComponent, {
value: timeRangeInputModel.toTimeInputModel.raw,
onChange: (value) => timeRangeInputModel.toTimeInputModel.update(value),

Check warning on line 75 in lib/public/components/common/form/inputs/TimeRangeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/TimeRangeInputComponent.js#L75

Added line #L75 was not covered by tests
required: timeRangeInputModel.isRequired(),
seconds,
min: toMin ? toMin + timeStep : null,

Check warning on line 78 in lib/public/components/common/form/inputs/TimeRangeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/TimeRangeInputComponent.js#L78

Added line #L78 was not covered by tests
max,
}),
]),
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @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';
import { RemoteData } from '/js/src/index.js';
import { qcFlagTypesProvider } from '../../services/qcFlags/qcFlagTypesProvider.js';
import { qcFlagTypeColoredBadge } from '../../views/QcFlags/common/qcFlagTypeColoredBadge.js';

/**
* Model storing state of a selection of QC flag types picked from the list of all the existing types
*/
export class QcFlagTypesSelectionDropdownModel extends SelectionDropdownModel {
// eslint-disable-next-line valid-jsdoc
/**
* @inheritDoc
*/
constructor(configuration) {
super({

Check warning on line 28 in lib/public/components/qcFlags/qcFlagTypesSelectionDropdownModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/qcFlags/qcFlagTypesSelectionDropdownModel.js#L27-L28

Added lines #L27 - L28 were not covered by tests
availableOptions: RemoteData.notAsked(),
...configuration,
});
}

// eslint-disable-next-line valid-jsdoc
/**
* @inheritDoc
*/
_initialize() {

Check warning on line 38 in lib/public/components/qcFlags/qcFlagTypesSelectionDropdownModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/qcFlags/qcFlagTypesSelectionDropdownModel.js#L38

Added line #L38 was not covered by tests
/**
* Update dropdown model options with QC flag types provider remote data
* @return {void}
*/
const update = () => this.setAvailableOptions(qcFlagTypesProvider.notArchived$.getCurrent().apply({
Success: (qcFlagTypes) => qcFlagTypes.map((qcFlagType) => ({

Check warning on line 44 in lib/public/components/qcFlags/qcFlagTypesSelectionDropdownModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/qcFlags/qcFlagTypesSelectionDropdownModel.js#L43-L44

Added lines #L43 - L44 were not covered by tests
value: qcFlagType.id,
label: qcFlagTypeColoredBadge(qcFlagType),
rawLabel: qcFlagType.name,
})),
}));
qcFlagTypesProvider.notArchived$.observe(update);
update();

Check warning on line 51 in lib/public/components/qcFlags/qcFlagTypesSelectionDropdownModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/qcFlags/qcFlagTypesSelectionDropdownModel.js#L50-L51

Added lines #L50 - L51 were not covered by tests
}
}
70 changes: 70 additions & 0 deletions lib/public/services/qcFlags/qcFlagTypesProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* @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 { Observable, RemoteData } from '/js/src/index.js';
import { getRemoteData } from '../../utilities/fetch/getRemoteData.js';
import { ObservableData } from '../../utilities/ObservableData.js';

/**
* Service class to fetch QC flag types from the backend
*/
export class QcFlagTypesProvider extends Observable {
/**
* Constructor
*/
constructor() {
super();
this._notArchived$ = new ObservableData(RemoteData.notAsked());

Check warning on line 27 in lib/public/services/qcFlags/qcFlagTypesProvider.js

View check run for this annotation

Codecov / codecov/patch

lib/public/services/qcFlags/qcFlagTypesProvider.js#L25-L27

Added lines #L25 - L27 were not covered by tests
}

/**
* Return not archived QC flag types observable data
*
* @return {ObservableData<RemoteData<QcFlagType[], ApiError>>} the observable QC flag types
*/
get notArchived$() {
if (this._isStale()) {
this._load();

Check warning on line 37 in lib/public/services/qcFlags/qcFlagTypesProvider.js

View check run for this annotation

Codecov / codecov/patch

lib/public/services/qcFlags/qcFlagTypesProvider.js#L35-L37

Added lines #L35 - L37 were not covered by tests
}
return this._notArchived$;

Check warning on line 39 in lib/public/services/qcFlags/qcFlagTypesProvider.js

View check run for this annotation

Codecov / codecov/patch

lib/public/services/qcFlags/qcFlagTypesProvider.js#L39

Added line #L39 was not covered by tests
}

/**
* States if the cached QC flag types list need to be created or updated
*
* @return {boolean} true if the QC flag types list must be refreshed
* @private
*/
_isStale() {
return this._notArchived$.getCurrent().match({
NotAsked: () => true,
Other: () => false,

Check warning on line 51 in lib/public/services/qcFlags/qcFlagTypesProvider.js

View check run for this annotation

Codecov / codecov/patch

lib/public/services/qcFlags/qcFlagTypesProvider.js#L48-L51

Added lines #L48 - L51 were not covered by tests
});
}

/**
* Load all the QC flag types and feed the observable data
*
* @return {void}
* @private
*/
_load() {
this._notArchived$.setCurrent(RemoteData.loading());
getRemoteData('/api/qcFlagTypes?filter[archived]=false').then(
({ data: qcFlagTypes }) => this._notArchived$.setCurrent(RemoteData.success(qcFlagTypes)),
(error) => this._notArchived$.setCurrent(RemoteData.failure(error)),

Check warning on line 65 in lib/public/services/qcFlags/qcFlagTypesProvider.js

View check run for this annotation

Codecov / codecov/patch

lib/public/services/qcFlags/qcFlagTypesProvider.js#L61-L65

Added lines #L61 - L65 were not covered by tests
);
}
}

export const qcFlagTypesProvider = new QcFlagTypesProvider();

Check warning on line 70 in lib/public/services/qcFlags/qcFlagTypesProvider.js

View check run for this annotation

Codecov / codecov/patch

lib/public/services/qcFlags/qcFlagTypesProvider.js#L70

Added line #L70 was not covered by tests
3 changes: 3 additions & 0 deletions lib/public/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { RunsPerSimulationPassOverviewPage } from './views/Runs/RunsPerSimulatio
import { QcFlagTypesOverviewPage } from './views/QcFlagTypes/Overview/QcFlagTypesOverviewPage.js';
import { QcFlagsForDataPassOverviewPage } from './views/QcFlags/ForDataPass/QcFlagsForDataPassOverviewPage.js';
import { QcFlagsForSimulationPassOverviewPage } from './views/QcFlags/ForSimulationPass/QcFlagsForSimulationPassOverviewPage.js';
import { QcFlagCreationForDataPassPage } from './views/QcFlags/Create/ForDataPass/QcFlagCreationForDataPassPage.js';

/**
* Main view layout
Expand Down Expand Up @@ -89,6 +90,8 @@ export default (model) => {
'qc-flags-for-data-pass': QcFlagsForDataPassOverviewPage,
'qc-flags-for-simulation-pass': QcFlagsForSimulationPassOverviewPage,

'qc-flag-creation-for-data-pass': QcFlagCreationForDataPassPage,

statistics: StatisticsPage,

'flp-overview': FlpOverview,
Expand Down
Loading
Loading