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
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
63 changes: 63 additions & 0 deletions app/public/components/buttons/dataActionButtons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* @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.
*/

import { h, iconDataTransferDownload, iconReload } from '/js/src/index.js';
import downloadCSV from '../../utils/csvExport.js';
import copyLinkButton from './copyLinkButton.js';

export const dataActions = {
hide: 'Hide',
reload: 'Reload',
downloadCSV: 'Download CSV',
copyLink: 'Copy link',
showFilteringPanel: 'Filter',
};

export default function dataActionButtons(model, applicableDataActions) {
return h('.btn-group',
applicableDataActions[dataActions.reload]
? h('button.btn.btn-secondary.icon-only-button', {
onclick: () => {
model.fetchedData.reqForData(true);
model.notify();
},
}, iconReload())
: '',

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

applicableDataActions[dataActions.copyLink]
? copyLinkButton(model.router.getUrl().toString())
: '',

applicableDataActions[dataActions.hide]
? h('button.btn.icon-only-button', {
className: model.hideCurrentPageMarkedRows ? 'btn-primary' : 'btn-secondary',
onclick: () => model.changeMarkedRowsVisibility(),
}, model.hideCurrentPageMarkedRows ? h('.hide-20-off-white.abs-center') : h('.hide-20-primary.abs-center'))
: '',

applicableDataActions[dataActions.showFilteringPanel]
? h('button.btn.icon-only-button', {
className: model.showFilteringPanel ? 'btn-primary' : 'btn-secondary',
onclick: () => model.changeSearchFieldsVisibility(),
}, model.showFilteringPanel ? h('.slider-20-off-white.abs-center') : h('.slider-20-primary.abs-center'))
: '');
}
10 changes: 8 additions & 2 deletions app/public/model/DataAccessModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export default class DataAccessModel extends Observable {
this.serviceUnavailable = new ServiceUnavailable(parent);
this.fetchedData = new FetchedDataManager(this.router, this);

this.searchFieldsVisible = false;
this.showFilteringPanel = false;
this.sortingRowVisible = false;
this.hideCurrentPageMarkedRows = false;

this.loader = new Loader();

Expand All @@ -60,7 +61,7 @@ export default class DataAccessModel extends Observable {
}

changeSearchFieldsVisibility() {
this.searchFieldsVisible = !this.searchFieldsVisible;
this.showFilteringPanel = !this.showFilteringPanel;
this.notify();
}

Expand All @@ -69,6 +70,11 @@ export default class DataAccessModel extends Observable {
this.notify();
}

changeMarkedRowsVisibility() {
this.hideCurrentPageMarkedRows = !this.hideCurrentPageMarkedRows;
this.fetchedData.changeRecordsVisibility(this.getCurrentData());
}

async logout() {
const logoutEndpoint = '/api/logout/';
const { result, status, ok } = this.loader.post(logoutEndpoint);
Expand Down
2 changes: 2 additions & 0 deletions app/public/model/data/FetchedDataManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export default class FetchedDataManager {
this.router = router;
this.loader = new Loader();

this.hideMarkedRecords = false;

for (const n in pageNames) {
if (Object.prototype.hasOwnProperty.call(pageNames, n)) {
this[n] = {};
Expand Down
9 changes: 9 additions & 0 deletions app/public/styles/images/icons/20/off-white/hide.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/public/styles/images/icons/20/primary/hide.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/public/styles/images/icons/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@
background-image: url('/styles/images/icons/20/primary/forward.svg');
}

.hide-20-off-white {
.icon-20;
background-image: url('/styles/images/icons/20/off-white/hide.svg');
}

.hide-20-primary {
.icon-20;
background-image: url('/styles/images/icons/20/primary/hide.svg');
}

.icon-placeholder-20-primary {
.icon-20;
background-image: url('/styles/images/icons/20/primary/icon-placeholder.svg');
Expand Down
38 changes: 12 additions & 26 deletions app/public/views/flags/overview/flagsContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,22 @@
* or submit itself to any jurisdiction.
*/

import { h, iconDataTransferDownload, iconReload } from '/js/src/index.js';
import { h } from '/js/src/index.js';
import filter from '../../userView/data/table/filtering/filter.js';
import downloadCSV from '../../../../utils/csvExport.js';
import flagsVisualization from '../../../components/flags/flagsVisualization.js';
import flagsTable from './flagsTable.js';
import flagBreadCrumbs from '../../../../components/flags/flagBreadcrumbs.js';
import { noRunNumbers } from '../../../../utils/defaults.js';
import noSubPageSelected from '../../userView/data/table/noSubPageSelected.js';
import copyLinkButton from '../../../components/buttons/copyLinkButton.js';
import dataActionButtons, { dataActions } from '../../../components/buttons/dataActionButtons.js';

const applicableDataActions = {
[dataActions.hide]: false,
[dataActions.reload]: true,
[dataActions.downloadCSV]: true,
[dataActions.copyLink]: true,
[dataActions.showFilteringPanel]: false,
};

export default function flagsContent(model, runs, detectors, flags) {
const urlParams = model.router.getUrl().searchParams;
Expand All @@ -33,35 +40,14 @@ export default function flagsContent(model, runs, detectors, flags) {
const flagsData = flags.getFlags(runNumber, detectorName);
const runData = runs.getRun(dataPassName, runNumber);

const functionalities = (model) => h('.btn-group',
h('button.btn.btn-secondary.icon-only-button', {
onclick: () => {
model.fetchedData.reqForData(true);
model.notify();
},
}, iconReload()),

h('button.btn.btn-secondary.icon-only-button', {
onclick: () => {
downloadCSV(model);
},
}, iconDataTransferDownload()),

copyLinkButton(model.router.getUrl().toString()),

h('button.btn.icon-only-button', {
className: model.searchFieldsVisible ? 'btn-primary' : 'btn-secondary',
onclick: () => model.changeSearchFieldsVisibility(),
}, model.searchFieldsVisible ? h('.slider-20-off-white.abs-center') : h('.slider-20-primary.abs-center')));

return runNumber > noRunNumbers && runData
? h('.p-1em', [
h('.flex-wrap.justify-between.items-center',
h('.flex-wrap.justify-between.items-center',
flagBreadCrumbs(model, dataPassName, runNumber, detectorName)),

functionalities(model)),
model.searchFieldsVisible ? filter(model) : '',
dataActionButtons(model, applicableDataActions)),
model.showFilteringPanel ? filter(model) : '',

flagsVisualization(runData, flagsData),
flagsTable(model, flagsData),
Expand Down
46 changes: 15 additions & 31 deletions app/public/views/runs/runsPerDataPass/overview/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* or submit itself to any jurisdiction.
*/

import { h } from '/js/src/index.js';
import indexChip from '../../../../components/chips/indexChip.js';
import pager from '../../../../components/table/pager.js';
import { defaultIndexString } from '../../../../utils/defaults.js';
Expand All @@ -20,18 +21,25 @@ import pagesCellsSpecials from '../../../userView/data/pagesCellsSpecials.js';
import title from '../../../../components/table/title.js';
import header from '../table/header.js';
import row from '../table/row.js';
import { h, iconDataTransferDownload, iconReload } from '/js/src/index.js';

import { RCT } from '../../../../config.js';
import downloadCSV from '../../../../utils/csvExport.js';
import filter from '../../../userView/data/table/filtering/filter.js';
import activeFilters from '../../../userView/data/table/filtering/activeFilters.js';
import sortingRow from '../../../userView/data/table/sortingRow.js';
import { noMatchingData, noDataFound } from '../../../../components/messagePanel/messages.js';
import noSubPageSelected from '../../../userView/data/table/noSubPageSelected.js';
import copyLinkButton from '../../../../components/buttons/copyLinkButton.js';
import dataActionButtons, { dataActions } from '../../../../components/buttons/dataActionButtons.js';
import { RCT } from '../../../../config.js';

const { pageNames } = RCT;

const applicableDataActions = {
[dataActions.hide]: true,
[dataActions.reload]: true,
[dataActions.downloadCSV]: true,
[dataActions.copyLink]: true,
[dataActions.showFilteringPanel]: true,
};

export default function content(model, runs, detectors) {
const dataPointer = model.getCurrentDataPointer();
const data = model.fetchedData[dataPointer.page][dataPointer.index].payload;
Expand All @@ -47,27 +55,6 @@ export default function content(model, runs, detectors) {
const { fields } = data;
const visibleFields = fields.filter((f) => f.marked);

const functionalities = (model) => h('.btn-group',
h('button.btn.btn-secondary.icon-only-button', {
onclick: () => {
model.fetchedData.reqForData(true);
model.notify();
},
}, iconReload()),

h('button.btn.btn-secondary.icon-only-button', {
onclick: () => {
downloadCSV(model);
},
}, iconDataTransferDownload()),

copyLinkButton(model.router.getUrl().toString()),

h('button.btn.icon-only-button', {
className: model.searchFieldsVisible ? 'btn-primary' : 'btn-secondary',
onclick: () => model.changeSearchFieldsVisibility(),
}, model.searchFieldsVisible ? h('.slider-20-off-white.abs-center') : h('.slider-20-primary.abs-center')));

return dataPointer.index === defaultIndexString
? noSubPageSelected(model)
: h('.p-1em', [
Expand All @@ -76,20 +63,17 @@ export default function content(model, runs, detectors) {
title(pageNames.runsPerDataPass),
chips),

functionalities(model)),
model.searchFieldsVisible ? filter(model) : '',
dataActionButtons(model, applicableDataActions)),
model.showFilteringPanel ? filter(model) : '',
anyFiltersActive(url) ? activeFilters(model, url) : '',

data.rows?.length > 0
? visibleFields.length > 0
? h('.p-top-05em',
h('.x-scrollable-table.border-sh',
pager(model, data, false),
h('table', {
h('table.runs-table', {
id: `data-table-${data.url}`,
className: `${[pageNames.runsPerDataPass, pageNames.runsPerPeriod].includes(dataPointer.page)
? 'runs-table'
: `${dataPointer.page}-table`}`,
}, [
header(visibleFields, data, model),
model.sortingRowVisible ? sortingRow(visibleFields, data, model) : '',
Expand Down
Loading