Skip to content

Commit 5985685

Browse files
authored
[O2B-1080] home overviews serparation (#1291)
* init model * expose home model * cleanup * docs * rename * rename * docs * rename * rename
1 parent 6d6d232 commit 5985685

7 files changed

Lines changed: 84 additions & 14 deletions

File tree

lib/public/Model.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { EosReportModel } from './views/EosReport/EosReportModel.js';
2929
import { AboutModel } from './views/About/About.js';
3030
import { StatisticsPageModel } from './views/Statistics/StatisticsPageModel.js';
3131
import { LhcPeriodsModel } from './views/lhcPeriods/LhcPeriodsModel.js';
32+
import { HomePageModel } from './views/Home/Overview/HomePageModel.js';
3233

3334
/**
3435
* Root of model tree
@@ -66,6 +67,9 @@ export default class Model extends Observable {
6667

6768
// Models
6869

70+
this.home = new HomePageModel(this);
71+
this.home.bubbleTo(this);
72+
6973
this.lhcPeriods = new LhcPeriodsModel(this);
7074
this.lhcPeriods.bubbleTo(this);
7175

@@ -148,8 +152,7 @@ export default class Model extends Observable {
148152
switch (this.router.params.page) {
149153
case 'home':
150154
// Setting the rows per page also collects all the runs and logs
151-
this.logs.loadOverview();
152-
this.runs.loadOverview();
155+
this.home.loadOverview();
153156
break;
154157
case 'lhc-period-overview':
155158
this.lhcPeriods.loadOverview();

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class EorReasonFilterModel extends Observable {
2929
*/
3030
constructor() {
3131
super();
32+
this._visualChange$ = new Observable();
3233
this._eorReasonTypes = RemoteData.notAsked();
3334
this._fetchReasonTypes();
3435
this._filterEorReason = { ...emptyEorReason };
@@ -41,7 +42,7 @@ export class EorReasonFilterModel extends Observable {
4142
*/
4243
async _fetchReasonTypes() {
4344
this._eorReasonTypes = RemoteData.loading();
44-
this.notify();
45+
this._visualChange$.notify();
4546

4647
try {
4748
const { data: reasonTypes } = await getRemoteData('/api/runs/reasonTypes');
@@ -50,7 +51,15 @@ export class EorReasonFilterModel extends Observable {
5051
this._eorReasonTypes = RemoteData.failure(error);
5152
}
5253

53-
this.notify();
54+
this._visualChange$.notify();
55+
}
56+
57+
/**
58+
* Returns an observable notified any time a visual change occurs that has no impact on the actual selection
59+
* @return {Observable} the visual change observable
60+
*/
61+
get visualChange$() {
62+
return this._visualChange$;
5463
}
5564

5665
/**

lib/public/view.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import TagCreate from './views/Tags/Create/index.js';
2424
import FlpOverview from './views/Flps/Overview/index.js';
2525
import AboutOverview from './views/About/Overview/index.js';
2626
import FlpDetail from './views/Flps/Details/index.js';
27-
import HomeOverview from './views/Home/Overview/index.js';
2827
import { EnvironmentOverviewPage } from './views/Environments/Overview/EnvironmentOverviewPage.js';
2928
import { Index } from './views/LhcFills/Overview/index.js';
3029
import { modalContainer } from './components/modal/modalContainer.js';
@@ -35,6 +34,7 @@ import { TagDetailsPage } from './views/Tags/Details/TagDetailsPage.js';
3534
import { EosReportCreationPage } from './views/EosReport/create/EosReportCreationPage.js';
3635
import { StatisticsPage } from './views/Statistics/StatisticsPage.js';
3736
import { LhcPeriodsOverviewPage } from './views/lhcPeriods/Overview/LhcPeriodsOverviewPage.js';
37+
import { HomePage } from './views/Home/Overview/HomePage.js';
3838

3939
/**
4040
* Main view layout
@@ -43,7 +43,7 @@ import { LhcPeriodsOverviewPage } from './views/lhcPeriods/Overview/LhcPeriodsOv
4343
*/
4444
export default (model) => {
4545
const pages = {
46-
home: HomeOverview,
46+
home: HomePage,
4747

4848
'lhc-period-overview': LhcPeriodsOverviewPage,
4949

lib/public/views/Home/Overview/index.js renamed to lib/public/views/Home/Overview/HomePage.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ const TABLEROW_HEIGHT = 46;
2222
const PAGE_USED_HEIGHT = 155;
2323

2424
/**
25-
* Home Page main components
26-
* @param {Object} model Pass the model to access the defined functions
27-
* @return {vnode} Return the view of the page with the filtering options
25+
* Home Page component
26+
* @param {Object} model global model
27+
* @return {Component} Return the component of the home page
2828
*/
29-
const HomeOverviewScreen = ({ logs: { overviewModel: logsOverviewModel }, runs: { overviewModel: runsOverviewModel } }) => {
29+
export const HomePage = ({ home: { logsOverviewModel, runsOverviewModel } }) => {
3030
const rowCount = estimateDisplayableRowsCount(TABLEROW_HEIGHT, PAGE_USED_HEIGHT);
3131
logsOverviewModel.pagination.provideDefaultItemsPerPage(rowCount);
3232
runsOverviewModel.pagination.provideDefaultItemsPerPage(rowCount);
@@ -44,5 +44,3 @@ const HomeOverviewScreen = ({ logs: { overviewModel: logsOverviewModel }, runs:
4444
]),
4545
]);
4646
};
47-
48-
export default (model) => [HomeOverviewScreen(model)];
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
import { Observable } from '/js/src/index.js';
15+
import { RunsOverviewModel } from '../../Runs/Overview/RunsOverviewModel.js';
16+
import { LogsOverviewModel } from '../../Logs/Overview/LogsOverviewModel.js';
17+
18+
/**
19+
* Model storing state for the home page
20+
*/
21+
export class HomePageModel extends Observable {
22+
/**
23+
* The constructor of the home model object
24+
* @param {Model} model global model
25+
*/
26+
constructor(model) {
27+
super();
28+
this._runsOverviewModel = new RunsOverviewModel(model);
29+
this._runsOverviewModel.bubbleTo(this);
30+
31+
this._logsOverviewModel = new LogsOverviewModel(model);
32+
this._logsOverviewModel.bubbleTo(this);
33+
}
34+
35+
/**
36+
* Load runs and logs overview data
37+
* @return {void}
38+
*/
39+
loadOverview() {
40+
this._runsOverviewModel.fetchRuns();
41+
this._logsOverviewModel.fetchLogs();
42+
}
43+
44+
/**
45+
* Returns the model for the runs overview
46+
* @return {RunsOverviewModel} the overview model
47+
*/
48+
get runsOverviewModel() {
49+
return this._runsOverviewModel;
50+
}
51+
52+
/**
53+
* Returns the model for the logs overview
54+
* @return {LogsOverviewModel} the overview model
55+
*/
56+
get logsOverviewModel() {
57+
return this._logsOverviewModel;
58+
}
59+
}

lib/public/views/Logs/Overview/LogsOverviewModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class LogsOverviewModel extends Observable {
2828
/**
2929
* The constructor of the Overview model object
3030
*
31-
* @param {Model} model Pass the model to access the defined functions
31+
* @param {Model} model global model
3232
*/
3333
constructor(model) {
3434
super();

lib/public/views/Runs/Overview/RunsOverviewModel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class RunsOverviewModel extends Observable {
5050

5151
this._eorReasonsFilterModel = new EorReasonFilterModel();
5252
this._eorReasonsFilterModel.observe(() => this._applyFilters());
53+
this._eorReasonsFilterModel.visualChange$.observe(() => this.notify());
5354

5455
this._pagination = new PaginationModel();
5556
this._pagination.observe(() => this.fetchRuns());
@@ -62,7 +63,7 @@ export class RunsOverviewModel extends Observable {
6263
this.reset(false);
6364

6465
// eslint-disable-next-line no-return-assign,require-jsdoc
65-
const updateDebounceTime = () => this._debouncedFetchAllRuns = debounce(this.fetchRuns.bind(this), model.inputDebounceTime);
66+
const updateDebounceTime = () => this._debouncedFetchAllRuns = debounce(() => this.fetchRuns(), model.inputDebounceTime);
6667
model.appConfiguration$.observe(() => updateDebounceTime());
6768
updateDebounceTime();
6869
}

0 commit comments

Comments
 (0)