-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[O2B-1116] Implement runs per data pass view (#1333)
* rename * reduce test data size * docs * refactor * typo * typo * docs * rename * docs * cleanup * remove dead code * add service * cleanup * add filtering by periods * add data passes seeders * rename * add data passes service tests * test * revoke unfound changes * add controllers * rename * refactor * refactor * refactor * no dependency * refactor * refactor * refactor: * reaname' * rename * cleanup * docs * reaname * refactor * add router * restore * amend test * expose api * add test * add tests * amend * docs * amend test * amend * add Data Passes page * expose page * styling * add reset method * rename * use sorting * add unit * docs * add filtering by data pass id * add test * amend test * amend test * init * use name instead of id * amend test * rename * use name instead of id * put instance * add to view and model * page openable * amend profiles * show qualities * refactor * cleanup * rename * rename * use filtering by name * add test * use generic model * aboid undefined destruciton error * use proper method * amend cell expected content * use in RunsOverviewModel * rename * rename * touched getAllRuns * extend pai * add styling and css * rename * amend test * cleanup * linter * make uppercase * amend test * add test * use correct page * amend dtest * amend test * amend tst * cleanup * amend * use id * use builder * refactor, add spinner * reset exportableItems * corrent condition * refactor * cleanup * replace build href * cleanup * correct filter values: * fixes * cleanup * make detectors fetching prvate * refactor * rename * rename * change error store * refactor * wip * cleanup * amend view * cleanup * unify title styling * unify title styling in RunsPerLhcPeriod * rename * docs correct * refactor * docs * amend test * fix * modify cell value checking * modify width * add badge * amend tests * amend test * docs * use apply * revoke * no by lambda * revoke change * amend apply * amend apply * refactor * refactor * use match * cleanup * rename * rename * revoke export changes * cleanup * refactor * correct docs * change load * typo * add export test * refactor * refactor * test title * Revert "add export test" This reverts commit 7ff5833. * add reverted file * remove reloadPage * linter * add logs * Revert "add logs" This reverts commit 15f4ce9. * change selectors * simplify * amed test WIP * cleanup * amed test WIP * add title * change title * add export test * Revert "add export test" This reverts commit 79e805f. * fix test * add spinner * typo
- Loading branch information
Showing
20 changed files
with
579 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
lib/public/views/Runs/RunPerDataPass/RunsPerDataPassOverviewModel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/** | ||
* @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 { buildUrl } from '../../../utilities/fetch/buildUrl.js'; | ||
import { detectorsProvider } from '../../../services/detectors/detectorsProvider.js'; | ||
import { RunsOverviewModel } from '../Overview/RunsOverviewModel.js'; | ||
import { ObservableData } from '../../../utilities/ObservableData.js'; | ||
import { getRemoteDataSlice } from '../../../utilities/fetch/getRemoteDataSlice.js'; | ||
|
||
/** | ||
* Runs Per Data Pass overview model | ||
*/ | ||
export class RunsPerDataPassOverviewModel extends RunsOverviewModel { | ||
/** | ||
* Constructor | ||
* @param {Model} model global model | ||
*/ | ||
constructor(model) { | ||
super(model); | ||
this._detectors = new ObservableData(RemoteData.notAsked()); | ||
this._detectors.bubbleTo(this); | ||
this._dataPass = new ObservableData(RemoteData.notAsked()); | ||
this._dataPass.bubbleTo(this); | ||
} | ||
|
||
/** | ||
* Retrieve a list of detector types from detectorsProvider | ||
* | ||
* @return {Promise<void>} resolves once the data has been fetched | ||
* @private | ||
*/ | ||
async _fetchDetectors() { | ||
this._detectors.setCurrent(RemoteData.loading()); | ||
try { | ||
this._detectors.setCurrent(RemoteData.success(await detectorsProvider.getAll())); | ||
} catch (error) { | ||
this._detectors.setCurrent(RemoteData.failure(error)); | ||
} | ||
} | ||
|
||
/** | ||
* Fetch data pass data which runs are fetched | ||
* @return {Promise<void>} promise | ||
*/ | ||
async _fetchDataPass() { | ||
this._dataPass.setCurrent(RemoteData.loading()); | ||
try { | ||
const { items: [dataPass] = [] } = await getRemoteDataSlice(`/api/dataPasses?filter[ids][]=${this._dataPassId}`); | ||
this._dataPass.setCurrent(RemoteData.success(dataPass)); | ||
} catch (error) { | ||
this._dataPass.setCurrent(RemoteData.failure(error)); | ||
} | ||
} | ||
|
||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* @inheritdoc | ||
*/ | ||
async load() { | ||
if (!this._dataPassId) { | ||
return; | ||
} | ||
this._fetchDetectors(); | ||
this._fetchDataPass(); | ||
super.load(); | ||
} | ||
|
||
// eslint-disable-next-line valid-jsdoc | ||
/** | ||
* @inheritdoc | ||
*/ | ||
getRootEndpoint() { | ||
const endpint = super.getRootEndpoint(); | ||
return buildUrl(endpint, { filter: { | ||
dataPassIds: [this._dataPassId], | ||
runQualities: 'good', | ||
definitions: 'PHYSICS', | ||
} }); | ||
} | ||
|
||
/** | ||
* Set id of data pass which runs are to be fetched | ||
* @param {number} dataPassId id of Data Pass | ||
*/ | ||
set dataPassId(dataPassId) { | ||
this._dataPassId = dataPassId; | ||
} | ||
|
||
/** | ||
* Get current data pass which runs are fetched | ||
*/ | ||
get dataPass() { | ||
return this._dataPass.getCurrent(); | ||
} | ||
|
||
/** | ||
* Get all detectors | ||
* @return {RemoteData<Detector[]>} detectors | ||
*/ | ||
get detectors() { | ||
return this._detectors.getCurrent(); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
lib/public/views/Runs/RunPerDataPass/RunsPerDataPassOverviewPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* @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 { table } from '../../../components/common/table/table.js'; | ||
import { createRunDetectorsActiveColumns } from '../ActiveColumns/runDetectorsActiveColumns.js'; | ||
import { paginationComponent } from '../../../components/Pagination/paginationComponent.js'; | ||
import { estimateDisplayableRowsCount } from '../../../utilities/estimateDisplayableRowsCount.js'; | ||
import { exportRunsTriggerAndModal } from '../Overview/exportRunsTriggerAndModal.js'; | ||
import { runsActiveColumns } from '../ActiveColumns/runsActiveColumns.js'; | ||
import spinner from '../../../components/common/spinner.js'; | ||
|
||
const TABLEROW_HEIGHT = 59; | ||
// Estimate of the navbar and pagination elements height total; Needs to be updated in case of changes; | ||
const PAGE_USED_HEIGHT = 215; | ||
|
||
/** | ||
* Render Runs Per LHC Period overview page | ||
* @param {Model} model The overall model object. | ||
* @param {Model} [model.runs.perDataPassOverviewModel] model holding state for of the page | ||
* @return {Component} The overview page | ||
*/ | ||
export const RunsPerDataPassOverviewPage = ({ runs: { perDataPassOverviewModel }, modalModel }) => { | ||
perDataPassOverviewModel.pagination.provideDefaultItemsPerPage(estimateDisplayableRowsCount( | ||
TABLEROW_HEIGHT, | ||
PAGE_USED_HEIGHT, | ||
)); | ||
|
||
const { items: runs, detectors, dataPass } = perDataPassOverviewModel; | ||
|
||
const activeColumns = { | ||
...runsActiveColumns, | ||
...createRunDetectorsActiveColumns(detectors.match({ | ||
Success: (payload) => payload, | ||
Other: () => [], | ||
}), { profiles: 'runsPerDataPass' }), | ||
}; | ||
|
||
return h('', [ | ||
h('.flex-row.justify-between.items-center', [ | ||
dataPass.match({ | ||
Success: (payload) => h('h2', `Good, physics runs of ${payload.name}`), | ||
Failure: () => h('h2.danger', 'Failed to fetch Data Pass information'), | ||
Loading: () => h('.p1', spinner({ size: 2, absolute: false })), | ||
NotAsked: () => h('h2', 'Good, physics runs'), | ||
}), | ||
exportRunsTriggerAndModal(perDataPassOverviewModel, modalModel), | ||
]), | ||
h('.flex-column.w-100', [ | ||
table(runs, activeColumns, null, { profile: 'runsPerDataPass' }), | ||
paginationComponent(perDataPassOverviewModel.pagination), | ||
]), | ||
]); | ||
}; |
Oops, something went wrong.