From f7ccbe97bc88c6199f21cc282e907e20a624b9ef Mon Sep 17 00:00:00 2001 From: Ramesh Kumar <r.kumar@redkarma.eu> Date: Thu, 3 Dec 2020 03:18:36 +0530 Subject: [PATCH] TMSS-427: Station list in SU summary view modified to load from task or subtask based on the SU status and listing only unique stations. --- .../src/layout/sass/_suSummary.scss | 7 +++ .../src/routes/Scheduling/summary.js | 13 ++++-- .../tmss_webapp/src/routes/Timeline/view.js | 46 +++++++++++-------- .../src/routes/Timeline/week.view.js | 12 ++++- 4 files changed, 54 insertions(+), 24 deletions(-) diff --git a/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/_suSummary.scss b/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/_suSummary.scss index 76b02736fb1..ab73c0560d1 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/_suSummary.scss +++ b/SAS/TMSS/frontend/tmss_webapp/src/layout/sass/_suSummary.scss @@ -45,4 +45,11 @@ .json-to-table::-webkit-scrollbar-thumb { background-color: #0000007c; + } + + .station-list { + max-height: 150px; + overflow-y: scroll; + border: 1px solid lightgrey; + padding: 0px 10px 10px 10px; } \ No newline at end of file diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/summary.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/summary.js index 660a7c1a0e4..94ca5e5213e 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/summary.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/summary.js @@ -154,12 +154,19 @@ export class SchedulingUnitSummary extends Component { </> } - {<Stations + {/* {<Stations stationGroup={this.props.stationGroup} view isSummary - />} - + />} */} + <div className="col-12"><label>Stations:</label></div> + <div className="col-12 station-list"> + {this.props.stationGroup && this.props.stationGroup.map((station, index) => ( + <div key={`stn-${index}`}>{station}</div> + ))} + + </div> + <div className="col-12 task-summary"> <label>Tasks:</label> <ViewTable diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/view.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/view.js index 05f2f9c2eca..d1c5a388e91 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/view.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/view.js @@ -158,7 +158,8 @@ export class TimelineView extends Component { task.band = task.specifications_doc.filter; } } - const targetObservation = _.find(taskList, (task)=> {return task.template.type_value==='observation' && task.tasktype.toLowerCase()==="blueprint" && task.specifications_doc.station_groups}); + this.setState({suTaskList: _.sortBy(taskList, "id"), isSummaryLoading: false, + stationGroup: this.getSUStations(suBlueprint)}); }); // Get the scheduling constraint template of the selected SU block ScheduleService.getSchedulingConstraintTemplate(suBlueprint.suDraft.scheduling_constraints_template_id) @@ -220,37 +221,44 @@ export class TimelineView extends Component { * @param {Array} items */ getStationItemGroups(suBlueprint, timelineItem, group, items) { - /** Get all observation tasks */ - const observtionTasks = _.filter(suBlueprint.tasks, (task) => { return task.template.type_value.toLowerCase() === "observation"}); + /* Get stations based on SU status */ + let stations = this.getSUStations(suBlueprint); + + /* Group the items by station */ + for (const station of stations) { + let stationItem = _.cloneDeep(timelineItem); + stationItem.id = `${stationItem.id}-${station}`; + stationItem.group = station; + items.push(stationItem); + } + } + + /** + * Get all stations of the SU bleprint from the observation task or subtask bases on the SU status. + * @param {Object} suBlueprint + */ + getSUStations(suBlueprint) { let stations = []; - for (const observtionTask of observtionTasks) { + /* Get all observation tasks */ + const observationTasks = _.filter(suBlueprint.tasks, (task) => { return task.template.type_value.toLowerCase() === "observation"}); + for (const observationTask of observationTasks) { /** If the status of SU is before scheduled, get all stations from the station_groups from the task specification_docs */ if (this.STATUS_BEFORE_SCHEDULED.indexOf(suBlueprint.status.toLowerCase()) >= 0 - && observtionTask.specifications_doc.station_groups) { - for (const grpStations of _.map(observtionTask.specifications_doc.station_groups, "stations")) { + && observationTask.specifications_doc.station_groups) { + for (const grpStations of _.map(observationTask.specifications_doc.station_groups, "stations")) { stations = _.concat(stations, grpStations); } } else if (this.STATUS_BEFORE_SCHEDULED.indexOf(suBlueprint.status.toLowerCase()) < 0 - && observtionTask.subTasks) { + && observationTask.subTasks) { /** If the status of SU is scheduled or after get the stations from the subtask specification tasks */ - for (const subtask of observtionTask.subTasks) { + for (const subtask of observationTask.subTasks) { if (subtask.specifications_doc.stations) { stations = _.concat(stations, subtask.specifications_doc.stations.station_list); } } } } - stations = _.uniq(stations); - /** Group the items by station */ - for (const station of stations) { - let stationItem = _.cloneDeep(timelineItem); - stationItem.id = `${stationItem.id}-${station}`; - stationItem.group = station; - items.push(stationItem); - // if (!_.find(group, {'id': station})) { - // group.push({'id': station, title: station}); - // } - } + return _.uniq(stations); } /** diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/week.view.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/week.view.js index 7843db74cc9..98da19ce7b8 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/week.view.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/week.view.js @@ -169,14 +169,22 @@ export class WeekTimelineView extends Component { const suBlueprint = _.find(this.state.suBlueprints, {id: parseInt(item.id.split('-')[0])}); ScheduleService.getTaskBlueprintsBySchedulingUnit(suBlueprint, true) .then(taskList => { - const targetObservation = _.find(taskList, (task)=> {return task.template.type_value==='observation' && task.tasktype.toLowerCase()==="blueprint" && task.specifications_doc.station_groups}); + const observationTask = _.find(taskList, (task)=> {return task.template.type_value==='observation' && task.specifications_doc.station_groups}); for (let task of taskList) { if (task.template.type_value.toLowerCase() === "observation") { task.antenna_set = task.specifications_doc.antenna_set; task.band = task.specifications_doc.filter; } } - this.setState({suTaskList: _.sortBy(taskList, "id"), isSummaryLoading: false, stationGroup: targetObservation?targetObservation.specifications_doc.station_groups:[]}) + let stations = []; + //>>>>>> TODO: Station groups from subtasks based on the status of SU + if (observationTask) { + for (const grpStations of _.map(observationTask.specifications_doc.station_groups, "stations")) { + stations = _.concat(stations, grpStations); + } + } + this.setState({suTaskList: _.sortBy(taskList, "id"), isSummaryLoading: false, + stationGroup: _.uniq(stations)}) }); // Get the scheduling constraint template of the selected SU block ScheduleService.getSchedulingConstraintTemplate(suBlueprint.suDraft.scheduling_constraints_template_id) -- GitLab