|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 4 | + * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 5 | + * All rights not expressly granted are reserved. |
| 6 | + * |
| 7 | + * This software is distributed under the terms of the GNU General Public |
| 8 | + * License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 9 | + * |
| 10 | + * In applying this license CERN does not waive the privileges and immunities |
| 11 | + * granted to it by virtue of its status as an Intergovernmental Organization |
| 12 | + * or submit itself to any jurisdiction. |
| 13 | + */ |
| 14 | + |
| 15 | +import { h, iconDataTransferDownload, iconReload, iconShareBoxed } from '/js/src/index.js'; |
| 16 | +import filter from '../../userView/data/table/filtering/filter.js'; |
| 17 | +import downloadCSV from '../../../../utils/csvExport.js'; |
| 18 | +import pageSettings from '../../userView/data/pageSettings/pageSettings.js'; |
| 19 | +import flagsVisualization from '../../../components/flags/flagsVisualization.js'; |
| 20 | +import flagsTable from './flagsTable.js'; |
| 21 | +import flagBreadCrumbs from '../../../../components/flags/flagBreadcrumbs.js'; |
| 22 | +import { defaultRunNumbers } from '../../../../utils/defaults.js'; |
| 23 | +import noSubPageSelected from '../../userView/data/table/noSubPageSelected.js'; |
| 24 | + |
| 25 | +export default function flagsContent(model, runs, detectors, flags) { |
| 26 | + const urlParams = model.router.getUrl().searchParams; |
| 27 | + |
| 28 | + const dataPassName = urlParams.get('data_pass_name'); |
| 29 | + const run = urlParams.get('run_numbers'); |
| 30 | + const detector = urlParams.get('detector'); |
| 31 | + |
| 32 | + const detectorName = detectors.getDetectorName(detector); |
| 33 | + const flagsData = flags.getFlags(run, detectorName); |
| 34 | + const runData = runs.getRun(dataPassName, run); |
| 35 | + |
| 36 | + const functionalities = (model) => h('.btn-group', |
| 37 | + h('button.btn.btn-secondary.icon-only-button', { |
| 38 | + onclick: () => { |
| 39 | + model.fetchedData.reqForData(true); |
| 40 | + model.notify(); |
| 41 | + }, |
| 42 | + }, iconReload()), |
| 43 | + |
| 44 | + h('button.btn.btn-secondary.icon-only-button', { |
| 45 | + onclick: () => { |
| 46 | + downloadCSV(model); |
| 47 | + }, |
| 48 | + }, iconDataTransferDownload()), |
| 49 | + |
| 50 | + h('button.btn.btn-secondary.icon-only-button', { |
| 51 | + onclick: () => { |
| 52 | + navigator.clipboard.writeText(model.router.getUrl().toString()) |
| 53 | + .then(() => { |
| 54 | + }) |
| 55 | + .catch(() => { |
| 56 | + }); |
| 57 | + }, |
| 58 | + }, iconShareBoxed()), |
| 59 | + |
| 60 | + h('button.btn.icon-only-button', { |
| 61 | + className: model.searchFieldsVisible ? 'btn-primary' : 'btn-secondary', |
| 62 | + onclick: () => model.changeSearchFieldsVisibility(), |
| 63 | + }, model.searchFieldsVisible ? h('.slider-20-off-white.abs-center') : h('.slider-20-primary.abs-center'))); |
| 64 | + |
| 65 | + return run > defaultRunNumbers && runData |
| 66 | + ? h('div.main-content', [ |
| 67 | + h('div.flex-wrap.justify-between.items-center', |
| 68 | + h('div.flex-wrap.justify-between.items-center', |
| 69 | + flagBreadCrumbs(model, dataPassName, run, detectorName), |
| 70 | + h('button.btn.btn-secondary', { |
| 71 | + onclick: () => { |
| 72 | + document.getElementById('pageSettingsModal').style.display = 'block'; |
| 73 | + document.addEventListener('click', (event) => { |
| 74 | + const modalContent = document.getElementsByClassName('modal-content'); |
| 75 | + const modal = document.getElementsByClassName('modal'); |
| 76 | + if (Array.from(modalContent).find((e) => e != event.target) |
| 77 | + && Array.from(modal).find((e) => e == event.target) |
| 78 | + && document.getElementById('pageSettingsModal')) { |
| 79 | + document.getElementById('pageSettingsModal').style.display = 'none'; |
| 80 | + } |
| 81 | + }); |
| 82 | + }, |
| 83 | + }, h('.settings-20'))), |
| 84 | + |
| 85 | + h('div', functionalities(model))), |
| 86 | + model.searchFieldsVisible ? filter(model) : '', |
| 87 | + |
| 88 | + flagsVisualization(runData, flagsData), |
| 89 | + flagsTable(model, flagsData), |
| 90 | + h('.modal', { id: 'pageSettingsModal' }, |
| 91 | + h('.modal-content.abs-center.p3', { |
| 92 | + id: 'pageSettingsModalContent', |
| 93 | + }, pageSettings(model, () => { |
| 94 | + document.getElementById('pageSettingsModal').style.display = 'none'; |
| 95 | + }))), |
| 96 | + ]) |
| 97 | + : noSubPageSelected(model); |
| 98 | +} |
0 commit comments