Skip to content

Commit bc71e8f

Browse files
[O2B-1534] Migrate log overview to use filtering model pattern (#2083)
* chore: remove redundant model assignment. * chore: move all filters denoted as so to a filteringModel * Make filterInputModel extend filterModel * rename inputfilter to ParsedInputFilter * implement authorfilter with ParsedInputFilterModel changes * re-implement filter * add tag-filters to the filtering object * replace titleFilter and contentFilter with RawTextFilterModels * make Authorfilter an implementation of RawTextFilterModel * add runs filter to the filteringmodel * add environments filter to the filteringmodel * add lhcFills filter to the filteringmodel * add created filter to the filteringmodel * move the sort 'filter' to fetchlogs, since it doesn't actually filter anything * change filter to rawTextFilter for title * fix test by changing event type to 'change' * fix content and author tests * import openFilteringPanel and resetFilters * fix createdAt filter test * change event types to change * fix isAnyFilterActive * remove _raw as from authorfilterModel, as it serves no purpose * chore: removed ParsedInputFilterModel * chore: add toLowerCase to filterQueryParam computation * [O2B-1530] Lhc fills add sb duration filter (#2080) * Filtering by stableBeamsStart and stableBeamsEnd has been added to LHC Fills overview page * lhcFills endpoint & DTO validation modified and testing added for the aforementioned changes --------- Co-authored-by: GuustMetz <guust.metz@cern.ch> Co-authored-by: Guust <metzguust@gmail.com> * [O2B-1544] Fix pagination for filtered envs and add a test (#2096) * Replaced the two-query pattern with a single queryBuilder in GetAllEnvironmentsUseCase. The previous approach was redundant following Sequelize performance improvements; furthermore, the original implementation's logic was flawed which resulted in the pagination bug. * remove the combination operator from runs * remove the combination operator from envirionments * remove the combination operator from lhcFills * make filter computation much more compact using filteringmodel.normalize * add happy-flow tests for logs api * fix usecase unit tests * chore: provide the authorFilterMode directly to the component * chore: alter rawTextFilter to accept a boolean parameter that determines if the reset function also notifies the observers * chore: 1. revert previous change. 2. overwrite reset in author model and call notify there * chore: remove true from the reset function call * chore: add placeholders for the new rawTextFilters * improve reset readability * check runnumber fill number and lhc period for existence rather than for length * undo test comments * chore rename reset to clear() * make overview test more efficient with beforeEach * test: remove unneeded OpenFilterPanel calls * remove takescreenshot * Remove unneeded javadoc params * chore: change the with margins to roughly span the filters the entire filter popover * test: add happy-flow rootOnly test * test: add log sorting tests for runs and for envirionments * reduce the width of the author filter component * chore removed unneeded length checks from should successfully filter by rootOnly * chore: remove the needless 'limit' part of the rootOnly logs test * feat: create textInputFilter * chore: replace runNumbersFilter and rawTextFileters with logsActiveColumns * feat: add a width argument to textinputFIlter * replace the rest of the rawTextFilters * update tests to function with the new textInput components * fix failing tests * chore: delete fillNumbersFilter createdFilter, logs/environmentFilter, runs/environmentFilter and schemeNameFilter * undo incorrect return description of the author component jsdoc
1 parent 47203c7 commit bc71e8f

30 files changed

Lines changed: 537 additions & 994 deletions

File tree

lib/domain/dtos/GetAllLogsDto.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,25 @@ const PaginationDto = require('./PaginationDto');
1717
const { CustomJoi } = require('./CustomJoi.js');
1818
const { TagsFilterDto } = require('./filters/TagsFilterDto.js');
1919
const { FromToFilterDto } = require('./filters/FromToFilterDto.js');
20-
const { EnvironmentsFilterDto } = require('./filters/EnvironmentsFilterDto');
2120

22-
const RunFilterDto = Joi.object({
23-
values: CustomJoi.stringArray().items(EntityIdDto).single().required(),
24-
operation: Joi.string().valid('and', 'or').required(),
25-
});
26-
27-
const LhcFillFilterDto = Joi.object({
28-
values: CustomJoi.stringArray().items(EntityIdDto).single().required(),
29-
operation: Joi.string().valid('and', 'or').required(),
30-
});
21+
const RunFilterDto = CustomJoi.stringArray().items(EntityIdDto).single();
22+
const EnvironmentsFilterDto = CustomJoi.stringArray().items(Joi.string()).single();
23+
const LhcFillFilterDto = CustomJoi.stringArray().items(EntityIdDto).single();
3124

3225
const FilterDto = Joi.object({
3326
title: Joi.string().trim(),
3427
content: Joi.string().trim(),
3528
author: Joi.string().trim(),
3629
created: FromToFilterDto,
3730
tags: TagsFilterDto,
38-
lhcFills: LhcFillFilterDto,
39-
run: RunFilterDto,
31+
fillNumbers: LhcFillFilterDto,
32+
runNumbers: RunFilterDto,
4033
origin: Joi.string()
4134
.valid('human', 'process'),
4235
parentLog: EntityIdDto,
4336
rootLog: EntityIdDto,
4437
rootOnly: Joi.boolean(),
45-
environments: EnvironmentsFilterDto,
38+
environmentIds: EnvironmentsFilterDto,
4639
});
4740

4841
const SortDto = Joi.object({

lib/domain/dtos/filters/EnvironmentsFilterDto.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

lib/public/components/Filters/LhcFillsFilter/fillNumberFilter.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

lib/public/components/Filters/LhcFillsFilter/schemeNameFilter.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

lib/public/components/Filters/LogsFilter/author/AuthorFilterModel.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
* or submit itself to any jurisdiction.
1212
*/
1313

14-
import { FilterInputModel } from '../../common/filters/FilterInputModel.js';
14+
import { RawTextFilterModel } from '../../common/filters/RawTextFilterModel.js';
1515

1616
/**
1717
* Model to handle the state of the Author Filter
1818
*/
19-
export class AuthorFilterModel extends FilterInputModel {
19+
export class AuthorFilterModel extends RawTextFilterModel {
2020
/**
2121
* Constructor
2222
*
@@ -32,7 +32,7 @@ export class AuthorFilterModel extends FilterInputModel {
3232
* @return {boolean} true if '!Anonymous' is included in the raw filter string, false otherwise.
3333
*/
3434
isAnonymousExcluded() {
35-
return this._raw.includes('!Anonymous');
35+
return this._value.includes('!Anonymous');
3636
}
3737

3838
/**
@@ -42,28 +42,25 @@ export class AuthorFilterModel extends FilterInputModel {
4242
*/
4343
toggleAnonymousFilter() {
4444
if (this.isAnonymousExcluded()) {
45-
this._raw = this._raw.split(',')
45+
this._value = this._value.split(',')
4646
.filter((author) => author.trim() !== '!Anonymous')
4747
.join(',');
4848
} else {
49-
this._raw += super.isEmpty ? '!Anonymous' : ', !Anonymous';
49+
this._value += super.isEmpty ? '!Anonymous' : ', !Anonymous';
5050
}
5151

52-
this._value = this.valueFromRaw(this._raw);
5352
this.notify();
5453
}
5554

5655
/**
57-
* Reset the filter to its default value and notify the observers.
56+
* Reset the filter to its default value and notify the observers if the reset changed anything.
5857
*
5958
* @return {void}
6059
*/
6160
clear() {
62-
if (this.isEmpty) {
63-
return;
61+
if (!this.isEmpty) {
62+
super.reset();
63+
this.notify();
6464
}
65-
66-
super.reset();
67-
this.notify();
6865
}
6966
}

lib/public/components/Filters/LogsFilter/author/authorFilter.js

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,16 @@
1414
import { h } from '/js/src/index.js';
1515
import { iconX } from '/js/src/icons.js';
1616
import { switchInput } from '../../../common/form/switchInput.js';
17-
18-
/**
19-
* Returns a text input field that can be used to filter logs by author
20-
*
21-
* @param {AuthorFilterModel} authorFilterModel The author filter model object
22-
* @returns {Component} A text box that allows the user to enter an author substring to match against all logs
23-
*/
24-
const authorFilterTextInput = (authorFilterModel) => h('input.w-40', {
25-
type: 'text',
26-
id: 'authorFilterText',
27-
value: authorFilterModel.raw,
28-
oninput: (e) => authorFilterModel.update(e.target.value),
29-
});
17+
import { rawTextFilter } from '../../common/filters/rawTextFilter.js';
3018

3119
/**
3220
* Returns a button that can be used to reset the author filter.
3321
*
3422
* @param {AuthorFilterModel} authorFilterModel The author filter model object
3523
* @return {Component} A button that can be used to reset the author filter
3624
*/
37-
const resetAuthorFilterButton = (authorFilterModel) => h(
38-
'.btn.btn-pill.f7',
39-
{ disabled: authorFilterModel.isEmpty, onclick: () => authorFilterModel.clear() },
40-
iconX(),
41-
);
25+
const resetAuthorFilterButton = (authorFilterModel) =>
26+
h('.btn.btn-pill.f7', { disabled: authorFilterModel.isEmpty, onclick: () => authorFilterModel.clear() }, iconX());
4227

4328
/**
4429
* Returns a toggle that can be used to exclude anonymous authors
@@ -55,11 +40,11 @@ export const excludeAnonymousLogAuthorToggle = (authorFilterModel) => switchInpu
5540
/**
5641
* Returns a authorFilter component with text input, reset button, and anonymous exclusion button.
5742
*
58-
* @param {LogModel} logModel the log model object
59-
* @returns {Component} the author filter component
43+
* @param {AuthorFilterModel} authorFilterModel the authorFilterModel
44+
* @return {Component} the author filter component
6045
*/
61-
export const authorFilter = ({ authorFilter }) => h('.flex-row.items-center.g3', [
62-
authorFilterTextInput(authorFilter),
63-
resetAuthorFilterButton(authorFilter),
64-
excludeAnonymousLogAuthorToggle(authorFilter),
46+
export const authorFilter = (authorFilterModel) => h('.flex-row.items-center.g3', [
47+
rawTextFilter(authorFilterModel, { classes: ['w-50'], id: 'authorFilterText', value: authorFilterModel.raw, placeholder: 'e.g. John Doe' }),
48+
resetAuthorFilterButton(authorFilterModel),
49+
excludeAnonymousLogAuthorToggle(authorFilterModel),
6550
]);

lib/public/components/Filters/LogsFilter/created.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

lib/public/components/Filters/LogsFilter/environments.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

lib/public/components/Filters/LogsFilter/runs.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

lib/public/components/Filters/RunsFilter/runNumbersFilter.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)