schedule-refactor #45

Merged
sebastian merged 18 commits from schedule-refactor into master 2023-11-11 18:56:16 +01:00
13 changed files with 224 additions and 133 deletions
Showing only changes of commit dadb1204e8 - Show all commits

View File

@ -16,6 +16,8 @@ index.ts
model/accountDeleteRequest.ts
model/basicScheduleEntityInfo.ts
model/basicScheduleFieldInfo.ts
model/basicScheduleInfo.ts
model/basicScheduleInfoAllOf.ts
model/eMailChangeRequest.ts
model/forgottenActivityRequest.ts
model/inlineResponse200.ts

View File

@ -18,7 +18,6 @@ import { HttpClient, HttpHeaders, HttpParams,
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
import { BasicScheduleEntityInfo } from '../model/models';
import { BasicScheduleFieldInfo } from '../model/models';
import { ForgottenActivityRequest } from '../model/models';
import { ScheduleActivateInfo } from '../model/models';
@ -626,76 +625,6 @@ export class ScheduleService {
);
}
/**
* creates basic schedule for task
* creates a basic schedule for a task
* @param taskID internal id of task
* @param basicScheduleFieldInfo
* @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 schedulesTaskIDBasicPut(taskID: number, basicScheduleFieldInfo?: BasicScheduleFieldInfo, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<BasicScheduleEntityInfo>;
public schedulesTaskIDBasicPut(taskID: number, basicScheduleFieldInfo?: BasicScheduleFieldInfo, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<BasicScheduleEntityInfo>>;
public schedulesTaskIDBasicPut(taskID: number, basicScheduleFieldInfo?: BasicScheduleFieldInfo, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<BasicScheduleEntityInfo>>;
public schedulesTaskIDBasicPut(taskID: number, basicScheduleFieldInfo?: BasicScheduleFieldInfo, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
if (taskID === null || taskID === undefined) {
throw new Error('Required parameter taskID was null or undefined when calling schedulesTaskIDBasicPut.');
}
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();
}
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
}
let responseType_: 'text' | 'json' = 'json';
if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
}
return this.httpClient.put<BasicScheduleEntityInfo>(`${this.configuration.basePath}/schedules/${encodeURIComponent(String(taskID))}/basic`,
basicScheduleFieldInfo,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}
/**
* registers forgotten schedule
* Registers forgotten schedule
@ -766,6 +695,65 @@ export class ScheduleService {
);
}
/**
* gets schedules of task
* gets schedules of task
* @param taskID internal id of task
* @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 schedulesTaskIDGet(taskID: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<ScheduleInfo>>;
public schedulesTaskIDGet(taskID: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<ScheduleInfo>>>;
public schedulesTaskIDGet(taskID: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<ScheduleInfo>>>;
public schedulesTaskIDGet(taskID: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
if (taskID === null || taskID === undefined) {
throw new Error('Required parameter taskID was null or undefined when calling schedulesTaskIDGet.');
}
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<Array<ScheduleInfo>>(`${this.configuration.basePath}/schedules/${encodeURIComponent(String(taskID))}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}
/**
* schedule task now
* schedule task now
@ -827,22 +815,19 @@ export class ScheduleService {
}
/**
* gets schedules of task
* gets schedules of task
* creates basic schedule for task
* creates a basic schedule for a task
* @param taskID internal id of task
* @param scheduleType internal id of task
* @param basicScheduleFieldInfo
* @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 schedulesTaskIDScheduleTypeGet(taskID: number, scheduleType: 'BASIC' | 'MODERATE' | 'ADVANCED', observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<BasicScheduleEntityInfo>>;
public schedulesTaskIDScheduleTypeGet(taskID: number, scheduleType: 'BASIC' | 'MODERATE' | 'ADVANCED', observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<BasicScheduleEntityInfo>>>;
public schedulesTaskIDScheduleTypeGet(taskID: number, scheduleType: 'BASIC' | 'MODERATE' | 'ADVANCED', observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<BasicScheduleEntityInfo>>>;
public schedulesTaskIDScheduleTypeGet(taskID: number, scheduleType: 'BASIC' | 'MODERATE' | 'ADVANCED', observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
public schedulesTaskIDPut(taskID: number, basicScheduleFieldInfo?: BasicScheduleFieldInfo, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<ScheduleInfo>;
public schedulesTaskIDPut(taskID: number, basicScheduleFieldInfo?: BasicScheduleFieldInfo, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<ScheduleInfo>>;
public schedulesTaskIDPut(taskID: number, basicScheduleFieldInfo?: BasicScheduleFieldInfo, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<ScheduleInfo>>;
public schedulesTaskIDPut(taskID: number, basicScheduleFieldInfo?: BasicScheduleFieldInfo, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
if (taskID === null || taskID === undefined) {
throw new Error('Required parameter taskID was null or undefined when calling schedulesTaskIDScheduleTypeGet.');
}
if (scheduleType === null || scheduleType === undefined) {
throw new Error('Required parameter scheduleType was null or undefined when calling schedulesTaskIDScheduleTypeGet.');
throw new Error('Required parameter taskID was null or undefined when calling schedulesTaskIDPut.');
}
let localVarHeaders = this.defaultHeaders;
@ -872,12 +857,22 @@ export class ScheduleService {
}
// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
}
let responseType_: 'text' | 'json' = 'json';
if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
}
return this.httpClient.get<Array<BasicScheduleEntityInfo>>(`${this.configuration.basePath}/schedules/${encodeURIComponent(String(taskID))}/${encodeURIComponent(String(scheduleType))}`,
return this.httpClient.put<ScheduleInfo>(`${this.configuration.basePath}/schedules/${encodeURIComponent(String(taskID))}`,
basicScheduleFieldInfo,
{
context: localVarHttpContext,
responseType: <any>responseType_,

View File

@ -0,0 +1,52 @@
/**
* 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.
*/
import { BasicScheduleInfoAllOf } from './basicScheduleInfoAllOf';
import { TaskgroupEntityInfo } from './taskgroupEntityInfo';
import { TaskShortInfo } from './taskShortInfo';
import { ScheduleInfo } from './scheduleInfo';
export interface BasicScheduleInfo {
/**
* internal id of schedule
*/
scheduleID: number;
/**
* type of schedule
*/
scheduleType: BasicScheduleInfo.ScheduleTypeEnum;
/**
* date on which the task schedule was started
*/
startTime: string;
/**
* date on which the tasks schedule was finished
*/
finishedTime?: string;
/**
* number in minutes that the schedule was active
*/
activeMinutes: number;
task: TaskShortInfo;
taskgroupPath: Array<TaskgroupEntityInfo>;
scheduleDate: string;
}
export namespace BasicScheduleInfo {
export type ScheduleTypeEnum = 'BASIC' | 'MODERATE' | 'ADVANCED';
export const ScheduleTypeEnum = {
Basic: 'BASIC' as ScheduleTypeEnum,
Moderate: 'MODERATE' as ScheduleTypeEnum,
Advanced: 'ADVANCED' as ScheduleTypeEnum
};
}

