issue-95 #101
@ -275,4 +275,20 @@ public class ScheduleController {
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package core.services;
|
||||
|
||||
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.AdvancedScheduleInfo;
|
||||
import core.api.models.timemanager.taskSchedule.scheduleInfos.BasicScheduleFieldInfo;
|
||||
@ -21,6 +22,7 @@ import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@ -237,4 +239,9 @@ public class TaskScheduleService {
|
||||
}
|
||||
return filteredSchedules;
|
||||
}
|
||||
|
||||
public void finishScheduleManual(AbstractSchedule schedule, ManualScheduleStopInfo manualScheduleStopInfo) {
|
||||
schedule.setStopTime(schedule.getStartTime().plusMinutes(manualScheduleStopInfo.getDuration()));
|
||||
scheduleRepository.save(schedule);
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ model/inlineResponse403.ts
|
||||
model/inlineResponse409.ts
|
||||
model/loginRequest.ts
|
||||
model/loginResponse.ts
|
||||
model/manualScheduleStopInfo.ts
|
||||
model/models.ts
|
||||
model/passwordChangeRequest.ts
|
||||
model/propertiesInfo.ts
|
||||
|
@ -21,6 +21,7 @@ import { Observable } from 'rxjs';
|
||||
import { AdvancedScheduleFieldInfo } from '../model/models';
|
||||
import { BasicScheduleFieldInfo } from '../model/models';
|
||||
import { ForgottenActivityRequest } from '../model/models';
|
||||
import { ManualScheduleStopInfo } from '../model/models';
|
||||
import { ScheduleActivateInfo } from '../model/models';
|
||||
import { ScheduleInfo } 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 at once
|
||||
|
20
frontend/src/api/model/manualScheduleStopInfo.ts
Normal file
20
frontend/src/api/model/manualScheduleStopInfo.ts
Normal 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;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ export * from './inlineResponse403';
|
||||
export * from './inlineResponse409';
|
||||
export * from './loginRequest';
|
||||
export * from './loginResponse';
|
||||
export * from './manualScheduleStopInfo';
|
||||
export * from './passwordChangeRequest';
|
||||
export * from './propertiesInfo';
|
||||
export * from './propertyInfo';
|
||||
|
@ -86,6 +86,9 @@ import {NgApexchartsModule} from "ng-apexcharts";
|
||||
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 { 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({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
@ -130,6 +133,7 @@ import { ScheduleHistoryComponent } from './statistics/schedule-history/schedule
|
||||
SimpleActivityDiagramComponent,
|
||||
HeatmapActivityComponent,
|
||||
ScheduleHistoryComponent,
|
||||
StopScheduleManuallyComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
@ -171,6 +175,8 @@ import { ScheduleHistoryComponent } from './statistics/schedule-history/schedule
|
||||
MatSliderModule,
|
||||
NgxSliderModule,
|
||||
NgApexchartsModule,
|
||||
MatButtonToggleModule,
|
||||
MatGridListModule,
|
||||
],
|
||||
providers: [
|
||||
HttpClientModule,
|
||||
|
@ -139,3 +139,26 @@
|
||||
color: white;
|
||||
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;
|
||||
}
|
||||
|
@ -13,7 +13,19 @@
|
||||
<p class="gray-text">Running for {{displayTime}}</p>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button class="grayBtn" (click)="stopTask(false)">Stop</button>
|
||||
<button mat-raised-button class="greenBtn" *ngIf="activeSchedule!.task.finishable" (click)="stopTask(true)">Finish</button>
|
||||
<button class="btn btn-secondary" (click)="stopTask(false)">Stop</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>
|
||||
|
@ -4,6 +4,7 @@ import {StopActiveScheduleInfo} from "./StopActiveScheduleInfo";
|
||||
import {TaskOverviewComponent} from "../task-overview/task-overview.component";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
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 {
|
||||
stopactiveScheduleResponse: StopActiveScheduleInfo,
|
||||
@ -89,6 +90,35 @@ export class ActiveScheduleComponent implements OnInit{
|
||||
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() {
|
||||
const dialogRef = this.dialog.open(ForgottenTaskStartDialogComponent, {width: "400px"})
|
||||
dialogRef.afterClosed().subscribe(res => {
|
||||
@ -97,4 +127,6 @@ export class ActiveScheduleComponent implements OnInit{
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
.dialog-padding {
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
@ -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>
|
@ -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();
|
||||
});
|
||||
});
|
@ -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))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
<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 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>
|
||||
<body class="mat-typography">
|
||||
<app-root></app-root>
|
||||
|
@ -2,3 +2,7 @@
|
||||
|
||||
html, body { height: 100%; }
|
||||
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
|
||||
|
||||
.long-form {
|
||||
width: 100%;
|
||||
}
|
||||
|
52
openapi.yaml
52
openapi.yaml
@ -1882,6 +1882,47 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$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:
|
||||
get:
|
||||
@ -2663,5 +2704,12 @@ components:
|
||||
type: number
|
||||
description: Number of minutes the task was active
|
||||
example: 122
|
||||
|
||||
|
||||
ManualScheduleStopInfo:
|
||||
required:
|
||||
- duration
|
||||
additionalProperties: false
|
||||
properties:
|
||||
duration:
|
||||
type: number
|
||||
description: duration in minutes
|
||||
example: 10
|
Loading…
Reference in New Issue
Block a user