Merge pull request 'issue-95' (#101) from issue-95 into master
All checks were successful
Java CI with Maven / test (push) Successful in 38s
Java CI with Maven / build-and-push-frontend (push) Successful in 2m9s
Java CI with Maven / build-and-push-backend (push) Successful in 1m21s

Reviewed-on: #101
This commit is contained in:
sebastian 2024-03-14 07:29:48 +01:00
commit 5366dcc0e3
18 changed files with 331 additions and 4 deletions

View File

@ -275,4 +275,20 @@ public class ScheduleController {
return ResponseEntity.ok(permissionResult.getResult().toScheduleInfo()); return ResponseEntity.ok(permissionResult.getResult().toScheduleInfo());
} }
@PostMapping("/schedules/{scheduleID}/stopManual")
public ResponseEntity<?> stopManual(@PathVariable long scheduleID, @Valid @RequestBody ManualScheduleStopInfo manualScheduleStopInfo) {
PermissionResult<AbstractSchedule> permissionResult = taskScheduleService.getSchedulePermissions(scheduleID, SecurityContextHolder.getContext().getAuthentication().getName());
if(!permissionResult.isHasPermissions()) {
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
}
if(permissionResult.getExitCode() == ServiceExitCode.MISSING_ENTITY) {
return ResponseEntity.status(404).body(new SimpleStatusResponse("failed"));
}
taskScheduleService.finishScheduleManual(permissionResult.getResult(), manualScheduleStopInfo);
return ResponseEntity.ok(new SimpleStatusResponse("success"));
}
} }

View File

@ -0,0 +1,15 @@
package core.api.models.timemanager.taskSchedule;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
public class ManualScheduleStopInfo {
@NotNull
private long duration;
public long getDuration() {
return duration;
}
}

View File

@ -1,6 +1,7 @@
package core.services; package core.services;
import core.api.models.timemanager.history.PastScheduleInfo; import core.api.models.timemanager.history.PastScheduleInfo;
import core.api.models.timemanager.taskSchedule.ManualScheduleStopInfo;
import core.api.models.timemanager.taskSchedule.scheduleInfos.AdvancedScheduleFieldInfo; import core.api.models.timemanager.taskSchedule.scheduleInfos.AdvancedScheduleFieldInfo;
import core.api.models.timemanager.taskSchedule.scheduleInfos.AdvancedScheduleInfo; import core.api.models.timemanager.taskSchedule.scheduleInfos.AdvancedScheduleInfo;
import core.api.models.timemanager.taskSchedule.scheduleInfos.BasicScheduleFieldInfo; import core.api.models.timemanager.taskSchedule.scheduleInfos.BasicScheduleFieldInfo;
@ -21,6 +22,7 @@ import java.time.Duration;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.*; import java.util.*;
@Service @Service
@ -237,4 +239,9 @@ public class TaskScheduleService {
} }
return filteredSchedules; return filteredSchedules;
} }
public void finishScheduleManual(AbstractSchedule schedule, ManualScheduleStopInfo manualScheduleStopInfo) {
schedule.setStopTime(schedule.getStartTime().plusMinutes(manualScheduleStopInfo.getDuration()));
scheduleRepository.save(schedule);
}
} }

View File

@ -30,6 +30,7 @@ model/inlineResponse403.ts
model/inlineResponse409.ts model/inlineResponse409.ts
model/loginRequest.ts model/loginRequest.ts
model/loginResponse.ts model/loginResponse.ts
model/manualScheduleStopInfo.ts
model/models.ts model/models.ts
model/passwordChangeRequest.ts model/passwordChangeRequest.ts
model/propertiesInfo.ts model/propertiesInfo.ts

View File

