From 2af23eef706a3342028d6777555dea08743f2edf Mon Sep 17 00:00:00 2001 From: Muthukrishnanmatriot <76949556+muthukrishnanmatriot@users.noreply.github.com> Date: Wed, 14 Apr 2021 14:59:33 +0530 Subject: [PATCH] Update code to show SU status after update/create --- .../src/components/Spreadsheet/Beamformer.js | 2 +- .../Scheduling/excelview.schedulingset.js | 51 +++++++++++++++++-- .../src/services/schedule.service.js | 38 +++++++++----- .../tmss_webapp/src/utils/ui.constants.js | 2 +- 4 files changed, 75 insertions(+), 18 deletions(-) diff --git a/SAS/TMSS/frontend/tmss_webapp/src/components/Spreadsheet/Beamformer.js b/SAS/TMSS/frontend/tmss_webapp/src/components/Spreadsheet/Beamformer.js index 7c69700a81f..d84d827a07a 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/components/Spreadsheet/Beamformer.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/components/Spreadsheet/Beamformer.js @@ -65,7 +65,7 @@ export default class Beamformer extends Component { schema['$id'] = taskTemplate.schema['$id']; schema['$schema'] = taskTemplate.schema['$schema']; let index = 0; - let param = _.find(observStrategy.template.parameters, {name: 'Beamformers'}); + let param = _.find(observStrategy.template.parameters, function(o) { return o.name === 'Beamformers' || o.name === 'beamformers' ;}); if(param) { if (param.refs[0].indexOf(`/tasks/${taskName}`) > 0) { // Resolve the identified template 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 36e42b32e7e..6c56adc33b8 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 @@ -5,6 +5,8 @@ import { Button } from 'primereact/button'; import { Growl } from 'primereact/components/growl/Growl'; import { Checkbox } from 'primereact/checkbox'; import { Accordion, AccordionTab } from 'primereact/accordion'; +import { DataTable } from 'primereact/datatable'; +import { Column } from 'primereact/column'; import TimeInputmask from '../../components/Spreadsheet/TimeInputmask' import DegreeInputmask from '../../components/Spreadsheet/DegreeInputmask' @@ -142,6 +144,7 @@ export class SchedulingSetCreate extends Component { this.onCancel =this.close; this.applyToEmptyRowOnly = false; + this.dialogWidth = "40vw"; this.dialogType = "confirmation"; this.dialogHeight = 'auto'; this.dialogHeader = ""; @@ -183,6 +186,7 @@ export class SchedulingSetCreate extends Component { this.resetCommonData = this.resetCommonData.bind(this); this.reload = this.reload.bind(this); this.applyChanges = this.applyChanges.bind(this); + this.getSchedulingDialogContent = this.getSchedulingDialogContent.bind(this); //this.setCurrentSUSet = this.setCurrentSUSet.bind(this); this.formRules = { // Form validation rules @@ -1680,6 +1684,7 @@ export class SchedulingSetCreate extends Component { }); let newSU = this.state.schedulingUnit; + let suStatus = []; for(const suRow of this.state.rowData){ if (!suRow['isValid']){ continue; @@ -1730,7 +1735,7 @@ export class SchedulingSetCreate extends Component { newConstraint['constraint'] = {'url':''}; newConstraint.constraint.url = this.state.constraintUrl; } - + let suUpdateStatus = {}; if (suRow.id > 0 && this.isNotEmpty(suRow.suname) && this.isNotEmpty(suRow.sudesc)){ newSU = _.find(this.state.schedulingUnitList, {'id': suRow.id}); newSU['name'] = suRow.suname; @@ -1740,10 +1745,17 @@ export class SchedulingSetCreate extends Component { if(taskdata){ taskDrafts = taskdata.data.results; } + suUpdateStatus['suName'] = suRow.suname; + suUpdateStatus['action'] = 'Update'; let updateSu = await ScheduleService.updateSUDraftFromObservStrategy(observStrategy, newSU, taskDrafts, this.state.tasksToUpdate, tmpStationGroups); + suUpdateStatus['suStatus']= "Sucessess"; + suUpdateStatus['taskName']= updateSu.taskName; if (updateSu && !updateSu.isSUUpdated) { isUpdated = false; - } + suUpdateStatus['taskStatus']= "Faild"; + } else { + suUpdateStatus['taskStatus']= "Sucessess"; + } existingSUCount++; } else if (suRow.id === 0 && this.isNotEmpty(suRow.suname) && this.isNotEmpty(suRow.sudesc)){ @@ -1753,15 +1765,24 @@ export class SchedulingSetCreate extends Component { scheduling_constraints_template_id: newSU['scheduling_constraints_template_id'], scheduling_set_id: newSU['scheduling_set_id'] } + suUpdateStatus['suName'] = suRow.suname; + suUpdateStatus['action'] = 'Create'; let updateSu = await ScheduleService.saveSUDraftFromObservStrategy(observStrategy, newSchedulueUnit, newConstraint, tmpStationGroups); + suUpdateStatus['suStatus']= "Sucessess"; + suUpdateStatus['taskName']= updateSu.taskName; if (updateSu && !updateSu.isSUUpdated) { isUpdated = false; + suUpdateStatus['taskStatus']= "Faild"; + } else { + suUpdateStatus['taskStatus']= "Sucessess"; } newSUCount++; } + suStatus.push(suUpdateStatus); } if ((newSUCount+existingSUCount) > 0){ + this.setState({suStatus:suStatus}); this.dialogType = "success"; this.dialogHeader = "Success"; this.showIcon = true; @@ -1769,10 +1790,11 @@ export class SchedulingSetCreate extends Component { this.dialogMsg = '['+newSUCount+'] Scheduling Units are created & ['+existingSUCount+'] Scheduling Units are updated successfully.'; } else { this.dialogHeader = "Warning"; + this.dialogWidth = "60vw"; this.dialogMsg = '['+newSUCount+'] Scheduling Units are created & ['+existingSUCount+'] Scheduling Units are updated successfully, and there are some Schedule Unit/Task failed to create/update'; } - this.dialogContent = ""; + this.dialogContent = this.getSchedulingDialogContent; this.onCancel = this.reset; this.onClose = this.reset; this.callBackFunction = this.reset; @@ -1787,6 +1809,27 @@ export class SchedulingSetCreate extends Component { } } + /** + * Prepare Scheduling Unit(s) details to show on confirmation dialog + */ + getSchedulingDialogContent() { + let suStatus = this.state.suStatus; + return <> + {suStatus.length > 0 && + <div style={{marginTop: '1em'}}> + <b>Scheduling Unit(s) & Task status</b> + <DataTable value={suStatus} resizableColumns columnResizeMode="expand" className="card" style={{paddingLeft: '0em'}}> + <Column field="suName" header="Scheduling Unit Name"></Column> + <Column field="action" header="Save Action"></Column> + <Column field="suStatus" header="SU Status"></Column> + <Column field="taskName" header="Task"></Column> + <Column field="taskStatus" header="Task Status"></Column> + </DataTable> + </div> + } + </> + } + /** * Convert the date to string value for Between And Not-Between Columns * @param {*} dates @@ -2433,7 +2476,7 @@ export class SchedulingSetCreate extends Component { </div> </> } - <CustomDialog type={this.dialogType} visible={this.state.confirmDialogVisible} width="40vw" height={this.dialogHeight} + <CustomDialog type={this.dialogType} visible={this.state.confirmDialogVisible} width={this.dialogWidth} height={this.dialogHeight} header={this.dialogHeader} message={this.dialogMsg} content={this.dialogContent} onClose={this.onClose} onCancel={this.onCancel} onSubmit={this.callBackFunction} showIcon={this.showIcon} actions={this.actions}> diff --git a/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js b/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js index 77768bfdb81..41facd82e02 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/services/schedule.service.js @@ -475,10 +475,12 @@ const ScheduleService = { schedulingUnit = await this.createSUTaskDrafts(schedulingUnit); if (schedulingUnit && schedulingUnit.task_drafts.length > 0) { schedulingUnit['isSUUpdated'] = true; + schedulingUnit['taskName'] = '(Tasks)'; return schedulingUnit; } } return { + taskName: '(Tasks)', error: true, message: 'Unable to Create Task Drafts' }; @@ -492,6 +494,7 @@ const ScheduleService = { }, updateSUDraftFromObservStrategy: async function(observStrategy,schedulingUnit,tasks,tasksToUpdate,station_groups) { + let taskName = ''; try { delete schedulingUnit['duration']; schedulingUnit['isSUUpdated'] = false; @@ -500,26 +503,37 @@ const ScheduleService = { schedulingUnit['isSUUpdated'] = true; for (const taskToUpdate in tasksToUpdate) { let task = tasks.find(task => { return task.name === taskToUpdate}); - task.specifications_doc = observStrategy.template.tasks[taskToUpdate].specifications_doc; - if (task.specifications_doc.station_groups) { - task.specifications_doc.station_groups = station_groups; - } - delete task['duration']; - delete task['relative_start_time']; - delete task['relative_stop_time']; - task = await TaskService.updateTask('draft', task); - if (task.error) { - schedulingUnit = task; + taskName = taskToUpdate; + if(task) { + task.specifications_doc = observStrategy.template.tasks[taskToUpdate].specifications_doc; + if (task.specifications_doc.station_groups) { + task.specifications_doc.station_groups = station_groups; + } + delete task['duration']; + delete task['relative_start_time']; + delete task['relative_stop_time']; + task = await TaskService.updateTask('draft', task); + if (task.error) { + schedulingUnit = task; + } + } else { + return { + taskName: taskName, + error: true, + message: 'Unable to Update Task Drafts' + } } } - + } else { + schedulingUnit['isSUUpdated'] = false; } - schedulingUnit['isSUUpdated'] = true; + schedulingUnit['taskName'] = taskName; return schedulingUnit; } catch(error) { console.error(error); schedulingUnit['isSUUpdated'] = false; return { + taskName: taskName, error: true, message: 'Unable to Update Task Drafts' } diff --git a/SAS/TMSS/frontend/tmss_webapp/src/utils/ui.constants.js b/SAS/TMSS/frontend/tmss_webapp/src/utils/ui.constants.js index b2cdb715626..408cdb52ae2 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/utils/ui.constants.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/utils/ui.constants.js @@ -9,7 +9,7 @@ const UIConstants = { 403: {severity: 'error', summary: 'Error', sticky: true, detail: 'Unknown request, please contact system admin'}, 404: {severity: 'error', summary: 'Error', sticky: true, detail: 'URL is not recognized, please contact system admin'}, 408: {severity: 'error', summary: 'Error', sticky: true, detail: 'Request is taking more time to response, please contact system admin'}, - 500: {severity: 'error', summary: 'Error', sticky: true, detail: 'Internal Server Error, URL may not exists, please contact system admin'}, + 500: {severity: 'error', summary: 'Error', sticky: true, detail: 'Internal Server Error, please contact system admin'}, 503: {severity: 'error', summary: 'Error', sticky: true, detail: 'Server not available, please check system admin'}, }, CALENDAR_DATE_FORMAT: 'yy-mm-dd', -- GitLab