From 7deb69fd3dd310526649540f71d8f5e7bf57c319 Mon Sep 17 00:00:00 2001 From: manueltauber Date: Thu, 1 Jun 2023 14:57:58 +0200 Subject: [PATCH] initialSupportGroupFilter/Done --- frontend/src/app/data.service.ts | 21 ++++++++++++++++++ .../filter-dialog.component.html | 2 +- .../filter-dialog/filter-dialog.component.ts | 9 ++++++++ frontend/src/ntt-gantt/ntt-gantt.component.ts | 22 ++++++++++++------- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/data.service.ts b/frontend/src/app/data.service.ts index 1c52c3c..4a3d960 100644 --- a/frontend/src/app/data.service.ts +++ b/frontend/src/app/data.service.ts @@ -19,6 +19,7 @@ export class DataService { private contracts: any []; private paketTypes: any []; private totalSize: number = null; + public userSupportGroup: string; public selectedLanguage: string = 'DE'; /** * This constructor builds the dataService and fetches the states from the backend @@ -38,6 +39,10 @@ export class DataService { this.paketTypes = res; // console.log(res); }); + this.fetchUserSupportGroup().then((res: any)=>{ + this.userSupportGroup = res.name; + console.log(this.userSupportGroup); + }); } /** @@ -64,6 +69,9 @@ export class DataService { return this.totalSize; } + public getUserSupportGroup():string{ + return this.userSupportGroup; + } /** * The function fetchStates fetches an array from the possible statuses per state * @returns promise for the fetched Status Array @@ -124,6 +132,19 @@ export class DataService { return promise; } + public async fetchUserSupportGroup(){ + const promise = new Promise(resolve=>{ + let res : any = {}; + this.http.get('http://localhost:8080/api/getUserSupportGroup') + .subscribe((response: any)=>{ + this.userSupportGroup = res.name; + res = response; + resolve(res); + }) + }) + return promise; + } + /** * The function updateDatePerChange sends the new date to the backend if the date was moved * @param change the Change (the Resource) from which the date should be changed diff --git a/frontend/src/app/filter-dialog/filter-dialog.component.html b/frontend/src/app/filter-dialog/filter-dialog.component.html index 4aa5eb6..40a8427 100644 --- a/frontend/src/app/filter-dialog/filter-dialog.component.html +++ b/frontend/src/app/filter-dialog/filter-dialog.component.html @@ -6,7 +6,7 @@

{{filterLabels[1]}}

diff --git a/frontend/src/app/filter-dialog/filter-dialog.component.ts b/frontend/src/app/filter-dialog/filter-dialog.component.ts index 705c18f..e2333af 100644 --- a/frontend/src/app/filter-dialog/filter-dialog.component.ts +++ b/frontend/src/app/filter-dialog/filter-dialog.component.ts @@ -41,6 +41,7 @@ export class FilterDialogComponent implements OnInit { public paketTypes: string[] = []; public states: string[] = []; public contracts: string[] = []; + public userSupportGroup: string; public criteria: string; public filterStartDate: Date; @@ -95,6 +96,8 @@ export class FilterDialogComponent implements OnInit { } ngOnInit(): void { + this.userSupportGroup = this.dataService.getUserSupportGroup(); + console.log(this.userSupportGroup); if(this.dataService.selectedLanguage == 'DE'){ for (const state of this.dataService.getStates()) { this.states.push(state.stateNameDE); @@ -210,6 +213,12 @@ export class FilterDialogComponent implements OnInit {       "filter": "equals",       "criteria": this.supportGroupsFilter }); + }else{ + filter.push({ + "column": "SupportGroup", +       "filter": "equals", +       "criteria": [this.dataService.userSupportGroup] + }); } diff --git a/frontend/src/ntt-gantt/ntt-gantt.component.ts b/frontend/src/ntt-gantt/ntt-gantt.component.ts index 2c15d85..26a8aee 100644 --- a/frontend/src/ntt-gantt/ntt-gantt.component.ts +++ b/frontend/src/ntt-gantt/ntt-gantt.component.ts @@ -47,6 +47,7 @@ export class NttGanttComponent implements OnInit { public data: any[] = []; public allResources: any[] = []; public resources: any[] = []; + public userSupportGroup: string; public taskSettings: object = {}; public labelSettings: object = {}; public projectStartDate: Date = new Date('12/01/2022'); @@ -257,16 +258,21 @@ public logg(args){ // }); // this.renderGantt = true; // }); - this.refreshData(); - this.states = this.dataService.getStates(); - this.dataService.fetchStates().then((res: any [])=>{ - this.states = res; - this.stateList = res; - this.spin = false; - console.log(this.states); + this.dataService.fetchUserSupportGroup().then((res: any)=>{ + console.log(res); + this.userSupportGroup = res.name; + this.refreshData(); + this.states = this.dataService.getStates(); + this.dataService.fetchStates().then((res: any [])=>{ + this.states = res; + this.stateList = res; + this.spin = false; + console.log(this.states); + }); }); + this.filterSettings = { ignoreAccent: true // columns: [ @@ -923,7 +929,7 @@ public logg(args){ { 'sliceStart': this.sliceStart, 'sliceEnd': this.sliceEnd, - filter: this.filterEnabled ? this.filters : null, + filter: this.filterEnabled ? this.filters : [{column: "SupportGroup", filter: "equals", criteria: [this.userSupportGroup]}], sort: this.sortEnabled ? this.sort : { 'column': 'ChangeNr',         'mode': 'asc'