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] Use time range filter for run start stop #1482

Merged
22 changes: 22 additions & 0 deletions lib/public/components/Filters/RunsFilter/o2StartFilter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @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 { timeRangeFilter } from '../common/filters/timeRangeFilter.js';

/**
* Returns a filter to be applied on run start
*
* @param {RunsOverviewModel} runsOverviewModel the run overview model object
* @return {Component} the filter component
*/
export const o2StartFilter = (runsOverviewModel) => timeRangeFilter(runsOverviewModel.o2StartFilterModel);

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L22 was not covered by tests
21 changes: 21 additions & 0 deletions lib/public/components/Filters/RunsFilter/o2StopFilter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @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 { timeRangeFilter } from '../common/filters/timeRangeFilter.js';

/**
* Returns a filter to be applied on run stop
*
* @param {RunsOverviewModel} runsOverviewModel the run overview model object
* @return {Component} the filter component
*/
export const o2StopFilter = (runsOverviewModel) => timeRangeFilter(runsOverviewModel.o2stopFilterModel);

Check warning on line 21 in lib/public/components/Filters/RunsFilter/o2StopFilter.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/Filters/RunsFilter/o2StopFilter.js#L21

Added line #L21 was not covered by tests
92 changes: 0 additions & 92 deletions lib/public/components/Filters/RunsFilter/o2start.js

This file was deleted.

89 changes: 0 additions & 89 deletions lib/public/components/Filters/RunsFilter/o2stop.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
this._toTimeInputModel.observe(() => this._periodLabel = null);
this._toTimeInputModel.bubbleTo(this);

this.setValue(value, periodLabel, false);
this.setValue(value, periodLabel, true);

Check warning on line 55 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#L55

Added line #L55 was not covered by tests
}

/**
Expand Down Expand Up @@ -132,7 +132,7 @@
* @override
*/
get isEmpty() {
return this._fromTimeInputModel.value === null && this._toTimeInputModel.value === null;
return this._fromTimeInputModel.isEmpty && this._toTimeInputModel.isEmpty;

Check warning on line 135 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#L135

Added line #L135 was not covered by tests
}

