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
2 changes: 1 addition & 1 deletion app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class RunConditionTableApplication {
httpServer.get(EP.rctData, (req, res) => databaseService.pgExecFetchData(req, res));
httpServer.post(EP.insertData, (req, res) => databaseService.pgExecDataInsert(req, res));
httpServer.get(EP.date, (req, res) => databaseService.getDate(req, res));
httpServer.get('sync', (req, res) => this.syncAll());
httpServer.get(EP.sync, async (req, res) => this.syncAll());
}

buildAuthControl() {
Expand Down
1 change: 1 addition & 0 deletions app/config/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = { // Properties that will be provided to frontend in the public
insertData: '/Rct-Data/insert-data/',
authControl: '/auth-control/',
date: '/date/',
sync: '/sync/',
},
methods: {
login: 'post',
Expand Down
11 changes: 3 additions & 8 deletions app/lib/ResProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,12 @@ class ResProvider {
const p = ResProvider.viaEnvVars(varsDef, null, 'warn');
let { host } = p;
let { path } = p;
// eslint-disable-next-line prefer-destructuring
let prot = p['prot'];
let { port } = p || {};
let { prot } = p || {};
prot = prot ? prot.trim().replace('://', '') : 'https';
// eslint-disable-next-line prefer-destructuring
let port = p['port'];
const hs = host.split(':');
if (hs.length === 2) {
// eslint-disable-next-line prefer-destructuring
port = hs[1];
// eslint-disable-next-line prefer-destructuring
host = hs[0];
[host, port] = hs;
} else if (hs.length != 1) {
const mess = `incorrect format of hostname: ${host}`;
logger.error(mess);
Expand Down
6 changes: 3 additions & 3 deletions app/lib/alimonitor-services/Cacher.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const fs = require('fs');

class Cacher {
static cache(synchronizerName, endpoint, data) {
const cacheDir = Cacher.serivceCacheDir(synchronizerName);
const cacheDir = Cacher.serviceCacheDir(synchronizerName);
if (!fs.existsSync(cacheDir)) {
fs.mkdirSync(cacheDir, { recursive: true });
}
Expand Down Expand Up @@ -46,7 +46,7 @@ class Cacher {
endpoint = endpoint.slice(0, maxSystemFilenameLength); // TODO better solution
}
return path.join(
Cacher.serivceCacheDir(synchronizerName),
Cacher.serviceCacheDir(synchronizerName),
Cacher.cachedFileName(endpoint),
);
}
Expand All @@ -55,7 +55,7 @@ class Cacher {
return `${endpoint.searchParams.toString()}.json`;
}

static serivceCacheDir(synchronizerName) {
static serviceCacheDir(synchronizerName) {
return path.join(
__dirname,
'..',
Expand Down
10 changes: 5 additions & 5 deletions app/lib/alimonitor-services/JsonsFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const path = require('path');
const Utils = require('../Utils.js');

class JsonsFetcher {
static makeHttpRequestForJSON(endpoint, opts, logger, onSuccess, onFialure) {
static makeHttpRequestForJSON(endpoint, opts, logger, onSuccess, onFailure) {
return new Promise((resolve, reject) => {
let rawData = '';
const req = Utils.checkClientType(endpoint).request(endpoint, opts, async (res) => {
Expand Down Expand Up @@ -55,8 +55,8 @@ class JsonsFetcher {

req.on('error', (e) => {
logger.error(`ERROR httpGet: ${e}`);
if (onFialure) {
onFialure(endpoint, e);
if (onFailure) {
onFailure(endpoint, e);
}
reject(e);
});
Expand Down Expand Up @@ -90,8 +90,8 @@ class JsonsFetcher {
'failing-endpoints.txt',
);
fs.appendFileSync(fp, `${endpoint.href}\n ${e.message}\n`);
if (onFialure) {
onFialure(endpoint, e);
if (onFailure) {
onFailure(endpoint, e);
}
reject(e);
}
Expand Down
87 changes: 87 additions & 0 deletions app/public/components/userView/data/table/noDataView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/**
* @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 } from '/js/src/index.js';
import { RCT } from '../../../../config.js';
const { pagesNames } = RCT;

function useState(defaultValue) {
let value = defaultValue;

function getValue() {
return value;
}

function setValue(newValue) {
value = newValue;
}

return [getValue, setValue];
}

const modes = {
requested: 0,
waiting: 1,
};

export default function noDataView(
model, dataPointer,
) {
const [mode, setMode] = useState(modes.waiting);
const goBackBtn = h('button.btn.btn-primary.m3', {
onclick: () => model.removeCurrentData(),
}, 'Go back');
const reloadBtn = h('button.btn.btn-primary.m3', {
onclick: async () => {
if (mode() === modes.waiting) {
await model.sync();

/*
* Await model.fetchedData.reqForData(true);
* model.notify();
* document.location.reload(true);
*/
} else {
model.fetchedData.reqForData(true);
}
setMode(modes.requested);
},
}, 'Reload');
const noDataMessage = h('h3', 'No data found');
const noDataExplanation = h('h5', `${
dataPointer.page === pagesNames.periods
? 'Please sysnchronize with outer services'
: 'There is no data to be displayed here'
}`);

const noPeriodsView = h('.loginDiv.top-100', [
h('.synchronize-90'),
noDataMessage,
noDataExplanation,
reloadBtn,
]);

const noDataView = h('.loginDiv.top-100', [
h('.nothing-found-90'),
noDataMessage,
noDataExplanation,
goBackBtn,
]);

return dataPointer.page === pagesNames.periods
? mode() === modes.requested
? 'loading'
: noPeriodsView
: noDataView;
}
23 changes: 4 additions & 19 deletions app/public/components/userView/data/table/tablePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import pager from '../pager.js';
import postingDataConfig from '../posting/postingDataConfig.js';
import { postForm } from '../posting/postForm.js';
import filter from './filter.js';
import noDataView from './noDataView.js';

import { RCT } from '../../../../config.js';
const { pagesNames } = RCT;
Expand All @@ -35,28 +36,12 @@ const { pagesNames } = RCT;
export default function tablePanel(model) {
const dataPointer = model.getCurrentDataPointer();
const data = model.fetchedData[dataPointer.page][dataPointer.index].payload;
data.rows = data.rows.filter((item) => item.name != 'null');

if (data.rows?.length == 0) {
const removeAndGoBackBtn = h('button.btn.btn-primary.m3', {
onclick: () => model.removeCurrentData(),
}, `${
dataPointer.page === pagesNames.periods
? 'Reload'
: 'Go back'
}`);
const noDataMessage = h('h3', 'No data found');
const noDataExplanation = h('h5', `${
dataPointer.page === pagesNames.periods
? 'Make sure the database works fine'
: 'There is no data to be displayed here'
}`);
return h('.loginDiv.top-100', [
h('.nothing-found-90'),
noDataMessage,
noDataExplanation,
removeAndGoBackBtn,
]);
return noDataView(model, dataPointer);
}

const cellsSpecials = pagesCellsSpecials[dataPointer.page];

const { fields } = data;
Expand Down
8 changes: 8 additions & 0 deletions app/public/model/PrimaryModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ export default class PrimaryModel extends Observable {
this.notify();
}

async sync() {
const syncEndpoint = '/api/sync/';
this.loader.get(syncEndpoint);
await this.fetchedData.reqForData(true);
document.location.reload(true);
this.notify();
}

getDataPointerFromUrl(url) {
const pointer = Object.fromEntries(new URLSearchParams(url.search));
return {
Expand Down
7 changes: 7 additions & 0 deletions app/public/styles/icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,10 @@
height: 90px;
display: inline-block;
}

.synchronize-90 {
background-image: url('./images/90/Synchronize.svg');
width: 90px;
height: 90px;
display: inline-block;
}
9 changes: 9 additions & 0 deletions app/public/styles/images/90/Synchronize.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docker/dev.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ENV_MODE=dev
RUNNING_ENV=DOCKER

## loggin
## logger
RCT_LOG_FILENAME=${RCT_LOG_FILENAME:-reports/rctlogs.txt}
RCT_LOG_FILE_LOGLEV=${RCT_LOG_FILE_LOGLEV:-warn}
RCT_LOG_CONSOLE_LOGLEV=${RCT_LOG_CONSOLE_LOGLEV:-debug}
Expand Down
57 changes: 51 additions & 6 deletions docker/test.env
Original file line number Diff line number Diff line change
@@ -1,26 +1,71 @@
ENV_MODE=test
RUNNING_ENV=DOCKER

## logger
RCT_LOG_FILENAME=${RCT_LOG_FILENAME:-reports/rctlogs.txt}
RCT_LOG_FILE_LOGLEV=${RCT_LOG_FILE_LOGLEV:-warn}
RCT_LOG_CONSOLE_LOGLEV=${RCT_LOG_CONSOLE_LOGLEV:-debug}
RCT_LOG_CONSOLE_SYSD=${RCT_LOG_CONSOLE_SYSD:-}

## http server
RCT_HTTP_PORT=8081
RCT_HOSTNAME=localhost
RCT_TLS_ENABLED=false

RCT_JWT_SECRET=secret
RCT_JWT_EXPIRATION=12h

## external services connections
CERN_SOCKS=false
RCT_SYNC_TASK_AT_START=false

## database configuration
### general
RCT_DB_HOST=database
RCT_DB_NAME=rct-db
RCT_DB_PORT=5432
RCT_DB_USERNAME=rct-user
RCT_DB_PASSWORD=rct-passwd
MOCK_DB=${MOCK_DB:-true}

CERN_SOCKS=false

RCT_SYNC_TASK_AT_START=false


### docker container postgres configuration
POSTGRES_PASSWORD=postgres
POSTGRES_USER=postgres
POSTGRES_DB=postgres
PGDATA=/var/lib/postgresql/data/pgdata
POSTGRES_HOST_AUTH_METHOD=md5
POSTGRES_HOST_AUTH_METHOD=md5

### endpoints
_DEF_BK_HOST=ali-bookkeeping.cern.ch
_DEF_ML_HOST=alimonitor.cern.ch
_DEF_ML_PROT=https

### bkp
RCT_EP_BK_RUNS_PROT=https
RCT_EP_BK_RUNS_HOST=${RCT_EP_BK_RUNS_HOST:-$_DEF_BK_HOST}
RCT_EP_BK_RUNS_PATH=${RCT_EP_BK_RUNS_PATH:-/api/runs?filter[definitions]=PHYSICS}


### data passes
RCT_EP_ML_DP_RAW_PROT=$_DEF_ML_PROT
RCT_EP_ML_DP_RAW_HOST=${RCT_EP_ML_DP_RAW_HOST:-$_DEF_ML_HOST}
RCT_EP_ML_DP_RAW_PATH=${RCT_EP_ML_DP_RAW_PATH:-/production/raw.jsp?res_path=json}


RCT_EP_ML_DP_DET_PROT=$_DEF_ML_PROT
RCT_EP_ML_DP_DET_HOST=${RCT_EP_ML_DP_DET_HOST:-$_DEF_ML_HOST}
RCT_EP_ML_DP_DET_PATH=${RCT_EP_ML_DP_DET_PATH:-/raw/raw_details.jsp?timesel=0&res_path=json}


### simulation passes
RCT_EP_ML_MC_RAW_PROT=$_DEF_ML_PROT
RCT_EP_ML_MC_RAW_HOST=${RCT_EP_ML_MC_RAW_HOST:-$_DEF_ML_HOST}
RCT_EP_ML_MC_RAW_PATH=${RCT_EP_ML_MC_RAW_PATH:-/MC/?res_path=json}

RCT_EP_ML_MC_DET_PROT=$_DEF_ML_PROT
RCT_EP_ML_MC_DET_HOST=${RCT_EP_ML_MC_DET_HOST:-$_DEF_ML_HOST}
RCT_EP_ML_MC_DET_PATH=${RCT_EP_ML_MC_DET_PATH:-/job_events.jsp?timesel=0&res_path=json}

RCT_EP_ML_MC_TAG_PROT=$_DEF_ML_PROT
RCT_EP_ML_MC_TAG_HOST=${RCT_EP_ML_MC_TAG_HOST:-$_DEF_ML_HOST}
RCT_EP_ML_MC_TAG_PATH=${RCT_EP_ML_MC_TAG_PATH:-/MC/prodDetails.jsp?res_path=json}
2 changes: 1 addition & 1 deletion docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ The following configuration items can be set using environment variables, note t
## Misc.
| Variable name | Description | Default value |
|---------------|-------------|---------------|
| ALIMONITOR_PASSPHRASE | passphrase to grid certificate myCertificate.p12 | |
| ALIMONITOR_PASSPHRASE | passphrase to the grid certificate (`rct-alimonitor-cert.p12`) | |
| CERN_SOCKS | address of proxy socket used for reaching CERN network | false |
Loading