View File

@ -0,0 +1,17 @@
/**
* 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 BasicScheduleInfoAllOf {
scheduleDate: string;
}

View File

@ -1,6 +1,8 @@
export * from './accountDeleteRequest';
export * from './basicScheduleEntityInfo';
export * from './basicScheduleFieldInfo';
export * from './basicScheduleInfo';
export * from './basicScheduleInfoAllOf';
export * from './eMailChangeRequest';
export * from './forgottenActivityRequest';
export * from './inlineResponse200';

View File

@ -9,7 +9,6 @@
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { BasicScheduleFieldInfo } from './basicScheduleFieldInfo';
import { TaskgroupEntityInfo } from './taskgroupEntityInfo';
import { TaskShortInfo } from './taskShortInfo';
@ -35,7 +34,6 @@ export interface ScheduleInfo {
* number in minutes that the schedule was active
*/
activeMinutes: number;
schedule: BasicScheduleFieldInfo;
task: TaskShortInfo;
taskgroupPath: Array<TaskgroupEntityInfo>;
}

View File

@ -13,7 +13,7 @@
<mat-progress-bar mode="determinate" [value]="schedule.activeMinutes"></mat-progress-bar>
<div class="originally-planned-container">
<div style="width: 100%">
<p style="display: inline-block"><i>Originally planned:</i> {{schedule.schedule.scheduleDate}}</p>
<p style="display: inline-block"><i>Originally planned:</i> {{toBasicSchedule(schedule).scheduleDate}}</p>
</div>
<div style="width: 100%" class="reschedule-actions-container">
<button mat-raised-button color="primary" class="rescheduleBtn"

View File