// eslint-disable-next-line valid-jsdoc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* - and if index axis is 'y', 'x' must contain an array in the same manner
*/
constructor(configuration, data) {
if (!data.length) {
if (!data?.length) {

Check warning on line 63 in lib/public/components/common/chart/rendering/ChartRenderer.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/chart/rendering/ChartRenderer.js#L63

Added line #L63 was not covered by tests
throw new Error('The data list can not be empty');
}
this._data = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
* @return {Component} the component
*/
view() {
const inputsMin = this._getInputsMin(this._min, this._value);
const inputsMax = this._getInputsMax(this._max, this._value);
const inputsMin = this._getInputsMin(this._minTimestamp, this._value);
const inputsMax = this._getInputsMax(this._maxTimestamp, this._value);

Check warning on line 72 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L71-L72

Added lines #L71 - L72 were not covered by tests

return h('.flex-row.items-center.g2', [
h(
Expand All @@ -81,8 +81,9 @@
required: this._required,
value: this._value.date,
onchange: (e) => this._patchValue({ date: e.target.value }),
min: inputsMin ? inputsMin.date : undefined,
max: inputsMax ? inputsMax.date : undefined,
// Mithril do not remove min/max if previously set...
min: inputsMin?.date ?? '',
max: inputsMax?.date ?? '',

Check warning on line 86 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L85-L86

Added lines #L85 - L86 were not covered by tests
},
),
h(
Expand All @@ -93,8 +94,9 @@
value: this._value.time,
step: this._seconds ? 1 : undefined,
onchange: (e) => this._patchValue({ time: e.target.value }),
min: inputsMin ? inputsMin.time : undefined,
max: inputsMax ? inputsMax.time : undefined,
// Mithril do not remove min/max if previously set...
min: inputsMin?.time ?? '',
max: inputsMax?.time ?? '',

Check warning on line 99 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L98-L99

Added lines #L98 - L99 were not covered by tests
},
),
h(
Expand Down Expand Up @@ -132,8 +134,8 @@
time: defaultTime,
};

this._min = min;
this._max = max;
this._minTimestamp = min;
this._maxTimestamp = max;

Check warning on line 138 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L137-L138

Added lines #L137 - L138 were not covered by tests
}

/**
Expand Down Expand Up @@ -163,59 +165,61 @@
/**
* Returns the min values to apply to the inputs
*
* @param {number|null} min the minimal timestamp to represent in the inputs
* @param {number|null} minTimestamp the minimal timestamp to represent in the inputs
* @param {DateTimeInputRawData} raw the current raw values
* @return {(Partial<{date: string, time: string}>|null)} the min values to apply to date and time inputs
*/
_getInputsMin(min, raw) {
if (min === null) {
_getInputsMin(minTimestamp, raw) {
if (minTimestamp === null) {

Check warning on line 173 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L172-L173

Added lines #L172 - L173 were not covered by tests
return null;
}

const minDateDayAfter = new Date(min + MILLISECONDS_IN_ONE_DAY);
const rawDate = raw.date || null;
const rawTime = raw.time || null;

Check warning on line 178 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L177-L178

Added lines #L177 - L178 were not covered by tests

const minDateAndTime = formatTimestampForDateTimeInput(min, this._seconds);
const ret = {};
const minDateAndTime = formatTimestampForDateTimeInput(minTimestamp, this._seconds);
const inputsMin = {};

Check warning on line 181 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L180-L181

Added lines #L180 - L181 were not covered by tests

if (raw.date !== null && raw.date === minDateAndTime.date) {
ret.time = minDateAndTime.time;
if (rawDate !== null && rawDate === minDateAndTime.date) {
inputsMin.time = minDateAndTime.time;

Check warning on line 184 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L183-L184

Added lines #L183 - L184 were not covered by tests
}

if (raw.time !== null && raw.time < minDateAndTime.time) {
ret.date = formatTimestampForDateTimeInput(minDateDayAfter.getTime(), this._seconds).date;
if (rawTime !== null && rawTime < minDateAndTime.time) {
inputsMin.date = formatTimestampForDateTimeInput(minTimestamp + MILLISECONDS_IN_ONE_DAY, this._seconds).date;

Check warning on line 188 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L187-L188

Added lines #L187 - L188 were not covered by tests
} else {
ret.date = minDateAndTime.date;
inputsMin.date = minDateAndTime.date;

Check warning on line 190 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L190

Added line #L190 was not covered by tests
}

return ret;
return inputsMin;

Check warning on line 193 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L193

Added line #L193 was not covered by tests
}

/**
* Returns the max values to apply to the inputs
*
* @param {number|null} max the maximal timestamp to represent in the inputs
* @param {number|null} maxTimestamp the maximal timestamp to represent in the inputs
* @param {DateTimeInputRawData} raw the current raw values
* @return {(Partial<{date: string, time: string}>|null)} the max values
*/
_getInputsMax(max, raw) {
if (max === null) {
_getInputsMax(maxTimestamp, raw) {
if (maxTimestamp === null) {

Check warning on line 204 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L203-L204

Added lines #L203 - L204 were not covered by tests
return null;
}

const maxDateDayBefore = new Date(max - MILLISECONDS_IN_ONE_DAY);
const rawDate = raw.date || null;
const rawTime = raw.time || null;

Check warning on line 209 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L208-L209

Added lines #L208 - L209 were not covered by tests

const maxDateAndTime = formatTimestampForDateTimeInput(max, this._seconds);
const ret = {};
const maxDateAndTime = formatTimestampForDateTimeInput(maxTimestamp, this._seconds);
const inputsMax = {};

Check warning on line 212 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L211-L212

Added lines #L211 - L212 were not covered by tests

if (raw.date !== null && raw.date === maxDateAndTime.date) {
ret.time = maxDateAndTime.time;
if (rawDate !== null && rawDate === maxDateAndTime.date) {
inputsMax.time = maxDateAndTime.time;

Check warning on line 215 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L214-L215

Added lines #L214 - L215 were not covered by tests
}
if (raw.time !== null && raw.time > maxDateAndTime.time) {
ret.date = formatTimestampForDateTimeInput(maxDateDayBefore.getTime(), this._seconds).date;
if (rawTime !== null && rawTime > maxDateAndTime.time) {
inputsMax.date = formatTimestampForDateTimeInput(maxTimestamp - MILLISECONDS_IN_ONE_DAY, this._seconds).date;

Check warning on line 218 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L217-L218

Added lines #L217 - L218 were not covered by tests
} else {
ret.date = maxDateAndTime.date;
inputsMax.date = maxDateAndTime.date;

Check warning on line 220 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L220

Added line #L220 was not covered by tests
}

return ret;
return inputsMax;

Check warning on line 223 in lib/public/components/common/form/inputs/DateTimeInputComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/form/inputs/DateTimeInputComponent.js#L223

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