From fb658c63bc4fb2eeb2c27a519feb9fb79495cd37 Mon Sep 17 00:00:00 2001 From: Muthukrishnanmatriot <76949556+muthukrishnanmatriot@users.noreply.github.com> Date: Tue, 5 Jul 2022 10:28:57 +0530 Subject: [PATCH] TMSS-1857 - updated the code to inject the Station Groups if not defined in parameters --- .../routes/Scheduling/ViewSchedulingUnit.js | 4 +++ .../src/routes/Scheduling/create.js | 3 +++ .../tmss_webapp/src/routes/Scheduling/edit.js | 4 ++- .../Scheduling/excelview.schedulingset.js | 1 + .../tmss_webapp/src/utils/unit.converter.js | 25 ++++++++++++++++++- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/ViewSchedulingUnit.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/ViewSchedulingUnit.js index 56fad6bd0ad..f0111305b1e 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/ViewSchedulingUnit.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/ViewSchedulingUnit.js @@ -501,6 +501,7 @@ class ViewSchedulingUnit extends Component { */ async loadTaskParameters(observStrategy) { if (observStrategy) { + await UnitConverter.updateStationGroupParameters(observStrategy); const tasks = observStrategy.template.tasks; const parameters = observStrategy.template.parameters; let paramsOutput = {}; @@ -1948,6 +1949,9 @@ class ViewSchedulingUnit extends Component { }); } const obsStrategy = this.state.scheduleunit?.observation_strategy_template; + if (obsStrategy) { + UnitConverter.updateStationGroupParameters(obsStrategy); + } return ( <> {userPermissions.scheduleunit.list ? diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js index 3d41137bb70..b9c21e644e2 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/create.js @@ -197,6 +197,9 @@ export class SchedulingUnitCreate extends Component { */ async changeStrategy (strategyId) { const observStrategy = _.find(this.observStrategies, {'id': strategyId}); + if (await UnitConverter.updateStationGroupParameters(observStrategy)) { + this.setState({observStrategies: this.observStrategies}); + } let stationGroups = {}; const tasks = observStrategy.template.tasks; const parameters = observStrategy.template.parameters; diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/edit.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/edit.js index c819191db7a..9b8e8ab83c1 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/edit.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/edit.js @@ -29,6 +29,7 @@ import UtilService from '../../services/util.service'; import ReactTooltip from "react-tooltip"; import AuthUtil from '../../utils/auth.util'; import AccessDenied from '../../layout/components/AccessDenied'; +import UnitConverter from '../../utils/unit.converter'; /** * Compoenent to edit scheduling unit draft @@ -71,7 +72,7 @@ export class EditSchedulingUnit extends Component { this.observStrategies = []; // All Observing strategy templates this.taskTemplates = []; // All task templates to be filtered based on tasks in selected strategy template this.schedulingSets = []; - this.observStrategies = []; + //this.observStrategies = []; this.taskTemplates = []; this.constraintTemplates = []; this.tooltipOptions = UIConstants.tooltipOptions; @@ -108,6 +109,7 @@ export class EditSchedulingUnit extends Component { */ async changeStrategy (strategyId) { const observStrategy = _.find(this.observStrategies, {'id': strategyId}); + await UnitConverter.updateStationGroupParameters(observStrategy); let stationGroups = {}; if (observStrategy) { let station_group = []; diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js index 474b290ab8b..43b7e5206a1 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.js @@ -570,6 +570,7 @@ export class SchedulingSetCreate extends Component { await this.setState({noOfSU: 10, isAGLoading: true, copyHeader: false, rowData: [], confirmDialogVisible: false, isDirty: false}); publish('edit-dirty', false); const observStrategy = _.find(this.observStrategies, {'id': strategyId}); + await UnitConverter.updateStationGroupParameters(observStrategy); // this.setState({schedulingUnitList: null, observStrategy: observStrategy, noOfSU: 10, isAGLoading: true, copyHeader: false, rowData: [], agSUWithDefaultValue: {}, confirmDialogVisible: false, isDirty: false}); this.setState({observStrategy: observStrategy, noOfSU: 10, isAGLoading: true, copyHeader: false, rowData: [], agSUWithDefaultValue: {}, confirmDialogVisible: false, isDirty: false, isObsoletStrategy: observStrategy.state_value === 'obsolete'? true: false}); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/utils/unit.converter.js b/SAS/TMSS/frontend/tmss_webapp/src/utils/unit.converter.js index f1d68410f2a..702cebab695 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/utils/unit.converter.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/utils/unit.converter.js @@ -311,7 +311,30 @@ const UnitConverter = { } prpOutput = subbandList; return prpOutput; - } + }, + updateStationGroupParameters(observStrategy) { + let isUpdated = false; + if (observStrategy.template ) { + const parameters = observStrategy.template.parameters; + let stationParameters = parameters.filter( parameter => _.endsWith(parameter['refs'],'station_groups')); + if (stationParameters === undefined || stationParameters.length === 0) { + const taskKeys = Object.keys(observStrategy.template.tasks); + for (const key of taskKeys) { + if (observStrategy.template.tasks[key]['specifications_doc'].hasOwnProperty(['station_configuration']) + && observStrategy.template.tasks[key]['specifications_doc']['station_configuration'].hasOwnProperty(['station_groups'])) { + observStrategy.template.parameters.push({ + "name": "Station Groups - "+key, + "refs": [ + `#/tasks/${key}/specifications_doc/station_configuration/station_groups` + ] + }); + isUpdated = true; + } + } + } + } + return isUpdated; + } }; export default UnitConverter; \ No newline at end of file -- GitLab