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 56fad6bd0ad2a1300b1a8a0749a88d50f5235a6f..f0111305b1ea90340ee40d69ef7d0a610c1fba29 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 3d41137bb7080f803d3b873e890cdbedf624ad5e..b9c21e644e2458a0f8d8b3119c59313d61e282b2 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 c819191db7abc24931fb46d423e95faf0b11b7a0..9b8e8ab83c1e42c3aea0d1b46f5e2ca2342a031c 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 474b290ab8bbbf260f49b1a4ed9cf41cb384b6f1..43b7e5206a1a1f2abf569fef554912ff0c6ce666 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 f1d68410f2a6605fcb7e8c4c00cd164c24ffb1cc..702cebab695d73fe8e9c8c5bbcf1d43d9874a12b 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