From 38cb5c914b06482bb422f81e7eb3745ef240bb1d Mon Sep 17 00:00:00 2001 From: manueltauber Date: Wed, 21 Jun 2023 14:35:22 +0200 Subject: [PATCH] Done --- .../plan-time-bar/plan-time-bar.component.ts | 79 ++++++++----------- frontend/src/ntt-gantt/ntt-gantt.component.ts | 9 ++- 2 files changed, 40 insertions(+), 48 deletions(-) diff --git a/frontend/src/app/plan-time-bar/plan-time-bar.component.ts b/frontend/src/app/plan-time-bar/plan-time-bar.component.ts index cd16563..9f7a8ef 100644 --- a/frontend/src/app/plan-time-bar/plan-time-bar.component.ts +++ b/frontend/src/app/plan-time-bar/plan-time-bar.component.ts @@ -63,53 +63,8 @@ export class PlanTimeBarComponent implements OnInit { // TaskID: '' + 0 , TaskName: "Woche " , StartDate: '28.11.2022', EndDate: '30.11.2022' , planzeit: 0, // resources: [{resourceId: 1}], Progress: 0, work: 0, isRes: false // }); - this.dataService.fetchUserSupportGroup().then((res: any)=>{ - this.userSupportGroup = res.name; - if(!this.filters){ - this.filterObj ={ - filter: { - filterElement: [{column: "SupportGroup", filter: "equals", criteria: [this.userSupportGroup]}] - } - } - }else{ - this.filterObj ={ - filter: { - filterElement: [this.filters] - } - } - } - this.dataService.fetchPlanTimes( this.filterObj, this.projectStartDate, this.projectEndDate).then((res:any[])=>{ - res.forEach((week)=>{ - this.data.push( - { - TaskID: '' + week.week , TaskName: "Woche " + week.week, StartDate: new Date(week.startDate.substring(6,11)+'-'+week.startDate.substring(3,5)+'-'+week.startDate.substring(0,2)), EndDate: new Date(week.endDate.substring(6,11)+'-'+week.endDate.substring(3,5)+'-'+week.endDate.substring(0,2)) , planzeit: week.planTime, - resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false - }); - }); - this.renderTimeGantt = true; - }); - - }); - - - // let calendarWeeks = this.getCalendarWeeks(this.projectStartDate , this.projectEndDate); - - - - // Ausgabe der Kalenderwochen - // calendarWeeks.forEach((week, index) => { - // let weekNr = this.getWeekNumber(new Date(calendarWeeks[index].start.toISOString())); - // let planzeit = this.getPlantimeFromResources(this.parentResources, weekNr); - // // console.log(`Kalenderwoche ${index + 1}: ${week.start} - ${week.end}`); - // // console.log(week); - // this.data.push( - // { - // TaskID: '' + weekNr, index , TaskName: "Woche " + weekNr, StartDate: calendarWeeks[index].start.toISOString(), EndDate: calendarWeeks[index].end.toISOString() , planzeit: planzeit.toFixed(0), - // resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false - // }); - // }); - + this.fetchPlanTimes(); this.timelineSettings = { bottomTier: { format: 'WW', @@ -141,6 +96,38 @@ export class PlanTimeBarComponent implements OnInit { ] } + public fetchPlanTimes(filter:any = null){ + this.renderTimeGantt = false; + this.data = []; + this.dataService.fetchUserSupportGroup().then((res: any)=>{ + this.userSupportGroup = res.name; + if(!this.filters || !filter){ + this.filterObj ={ + filter: { + filterElement: [{column: "SupportGroup", filter: "equals", criteria: [this.userSupportGroup]}] + } + } + }else{ + this.filterObj ={ + filter: { + filterElement: [filter] + } + } + } + console.log(this.filterObj); + this.dataService.fetchPlanTimes( this.filterObj, this.projectStartDate, this.projectEndDate).then((res:any[])=>{ + res.forEach((week)=>{ + this.data.push( + { + TaskID: '' + week.week , TaskName: "Woche " + week.week, StartDate: new Date(week.startDate.substring(6,11)+'-'+week.startDate.substring(3,5)+'-'+week.startDate.substring(0,2)), EndDate: new Date(week.endDate.substring(6,11)+'-'+week.endDate.substring(3,5)+'-'+week.endDate.substring(0,2)) , planzeit: week.planTime, + resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false + }); + }); + this.renderTimeGantt = true; + }); + + }); + } getPlantimeFromResources(resources: any[], week: string){ let planzeit = 0; for (const res of resources) { diff --git a/frontend/src/ntt-gantt/ntt-gantt.component.ts b/frontend/src/ntt-gantt/ntt-gantt.component.ts index abe1720..1c5d02c 100644 --- a/frontend/src/ntt-gantt/ntt-gantt.component.ts +++ b/frontend/src/ntt-gantt/ntt-gantt.component.ts @@ -1,3 +1,4 @@ +import { PlanTimeBarComponent } from './../app/plan-time-bar/plan-time-bar.component'; import { FilterDialogComponent } from './../app/filter-dialog/filter-dialog.component'; import { filteredData, editingData } from './../data'; import { ImplementerDialogComponent } from './../app/implementer-dialog/implementer-dialog.component'; @@ -36,6 +37,8 @@ export const MY_DATE_FORMATS = { export class NttGanttComponent implements OnInit { @ViewChild('ganttObject') public ganttDefault!: GanttComponent; + @ViewChild('plantimeComponent') + public plantimeComponent!: PlanTimeBarComponent; @ViewChild(MatPaginator) paginator: MatPaginator; @@ -463,8 +466,8 @@ public logg(args){ return resource.resourceId == args.data.taskData.resources[0].resourceId; }); this.dataService.updateDatePerChange(found); - this.renderplanTime = false; - this.refreshData(); + //this.renderplanTime = false; + this.plantimeComponent.fetchPlanTimes(); } } @@ -1070,9 +1073,11 @@ private oldFilters:{}; this.oldFilters = this.filters this.filters = null; this.refreshData(); + this.plantimeComponent.fetchPlanTimes(this.filters); }else{ this.filters = this.oldFilters; this.refreshData(); + this.plantimeComponent.fetchPlanTimes(this.filters); } }