diff --git a/frontend/src/app/data.service.ts b/frontend/src/app/data.service.ts index 2802fd2..ea4e254 100644 --- a/frontend/src/app/data.service.ts +++ b/frontend/src/app/data.service.ts @@ -175,10 +175,9 @@ export class DataService { this.http.post('http://localhost:8080/api/updateState', dataJson).subscribe((response:any)=>{ resolve(response); },(error:any)=>{ - console.log(error); resolve(error); }); - }) + }); return promise; } @@ -230,9 +229,10 @@ export class DataService { this.http.post('http://localhost:8080/api/updateApproval', dataJson).subscribe((response:any)=>{ resolve(response); },(error:any)=>{ - console.log(error); resolve(error); }); + }).catch((error)=>{ + throw(error); }) return promise; diff --git a/frontend/src/app/state-dialog/state-dialog.component.ts b/frontend/src/app/state-dialog/state-dialog.component.ts index 6e696de..370cb96 100644 --- a/frontend/src/app/state-dialog/state-dialog.component.ts +++ b/frontend/src/app/state-dialog/state-dialog.component.ts @@ -105,7 +105,6 @@ export class StateDialogComponent implements OnInit { this.dataService.updateStatePerChange(modifiedChange).then((res: any)=>{ this.diasbled = true; this.bdiasbled = true; - console.log(res); if(res.status == 200){ counter++; this.progress = (counter/this.data.changes.length)*100; @@ -114,13 +113,13 @@ export class StateDialogComponent implements OnInit { let msg; let action; if(this.dataService.selectedLanguage == 'DE'){ - msg = 'Statusübergang fehlgeschlagen'; - action ='Schließen'; + msg = 'Statusübergang fehlgeschlagen:'; + action = 'Schließen'; }else{ msg = 'State Transition failed'; action ='close'; } - this._snackBar.open(msg, action, { + this._snackBar.open(msg + res.error.message, action, { horizontalPosition: this.horizontalPosition, verticalPosition: this.verticalPosition, panelClass: ['mat-primary'] diff --git a/frontend/src/ntt-gantt/ntt-gantt.component.ts b/frontend/src/ntt-gantt/ntt-gantt.component.ts index 603e819..538f980 100644 --- a/frontend/src/ntt-gantt/ntt-gantt.component.ts +++ b/frontend/src/ntt-gantt/ntt-gantt.component.ts @@ -75,6 +75,8 @@ export class NttGanttComponent implements OnInit { public showNoResultsError: boolean = false; public languages: string[] = ['DE', 'EN']; public language: string = 'DE'; + public horizontalPosition: MatSnackBarHorizontalPosition = 'end'; + public verticalPosition: MatSnackBarVerticalPosition = 'bottom'; public deMap : Map = new Map() public enMap : Map = new Map() @@ -853,23 +855,75 @@ public logg(args){ } if(args.item.text === "Genehmigen" || args.item.text === "Approve"){ + for (const selectedRescourceId of this.selectedRescourceIds) { for (const change of this.resources) { if(change.resourceId == selectedRescourceId){ - this.dataService.updateApproval(change, 1); + this.dataService.updateApproval(change, 1).then((res: any)=>{ + if(res.status == 200){ + this._snackBar.open("Genehmigung erfolgreich", 'Schließen', { + horizontalPosition: this.horizontalPosition, + verticalPosition: this.verticalPosition, + panelClass: ['mat-primary'] + }); + }else{ + this._snackBar.open(res.HttpErrorResponse.message, 'Schließen', { + horizontalPosition: this.horizontalPosition, + verticalPosition: this.verticalPosition, + panelClass: ['mat-primary'] + }); + } + this.refreshData(); + }); } } } //this.ganttDefault.refresh(); } + if(args.item.text === "Zur Genehmigung" || args.item.text === "Permit"){ + let data = {changes: [], states: this.states}; + for (const selectedRescourceId of this.selectedRescourceIds) { + for (const iterator of this.resources) { + if(iterator.resourceId == selectedRescourceId){ + data.changes.push({resourceId: iterator.resourceId, changeNr: iterator.changeNr, currentState: iterator.state}); + } + } + } + let dialogRef = StateDialogComponent; + this.matDialog.open(dialogRef, + { + data : data, + }).afterClosed().subscribe((res)=>{ + if(res.status == 200){ + this.refreshData(); + } + + }); + } - if(args.item.text === "ablehnen" || args.item.text === "Reject"){ + + if(args.item.text === "Ablehnen" || args.item.text === "Reject"){ for (const selectedRescourceId of this.selectedRescourceIds) { for (const change of this.resources) { if(change.resourceId == selectedRescourceId){ - this.dataService.updateApproval(change, 2); + this.dataService.updateApproval(change, 2).then((res: any)=>{ + if(res.status == 200){ + this._snackBar.open("Ablehnen erfolgreich", 'Schließen', { + horizontalPosition: this.horizontalPosition, + verticalPosition: this.verticalPosition, + panelClass: ['mat-primary'] + }); + }else{ + this._snackBar.open(res.HttpErrorResponse.message, 'Schließen', { + horizontalPosition: this.horizontalPosition, + verticalPosition: this.verticalPosition, + panelClass: ['mat-primary'] + }); + } + this.refreshData(); + }); } } } @@ -880,7 +934,22 @@ public logg(args){ for (const selectedRescourceId of this.selectedRescourceIds) { for (const change of this.resources) { if(change.resourceId == selectedRescourceId){ - this.dataService.updateApproval(change, 3); + this.dataService.updateApproval(change, 3).then((res: any)=>{ + if(res.status == 200){ + this._snackBar.open("Stornieren erfolgreich", 'Schließen', { + horizontalPosition: this.horizontalPosition, + verticalPosition: this.verticalPosition, + panelClass: ['mat-primary'] + }); + }else{ + this._snackBar.open(res.HttpErrorResponse.message, 'Schließen', { + horizontalPosition: this.horizontalPosition, + verticalPosition: this.verticalPosition, + panelClass: ['mat-primary'] + }); + } + this.refreshData(); + }); } } }