@ -21,6 +21,7 @@ import { Observable } from 'rxjs';
import { AdvancedScheduleFieldInfo } from '../model/models'; import { AdvancedScheduleFieldInfo } from '../model/models';
import { BasicScheduleFieldInfo } from '../model/models'; import { BasicScheduleFieldInfo } from '../model/models';
import { ForgottenActivityRequest } from '../model/models'; import { ForgottenActivityRequest } from '../model/models';
import { ManualScheduleStopInfo } from '../model/models';
import { ScheduleActivateInfo } from '../model/models'; import { ScheduleActivateInfo } from '../model/models';
import { ScheduleInfo } from '../model/models'; import { ScheduleInfo } from '../model/models';
import { SimpleStatusResponse } from '../model/models'; import { SimpleStatusResponse } from '../model/models';
@ -699,6 +700,76 @@ export class ScheduleService {
); );
} }
/**
* load schedule
* gets details of schedule
* @param scheduleID internal id of schedule
* @param manualScheduleStopInfo
* @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 schedulesScheduleIDStopManualPost(scheduleID: number, manualScheduleStopInfo?: ManualScheduleStopInfo, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<ScheduleInfo>;
public schedulesScheduleIDStopManualPost(scheduleID: number, manualScheduleStopInfo?: ManualScheduleStopInfo, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<ScheduleInfo>>;
public schedulesScheduleIDStopManualPost(scheduleID: number, manualScheduleStopInfo?: ManualScheduleStopInfo, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<ScheduleInfo>>;
public schedulesScheduleIDStopManualPost(scheduleID: number, manualScheduleStopInfo?: ManualScheduleStopInfo, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
if (scheduleID === null || scheduleID === undefined) {
throw new Error('Required parameter scheduleID was null or undefined when calling schedulesScheduleIDStopManualPost.');
}
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.post<ScheduleInfo>(`${this.configuration.basePath}/schedules/${encodeURIComponent(String(scheduleID))}/stopManual`,
manualScheduleStopInfo,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}
/** /**
* deletes multiple schedules * deletes multiple schedules
* deletes multiple schedules at once * deletes multiple schedules at once

View File

@ -0,0 +1,20 @@
/**
* 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 ManualScheduleStopInfo {
/**
* duration in minutes
*/
duration: number;
}

View File

@ -14,6 +14,7 @@ export * from './inlineResponse403';
export * from './inlineResponse409'; export * from './inlineResponse409';
export * from './loginRequest'; export * from './loginRequest';
export * from './loginResponse'; export * from './loginResponse';
export * from './manualScheduleStopInfo';
export * from './passwordChangeRequest'; export * from './passwordChangeRequest';
export * from './propertiesInfo'; export * from './propertiesInfo';
export * from './propertyInfo'; export * from './propertyInfo';

View File

@ -86,6 +86,9 @@ import {NgApexchartsModule} from "ng-apexcharts";
import { SimpleActivityDiagramComponent } from './statistics/taskgroup-activity/simple-activity-diagram/simple-activity-diagram.component'; import { SimpleActivityDiagramComponent } from './statistics/taskgroup-activity/simple-activity-diagram/simple-activity-diagram.component';
import { HeatmapActivityComponent } from './statistics/taskgroup-activity/heatmap-activity/heatmap-activity.component'; import { HeatmapActivityComponent } from './statistics/taskgroup-activity/heatmap-activity/heatmap-activity.component';
import { ScheduleHistoryComponent } from './statistics/schedule-history/schedule-history.component'; import { ScheduleHistoryComponent } from './statistics/schedule-history/schedule-history.component';
import {MatButtonToggleModule} from "@angular/material/button-toggle";
import {MatGridListModule} from "@angular/material/grid-list";
import { StopScheduleManuallyComponent } from './dashboard/active-schedule/stop-schedule-manually/stop-schedule-manually.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
AppComponent, AppComponent,
@ -130,6 +133,7 @@ import { ScheduleHistoryComponent } from './statistics/schedule-history/schedule
SimpleActivityDiagramComponent, SimpleActivityDiagramComponent,
HeatmapActivityComponent, HeatmapActivityComponent,
ScheduleHistoryComponent, ScheduleHistoryComponent,
StopScheduleManuallyComponent,
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
@ -171,6 +175,8 @@ import { ScheduleHistoryComponent } from './statistics/schedule-history/schedule
MatSliderModule, MatSliderModule,
NgxSliderModule, NgxSliderModule,
NgApexchartsModule, NgApexchartsModule,
MatButtonToggleModule,
MatGridListModule,
], ],
providers: [ providers: [
HttpClientModule, HttpClientModule,

View File

@ -139,3 +139,26 @@
color: white; color: white;
border-radius: 0; border-radius: 0;
} }
::ng-deep mat-button-toggle.drop-down-button {
margin-left: 0;
}
.parent-container {
display: flex;
justify-content: space-between;
width: 100%;
}
.right-container {
margin-top: -5px;
}
::ng-deep .small-button {
padding: 6px; /* Adjust padding as needed */
font-size: 10px; /* Adjust font size as needed */
}
.btn {
border-radius: 0;
}

