From 183030611b4f6c0fe8e95a7724f80106c948aac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Mon, 18 Mar 2024 14:45:25 +0100 Subject: [PATCH] Select top taskgroups by default in Activity Statistic --- .../api/controller/StatisticController.java | 2 +- .../timemanager/history/ActivityInfo.java | 12 +- frontend/src/api/.openapi-generator/FILES | 1 + frontend/src/api/api/history.service.ts | 22 +-- frontend/src/api/model/activityInfo.ts | 21 +++ frontend/src/api/model/models.ts | 1 + .../src/api/model/taskgroupActivityInfo.ts | 9 +- .../heatmap-activity.component.ts | 6 +- .../simple-activity-diagram.component.html | 2 +- .../simple-activity-diagram.component.ts | 126 +++++++----------- .../taskgroup-activity.component.html | 2 +- .../taskgroup-activity.component.ts | 8 -- 12 files changed, 93 insertions(+), 119 deletions(-) create mode 100644 frontend/src/api/model/activityInfo.ts diff --git a/backend/src/main/java/core/api/controller/StatisticController.java b/backend/src/main/java/core/api/controller/StatisticController.java index ee66710..54f6a53 100644 --- a/backend/src/main/java/core/api/controller/StatisticController.java +++ b/backend/src/main/java/core/api/controller/StatisticController.java @@ -39,7 +39,7 @@ public class StatisticController { return ResponseEntity.ok(new WorkingStatus(missedSchedules, activeTime)); } - @GetMapping("/statistics/{startingDate}/{endingDate}/{includeSubTaskgroups}") + @GetMapping("/statistics/{startingDate}/{endingDate}") public ResponseEntity getTaskgroupActivity(@PathVariable String startingDate, @PathVariable String endingDate){ LocalDate starting = LocalDate.parse(startingDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")); LocalDate ending = LocalDate.parse(endingDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")); diff --git a/backend/src/main/java/core/api/models/timemanager/history/ActivityInfo.java b/backend/src/main/java/core/api/models/timemanager/history/ActivityInfo.java index 44d0b5a..f74dc72 100644 --- a/backend/src/main/java/core/api/models/timemanager/history/ActivityInfo.java +++ b/backend/src/main/java/core/api/models/timemanager/history/ActivityInfo.java @@ -5,11 +5,11 @@ import java.time.LocalDate; public class ActivityInfo { private LocalDate scheduleDate; - private int workedMinutes; + private int activeMinutes; public ActivityInfo(LocalDate scheduleDate, int workedMinutes) { this.scheduleDate = scheduleDate; - this.workedMinutes = workedMinutes; + this.activeMinutes = workedMinutes; } public LocalDate getScheduleDate() { @@ -20,11 +20,11 @@ public class ActivityInfo { this.scheduleDate = scheduleDate; } - public int getWorkedMinutes() { - return workedMinutes; + public int getActiveMinutes() { + return activeMinutes; } - public void setWorkedMinutes(int workedMinutes) { - this.workedMinutes = workedMinutes; + public void setActiveMinutes(int activeMinutes) { + this.activeMinutes = activeMinutes; } } diff --git a/frontend/src/api/.openapi-generator/FILES b/frontend/src/api/.openapi-generator/FILES index 8171b54..9c3f8e8 100644 --- a/frontend/src/api/.openapi-generator/FILES +++ b/frontend/src/api/.openapi-generator/FILES @@ -17,6 +17,7 @@ encoder.ts git_push.sh index.ts model/accountDeleteRequest.ts +model/activityInfo.ts model/advancedScheduleFieldInfo.ts model/advancedScheduleInfo.ts model/advancedScheduleInfoAllOf.ts diff --git a/frontend/src/api/api/history.service.ts b/frontend/src/api/api/history.service.ts index 1e5ec3d..f567d47 100644 --- a/frontend/src/api/api/history.service.ts +++ b/frontend/src/api/api/history.service.ts @@ -203,28 +203,20 @@ export class HistoryService { } /** - * @param taskgroupID internal id of taskgroup * @param startingDate starting date * @param endingDate starting date - * @param includeSubTaskgroups determines whether to include subtaskgroups or not * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet(taskgroupID: number, startingDate: string, endingDate: string, includeSubTaskgroups: boolean, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet(taskgroupID: number, startingDate: string, endingDate: string, includeSubTaskgroups: boolean, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>>; - public statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet(taskgroupID: number, startingDate: string, endingDate: string, includeSubTaskgroups: boolean, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>>; - public statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet(taskgroupID: number, startingDate: string, endingDate: string, includeSubTaskgroups: boolean, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - if (taskgroupID === null || taskgroupID === undefined) { - throw new Error('Required parameter taskgroupID was null or undefined when calling statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet.'); - } + public statisticsStartingDateEndingDateGet(startingDate: string, endingDate: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public statisticsStartingDateEndingDateGet(startingDate: string, endingDate: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>>; + public statisticsStartingDateEndingDateGet(startingDate: string, endingDate: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>>; + public statisticsStartingDateEndingDateGet(startingDate: string, endingDate: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { if (startingDate === null || startingDate === undefined) { - throw new Error('Required parameter startingDate was null or undefined when calling statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet.'); + throw new Error('Required parameter startingDate was null or undefined when calling statisticsStartingDateEndingDateGet.'); } if (endingDate === null || endingDate === undefined) { - throw new Error('Required parameter endingDate was null or undefined when calling statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet.'); - } - if (includeSubTaskgroups === null || includeSubTaskgroups === undefined) { - throw new Error('Required parameter includeSubTaskgroups was null or undefined when calling statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet.'); + throw new Error('Required parameter endingDate was null or undefined when calling statisticsStartingDateEndingDateGet.'); } let localVarHeaders = this.defaultHeaders; @@ -259,7 +251,7 @@ export class HistoryService { responseType_ = 'text'; } - return this.httpClient.get>(`${this.configuration.basePath}/statistics/taskgroup-activity/${encodeURIComponent(String(taskgroupID))}/${encodeURIComponent(String(startingDate))}/${encodeURIComponent(String(endingDate))}/${encodeURIComponent(String(includeSubTaskgroups))}`, + return this.httpClient.get>(`${this.configuration.basePath}/statistics/${encodeURIComponent(String(startingDate))}/${encodeURIComponent(String(endingDate))}`, { context: localVarHttpContext, responseType: responseType_, diff --git a/frontend/src/api/model/activityInfo.ts b/frontend/src/api/model/activityInfo.ts new file mode 100644 index 0000000..80da109 --- /dev/null +++ b/frontend/src/api/model/activityInfo.ts @@ -0,0 +1,21 @@ +/** + * API Title + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface ActivityInfo { + date: string; + /** + * Number of minutes the task was active + */ + activeMinutes: number; +} + diff --git a/frontend/src/api/model/models.ts b/frontend/src/api/model/models.ts index 12edcd1..ec5d33b 100644 --- a/frontend/src/api/model/models.ts +++ b/frontend/src/api/model/models.ts @@ -1,4 +1,5 @@ export * from './accountDeleteRequest'; +export * from './activityInfo'; export * from './advancedScheduleFieldInfo'; export * from './advancedScheduleInfo'; export * from './advancedScheduleInfoAllOf'; diff --git a/frontend/src/api/model/taskgroupActivityInfo.ts b/frontend/src/api/model/taskgroupActivityInfo.ts index fc6a973..0c4d052 100644 --- a/frontend/src/api/model/taskgroupActivityInfo.ts +++ b/frontend/src/api/model/taskgroupActivityInfo.ts @@ -9,13 +9,12 @@ * https://openapi-generator.tech * Do not edit the class manually. */ +import { ActivityInfo } from './activityInfo'; +import { TaskgroupEntityInfo } from './taskgroupEntityInfo'; export interface TaskgroupActivityInfo { - date: string; - /** - * Number of minutes the task was active - */ - activeMinutes: number; + taskgroup: TaskgroupEntityInfo; + activityInfos: Array; } diff --git a/frontend/src/app/statistics/taskgroup-activity/heatmap-activity/heatmap-activity.component.ts b/frontend/src/app/statistics/taskgroup-activity/heatmap-activity/heatmap-activity.component.ts index 301e822..e2fb081 100644 --- a/frontend/src/app/statistics/taskgroup-activity/heatmap-activity/heatmap-activity.component.ts +++ b/frontend/src/app/statistics/taskgroup-activity/heatmap-activity/heatmap-activity.component.ts @@ -40,7 +40,7 @@ export class HeatmapActivityComponent implements OnChanges{ ngOnChanges() { if(this.selectedTaskgroupPath != undefined) { - this.historyService.statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet( + /*this.historyService.statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet( this.selectedTaskgroupPath!.rootTasktroup.taskgroupID, moment().startOf('year').format("YYYY-MM-DD"), moment().endOf("year").format("YYYY-MM-DD"), @@ -149,7 +149,7 @@ export class HeatmapActivityComponent implements OnChanges{ } }; } - }) + })*/ } } @@ -175,6 +175,6 @@ export class HeatmapActivityComponent implements OnChanges{ } private findTaskgroupActivityInfoByDate(date: moment.Moment, data: TaskgroupActivityInfo[]) { - return data.find(taskActivity => moment(taskActivity.date).isSame(date)) + //return data.find(taskActivity => moment(taskActivity.date).isSame(date)) } } diff --git a/frontend/src/app/statistics/taskgroup-activity/simple-activity-diagram/simple-activity-diagram.component.html b/frontend/src/app/statistics/taskgroup-activity/simple-activity-diagram/simple-activity-diagram.component.html index bda266d..46622b2 100644 --- a/frontend/src/app/statistics/taskgroup-activity/simple-activity-diagram/simple-activity-diagram.component.html +++ b/frontend/src/app/statistics/taskgroup-activity/simple-activity-diagram/simple-activity-diagram.component.html @@ -1,5 +1,5 @@
- = this.generateChartOptions() + + series: ApexAxisChartSeries = [] + chartOptions: Partial | undefined; constructor(private taskgroupService: TaskgroupService, private historyService: HistoryService) { } + ngOnChanges() { + this.series = []; + const startingDate = moment(this.dateRange[0]).format("yyyy-MM-DD"); + const endingDate = moment(this.dateRange[this.dateRange.length-1]).format("yyyy-MM-DD"); + this.historyService.statisticsStartingDateEndingDateGet(startingDate, endingDate).subscribe({ + next: resp => { + resp.forEach(taskgroupActivityInfo => { + const data: any[] = []; + this.dateRange.map(date => { + const selectedActivity = taskgroupActivityInfo.activityInfos.find(activity => moment(date).isSame(moment(activity.date), "day")) + if(selectedActivity != undefined) { + data.push(selectedActivity.activeMinutes) + } else { + data.push(0) + } + }) + + this.series.push({ + name: taskgroupActivityInfo.taskgroup.taskgroupName, + data: data + }) + }) + + this.chartOptions = { + series: this.series, + chart: { + height: 350, + type: this.selectedChartype as ChartType, + stacked: true + }, + title: { + text: "" + }, + xaxis: { + categories: this.selectedDateRange.map(date => date.toDateString()) + } + } + } + }) + } createDateRange(): Date[] { const dates: Date[] = []; @@ -63,84 +105,10 @@ export class SimpleActivityDiagramComponent { console.log("min " + moment(changeContext.value).format("YYYY-MM-DD")); console.log("max " + moment(changeContext.highValue!).format("YYYY-MM-DD")) this.selectedDateRange = this.createDateRangeBetween(moment(changeContext.value), moment(changeContext.highValue!)) - this.chartOptions = this.generateChartOptions() - } - - generateChartOptions(): Partial { - return { - series: this.generateSeries(), - chart: { - height: 350, - type: this.selectedChartype as ChartType, - stacked: true - }, - title: { - text: "" - }, - xaxis: { - categories: this.selectedDateRange.map(date => date.toDateString()) - } - }; - } - - generateSeries() : ApexAxisChartSeries { - const series: ApexAxisChartSeries = [] - - if(this.selectedTaskgroupPath != undefined) { - this.historyService.statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet( - this.selectedTaskgroupPath!.rootTasktroup.taskgroupID, - moment(this.selectedDateRange[0]).format("YYYY-MM-DD"), - moment(this.selectedDateRange[this.selectedDateRange.length-1]).format("YYYY-MM-DD"), - false - ).subscribe({ - next: resp => { - series.push( - { - name: this.selectedTaskgroupPath!.rootTasktroup.taskgroupName, - data: resp.map(dailyActivityInfo => dailyActivityInfo.activeMinutes) - } - ); - } - }) - } - - - - - this.selectedTaskgroupPath?.directChildren.forEach(taskgroup => { - - this.historyService.statisticsTaskgroupActivityTaskgroupIDStartingDateEndingDateIncludeSubTaskgroupsGet( - taskgroup.taskgroupID, - moment(this.selectedDateRange[0]).format("YYYY-MM-DD"), - moment(this.selectedDateRange[this.selectedDateRange.length-1]).format("YYYY-MM-DD"), true - ).subscribe({ - next: resp => { - series.push( - { - name: taskgroup.taskgroupName, - data: resp.map(dailyActivityInfo => dailyActivityInfo.activeMinutes) - } - ) - } - }) - - }) - console.log(series); - return series; - - } - - updateSerieSelection() { - this.chartOptions = this.generateChartOptions() } setSelectedChartType(selectedChartype: string) { - this.selectedChartype = selectedChartype; - this.updateSerieSelection(); - } + //this.selectedChartype = selectedChartype; - setSelectedTaskgroupPath(selectedTaskgroupPath: TaskgroupPathInfo) { - this.selectedTaskgroupPath = selectedTaskgroupPath; - this.updateSerieSelection(); } } diff --git a/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.html b/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.html index 3d73666..7ca0e64 100644 --- a/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.html +++ b/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.html @@ -2,7 +2,7 @@ Taskgroup - + {{topping.taskgroupPath}} diff --git a/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.ts b/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.ts index c8bd252..28ee779 100644 --- a/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.ts +++ b/frontend/src/app/statistics/taskgroup-activity/taskgroup-activity.component.ts @@ -65,14 +65,6 @@ export class TaskgroupActivityComponent implements OnInit{ } - onSelectTaskgroupPath() { - if(this.simpleActivityDiagram != undefined) { - this.simpleActivityDiagram.setSelectedTaskgroupPath(this.selectedTaskgroupPath!); - } - - //this.heatMap?.setSelectedTaskgroupPath(this.selectedTaskgroupPath!); - } - onSelectChartType() { if(this.simpleActivityDiagram != undefined) { this.simpleActivityDiagram.setSelectedChartType(this.selectedChartype);