Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TODO keep this comment until the subsystem dashboard migration is complete
- createSelector(getSystemDetailDashboardState, getRawConfig); // export const getSystemDetailDashboardConfigurationParsedFromV1 =
- export const getSystemDetailDashboardConfigurationParsedFromV1 = // createSelector(getSystemDetailDashboardRawConfig, (rawConfig, hasLayout) => {
- createSelector(getSystemDetailDashboardRawConfig, getSystemEntityHasSystemLayout, (rawConfig, hasLayout) => {
- // const createDashboardRow = (type: 'chart' | 'kpiRow' | 'systemLayout', configuration): IConfigurationRow =>
- const createDashboardRow = (type: 'chart' | 'kpiRow' | 'systemLayout', configuration): IConfigurationRow => // ({ type, configuration, uid: Math.random().toString() });
- ({ type, configuration, uid: Math.random().toString() });
- // // Creates row that serves as placeholder for the systemLayout row
- // Creates row that serves as placeholder for the systemLayout row // const systemLayout = hasLayout ? [createDashboardRow('systemLayout', { minimized: false })] : [];
- const systemLayout = hasLayout ? [createDashboardRow('systemLayout', { minimized: false })] : [];
- // // Parse old eCharts config to the new format and creates a row config for each one
- // Parse old eCharts config to the new format and creates a row config for each one // const parsedCharts = (rawConfig.charts || []).map(rawChart => createDashboardRow('chart', setUpConfig(rawChart)));
- const parsedCharts = (rawConfig.charts || []).map(rawChart => createDashboardRow('chart', setUpConfig(rawChart)));
- // // Parse old kpi box configs to the new format and creates a single row config that contains all exiting kpi-s
- // Parse old kpi box configs to the new format and creates a single row config that contains all exiting kpi-s // const parsedKpi = (rawConfig.kpi_boxes && rawConfig.kpi_boxes.length !== 0)
- const parsedKpi = (rawConfig.kpi_boxes && rawConfig.kpi_boxes.length !== 0) // ? [createDashboardRow('kpiRow', {
- ? [createDashboardRow('kpiRow', { // kpiConfigs: rawConfig.kpi_boxes.map(x => {
- kpiConfigs: rawConfig.kpi_boxes.map(x => { // if (x.type === KPIBoxType.VALUE) {
- if (x.type === KPIBoxType.VALUE) { // return ({
- return ({ // uid: Math.random().toString(),
- uid: Math.random().toString(), // ...x,
- ...x, // title: x.abbreviation,
- title: x.abbreviation, // tooltip: x.alias,
- tooltip: x.alias, // precision: x.decimals || 0,
- precision: x.decimals || 0, // multiplier: 1,
- multiplier: 1, // showLabel: !!x.value_mapping,
- showLabel: !!x.value_mapping, // value_mapping: (x.value_mapping || []).map(y => ({ ...y, uid: Math.random() }))
- value_mapping: (x.value_mapping || []).map(y => ({ ...y, uid: Math.random() })) // });
- }); // }
- } // if (x.type === KPIBoxType.CALCULATED) {
- if (x.type === KPIBoxType.CALCULATED) { // return ({
- return ({ // uid: Math.random().toString(),
- uid: Math.random().toString(), // ...x,
- ...x, // title: x.abbreviation,
- title: x.abbreviation, // tooltip: x.alias,
- tooltip: x.alias, // precision: x.decimals || 0,
- precision: x.decimals || 0, // multiplier: 1
- multiplier: 1 // });
- }); // }
- }
- // if (x.type === KPIBoxType.STATUS) {
- if (x.type === KPIBoxType.STATUS) { // const baseStatusKPI: any = {
- const baseStatusKPI: any = { // uid: Math.random().toString(),
- uid: Math.random().toString(), // title: x.abbreviation,
- title: x.abbreviation, // tooltip: x.alias,
- tooltip: x.alias, // type: x.type
- type: x.type // };
- }; // baseStatusKPI.sourceType = KPIBoxSourceType.SYSTEM;
- baseStatusKPI.sourceType = KPIBoxSourceType.SYSTEM;
- // if (x.subsystemId) {
- if (x.subsystemId) { // baseStatusKPI.subsystemId = x.subsystemId;
- baseStatusKPI.subsystemId = x.subsystemId; // baseStatusKPI.sourceType = KPIBoxSourceType.SUBSYSTEM;
- baseStatusKPI.sourceType = KPIBoxSourceType.SUBSYSTEM; // }
- }
- // if (x.controllerId) {
- if (x.controllerId) { // // We are using idx of controller instead of the id so it doesn't make sense to store the id
- // We are using idx of controller instead of the id so it doesn't make sense to store the id // baseStatusKPI.controller_idx = 0;
- baseStatusKPI.controller_idx = 0; // baseStatusKPI.sourceType = KPIBoxSourceType.CONTROLLER;
- baseStatusKPI.sourceType = KPIBoxSourceType.CONTROLLER; // }
- }
- // if (x.abbreviation) {
- if (x.abbreviation) { // baseStatusKPI.title = x.abbreviation;
- baseStatusKPI.title = x.abbreviation; // baseStatusKPI.tooltip = x.alias;
- baseStatusKPI.tooltip = x.alias; // }
- } // return baseStatusKPI;
- return baseStatusKPI; // }
- }
- // if (x.type === KPIBoxType.MAP) {
- if (x.type === KPIBoxType.MAP) { // const baseStatusKPI: any = {
- const baseStatusKPI: any = { // uid: Math.random().toString(),
- uid: Math.random().toString(), // title: x.abbreviation,
- title: x.abbreviation, // tooltip: x.alias,
- tooltip: x.alias, // type: x.type
- type: x.type // };
- };
- // if (!x.source) {
- if (!x.source) { // baseStatusKPI.sourceType = KPIBoxSourceType.SYSTEM;
- baseStatusKPI.sourceType = KPIBoxSourceType.SYSTEM; // return baseStatusKPI;
- return baseStatusKPI; // }
- }
- // baseStatusKPI.sourceType = KPIBoxSourceType.CONTROLLER;
- baseStatusKPI.sourceType = KPIBoxSourceType.CONTROLLER; // baseStatusKPI.device_id = x.source.device_id;
- baseStatusKPI.device_id = x.source.device_id; // baseStatusKPI.controller_instance_idx = x.source.controller_instance_idx;
- baseStatusKPI.controller_instance_idx = x.source.controller_instance_idx;
- // return baseStatusKPI;
- return baseStatusKPI; // }
- } // return {
- return { // uid: Math.random().toString(),
- uid: Math.random().toString(), // ...x,
- ...x, // title: x.alias
- title: x.alias // };
- }; // }),
- }), // // TODO: add generic placeholder name
- // TODO: add generic placeholder name // title: 'General System Details',
- title: 'General System Details', // minimized: false
- minimized: false // })]
- })] // : [];
- : []; // return [...systemLayout, ...parsedKpi, ...parsedCharts];
- return [...systemLayout, ...parsedKpi, ...parsedCharts]; // });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement