From 262eab4e6843ca2db5906e1819403035afd837db Mon Sep 17 00:00:00 2001 From: manueltauber Date: Tue, 13 Jun 2023 17:07:39 +0200 Subject: [PATCH] SummenPlanzeit/inProgress --- frontend/src/app/data.service.ts | 19 ++++++++++++++- .../plan-time-bar/plan-time-bar.component.ts | 23 +++++++++++++++---- .../src/ntt-gantt/ntt-gantt.component.html | 1 + frontend/src/ntt-gantt/ntt-gantt.component.ts | 1 + 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/data.service.ts b/frontend/src/app/data.service.ts index 7b06e8b..26a05df 100644 --- a/frontend/src/app/data.service.ts +++ b/frontend/src/app/data.service.ts @@ -321,7 +321,9 @@ export class DataService { flagPermit: this.validatePermit(resp.state), changeImplementerLogin: resp.changeImplementerLogin, packageName: resp.packageName, - coordinatorSg: resp.coordinatorSg + coordinatorSg: resp.coordinatorSg, + planTime: 1, + calenderWeek: this.getWeekNumber(new Date(resp.d2)) }); @@ -333,6 +335,21 @@ export class DataService { return promise; } + getWeekNumber(d) { + // Copy date so don't modify original + d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate())); + // Set to nearest Thursday: current date + 4 - current day number + // Make Sunday's day number 7 + d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay()||7)); + // Get first day of year + let yearStart : any; + yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1)); + // Calculate full weeks to nearest Thursday + let weekNo = Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7); + // Return array of year and week number + return '' + d.getUTCFullYear() + weekNo; +} + validateImplementerEdit(state):boolean{ if(state == 1 || state == 3 || state == 6){ return true 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 12d96a2..a51fdaf 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 @@ -23,6 +23,7 @@ export const MY_DATE_FORMATS = { export class PlanTimeBarComponent implements OnInit { @Input() inputData: Array = []; @Input() splitterSettings: object; + @Input() parentResources: Array = []; @ViewChild('ganttObjectSum') public ganttDefault!: GanttComponent; public data: any[] = []; @@ -53,17 +54,18 @@ export class PlanTimeBarComponent implements OnInit { } this.resources = [{resourceId: 1, resourceName: 'Planzeit Summen pro Woche'}]; - + console.log(this.parentResources); let calendarWeeks = this.getCalendarWeeks(this.projectStartDate , this.projectEndDate); // Ausgabe der Kalenderwochen calendarWeeks.forEach((week, index) => { - console.log(`Kalenderwoche ${index + 1}: ${week.start} - ${week.end}`); - + 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}`); this.data.push( { - TaskID: '' + this.getWeekNumber(new Date(calendarWeeks[index].start.toISOString())), index , TaskName: "Woche " + this.getWeekNumber(new Date(calendarWeeks[index].start.toISOString())), StartDate: calendarWeeks[index].start.toISOString(),EndDate: calendarWeeks[index].end.toISOString() , planzeit: 1, + TaskID: '' + weekNr, index , TaskName: "Woche " + weekNr, StartDate: calendarWeeks[index].start.toISOString(),EndDate: calendarWeeks[index].end.toISOString() , planzeit: planzeit, resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false }); }); @@ -97,6 +99,19 @@ export class PlanTimeBarComponent implements OnInit { name: 'resourceName', }; } + + getPlantimeFromResources(resources: any[], week: string){ + let planzeit = 0; + for (const res of resources) { + console.log(res); + if(res.calenderWeek == week){ + planzeit+= res.plantime; + + } + } + return planzeit + } + getWeekNumber(d) { // Copy date so don't modify original d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate())); diff --git a/frontend/src/ntt-gantt/ntt-gantt.component.html b/frontend/src/ntt-gantt/ntt-gantt.component.html index 51f13d7..bf9db30 100644 --- a/frontend/src/ntt-gantt/ntt-gantt.component.html +++ b/frontend/src/ntt-gantt/ntt-gantt.component.html @@ -141,6 +141,7 @@

Die Suche lieferte keine Ergebnisse

The search did not return any results

diff --git a/frontend/src/ntt-gantt/ntt-gantt.component.ts b/frontend/src/ntt-gantt/ntt-gantt.component.ts index f166ac9..584239e 100644 --- a/frontend/src/ntt-gantt/ntt-gantt.component.ts +++ b/frontend/src/ntt-gantt/ntt-gantt.component.ts @@ -271,6 +271,7 @@ public logg(args){ this.stateList = res; this.spin = false; console.log(this.states); + this.inputForTimeline = [this.splitterSettings, this.projectStartDate, this.projectEndDate]; }); });