View File

@ -13,7 +13,19 @@
<p class="gray-text">Running for {{displayTime}}</p> <p class="gray-text">Running for {{displayTime}}</p>
</mat-card-content> </mat-card-content>
<mat-card-actions> <mat-card-actions>
<button mat-raised-button class="grayBtn" (click)="stopTask(false)">Stop</button> <button class="btn btn-secondary" (click)="stopTask(false)">Stop</button>
<button mat-raised-button class="greenBtn" *ngIf="activeSchedule!.task.finishable" (click)="stopTask(true)">Finish</button> <div class="btn-group">
<button type="button" class="btn btn-success">Finish</button>
<button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><button class="dropdown-item" (click)="abortSchedule()">Abort</button></li>
<li><button class="dropdown-item" (click)="finishManual()">Set manually stop time</button></li>
</ul>
</div>
</mat-card-actions> </mat-card-actions>
</mat-card> </mat-card>

View File

@ -4,6 +4,7 @@ import {StopActiveScheduleInfo} from "./StopActiveScheduleInfo";
import {TaskOverviewComponent} from "../task-overview/task-overview.component"; import {TaskOverviewComponent} from "../task-overview/task-overview.component";
import {MatDialog} from "@angular/material/dialog"; import {MatDialog} from "@angular/material/dialog";
import {ForgottenTaskStartDialogComponent} from "../forgotten-task-start-dialog/forgotten-task-start-dialog.component"; import {ForgottenTaskStartDialogComponent} from "../forgotten-task-start-dialog/forgotten-task-start-dialog.component";
import {StopScheduleManuallyComponent} from "./stop-schedule-manually/stop-schedule-manually.component";
export interface StopActiveScheduleEmitterInfo { export interface StopActiveScheduleEmitterInfo {
stopactiveScheduleResponse: StopActiveScheduleInfo, stopactiveScheduleResponse: StopActiveScheduleInfo,
@ -89,6 +90,35 @@ export class ActiveScheduleComponent implements OnInit{
this.activeSchedule = undefined this.activeSchedule = undefined
} }
abortSchedule() {
this.scheduleService.schedulesScheduleIDDelete(this.activeSchedule!.scheduleID).subscribe({
next: resp => {
this.activeSchedule = undefined;
}
})
}
finishManual() {
const dialogRef = this.dialog.open(StopScheduleManuallyComponent, {
data: this.activeSchedule,
minWidth: "400px"})
dialogRef.afterClosed().subscribe(res => {
if(res != undefined) {
this.scheduleStopEmitter.emit({
finish: false,
taskID: this.activeSchedule!.scheduleID,
stopactiveScheduleResponse: {
schedule: this.activeSchedule!,
workedMinutes: res
}
})
this.activeSchedule = undefined;
}
})
}
openForgettedActivityDialog() { openForgettedActivityDialog() {
const dialogRef = this.dialog.open(ForgottenTaskStartDialogComponent, {width: "400px"}) const dialogRef = this.dialog.open(ForgottenTaskStartDialogComponent, {width: "400px"})
dialogRef.afterClosed().subscribe(res => { dialogRef.afterClosed().subscribe(res => {
@ -97,4 +127,6 @@ export class ActiveScheduleComponent implements OnInit{
} }
}) })
} }
} }

