Skip to content

Commit

Permalink
[OGUI-1516] Merge epn tasks in general table following new ECS mapping (
Browse files Browse the repository at this point in the history
#2421)

* following ECS new mapping (devices as Object<String, Object> instead of array of objects), updates the adapter on back-end to ensure compatibility with front-end
* updates front-end to merge EPN summary table into general table summary
  • Loading branch information
graduta authored Jun 4, 2024
1 parent 9b07660 commit 9d921fa
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 94 deletions.
19 changes: 12 additions & 7 deletions Control/lib/adapters/EnvironmentInfoAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ class EnvironmentInfoAdapter {
if (taskSource === TASKS_SOURCE.EPN) {
const {integratedServicesData: {odc = '{}'}} = environment;
const odcParsed = JSON.parse(odc);
environmentInfo.tasks = odcParsed.devices;
environmentInfo.tasks = Array.from(Object.values(odcParsed.devices).map((device) => {
device.epnState = device.state;
device.state = device.ecsState;
delete device.ecsState;
return device;
}));
} else if (taskSource === TASKS_SOURCE.FLP) {
const {tasks = [], includedDetectors} = environment;
environmentInfo.tasks = [];
Expand Down Expand Up @@ -249,14 +254,15 @@ class EnvironmentInfoAdapter {
const {devices = [], ddsSessionId = '', ddsSessionStatus = '', state = ''} = JSON.parse(odc);
const states = {};
const hosts = new Set();
for (const device of devices) {
const {state, host} = device;

Object.values(devices).forEach((device) => {
const {ecsState, host} = device;
hosts.add(host);
states[state] = (states[state] + 1) || 1;
}
states[ecsState] = (states[ecsState] + 1) || 1;
});
return {
tasks: {
total: devices.length,
total: Object.keys(devices).length,
states
},
hosts: hosts.size,
Expand All @@ -274,7 +280,6 @@ class EnvironmentInfoAdapter {
}
}


/**
* Given a JSON containing environment information and a specific key:
* * check if that key maps to an existing values
Expand Down
16 changes: 0 additions & 16 deletions Control/public/common/enums/HardwareComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,3 @@ export const HARDWARE_COMPONENTS = Object.keys(HardwareComponent)
return a.localeCompare(b);
}
});

/**
* List of possible hardware components sorted alphabetically with FLP first
* @return {Array<String>} list of hardware components
*/
export const HARDWARE_COMPONENTS_WITHOUT_EPN = Object.keys(HardwareComponent)
.filter((component) => component !== HardwareComponent.EPN)
.sort((a, b) => {
if (a === 'FLP') {
return -1;
} else if (b === 'FLP') {
return 1;
} else {
return a.localeCompare(b);
}
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

import {dcsProperty} from '../../common/dcs/dcsPropertiesRow.js';
import {HARDWARE_COMPONENTS_WITHOUT_EPN, HardwareComponent} from '../../common/enums/HardwareComponent.js';
import {HARDWARE_COMPONENTS, HardwareComponent} from '../../common/enums/HardwareComponent.js';
import {FLP_TASK_STATES, getTaskStateClassAssociation} from './../../common/enums/TaskState.js';
import {h} from '/js/src/index.js';

Expand Down Expand Up @@ -46,8 +46,7 @@ export const environmentTasksSummaryTable = (environment, detectorsAvailability)
*/
const hardwareComponentsTableHeaderRow = (hardware) => h('tr', [
h('th', 'Tasks Summary'),
HARDWARE_COMPONENTS_WITHOUT_EPN
.filter(component => component !== 'EPN')
HARDWARE_COMPONENTS
.map((component) => {
const componentInLowerCase = component.toLocaleLowerCase();
const colspan = hardware[componentInLowerCase]?.detectorCounters
Expand All @@ -73,7 +72,7 @@ const detectorsTableHeaderRow = ({flp: {detectorCounters = {}} = {}}, availabili
detector,
shouldDisplaySorAvailability && h('.f6', dcsProperty(availability[detector].sorAvailability, 'SOR'))
])),
h('th.text-center', {colspan: HARDWARE_COMPONENTS_WITHOUT_EPN.length - 1}, ''), // empty cell to align with the rest of the table
h('th.text-center', {colspan: HARDWARE_COMPONENTS.length - 1}, ''), // empty cell to align with the rest of the table
]);

/**
Expand All @@ -86,7 +85,7 @@ const rowForTaskSate = (state, hardware) => {
const taskClass = getTaskStateClassAssociation(state);
return h('tr', [
h(`td${taskClass}`, state),
HARDWARE_COMPONENTS_WITHOUT_EPN
HARDWARE_COMPONENTS
.map((component) => {
const componentInLowerCase = component.toLocaleLowerCase();
if (componentInLowerCase === 'flp') {
Expand Down
2 changes: 0 additions & 2 deletions Control/public/environment/environmentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {h} from '/js/src/index.js';
import {environmentActionPanel} from './components/environmentActionPanel.js';
import {environmentNavigationTabs} from './components/environmentNavigationTabs.js';
import {environmentTasksSummaryTable} from './components/environmentTasksSummaryTable.js';
import {environmentEpnTasksSummaryTable} from './components/environmentEpnTasksSummaryTable.js';
import {monitoringRunningPlotsPanel} from './components/monitoringRunningPlotsPanel.js';
import pageLoading from '../common/pageLoading.js';
import errorPage from '../common/errorPage.js';
Expand Down Expand Up @@ -63,7 +62,6 @@ const showEnvironmentPage = (model, environmentInfo) => {
isRunningStable && monitoringRunningPlotsPanel(environmentInfo),
h('.flex-row.g2.z-index-one', [
environmentTasksSummaryTable(environmentInfo, availability),
environmentEpnTasksSummaryTable(environmentInfo),
]),
environmentNavigationTabs(model, environmentInfo),
]);
Expand Down
4 changes: 2 additions & 2 deletions Control/test/integration/control-environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ describe('`Control Environment` test-suite', async () => {
await page.goto(config.url + '?page=locks');
const location = await page.evaluate(() => window.location);
assert.strictEqual(location.search, '?page=locks');
await page.waitForSelector('button.danger');
await page.evaluate(() => document.querySelector('button.danger').click());
await page.waitForSelector('button.btn.btn-danger', {timeout: 5000});
await page.evaluate(() => document.querySelector('button.btn.btn-danger').click());
});
});

Expand Down
11 changes: 5 additions & 6 deletions Control/test/integration/create-new-environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ describe('`pageNewEnvironment` test-suite', async () => {
});

it('should successfully request a list of template objects', async () => {
const templates = await page.evaluate(() => window.model.workflow.templates.match({
Success: (payload) => payload,
Other: () => null,
}));
await page.waitForTimeout(500);
const templates = await page.evaluate(() => window.model.workflow.templates.payload);

assert.ok(templates?.length !== 0, `No templates received`);
});
Expand Down Expand Up @@ -82,7 +80,7 @@ describe('`pageNewEnvironment` test-suite', async () => {
});

it('should have successfully lock and select detector from area list', async () => {
await page.evaluate(() => document.querySelector('.m1 > div:nth-child(1) > div > a:nth-child(1)').click());
await page.evaluate(() => document.querySelector('.m1 > div:nth-child(1) > div > div').click());
await page.waitForTimeout(1000);
await page.evaluate(() => document.querySelector('.m1 > div:nth-child(1) > div > a:nth-child(2)').click());
await page.waitForTimeout(1000);
Expand Down Expand Up @@ -110,7 +108,8 @@ describe('`pageNewEnvironment` test-suite', async () => {
const queryResult = await page.evaluate(() => window.model.environment.itemNew.match({
Failure: (error) => [error],
NotAsked: () => [],
Other: () => null,
Loading: () => [],
Success: () => null,
}));
const revision = await page.evaluate(() => window.model.workflow.form.revision);

Expand Down

0 comments on commit 9d921fa

Please sign in to comment.