@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core';
import {ScheduleInfo, ScheduleService} from "../../api";
import {BasicScheduleInfo, ScheduleInfo, ScheduleService} from "../../api";
import {NavigationLink} from "../navigation-link-list/navigation-link-list.component";
import {MatSnackBar} from "@angular/material/snack-bar";
import {MatDialog} from "@angular/material/dialog";
@ -63,4 +63,8 @@ export class MissedSchedulesComponent implements OnInit{
}
})
}
toBasicSchedule(schedule: ScheduleInfo) {
return schedule as BasicScheduleInfo
}
}

View File

@ -1,6 +1,12 @@
import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core';
import {FormControl, Validators} from "@angular/forms";
import {BasicScheduleEntityInfo, ScheduleService, TaskEntityInfo, TaskgroupEntityInfo} from "../../../api";
import {
BasicScheduleEntityInfo,
BasicScheduleInfo,
ScheduleService,
TaskEntityInfo,
TaskgroupEntityInfo
} from "../../../api";
import {MatSnackBar} from "@angular/material/snack-bar";
import {Router} from "@angular/router";
@ -29,11 +35,11 @@ export class BasicSchedulerComponent implements OnChanges{
schedule() {
if(this.task != undefined) {
if(this.scheduleEntityInfo == undefined) {
this.scheduleService.schedulesTaskIDBasicPut(this.task.taskID, {
this.scheduleService.schedulesTaskIDPut(this.task.taskID, {
scheduleDate: this.dateCtrl.value
}).subscribe({
next: resp => {
this.scheduleEmitter.emit(resp);
this.scheduleEmitter.emit(resp as BasicScheduleInfo);
}
})
} else {

View File

@ -1,12 +1,16 @@
<mat-card *ngFor="let schedule of schedules" class="scheduleContainer">
<mat-card-content>
<div class="basicScheduleContainer">
<p class="basicScheduleContent">{{schedule.scheduleDate | date:'EEEE, d MMM. y'}}</p>
<div class="basicScheduleContent">
<button mat-icon-button color="primary" [routerLink]="['/taskgroups', taskgroup!.taskgroupID, 'tasks', task!.taskID, 'schedule', schedule.scheduleID]"><mat-icon>edit</mat-icon></button>
<button mat-icon-button color="warn" (click)="deleteSchedule(schedule)"><mat-icon>delete</mat-icon></button>
<ng-container *ngIf="schedule.scheduleType == 'BASIC'">
<div class="basicScheduleContainer">
<p class="basicScheduleContent">{{ toBasicSchedule(schedule).scheduleDate | date:'EEEE, d MMM. y'}}</p>
<div class="basicScheduleContent">
<button mat-icon-button color="primary" [routerLink]="['/taskgroups', taskgroup!.taskgroupID, 'tasks', task!.taskID, 'schedule', schedule.scheduleID]"><mat-icon>edit</mat-icon></button>
<button mat-icon-button color="warn" (click)="deleteSchedule(schedule)"><mat-icon>delete</mat-icon></button>
</div>
</div>
</div>
</ng-container>

View File

@ -1,5 +1,11 @@
import {Component, Input, OnInit} from '@angular/core';
import {BasicScheduleEntityInfo, ScheduleService, TaskEntityInfo, TaskgroupEntityInfo} from "../../../api";
import {
BasicScheduleEntityInfo, BasicScheduleInfo,
ScheduleInfo,
ScheduleService,
TaskEntityInfo,
TaskgroupEntityInfo
} from "../../../api";
import {MatSnackBar} from "@angular/material/snack-bar";
@Component({
@ -12,7 +18,7 @@ export class ScheduleDashboardComponent implements OnInit{
@Input('taskgroup') taskgroup: TaskgroupEntityInfo | undefined
@Input('task') task: TaskEntityInfo | undefined
schedules: BasicScheduleEntityInfo[] = []
schedules: ScheduleInfo[] = []
constructor(private scheduleService: ScheduleService,
private snackbar: MatSnackBar) {
@ -20,7 +26,7 @@ export class ScheduleDashboardComponent implements OnInit{
}
ngOnInit() {
this.scheduleService.schedulesTaskIDScheduleTypeGet(this.task!.taskID, "BASIC").subscribe({
this.scheduleService.schedulesTaskIDGet(this.task!.taskID).subscribe({
next: resp => {
this.schedules = resp;
}
@ -31,7 +37,7 @@ export class ScheduleDashboardComponent implements OnInit{
//todo
}
deleteSchedule(deletedSchedule: BasicScheduleEntityInfo) {
deleteSchedule(deletedSchedule: ScheduleInfo) {
this.scheduleService.schedulesScheduleIDScheduleTypeDelete(deletedSchedule.scheduleID, 'BASIC').subscribe({
next: resp => {
this.schedules = this.schedules.filter(schedule => schedule.scheduleID !== deletedSchedule.scheduleID);
@ -47,4 +53,8 @@ export class ScheduleDashboardComponent implements OnInit{
}
})
}
toBasicSchedule(schedule: ScheduleInfo) {
return schedule as BasicScheduleInfo
}
}

View File

@ -1,7 +1,7 @@
import {Component, OnInit, ViewChild} from '@angular/core';
import {NavigationLink, NavigationLinkListComponent} from "../../navigation-link-list/navigation-link-list.component";
import {
BasicScheduleEntityInfo, ScheduleService,
BasicScheduleEntityInfo, BasicScheduleInfo, ScheduleService,
TaskEntityInfo,
TaskgroupEntityInfo,
TaskgroupService,
@ -136,26 +136,33 @@ export class SchedulerComponent implements OnInit{
fetschSchedules() {
this.scheduleService.schedulesGet().subscribe({
next: resp => {
resp.forEach(schedule => {
let color: EventColor = colors['red']
if(schedule.scheduleID === this.scheduleID) {
color = colors['yellow']
resp.forEach(abstractSchedule => {
if(abstractSchedule.scheduleType == 'BASIC') {
this.handleFetchedBasicSchedule(abstractSchedule as BasicScheduleInfo)
}
if(schedule.scheduleType === 'BASIC') {
this.events.push({
start: new Date(schedule.schedule.scheduleDate),
title: this.computeTaskPath(schedule.taskgroupPath, schedule.task),
color: color,
allDay: true,
})
}
})
this.refresh.next();
}
})
}
handleFetchedBasicSchedule(schedule: BasicScheduleInfo) {
let color: EventColor = colors['red']
if(schedule.scheduleID === this.scheduleID) {
color = colors['yellow']
}
if(schedule.scheduleType === 'BASIC') {
this.events.push({
start: new Date(schedule.scheduleDate),
title: this.computeTaskPath(schedule.taskgroupPath, schedule.task),
color: color,
allDay: true,
})
}
}
eventClicked({ event }: { event: CalendarEvent }): void {
this.router.navigateByUrl("/taskgroups/" + this.taskgroupID.toString() + "/tasks/" + this.task!.taskID )
}

View File

@ -1270,7 +1270,7 @@ paths:
items:
$ref: '#/components/schemas/ScheduleInfo'
/schedules/{taskID}/{scheduleType}:
/schedules/{taskID}:
get:
security:
- API_TOKEN: []
@ -1286,16 +1286,6 @@ paths:
schema:
type: number
example: 1
- name: scheduleType
in: path
description: internal id of task
required: true
schema:
type: string
enum:
- BASIC
- MODERATE
- ADVANCED
responses:
200:
description: operation successfull
@ -1304,7 +1294,7 @@ paths:
schema:
type: array
items:
$ref: '#/components/schemas/BasicScheduleEntityInfo'
$ref: '#/components/schemas/ScheduleInfo'
403:
description: No permission
content:
@ -1319,7 +1309,6 @@ paths:
schema:
type: object
$ref: "#/components/schemas/SimpleStatusResponse"
/schedules/{taskID}/basic:
put:
security:
- API_TOKEN: []
@ -1347,7 +1336,7 @@ paths:
application/json:
schema:
type: object
$ref: '#/components/schemas/BasicScheduleEntityInfo'
$ref: '#/components/schemas/ScheduleInfo'
403:
description: No permission
content:
@ -2182,7 +2171,6 @@ components:
- startTime
- finishTime
- activeMinutes
- schedule
- task
- taskgroupPath
additionalProperties: false
@ -2211,10 +2199,6 @@ components:
type: number
description: number in minutes that the schedule was active
example: 10
schedule:
type: object
oneOf:
- $ref: '#/components/schemas/BasicScheduleFieldInfo'
task:
type: object
$ref: '#/components/schemas/TaskShortInfo'
@ -2222,7 +2206,17 @@ components:
type: array
items:
$ref: '#/components/schemas/TaskgroupEntityInfo'
BasicScheduleInfo:
allOf:
- $ref: '#/components/schemas/ScheduleInfo'
- type: object
required:
- scheduleDate
additionalProperties: false
properties:
scheduleDate:
type: string
format: date
TaskShortInfo:
required:
- taskID