From 0e07549a652ac8a5fdb0193d1d4a0b8144fe4f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 11 Nov 2023 19:20:05 +0100 Subject: [PATCH] Fix typos and date type --- .../timemanager/history/WorkingStatus.java | 12 +- frontend/src/api/.openapi-generator/FILES | 1 + frontend/src/api/api.module.ts | 1 + frontend/src/api/api/api.ts | 4 +- frontend/src/api/api/history.service.ts | 144 ++++++++++++++++++ frontend/src/api/api/schedule.service.ts | 56 ------- .../src/app/dashboard/dashboard.component.ts | 11 +- 7 files changed, 162 insertions(+), 67 deletions(-) create mode 100644 frontend/src/api/api/history.service.ts diff --git a/backend/src/main/java/core/api/models/timemanager/history/WorkingStatus.java b/backend/src/main/java/core/api/models/timemanager/history/WorkingStatus.java index 7e5c6c1..820f939 100644 --- a/backend/src/main/java/core/api/models/timemanager/history/WorkingStatus.java +++ b/backend/src/main/java/core/api/models/timemanager/history/WorkingStatus.java @@ -3,11 +3,11 @@ package core.api.models.timemanager.history; public class WorkingStatus { private boolean missedSchedules; - private int activeTime; + private int activeMinutes; public WorkingStatus(boolean missedSchedules, int activeTime) { this.missedSchedules = missedSchedules; - this.activeTime = activeTime; + this.activeMinutes = activeTime; } public boolean isMissedSchedules() { @@ -18,11 +18,11 @@ public class WorkingStatus { this.missedSchedules = missedSchedules; } - public int getActiveTime() { - return activeTime; + public int getActiveMinutes() { + return activeMinutes; } - public void setActiveTime(int activeTime) { - this.activeTime = activeTime; + 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 c190ae0..299edc4 100644 --- a/frontend/src/api/.openapi-generator/FILES +++ b/frontend/src/api/.openapi-generator/FILES @@ -3,6 +3,7 @@ README.md api.module.ts api/account.service.ts api/api.ts +api/history.service.ts api/login.service.ts api/properties.service.ts api/schedule.service.ts diff --git a/frontend/src/api/api.module.ts b/frontend/src/api/api.module.ts index 1781bef..1a6b886 100644 --- a/frontend/src/api/api.module.ts +++ b/frontend/src/api/api.module.ts @@ -3,6 +3,7 @@ import { Configuration } from './configuration'; import { HttpClient } from '@angular/common/http'; import { AccountService } from './api/account.service'; +import { HistoryService } from './api/history.service'; import { LoginService } from './api/login.service'; import { PropertiesService } from './api/properties.service'; import { ScheduleService } from './api/schedule.service'; diff --git a/frontend/src/api/api/api.ts b/frontend/src/api/api/api.ts index 15a0982..d483dcf 100644 --- a/frontend/src/api/api/api.ts +++ b/frontend/src/api/api/api.ts @@ -1,5 +1,7 @@ export * from './account.service'; import { AccountService } from './account.service'; +export * from './history.service'; +import { HistoryService } from './history.service'; export * from './login.service'; import { LoginService } from './login.service'; export * from './properties.service'; @@ -12,4 +14,4 @@ export * from './taskgroup.service'; import { TaskgroupService } from './taskgroup.service'; export * from './users.service'; import { UsersService } from './users.service'; -export const APIS = [AccountService, LoginService, PropertiesService, ScheduleService, TaskService, TaskgroupService, UsersService]; +export const APIS = [AccountService, HistoryService, LoginService, PropertiesService, ScheduleService, TaskService, TaskgroupService, UsersService]; diff --git a/frontend/src/api/api/history.service.ts b/frontend/src/api/api/history.service.ts new file mode 100644 index 0000000..21b3869 --- /dev/null +++ b/frontend/src/api/api/history.service.ts @@ -0,0 +1,144 @@ +/** + * 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. + */ +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent, HttpParameterCodec, HttpContext + } from '@angular/common/http'; +import { CustomHttpParameterCodec } from '../encoder'; +import { Observable } from 'rxjs'; + +import { ScheduleStatus } from '../model/models'; +import { SimpleStatusResponse } from '../model/models'; + +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; + + + +@Injectable({ + providedIn: 'root' +}) +export class HistoryService { + + protected basePath = 'http://localhost:8080/api'; + public defaultHeaders = new HttpHeaders(); + public configuration = new Configuration(); + public encoder: HttpParameterCodec; + + constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { + if (configuration) { + this.configuration = configuration; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; + } + this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); + } + + + private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams { + if (typeof value === "object" && value instanceof Date === false) { + httpParams = this.addToHttpParamsRecursive(httpParams, value); + } else { + httpParams = this.addToHttpParamsRecursive(httpParams, value, key); + } + return httpParams; + } + + private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams { + if (value == null) { + return httpParams; + } + + if (typeof value === "object") { + if (Array.isArray(value)) { + (value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key)); + } else if (value instanceof Date) { + if (key != null) { + httpParams = httpParams.append(key, + (value as Date).toISOString().substr(0, 10)); + } else { + throw Error("key may not be null if value is Date"); + } + } else { + Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive( + httpParams, value[k], key != null ? `${key}.${k}` : k)); + } + } else if (key != null) { + httpParams = httpParams.append(key, value); + } else { + throw Error("key may not be null if value is not object or array"); + } + return httpParams; + } + + /** + * get number of active minutes + * get number of worked minutes today + * @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 historyWorkingStatusGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public historyWorkingStatusGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public historyWorkingStatusGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public historyWorkingStatusGet(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarCredential: string | undefined; + // authentication (API_TOKEN) required + localVarCredential = this.configuration.lookupCredential('API_TOKEN'); + if (localVarCredential) { + localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); + } + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + let responseType_: 'text' | 'json' = 'json'; + if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } + + return this.httpClient.get(`${this.configuration.basePath}/history/workingStatus`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + +} diff --git a/frontend/src/api/api/schedule.service.ts b/frontend/src/api/api/schedule.service.ts index c14f0e8..74243cf 100644 --- a/frontend/src/api/api/schedule.service.ts +++ b/frontend/src/api/api/schedule.service.ts @@ -22,7 +22,6 @@ import { BasicScheduleFieldInfo } from '../model/models'; import { ForgottenActivityRequest } from '../model/models'; import { ScheduleActivateInfo } from '../model/models'; import { ScheduleInfo } from '../model/models'; -import { ScheduleStatus } from '../model/models'; import { SimpleStatusResponse } from '../model/models'; import { TaskScheduleStopResponse } from '../model/models'; @@ -629,61 +628,6 @@ export class ScheduleService { ); } - /** - * get number of active minutes - * get number of worked minutes today - * @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 schedulesStatusTodayGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public schedulesStatusTodayGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public schedulesStatusTodayGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public schedulesStatusTodayGet(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarCredential: string | undefined; - // authentication (API_TOKEN) required - localVarCredential = this.configuration.lookupCredential('API_TOKEN'); - if (localVarCredential) { - localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); - } - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' = 'json'; - if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } - - return this.httpClient.get(`${this.configuration.basePath}/schedules/status/today`, - { - context: localVarHttpContext, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - /** * registers forgotten schedule * Registers forgotten schedule diff --git a/frontend/src/app/dashboard/dashboard.component.ts b/frontend/src/app/dashboard/dashboard.component.ts index 1f7cfaf..d3a1283 100644 --- a/frontend/src/app/dashboard/dashboard.component.ts +++ b/frontend/src/app/dashboard/dashboard.component.ts @@ -1,6 +1,6 @@ import {Component, OnInit, ViewChild} from '@angular/core'; import { - BasicScheduleEntityInfo, + BasicScheduleEntityInfo, HistoryService, ScheduleInfo, ScheduleService, TaskOverviewInfo, @@ -26,17 +26,20 @@ export class DashboardComponent implements OnInit{ selectedTaskgroupID: number | undefined @ViewChild('activeSchedule') activeScheduleComponent: ActiveScheduleComponent | undefined - constructor(private scheduleService: ScheduleService) { + constructor(private scheduleService: ScheduleService, + private historyService: HistoryService) { } ngOnInit() { - this.scheduleService.schedulesDateStartableGet(String(Date.now()), true).subscribe({ + const date: Date = new Date(); + console.log(date) + this.scheduleService.schedulesDateStartableGet(date.toISOString().split("T")[0], true).subscribe({ next: resp => { this.schedules = resp; } }) - this.scheduleService.schedulesStatusTodayGet().subscribe({ + this.historyService.historyWorkingStatusGet().subscribe({ next: resp => { this.workedMinutesToday = resp.activeMinutes; this.missedSchedules = resp.missedSchedules;