View File

@ -0,0 +1,4 @@
.dialog-padding {
padding-left: 5px;
padding-right: 5px;
}

View File

@ -0,0 +1,11 @@
<h1 mat-dialog-title>Set Stoptime Manually</h1>
<mat-dialog-content>
<mat-form-field appearance="outline" class="long-form dialog-padding">
<mat-label>Spent Minutes</mat-label>
<input matInput type="number" [formControl]="formControl">
</mat-form-field>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-raised-button (click)="cancel()">Cancel</button>
<button mat-raised-button color="primary" (click)="save()" [disabled]="formControl.invalid">Confirm</button>
</mat-dialog-actions>

View File

@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { StopScheduleManuallyComponent } from './stop-schedule-manually.component';
describe('StopScheduleManuallyComponent', () => {
let component: StopScheduleManuallyComponent;
let fixture: ComponentFixture<StopScheduleManuallyComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [StopScheduleManuallyComponent]
});
fixture = TestBed.createComponent(StopScheduleManuallyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,34 @@
import {Component, Inject} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {ScheduleInfo, ScheduleService} from "../../../../api";
import {FormControl, Validators} from "@angular/forms";
@Component({
selector: 'app-stop-schedule-manually',
templateUrl: './stop-schedule-manually.component.html',
styleUrls: ['./stop-schedule-manually.component.css']
})
export class StopScheduleManuallyComponent {
formControl: FormControl = new FormControl('', [Validators.required])
constructor(@Inject(MAT_DIALOG_DATA) public schedule: ScheduleInfo,
private scheduleService: ScheduleService,
private dialogRef: MatDialogRef<StopScheduleManuallyComponent>) {
}
cancel() {
this.dialogRef.close();
}
save() {
console.log(this.schedule.scheduleID)
this.scheduleService.schedulesScheduleIDStopManualPost(this.schedule.scheduleID, {
duration: this.formControl.value
}).subscribe({
next: resp => {
this.dialogRef.close(Number(this.formControl.value))
}
})
}
}

View File

@ -12,6 +12,7 @@
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/> <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</head> </head>
<body class="mat-typography"> <body class="mat-typography">
<app-root></app-root> <app-root></app-root>

View File

@ -2,3 +2,7 @@
html, body { height: 100%; } html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
.long-form {
width: 100%;
}

View File

@ -1882,6 +1882,47 @@ paths:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/SimpleStatusResponse' $ref: '#/components/schemas/SimpleStatusResponse'
/schedules/{scheduleID}/stopManual:
post:
security:
- API_TOKEN: []
tags:
- schedule
description: gets details of schedule
summary: load schedule
parameters:
- name: scheduleID
in: path
description: internal id of schedule
required: true
schema:
type: number
example: 1
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ManualScheduleStopInfo'
responses:
200:
description: Operation successfull
content:
application/json:
schema:
$ref: '#/components/schemas/ScheduleInfo'
403:
description: No permission
content:
application/json:
schema:
$ref: '#/components/schemas/SimpleStatusResponse'
404:
description: Schedule not found
content:
application/json:
schema:
$ref: '#/components/schemas/SimpleStatusResponse'
/history/workingStatus: /history/workingStatus:
get: get:
@ -2663,5 +2704,12 @@ components:
type: number type: number
description: Number of minutes the task was active description: Number of minutes the task was active
example: 122 example: 122
ManualScheduleStopInfo:
required:
- duration
additionalProperties: false
properties:
duration:
type: number
description: duration in minutes
example: 10