From c1d1bd1e72e30554471dd34d43582c876bfece79 Mon Sep 17 00:00:00 2001 From: Manuel Tauber Date: Wed, 27 Mar 2024 15:23:17 +0100 Subject: [PATCH] Done --- .../nttdata/calender/api/RemedyJavaAPI.java | 4 +- frontend/src/app/data.service.ts | 8 +- .../src/app/ntt-gantt/ntt-gantt.component.ts | 309 +++++++++--------- 3 files changed, 165 insertions(+), 156 deletions(-) diff --git a/backend/src/main/java/com/nttdata/calender/api/RemedyJavaAPI.java b/backend/src/main/java/com/nttdata/calender/api/RemedyJavaAPI.java index f3deef0..f471a76 100644 --- a/backend/src/main/java/com/nttdata/calender/api/RemedyJavaAPI.java +++ b/backend/src/main/java/com/nttdata/calender/api/RemedyJavaAPI.java @@ -41,10 +41,12 @@ public class RemedyJavaAPI { */ public RemedyJavaAPI() throws ARException, NotFoundError { server = new ARServerUser(); - server.setServer("itsm-app-dev-neu.asfinag.at"); + // server.setServer("itsm-app-dev.asfinag.at"); + server.setServer("itsm-app-test-neu.asfinag.at"); server.setUser("changecalender_integration"); server.setPassword("VXrvLm4q#8P#MXthfZNc"); server.setPort(46262); + // server.setPort(50000); this.connect(); // TODO: move to APIApplication.java or State.java - see where it fits diff --git a/frontend/src/app/data.service.ts b/frontend/src/app/data.service.ts index 7feb6bd..cc8af7e 100644 --- a/frontend/src/app/data.service.ts +++ b/frontend/src/app/data.service.ts @@ -616,7 +616,7 @@ export class DataService { console.log(dataJson); this.http.post('http://localhost:8080/api/getChanges', dataJson) .subscribe((response:any)=>{ - console.log(response); + console.log("ALL CHANGES ##############\n",response); this.totalSize = response.totalSize; response.changes.forEach(resp=>{ //console.log(resp.resourceId+" "+resp.approvalStatus) @@ -663,6 +663,12 @@ export class DataService { } //let approval = this.validateApproval(resp.approvalStatus); res.push({ + // flagApproval: resp.flagApproval, + // flagCancel: resp.flagCancel, + // flagPermit: resp.flagPermit, + // flagReject: resp.flagReject, + + approval: resp.approval, resourceId: resp.resourceId, approvalStatus: resp.approvalStatus, statusReason: resp.statusReason, diff --git a/frontend/src/app/ntt-gantt/ntt-gantt.component.ts b/frontend/src/app/ntt-gantt/ntt-gantt.component.ts index f05fca7..0f522cd 100644 --- a/frontend/src/app/ntt-gantt/ntt-gantt.component.ts +++ b/frontend/src/app/ntt-gantt/ntt-gantt.component.ts @@ -282,7 +282,7 @@ export class NttGanttComponent implements OnInit { this.editSettings = {allowAdding: true, allowEditing: true, allowDeleting: true, allowTaskbarEditing: true, showDeleteConfirmDialog: true}; this.filterSettings = {ignoreAccent: true}; this.selectionSettings = {mode: 'Row',type: 'Multiple'}; - this.toolbar = ['Cancel']; + this.toolbar = ['']; this.labelSettings = {rightLabel: 'resources',taskLabel: 'TaskName'}; this.tooltipSettings = {showTooltip: true} this.projectStartDate = this.range.controls.start.value; @@ -1149,6 +1149,53 @@ export class NttGanttComponent implements OnInit { } } + + public isStateTransitionPossible(change: any): boolean{ + let states = this.dataService.getStates(); + let state = change.state; + // console.log(change.taskData.state); + for (const state of states) { + if(change.taskData.state == state.actualState){ + // console.log(state.possibleStates); + if(state.possibleStates[0]){ + return true; + }else{ + return false + } + + } + } + return false; + } + + public evaluateCancelFlag(change: any): boolean{ + for (const state of this.dataService.getStates()) { + if(change.taskData.state == state.actualState){ + return state.cancelFlag; + } + } + return false; + } + + + public evaluateImplementerFlag(change: any): boolean{ + for (const state of this.dataService.getStates()) { + if(change.taskData.state == state.actualState){ + return state.implementerFlag; + } + } + return false; + } + + public evaluateRestartFlag(change: any): boolean{ + for (const state of this.dataService.getStates()) { + if(change.taskData.state == state.actualState){ + return state.restartFlag; + } + } + return false; + } + /** * The function rowSelected catches the corresponding syncfsuions event and checks if all selected resources (changes) have the same status, then it displays the corresponding buttons * @param args event arguments from the syncfusion gantt chart @@ -1167,89 +1214,7 @@ export class NttGanttComponent implements OnInit { }else{ this.selRecs = this.selectedrecords; } - let allStates: boolean = true; - let allPermit: boolean = true; - let allApprove: boolean = true; - let allReject: boolean = true; - let allCancel: boolean = true; - let allImplementer: boolean = true; - let allTransition: boolean = true; - this.selectedRescourceIds = []; - for (const change of this.selRecs) { - if(change.taskData.approvalStatus == 1){ - this.approvalPending = true; - } - if(change.taskData.state == this.selRecs[0].taskData.state){ - if(allStates){ - allStates = true; - } - else{ - allStates = false; - } - this.selectedRescourceIds.push(change.taskData.resourceId); - }else{ - allStates = false; - } - if(change.taskData.flagPermit == true && allPermit == true){ - allPermit = true; - }else{ - allPermit = false; - } - if(change.taskData.flagApproval == true && allApprove == true){ - allApprove = true; - }else{ - allApprove = false; - } - if(change.taskData.flagReject == true && allReject == true){ - allReject = true; - }else{ - allReject = false; - } - if(change.taskData.flagCancel == true && allCancel == true){ - allCancel = true; - }else{ - allCancel = false; - } - if(change.taskData.implementerEdit == true && allImplementer == true){ - allImplementer = true; - }else{ - allImplementer = false; - } - if(change.taskData.state > 0 && allTransition == true){ - allTransition = true; - }else{ - allTransition = false; - } - } - - if(allStates){ - this.toolbar = []; - if(allTransition && !this.approvalPending){ - this.toolbar.push({text:this.languageService.lMap.get("stateChange"), id: "6"}); - } - if(allPermit){ - this.toolbar.push({text: this.languageService.lMap.get("permit"), id: "5"}); - } - if(allApprove){ - this.toolbar.push({text: this.languageService.lMap.get("genehmigen"), id: "7"}); - } - if(allReject){ - this.toolbar.push({text: this.languageService.lMap.get("ablehnen"), id: "8"}); - } - if(allCancel){ - this.toolbar.push({text: this.languageService.lMap.get("stornieren"), id: "11"}); - } - if(allImplementer){ - this.toolbar.push({text: this.languageService.lMap.get("implementer"), id: "10"}); - } - - }else{ - this.toolbar = []; - } - this.approvalPending = false; - this.selRecs = []; - this.selectedrecords = []; - this.selectedrowindex = []; + this.evaluateBulkOperationButtons(); } /** @@ -1274,84 +1239,120 @@ export class NttGanttComponent implements OnInit { }else{ this.selRecs = this.selectedrecords; } - let allStates: boolean = true; - let allPermit: boolean = true; - let allApprove: boolean = true; - let allReject: boolean = true; - let allCancel: boolean = true; - let allImplementer: boolean = true; - let allTransition: boolean = true; - this.selectedRescourceIds = []; - for (const change of this.selRecs) { - if(change.taskData.state == this.selRecs[0].taskData.state){ - if(change.taskData.approvalStatus == 1){ - this.approvalPending = true; - } - if(allStates){ - allStates = true; - } - this.selectedRescourceIds.push(change.taskData.resourceId); - }else{ - allStates = false; - } - if(change.taskData.flagPermit == true && allPermit == true){ - allPermit = true; + // console.log(this.selRecs[0]); + if(!this.selRecs[0]){ + this.toolbar = ['']; }else{ - allPermit = false; - } - if(change.taskData.flagApproval == true && allApprove == true){ - allApprove = true; - }else{ - allApprove = false; - } - if(change.taskData.flagReject == true && allReject == true){ - allReject = true; - }else{ - allReject = false; - } - if(change.taskData.flagCancel == true && allCancel == true){ - allCancel = true; - }else{ - allCancel = false; - } - if(change.taskData.implementerEdit == true && allImplementer == true){ - allImplementer = true; - }else{ - allImplementer = false; - } - if(change.taskData.state > 0 && allTransition == true){ - allTransition = true; - }else{ - allTransition = false; + this.evaluateBulkOperationButtons(); } + } + + public evaluateBulkOperationButtons(){ + let allStates: boolean = true; + let allPermit: boolean = true; + let allApprove: boolean = true; + let allReject: boolean = true; + let allCancel: boolean = true; + let allImplementer: boolean = true; + let allTransition: boolean = true; + this.selectedRescourceIds = []; + for (const change of this.selRecs) { + // console.log("Status: ",change.taskData.state); + // console.log("APPROVAL Genehmigen/Ablehnen: ",change.taskData.approval); + // console.log("Stornieren",this.evaluateCancelFlag(change)); + // console.log("Statusübergang",this.isStateTransitionPossible(change)); + // console.log("Implementer",this.evaluateImplementerFlag(change)); + // console.log("Restart",this.evaluateRestartFlag(change)); + + if(change.taskData.approvalStatus == 1){ + this.approvalPending = true; } - if(allStates){ - this.toolbar = []; - if(allTransition&&!this.approvalPending){ - this.toolbar.push({text:this.languageService.lMap.get("stateChange"), id: "6"}); + if(change.taskData.state == this.selRecs[0].taskData.state){ + if(allStates){ + allStates = true; } - if(allPermit){ - this.toolbar.push({text: this.languageService.lMap.get("permit"), id: "5"}); + else{ + allStates = false; } - if(allApprove){ - this.toolbar.push({text: this.languageService.lMap.get("genehmigen"), id: "7"}); - } - if(allReject){ - this.toolbar.push({text: this.languageService.lMap.get("ablehnen"), id: "8"}); - } - if(allCancel){ - this.toolbar.push({text: this.languageService.lMap.get("stornieren"), id: "11"}); - } - if(allImplementer){ - this.toolbar.push({text: this.languageService.lMap.get("implementer"), id: "10"}); + this.selectedRescourceIds.push(change.taskData.resourceId); + }else{ + allStates = false; } + if(change.taskData.approval == true && allPermit == true){ + allPermit = true; }else{ - this.toolbar = []; + allPermit = false; } - this.selRecs = []; - this.selectedrecords = []; - this.selectedrowindex = []; - this.approvalPending = false; + if(change.taskData.approval == true && allApprove == true){ + allApprove = true; + }else{ + allApprove = false; + } + if(change.taskData.approval == true && allReject == true){ + allReject = true; + }else{ + allReject = false; + } + if(this.evaluateCancelFlag(change) == true && allCancel == true){ + allCancel = true; + }else{ + allCancel = false; + } + if(this.evaluateImplementerFlag(change) == true && allImplementer == true){ + allImplementer = true; + }else{ + allImplementer = false; + } + if(this.isStateTransitionPossible(change) && allTransition == true){ + allTransition = true; + }else{ + allTransition = false; + } + } + + if(allStates){ + this.toolbar = ['']; + if(allTransition && !this.approvalPending){ + this.toolbar.push({text:this.languageService.lMap.get("stateChange"), id: "6"}); + } + if(allPermit){ + this.toolbar.push({text: this.languageService.lMap.get("permit"), id: "5"}); + } + if(allApprove){ + this.toolbar.push({text: this.languageService.lMap.get("genehmigen"), id: "7"}); + } + if(allReject){ + this.toolbar.push({text: this.languageService.lMap.get("ablehnen"), id: "8"}); + } + if(allCancel){ + this.toolbar.push({text: this.languageService.lMap.get("stornieren"), id: "11"}); + } + if(allImplementer){ + this.toolbar.push({text: this.languageService.lMap.get("implementer"), id: "10"}); + } + + // console.log(this.toolbar) + // if(this.toolbar[1]){ + // delete this.toolbar[0]; + // } + // let tmp = []; + // for (const button of this.toolbar) { + // if(button.text){ + // tmp.push(button); + // } + // } + // this.toolbar = tmp; + // tmp = []; + + }else{ + this.toolbar = ['']; + } + this.approvalPending = false; + this.selRecs = []; + this.selectedrecords = []; + this.selectedrowindex = []; } } + +