Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
8216274
New api periods
Ehevi Aug 14, 2023
073fef1
Apply eslint rules :sparkles:
Ehevi Aug 15, 2023
f2b237b
Use message panels
Ehevi Aug 15, 2023
c3df896
Messages
Ehevi Aug 15, 2023
2a9f8eb
Add dataAccess
Ehevi Aug 15, 2023
00965ae
Move userPreferences up in model hierarchy
Ehevi Aug 15, 2023
f917829
Eslint :sparkles:
Ehevi Aug 15, 2023
116ce04
Cleanup :broom:
Ehevi Aug 15, 2023
7beba23
Cleanup :broom:
Ehevi Aug 15, 2023
cce4554
Display periods from the new API
Ehevi Aug 15, 2023
b3c38e5
Run energies
Ehevi Aug 15, 2023
b2ca901
Periods css update
Ehevi Aug 15, 2023
31cd33b
Update user preferences access
Ehevi Aug 15, 2023
ebcb8a4
Enable data selection
Ehevi Aug 15, 2023
544140f
Add column filtering options
Ehevi Aug 15, 2023
a571ef6
Add pagination
Ehevi Aug 15, 2023
81cd499
Add year field
Ehevi Aug 16, 2023
01b4528
Improve display of the distinct energies
Ehevi Aug 16, 2023
091377a
Rename pager to obsolete pager
Ehevi Aug 16, 2023
5e0fc39
Remove the old period field name config
Ehevi Aug 16, 2023
dc18122
Mark previous items couter as obsolete
Ehevi Aug 16, 2023
b3060f9
Use the new items counter in the periods view
Ehevi Aug 16, 2023
c879e25
Docs cleanup :broom:
Ehevi Aug 16, 2023
5b565e3
Rename column display options
Ehevi Aug 16, 2023
4b90f21
Rename css class
Ehevi Aug 16, 2023
9ee617a
Rename column display options select
Ehevi Aug 16, 2023
7f66310
Cleanup :broom:
Ehevi Aug 16, 2023
e27b345
Use the tableManager row
Ehevi Aug 16, 2023
ae26171
Fix setting rows on page
Ehevi Aug 16, 2023
4311b94
Cleanup :broom:
Ehevi Aug 16, 2023
46e3168
Fix pagination
Ehevi Aug 16, 2023
628e3f0
Cleanup :broom:
Ehevi Aug 16, 2023
7beb922
ItemsCounter cleanup :broom:
Ehevi Aug 16, 2023
ad51576
SetRowsOnSite cleanup :broom:
Ehevi Aug 16, 2023
ab7af4e
Cleanup :broom:
Ehevi Aug 16, 2023
5cf1469
Cleanup :broom:
Ehevi Aug 16, 2023
21acc3d
Remove unused delay function
Ehevi Aug 16, 2023
96b1cef
Rename header columns
Ehevi Aug 16, 2023
7745401
Cleanup :broom:
Ehevi Aug 16, 2023
574d884
Cleanup :broom:
Ehevi Aug 16, 2023
6060f57
Quickfix
Ehevi Aug 18, 2023
6b67ef7
[ORCT-157] Mark obsolete data requests as @deprecated (#176)
Ehevi Aug 23, 2023
e936501
Add items counter test
Ehevi Aug 24, 2023
efea3d5
Rename files
Ehevi Aug 18, 2023
e3c3103
Prepare periods export modal
Ehevi Aug 18, 2023
b3b12ab
Enable user to select csv or json export
Ehevi Aug 22, 2023
bf04c25
Cleanup :broom:
Ehevi Aug 23, 2023
5b47e18
Mark obsolete csv download as deprecated
Ehevi Aug 23, 2023
f8becf7
Pass userPreferences directly to modals
Ehevi Aug 23, 2023
4ab63c8
Cleanup :broom:
Ehevi Aug 23, 2023
384dc79
Cleanup :broom:
Ehevi Aug 23, 2023
606f3c7
Remove dependencies
Ehevi Aug 23, 2023
d54b1db
Fix preparedData in obsoleteCsvExport
Ehevi Aug 23, 2023
1e4b1c9
Cleanup :broom:
Ehevi Aug 23, 2023
0fbf57a
Use the model name as downloaded filename for exports
Ehevi Aug 23, 2023
acda977
Add capitalization tests
Ehevi Aug 23, 2023
d2d7cd8
Add readable file size test
Ehevi Aug 23, 2023
9104a20
Cleanup :broom:
Ehevi Aug 23, 2023
fdf8618
Cleanup :broom:
Ehevi Aug 24, 2023
7ea3ace
Tests cleanup :broom:
Ehevi Aug 24, 2023
66529b0
Enum content types
Ehevi Aug 24, 2023
ca85ace
Add CSV data preparation test
Ehevi Aug 24, 2023
809176a
Remove console logs
Ehevi Aug 24, 2023
4fdc9b5
Fix dataExport modal rendering condition
Ehevi Aug 24, 2023
8c4d9d7
Address review comments
Ehevi Aug 24, 2023
e3e30a7
Address review comments
Ehevi Aug 24, 2023
f4aa38e
Remove capitalizeFirstLetter function
Ehevi Aug 24, 2023
6950d88
Newlines
Ehevi Aug 24, 2023
489c1d6
Pagename tests
Ehevi Aug 24, 2023
ac25f2f
Cleanup :broom:
Ehevi Aug 24, 2023
85bb90a
Sort cleanup
Ehevi Aug 24, 2023
c2e7267
Address review comments
Ehevi Aug 24, 2023
ad73985
Address review comments
Ehevi Aug 24, 2023
4277845
Move pageTitle to separate component
Ehevi Aug 25, 2023
4a06657
Chai export cleanup :broom:
Ehevi Aug 25, 2023
d25936a
Tests cleanup :broom:
Ehevi Aug 25, 2023
9c58165
Tests cleanup :broom:
Ehevi Aug 25, 2023
9cee950
Cleanup :broom:
Ehevi Aug 25, 2023
d078ce2
Address review comments
Ehevi Aug 28, 2023
a83b26e
Address review comments
Ehevi Aug 28, 2023
da57811
Address review comments
Ehevi Aug 28, 2023
3f8bd44
Address review comments
Ehevi Aug 28, 2023
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
14 changes: 9 additions & 5 deletions app/config/rct-data/viewFieldNames/periodFieldNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ const periodFieldNames = {
fieldName: 'Name',
filterInput: filterInputTypes.text,
},
beamType: {
fieldName: 'Beam',
filterInput: filterInputTypes.text,
},
year: {
fieldName: 'Year',
filterInput: filterInputTypes.number,
},
beam: {
fieldName: 'Beam',
filterInput: filterInputTypes.text,
},
energy: {
avgEnergy: {
fieldName: 'Mean energy [GeV]',
filterInput: filterInputTypes.number,
},
distinctEnergies: {
fieldName: 'Run energies [GeV]',
filterInput: filterInputTypes.number,
},
};

module.exports = periodFieldNames;
5 changes: 0 additions & 5 deletions app/lib/utils/obj-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ function switchCase(caseName, cases, opts) {
opts.default ? opts.default : (() => { throw new Error('not last found option, no case, no default case'); })();
}

function delay(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}

function replaceAll(s, pattern, replace) {
const p = s.split(pattern);
return p.join(replace);
Expand Down Expand Up @@ -122,7 +118,6 @@ module.exports = {
reversePrimitiveObject,
filterObject,
switchCase,
delay,
replaceAll,
arrayToChunks,
applyOptsToObj,
Expand Down
26 changes: 25 additions & 1 deletion app/public/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import { RCT } from './config.js';
import Flags from './views/flags/Flags.js';
import Detectors from './views/detectors/Detectors.js';
import Runs from './views/runs/Runs.js';
const { roles, dataAccess } = RCT;
import PeriodsModel from './views/periods/PeriodsModel.js';
import UserPreferences from './model/UserPreferences.js';
const { roles, dataAccess, pageNames } = RCT;

export default class Model extends Observable {
constructor() {
Expand All @@ -34,6 +36,12 @@ export default class Model extends Observable {

this.loader = new Loader();

this.userPreferences = new UserPreferences(this);
this.userPreferences.bubbleTo(this);

this.periods = new PeriodsModel(this);
this.periods.bubbleTo(this);

this.runs = new Runs(this);
this.runs.bubbleTo(this);

Expand All @@ -49,6 +57,22 @@ export default class Model extends Observable {

this.loginEndpoint = `/api${RCT.endpoints.login}`;
this.login('physicist');

this.handleLocationChange();
}

/**
* Delegates sub-model actions depending on new location of the page
* @returns {void}
*/
async handleLocationChange() {
switch (this.router.params.page) {
case pageNames.periods:
await this.periods.fetchCurrentPagePeriods();
break;
default:
break;
}
}

async login(username) {
Expand Down
2 changes: 1 addition & 1 deletion app/public/components/buttons/copyLinkButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function copyLinkButton(url) {
snackbar.style.display = 'flex';

document.addEventListener('click', (event) => {
if (thisButton != event.target && thisButtonContent != event.target) {
if (thisButton !== event.target && thisButtonContent !== event.target) {
snackbar.style.display = 'none';
}
});
Expand Down
14 changes: 12 additions & 2 deletions app/public/components/buttons/dataActionButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
*/

import { h, iconDataTransferDownload, iconReload } from '/js/src/index.js';
import downloadCSV from '../../utils/csvExport.js';
import obsoleteDownloadCSV from '../../utils/obsoleteCsvExport.js';
import copyLinkButton from './copyLinkButton.js';
import { modalIds, showModal } from '../../views/modal/modal.js';

export const dataActions = {
hide: 'Hide',
reload: 'Reload',
obsoleteDownloadCSV: 'Download CSV (obsolete)',
downloadCSV: 'Download CSV',
copyLink: 'Copy link',
showFilteringPanel: 'Filter',
Expand All @@ -35,10 +37,18 @@ export default function dataActionButtons(model, applicableDataActions) {
}, iconReload())
: '',

applicableDataActions[dataActions.obsoleteDownloadCSV]
? h('button.btn.btn-secondary.icon-only-button', {
onclick: () => {
obsoleteDownloadCSV(model);
},
}, iconDataTransferDownload())
: '',

applicableDataActions[dataActions.downloadCSV]
? h('button.btn.btn-secondary.icon-only-button', {
onclick: () => {
downloadCSV(model);
showModal(modalIds.dataExport.modal);
},
}, iconDataTransferDownload())
: '',
Expand Down
27 changes: 27 additions & 0 deletions app/public/components/common/pageTitle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @license
* Copyright 2019-2020 CERN and copyright holders of ALICE O2.
* See http://alice-o2.web.cern.ch/copyright for details of the copyright holders.
* All rights not expressly granted are reserved.
*
* This software is distributed under the terms of the GNU General Public
* License v3 (GPL Version 3), copied verbatim in the file "COPYING".
*
* 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.
*/

export const pageTitle = (page, pageNames) => {
switch (page) {
case pageNames.periods: return 'Periods';
case pageNames.runsPerPeriod: return 'Runs per period';
case pageNames.runsPerDataPass: return 'Runs per data pass';
case pageNames.dataPasses: return 'Data passes per period';
case pageNames.mc: return 'Monte Carlo';
case pageNames.flags: return 'Quality flags';
case pageNames.anchoragePerDatapass: return 'Anchorage per data pass';
case pageNames.anchoredPerMC: return 'Anchored per MC';
default: return page;
}
};
3 changes: 1 addition & 2 deletions app/public/components/common/quantityInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import { h } from '/js/src/index.js';

export default function quantityInput(id, defaultQuantity, callback) {
export default function quantityInput(id, defaultQuantity) {
function handleInput(e) {
e.preventDefault();
if (e.key === '1'
Expand Down Expand Up @@ -53,7 +53,6 @@ export default function quantityInput(id, defaultQuantity, callback) {
quantity += change;
quantity = Math.max(quantity, 1);
document.getElementById(id).value = quantity;
() => callback(quantity);
};

const increaseButton = h('button.btn.btn-secondary', {
Expand Down
61 changes: 55 additions & 6 deletions app/public/components/messagePanel/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,69 @@ import spinner from '../common/spinner.js';
const goBack = 'Go back';
const nothingFound = 'Nothing found';

const requestButton = (model) => h('button.btn.btn-primary.m3', {
/**
* Uses deprecated data request.
* Please use the `requestButton` with the specific dataModel (e.g. `periodsModel`) instead.
* @deprecated
* @param {DataAccessModel} model dataAccessModel
* @returns {button} button that enables user to request data
*/
const obsoleteRequestButton = (model) => h('button.btn.btn-primary.m3', {
onclick: () => model.fetchedData.reqForData(true),
}, 'Reload');

const requestButton = (dataModel) => h('button.btn.btn-primary.m3', {
onclick: () => dataModel.fetchCurrentPageData(),
}, 'Reload');

const removeCurrentDataButton = (model, label) => h('button.btn.btn-primary.m3', {
onclick: () => model.removeCurrentData(),
}, label);

export const failure = (model, status) => messagePanel(
/**
* Uses deprecated `obsoleteRequestButton`.
* Please use the `failureWithMessage` with the specific dataModel (e.g. `periodsModel`) and errorObject instead.
* @deprecated
* @param {DataAccessModel} model dataAccessModel
* @param {number} status request status
* @returns {messagePanel} messagePanel informing the user about an unknown error.
*/
export const failureWithStatus = (model, status) => messagePanel(
'no-network-90',
'Failed to load data',
`The services are unavailable (status: ${status ? status : 'unknown'})`,
requestButton(model),
obsoleteRequestButton(model),
);

export const unknown = (model) => messagePanel(
export const failureWithMessage = (dataModel, errorObject) => {
const { detail, title } = errorObject.find((e) => Boolean(e));
return messagePanel(
'no-network-90',
detail,
title,
requestButton(dataModel),
);
};

/**
* Uses deprecated `obsoleteRequestButton`.
* Please use the `unknown` with the specific dataModel (e.g. `periodsModel`) instead.
* @deprecated
* @param {DataAccessModel} model dataAccessModel
* @returns {messagePanel} messagePanel informing the user about an unknown error.
*/
export const obsoleteUnknown = (model) => messagePanel(
'unexpected-90',
'Unknown error',
'Request could not be handled properly',
obsoleteRequestButton(model),
);

export const unknown = (dataModel) => messagePanel(
'unexpected-90',
'Unknown error',
'Request could not be handled properly',
requestButton(model),
requestButton(dataModel),
);

export const sessionError = (model) => messagePanel(
Expand Down Expand Up @@ -72,13 +115,19 @@ export const noMatchingData = (model, page) => messagePanel(
],
);

/**
* Uses deprecated `obsoleteRequestButton`.
* @deprecated
* @param {DataAccessModel} model dataAccessModel
* @returns {messagePanel} messagePanel informing the user about an unknown error.
*/
export const noDataFound = (model) => messagePanel(
'nothing-found-90',
nothingFound,
'There is no data to be displayed here',
[
removeCurrentDataButton(model, goBack),
requestButton(model),
obsoleteRequestButton(model),
],
);

Expand Down
24 changes: 13 additions & 11 deletions app/public/components/sidebar/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { h } from '/js/src/index.js';
import { RCT } from '../../config.js';
import sidebarItem from './sidebarItem.js';
import { modal, modalIds, showModal } from '../../views/modal/modal.js';
import { pageTitle } from '../table/title.js';
import { pageTitle } from '../common/pageTitle.js';
const { pageNames } = RCT;

/**
Expand All @@ -27,24 +27,26 @@ const { pageNames } = RCT;
*/

export default function sidebar(model) {
const { userPreferences } = model.parent;
return h('.sidebar.sidebar-collapsible', {
id: 'sidebar',
},
modal(modalIds.about.modal),
modal(modalIds.pageSettings.modal, model),
modal(modalIds.detectors.modal, model),
modal(modalIds.pageSettings.modal, null, userPreferences),
modal(modalIds.detectors.modal, null, userPreferences),
modal(modalIds.dataExport.modal, model.parent.periods, userPreferences),
h('.logo.ph3.hide-on-close'),
h('.flex-column.gap-20',
h('.sidebar-section',
h('.sidebar-section-title.ph2.hide-on-close', 'Pages'),
sidebarItem(model, pageNames.periods, pageTitle(pageNames.periods)),
sidebarItem(model, pageNames.dataPasses, pageTitle(pageNames.dataPasses)),
sidebarItem(model, pageNames.anchoragePerDatapass, pageTitle(pageNames.anchoragePerDatapass)),
sidebarItem(model, pageNames.mc, pageTitle(pageNames.mc)),
sidebarItem(model, pageNames.anchoredPerMC, pageTitle(pageNames.anchoredPerMC)),
sidebarItem(model, pageNames.runsPerPeriod, pageTitle(pageNames.runsPerPeriod)),
sidebarItem(model, pageNames.runsPerDataPass, pageTitle(pageNames.runsPerDataPass)),
sidebarItem(model, pageNames.flags, pageTitle(pageNames.flags))),
sidebarItem(model, pageNames.periods, pageTitle(pageNames.periods, pageNames)),
sidebarItem(model, pageNames.dataPasses, pageTitle(pageNames.dataPasses, pageNames)),
sidebarItem(model, pageNames.anchoragePerDatapass, pageTitle(pageNames.anchoragePerDatapass, pageNames)),
sidebarItem(model, pageNames.mc, pageTitle(pageNames.mc, pageNames)),
sidebarItem(model, pageNames.anchoredPerMC, pageTitle(pageNames.anchoredPerMC, pageNames)),
sidebarItem(model, pageNames.runsPerPeriod, pageTitle(pageNames.runsPerPeriod, pageNames)),
sidebarItem(model, pageNames.runsPerDataPass, pageTitle(pageNames.runsPerDataPass, pageNames)),
sidebarItem(model, pageNames.flags, pageTitle(pageNames.flags, pageNames))),

h('.sidebar-section',
h('.sidebar-section-title.ph2.hide-on-close', 'Preferences'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
* or submit itself to any jurisdiction.
*/

export const zip = (a, b) => Array.from(Array(Math.max(b.length, a.length)), (_, i) => [a[i], b[i]]);
export default function itemsCounter(paginationModel) {
const { currentPage, itemsPerPage, itemsCount } = paginationModel;

export function getReadableFileSizeString(fileSizeInBytes) {
let i = -1;
const byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
do {
fileSizeInBytes /= 1024;
i++;
} while (fileSizeInBytes > 1024);
const firstItemIndex = (currentPage - 1) * itemsPerPage + 1;
const lastItemIndex = currentPage * itemsPerPage > itemsCount
? itemsCount
: currentPage * itemsPerPage;

return `${Math.max(fileSizeInBytes, 0.1).toFixed(1)} ${byteUnits[i]}`;
return `${firstItemIndex}-${lastItemIndex} of ${itemsCount}`;
}
Loading