issue-32 #34

Merged
sebastian merged 6 commits from issue-32 into master 2023-10-29 12:35:11 +01:00
8 changed files with 128 additions and 10 deletions
Showing only changes of commit 30cbe60d6d - Show all commits

View File

@ -6,8 +6,13 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Load worked minutes when reloading dashboard"> <list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Load worked minutes when reloading dashboard">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/BasicTaskScheduleRepository.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/BasicTaskScheduleRepository.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component.ts" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../frontend/src/api/api/schedule.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/api/schedule.service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/app.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/app.module.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/app/dashboard/dashboard.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/dashboard/dashboard.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../openapi.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../openapi.yaml" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -18,15 +23,15 @@
<option name="RECENT_TEMPLATES"> <option name="RECENT_TEMPLATES">
<list> <list>
<option value="Interface" /> <option value="Interface" />
<option value="Class" />
<option value="Enum" /> <option value="Enum" />
<option value="Class" />
</list> </list>
</option> </option>
</component> </component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY"> <option name="RECENT_BRANCH_BY_REPOSITORY">
<map> <map>
<entry key="$PROJECT_DIR$/.." value="issue-29" /> <entry key="$PROJECT_DIR$/.." value="master" />
</map> </map>
</option> </option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
@ -236,7 +241,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1698512069065</updated> <updated>1698512069065</updated>
</task> </task>
<option name="localTasksCounter" value="17" /> <task id="LOCAL-00017" summary="Work also with start schedule based on last minute">
<option name="closed" value="true" />
<created>1698569793571</created>
<option name="number" value="00017" />
<option name="presentableId" value="LOCAL-00017" />
<option name="project" value="LOCAL" />
<updated>1698569793571</updated>
</task>
<option name="localTasksCounter" value="18" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">

View File

@ -220,4 +220,15 @@ public class ScheduleController {
return ResponseEntity.ok(new TaskScheduleStopResponse(serviceResult.getResult())); return ResponseEntity.ok(new TaskScheduleStopResponse(serviceResult.getResult()));
} }
} }
@GetMapping("/schedules/missed")
public ResponseEntity<?> loadMissedSchedules() {
Optional<User> user = userRepository.findByUsername(SecurityContextHolder.getContext().getAuthentication().getName());
if(user.isEmpty()) {
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
}
List<BasicTaskSchedule> schedules = taskScheduleService.loadMissedSchedules(user.get());
return ResponseEntity.ok(schedules.stream().map(ScheduleInfo::new).toList());
}
} }

View File

@ -39,4 +39,7 @@ public interface BasicTaskScheduleRepository extends CrudRepository<BasicTaskSch
@Query(value = "SELECT bts FROM BasicTaskSchedule bts WHERE bts.task.taskgroup.user = ?1 AND bts.scheduleDate = ?2 AND bts.finishedTime IS NOT NULL") @Query(value = "SELECT bts FROM BasicTaskSchedule bts WHERE bts.task.taskgroup.user = ?1 AND bts.scheduleDate = ?2 AND bts.finishedTime IS NOT NULL")
List<BasicTaskSchedule> findAllFinishedByUserAndDate(User user, LocalDate now); List<BasicTaskSchedule> findAllFinishedByUserAndDate(User user, LocalDate now);
@Query(value = "SELECT bts FROM BasicTaskSchedule bts WHERE bts.task.taskgroup.user = ?1 AND bts.startTime IS NULL AND bts.finishedTime IS NULL")
List<BasicTaskSchedule> findAllUnstartedSchedulesOfUser(User user);
} }

View File

@ -213,4 +213,16 @@ public class TaskScheduleService {
} }
} }
public List<BasicTaskSchedule> loadMissedSchedules(User user) {
List<BasicTaskSchedule> unstartedSchedules = basicTaskScheduleRepository.findAllUnstartedSchedulesOfUser(user);
LocalDate currentDate = LocalDate.now();
List<BasicTaskSchedule> missedSchedules = new LinkedList<>();
for(BasicTaskSchedule schedule : unstartedSchedules) {
if(schedule.getScheduleDate().isBefore(currentDate)) {
missedSchedules.add(schedule);
}
}
return missedSchedules;
}
} }

View File

@ -202,6 +202,61 @@ export class ScheduleService {
); );
} }
/**
* registers forgotten schedule
* Registers forgotten schedule
* @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 schedulesMissedGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<ScheduleInfo>>;
public schedulesMissedGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<ScheduleInfo>>>;
public schedulesMissedGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<ScheduleInfo>>>;
public schedulesMissedGet(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
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/missed`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}
/** /**
* activates schedule * activates schedule
* activates schedule * activates schedule

View File

@ -69,6 +69,7 @@ import { TaskgroupOverviewComponent } from './dashboard/taskgroup-overview/taskg
import { TaskOverviewComponent } from './dashboard/task-overview/task-overview.component'; import { TaskOverviewComponent } from './dashboard/task-overview/task-overview.component';
import { ForgottenTaskStartDialogComponent } from './dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component'; import { ForgottenTaskStartDialogComponent } from './dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component';
import {MatAutocompleteModule} from "@angular/material/autocomplete"; import {MatAutocompleteModule} from "@angular/material/autocomplete";
import { MissedSchedulesComponent } from './missed-schedules/missed-schedules.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
AppComponent, AppComponent,
@ -100,7 +101,8 @@ import {MatAutocompleteModule} from "@angular/material/autocomplete";
ActiveScheduleComponent, ActiveScheduleComponent,
TaskgroupOverviewComponent, TaskgroupOverviewComponent,
TaskOverviewComponent, TaskOverviewComponent,
ForgottenTaskStartDialogComponent ForgottenTaskStartDialogComponent,
MissedSchedulesComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View File

@ -3,7 +3,7 @@
<mat-card *ngIf="missedSchedules" class="red-card"> <mat-card *ngIf="missedSchedules" class="red-card">
<mat-card-content> <mat-card-content>
<p>There are missed schedules. Please reschedule them.</p> <p>There are missed schedules. Please reschedule them.</p>
<a class="btn-link" routerLink="/">Reschedule</a> <a class="btn-link" routerLink="/reschedule">Reschedule</a>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
<h1 class="dashboard-heading">Now<b class="today-worked-info">Today: {{workedMinutesToday}} min</b></h1> <h1 class="dashboard-heading">Now<b class="today-worked-info">Today: {{workedMinutesToday}} min</b></h1>

View File

@ -1694,8 +1694,29 @@ paths:
schema: schema:
type: object type: object
$ref: "#/components/schemas/SimpleStatusResponse" $ref: "#/components/schemas/SimpleStatusResponse"
/schedules/missed:
get:
security:
- API_TOKEN: []
tags:
- schedule
description: Registers forgotten schedule
summary: registers forgotten schedule
responses:
200:
description: Operation successfull
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ScheduleInfo'
403:
description: User not found/No permission
content:
application/json:
schema:
$ref: '#/components/schemas/SimpleStatusResponse'
components: components:
securitySchemes: securitySchemes:
@ -2232,3 +2253,4 @@ components:
type: number type: number
description: number of minutes spent on task description: number of minutes spent on task
example: 10 example: 10