issue-23 #24
@ -5,8 +5,9 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Delete Schedules">
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/schedules/schedule-dashboard/schedule-dashboard.component.html" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/app/schedules/scheduler/scheduler.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/schedules/scheduler/scheduler.component.html" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/tasks/TaskShortInfo.java" 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/models/timemanager/taskSchedule/ScheduleInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/taskSchedule/ScheduleInfo.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../frontend/src/app/schedules/scheduler/scheduler.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/app/schedules/scheduler/scheduler.component.ts" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -96,6 +97,8 @@
|
||||
<workItem from="1697969480767" duration="6407000" />
|
||||
<workItem from="1697989716016" duration="3814000" />
|
||||
<workItem from="1698067098771" duration="4770000" />
|
||||
<workItem from="1698127431684" duration="2039000" />
|
||||
<workItem from="1698164397550" duration="2329000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
|
||||
<option name="closed" value="true" />
|
||||
@ -180,7 +183,7 @@
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java</url>
|
||||
<line>36</line>
|
||||
<line>41</line>
|
||||
<option name="timeStamp" value="2" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
|
@ -3,9 +3,11 @@ package core.api.controller;
|
||||
import core.api.models.auth.SimpleStatusResponse;
|
||||
import core.api.models.timemanager.taskSchedule.BasicTaskScheduleEntityInfo;
|
||||
import core.api.models.timemanager.taskSchedule.BasicTaskScheduleFieldInfo;
|
||||
import core.api.models.timemanager.taskSchedule.ScheduleInfo;
|
||||
import core.entities.timemanager.BasicTaskSchedule;
|
||||
import core.entities.timemanager.ScheduleType;
|
||||
import core.entities.timemanager.Task;
|
||||
import core.repositories.timemanager.BasicTaskScheduleRepository;
|
||||
import core.services.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -24,10 +26,13 @@ public class ScheduleController {
|
||||
|
||||
private final TaskService taskService;
|
||||
private final TaskScheduleService taskScheduleService;
|
||||
private final BasicTaskScheduleRepository basicTaskScheduleRepository;
|
||||
|
||||
public ScheduleController(@Autowired TaskService taskService, @Autowired TaskScheduleService taskScheduleService) {
|
||||
public ScheduleController(@Autowired TaskService taskService, @Autowired TaskScheduleService taskScheduleService,
|
||||
BasicTaskScheduleRepository basicTaskScheduleRepository) {
|
||||
this.taskService = taskService;
|
||||
this.taskScheduleService = taskScheduleService;
|
||||
this.basicTaskScheduleRepository = basicTaskScheduleRepository;
|
||||
}
|
||||
|
||||
@GetMapping("/schedules/{taskID}/{scheduleType}")
|
||||
@ -96,4 +101,24 @@ public class ScheduleController {
|
||||
taskScheduleService.deleteBasicSchedule(permissionResult.getResult());
|
||||
return ResponseEntity.ok(new SimpleStatusResponse("success"));
|
||||
}
|
||||
|
||||
@GetMapping("/schedules/today")
|
||||
public ResponseEntity<?> loadTodaysSchedules() {
|
||||
ServiceResult<List<BasicTaskSchedule>> todaysSchedules = taskScheduleService.loadTodaysSchedule(SecurityContextHolder.getContext().getAuthentication().getName());
|
||||
if(todaysSchedules.getExitCode() == ServiceExitCode.MISSING_ENTITY) {
|
||||
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
||||
} else {
|
||||
return ResponseEntity.ok(todaysSchedules.getResult().stream().map(ScheduleInfo::new).toList());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/schedules")
|
||||
public ResponseEntity<?> loadSchedules() {
|
||||
ServiceResult<List<BasicTaskSchedule>> schedules = taskScheduleService.loadSchedules(SecurityContextHolder.getContext().getAuthentication().getName());
|
||||
if(schedules.getExitCode() == ServiceExitCode.MISSING_ENTITY) {
|
||||
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
|
||||
} else {
|
||||
return ResponseEntity.ok(schedules.getResult().stream().map(ScheduleInfo::new).toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
package core.api.models.timemanager.taskSchedule;
|
||||
|
||||
public abstract class AbstractScheduleShortInfo {
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package core.api.models.timemanager.taskSchedule;
|
||||
|
||||
import core.entities.timemanager.BasicTaskSchedule;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class BasicScheduleShortInfo extends AbstractScheduleShortInfo {
|
||||
|
||||
private LocalDate scheduleDate;
|
||||
|
||||
public BasicScheduleShortInfo(BasicTaskSchedule basicTaskSchedule) {
|
||||
this.scheduleDate = basicTaskSchedule.getScheduleDate();
|
||||
}
|
||||
|
||||
public LocalDate getScheduleDate() {
|
||||
return scheduleDate;
|
||||
}
|
||||
|
||||
public void setScheduleDate(LocalDate scheduleDate) {
|
||||
this.scheduleDate = scheduleDate;
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package core.api.models.timemanager.taskSchedule;
|
||||
|
||||
import core.api.models.timemanager.taskgroup.TaskgroupEntityInfo;
|
||||
import core.api.models.timemanager.tasks.TaskShortInfo;
|
||||
import core.entities.timemanager.BasicTaskSchedule;
|
||||
import core.entities.timemanager.ScheduleType;
|
||||
import core.entities.timemanager.Taskgroup;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public class ScheduleInfo {
|
||||
|
||||
private long scheduleID;
|
||||
private ScheduleType scheduleType;
|
||||
private LocalDateTime startTime;
|
||||
|
||||
private LocalDateTime finishTime;
|
||||
private int activeMinutes;
|
||||
private AbstractScheduleShortInfo schedule;
|
||||
|
||||
private List<TaskgroupEntityInfo> taskgroupPath;
|
||||
|
||||
private TaskShortInfo task;
|
||||
|
||||
public ScheduleInfo(BasicTaskSchedule basicTaskSchedule) {
|
||||
this.scheduleID = basicTaskSchedule.getScheduleID();
|
||||
this.scheduleType = ScheduleType.BASIC;
|
||||
this.startTime = basicTaskSchedule.getStartTime();
|
||||
this.finishTime = basicTaskSchedule.getFinishedTime();
|
||||
|
||||
if(this.finishTime == null && this.startTime != null) {
|
||||
this.activeMinutes = (int) Duration.between(basicTaskSchedule.getStartTime(), LocalDate.now()).toMinutes();
|
||||
} else if(this.startTime != null){
|
||||
this.activeMinutes = (int) Duration.between(basicTaskSchedule.getStartTime(), basicTaskSchedule.getFinishedTime()).toMinutes();
|
||||
}
|
||||
|
||||
this.schedule = new BasicScheduleShortInfo(basicTaskSchedule);
|
||||
this.task = new TaskShortInfo(basicTaskSchedule.getTask());
|
||||
List<Taskgroup> taskgroupPath = Taskgroup.getAncestorList(basicTaskSchedule.getTask().getTaskgroup());
|
||||
taskgroupPath.add(basicTaskSchedule.getTask().getTaskgroup());
|
||||
this.taskgroupPath = taskgroupPath.stream().map(TaskgroupEntityInfo::new).toList();
|
||||
}
|
||||
|
||||
public long getScheduleID() {
|
||||
return scheduleID;
|
||||
}
|
||||
|
||||
public void setScheduleID(long scheduleID) {
|
||||
this.scheduleID = scheduleID;
|
||||
}
|
||||
|
||||
public ScheduleType getScheduleType() {
|
||||
return scheduleType;
|
||||
}
|
||||
|
||||
public void setScheduleType(ScheduleType scheduleType) {
|
||||
this.scheduleType = scheduleType;
|
||||
}
|
||||
|
||||
public LocalDateTime getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(LocalDateTime startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getFinishTime() {
|
||||
return finishTime;
|
||||
}
|
||||
|
||||
public void setFinishTime(LocalDateTime finishTime) {
|
||||
this.finishTime = finishTime;
|
||||
}
|
||||
|
||||
public int getActiveMinutes() {
|
||||
return activeMinutes;
|
||||
}
|
||||
|
||||
public void setActiveMinutes(int activeMinutes) {
|
||||
this.activeMinutes = activeMinutes;
|
||||
}
|
||||
|
||||
public AbstractScheduleShortInfo getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
public void setSchedule(AbstractScheduleShortInfo schedule) {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
|
||||
public List<TaskgroupEntityInfo> getTaskgroupPath() {
|
||||
return taskgroupPath;
|
||||
}
|
||||
|
||||
public void setTaskgroupPath(List<TaskgroupEntityInfo> taskgroupPath) {
|
||||
this.taskgroupPath = taskgroupPath;
|
||||
}
|
||||
|
||||
public TaskShortInfo getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
public void setTask(TaskShortInfo task) {
|
||||
this.task = task;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package core.api.models.timemanager.tasks;
|
||||
|
||||
import core.entities.timemanager.Task;
|
||||
|
||||
public class TaskShortInfo {
|
||||
|
||||
private long taskID;
|
||||
private String taskName;
|
||||
|
||||
public TaskShortInfo(Task task) {
|
||||
this.taskID = task.getTaskID();
|
||||
this.taskName = task.getTaskName();
|
||||
}
|
||||
|
||||
public long getTaskID() {
|
||||
return taskID;
|
||||
}
|
||||
|
||||
public void setTaskID(long taskID) {
|
||||
this.taskID = taskID;
|
||||
}
|
||||
|
||||
public String getTaskName() {
|
||||
return taskName;
|
||||
}
|
||||
|
||||
public void setTaskName(String taskName) {
|
||||
this.taskName = taskName;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package core.repositories.timemanager;
|
||||
|
||||
import core.entities.User;
|
||||
import core.entities.timemanager.BasicTaskSchedule;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
@ -7,6 +8,8 @@ import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface BasicTaskScheduleRepository extends CrudRepository<BasicTaskSchedule, Long> {
|
||||
@ -15,4 +18,10 @@ public interface BasicTaskScheduleRepository extends CrudRepository<BasicTaskSch
|
||||
@Transactional
|
||||
@Query(value = "DELETE FROM BasicTaskSchedule bts WHERE bts.scheduleID = ?1")
|
||||
void deleteBasicTaskScheduleByID(long id);
|
||||
|
||||
@Query(value = "SELECT bts FROM BasicTaskSchedule bts WHERE bts.task.taskgroup.user = ?1")
|
||||
List<BasicTaskSchedule> findAllByUser(User user);
|
||||
|
||||
@Query(value = "SELECT bts FROM BasicTaskSchedule bts WHERE bts.task.taskgroup.user = ?1 AND bts.scheduleDate = ?2")
|
||||
List<BasicTaskSchedule> findAllByUserAndDate(User user, LocalDate localDate);
|
||||
}
|
||||
|
@ -1,13 +1,17 @@
|
||||
package core.services;
|
||||
|
||||
import core.api.models.timemanager.taskSchedule.BasicTaskScheduleFieldInfo;
|
||||
import core.entities.User;
|
||||
import core.entities.timemanager.BasicTaskSchedule;
|
||||
import core.entities.timemanager.Task;
|
||||
import core.repositories.UserRepository;
|
||||
import core.repositories.timemanager.BasicTaskScheduleRepository;
|
||||
import core.repositories.timemanager.TaskRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@ -15,11 +19,14 @@ public class TaskScheduleService {
|
||||
|
||||
private final BasicTaskScheduleRepository basicTaskScheduleRepository;
|
||||
private final TaskRepository taskRepository;
|
||||
private final UserRepository userRepository;
|
||||
|
||||
public TaskScheduleService(@Autowired BasicTaskScheduleRepository basicTaskScheduleRepository,
|
||||
@Autowired TaskRepository taskRepository) {
|
||||
@Autowired TaskRepository taskRepository,
|
||||
UserRepository userRepository) {
|
||||
this.basicTaskScheduleRepository = basicTaskScheduleRepository;
|
||||
this.taskRepository = taskRepository;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
public ServiceResult<BasicTaskSchedule> createBasicTaskSchedule(Task task, BasicTaskScheduleFieldInfo basicTaskScheduleFieldInfo) {
|
||||
@ -44,4 +51,16 @@ public class TaskScheduleService {
|
||||
public void deleteBasicSchedule(BasicTaskSchedule basicTaskSchedule) {
|
||||
basicTaskScheduleRepository.deleteBasicTaskScheduleByID(basicTaskSchedule.getScheduleID());
|
||||
}
|
||||
|
||||
public ServiceResult<List<BasicTaskSchedule>> loadTodaysSchedule(String username) {
|
||||
Optional<User> user = userRepository.findByUsername(username);
|
||||
return user.map(value -> new ServiceResult<>(basicTaskScheduleRepository.findAllByUserAndDate(value, LocalDate.now()))).orElseGet(() ->
|
||||
new ServiceResult<>(ServiceExitCode.MISSING_ENTITY));
|
||||
}
|
||||
|
||||
public ServiceResult<List<BasicTaskSchedule>> loadSchedules(String username) {
|
||||
Optional<User> user = userRepository.findByUsername(username);
|
||||
return user.map(value -> new ServiceResult<>(basicTaskScheduleRepository.findAllByUser(value))).orElseGet(() ->
|
||||
new ServiceResult<>(ServiceExitCode.MISSING_ENTITY));
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ model/signUpRequest.ts
|
||||
model/simpleStatusResponse.ts
|
||||
model/taskEntityInfo.ts
|
||||
model/taskFieldInfo.ts
|
||||
model/taskShortInfo.ts
|
||||
model/taskgroupDetailInfo.ts
|
||||
model/taskgroupEntityInfo.ts
|
||||
model/taskgroupFieldInfo.ts
|
||||
|
@ -409,4 +409,59 @@ export class ScheduleService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* get today\'s schedules
|
||||
* get all schedules of 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 schedulesTodayGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<ScheduleInfo>>;
|
||||
public schedulesTodayGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<ScheduleInfo>>>;
|
||||
public schedulesTodayGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<ScheduleInfo>>>;
|
||||
public schedulesTodayGet(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/today`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ export * from './signUpRequest';
|
||||
export * from './simpleStatusResponse';
|
||||
export * from './taskEntityInfo';
|
||||
export * from './taskFieldInfo';
|
||||
export * from './taskShortInfo';
|
||||
export * from './taskgroupDetailInfo';
|
||||
export * from './taskgroupEntityInfo';
|
||||
export * from './taskgroupFieldInfo';
|
||||
|
@ -9,7 +9,9 @@
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { BasicScheduleEntityInfo } from './basicScheduleEntityInfo';
|
||||
import { BasicScheduleFieldInfo } from './basicScheduleFieldInfo';
|
||||
import { TaskgroupEntityInfo } from './taskgroupEntityInfo';
|
||||
import { TaskShortInfo } from './taskShortInfo';
|
||||
|
||||
|
||||
export interface ScheduleInfo {
|
||||
@ -21,7 +23,21 @@ export interface ScheduleInfo {
|
||||
* type of schedule
|
||||
*/
|
||||
scheduleType: ScheduleInfo.ScheduleTypeEnum;
|
||||
schedule: BasicScheduleEntityInfo;
|
||||
/**
|
||||
* 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;
|
||||
schedule: BasicScheduleFieldInfo;
|
||||
task: TaskShortInfo;
|
||||
taskgroupPath: Array<TaskgroupEntityInfo>;
|
||||
}
|
||||
export namespace ScheduleInfo {
|
||||
export type ScheduleTypeEnum = 'BASIC' | 'MODERATE' | 'ADVANCED';
|
||||
|
24
frontend/src/api/model/taskShortInfo.ts
Normal file
24
frontend/src/api/model/taskShortInfo.ts
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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 TaskShortInfo {
|
||||
/**
|
||||
* internal id of task
|
||||
*/
|
||||
taskID: number;
|
||||
/**
|
||||
* name of task
|
||||
*/
|
||||
taskName: string;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
TaskEntityInfo,
|
||||
TaskgroupEntityInfo,
|
||||
TaskgroupService,
|
||||
TaskService
|
||||
TaskService, TaskShortInfo
|
||||
} from "../../../api";
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {CalendarDateFormatter, CalendarEvent, CalendarView} from "angular-calendar";
|
||||
@ -49,6 +49,7 @@ export class SchedulerComponent implements OnInit{
|
||||
taskgroup: TaskgroupEntityInfo | undefined
|
||||
taskgroupPath: TaskgroupEntityInfo[] = []
|
||||
taskgroupID: number = -1;
|
||||
scheduleID: number = -1;
|
||||
@ViewChild('navLinkList') navLinkListComponent: NavigationLinkListComponent | undefined
|
||||
|
||||
task: TaskEntityInfo | undefined
|
||||
@ -92,10 +93,14 @@ export class SchedulerComponent implements OnInit{
|
||||
next: resp => {
|
||||
this.task = resp;
|
||||
this.initializeNavigationLinkList()
|
||||
this.fetchBasicSchedules();
|
||||
this.fetschSchedules();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if(params.has('scheduleID')) {
|
||||
this.scheduleID = Number(params.get('scheduleID'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -128,63 +133,40 @@ export class SchedulerComponent implements OnInit{
|
||||
this.refresh.next();
|
||||
}
|
||||
|
||||
fetchBasicSchedules() {
|
||||
this.activatedRoute.paramMap.subscribe(params => {
|
||||
if(params.has('scheduleID')) {
|
||||
this.scheduleService.schedulesTaskIDScheduleTypeGet(this.task!.taskID, "BASIC").subscribe({
|
||||
next: resp => {
|
||||
resp.forEach(basicSchedule => {
|
||||
if(basicSchedule.scheduleID === Number(params.get('scheduleID'))) {
|
||||
this.events.push({
|
||||
start: new Date(basicSchedule.scheduleDate),
|
||||
title: this.computeTaskPath(),
|
||||
color: colors['yellow'],
|
||||
allDay: true,
|
||||
})
|
||||
this.basicScheduler?.setEditedBasicSchedule(basicSchedule);
|
||||
} else {
|
||||
this.events.push({
|
||||
start: new Date(basicSchedule.scheduleDate),
|
||||
title: this.computeTaskPath(),
|
||||
color: colors['red'],
|
||||
allDay: true,
|
||||
})
|
||||
}
|
||||
})
|
||||
this.refresh.next();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.scheduleService.schedulesTaskIDScheduleTypeGet(this.task!.taskID, "BASIC").subscribe({
|
||||
next: resp => {
|
||||
resp.forEach(basicSchedule => {
|
||||
this.events.push({
|
||||
start: new Date(basicSchedule.scheduleDate),
|
||||
title: this.computeTaskPath(),
|
||||
color: colors['red'],
|
||||
allDay: true,
|
||||
})
|
||||
fetschSchedules() {
|
||||
this.scheduleService.schedulesGet().subscribe({
|
||||
next: resp => {
|
||||
resp.forEach(schedule => {
|
||||
let color: EventColor = colors['red']
|
||||
if(schedule.scheduleID === this.scheduleID) {
|
||||
color = colors['yellow']
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
})
|
||||
this.refresh.next();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
eventClicked({ event }: { event: CalendarEvent }): void {
|
||||
this.router.navigateByUrl("/taskgroups/" + this.taskgroupID.toString() + "/tasks/" + this.task!.taskID )
|
||||
}
|
||||
|
||||
computeTaskPath() {
|
||||
computeTaskPath(taskgroupPath: TaskgroupEntityInfo[], task: TaskShortInfo | TaskEntityInfo) {
|
||||
let result = "";
|
||||
this.taskgroupPath.forEach(taskgroupPathPart => {
|
||||
taskgroupPath.forEach(taskgroupPathPart => {
|
||||
result += taskgroupPathPart.taskgroupName + "/"
|
||||
});
|
||||
result += this.taskgroup!.taskgroupName + "/"
|
||||
result += this.task!.taskName
|
||||
result += task!.taskName
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
59
openapi.yaml
59
openapi.yaml
@ -1355,6 +1355,24 @@ paths:
|
||||
schema:
|
||||
type: object
|
||||
$ref: "#/components/schemas/SimpleStatusResponse"
|
||||
/schedules/today:
|
||||
get:
|
||||
security:
|
||||
- API_TOKEN: []
|
||||
tags:
|
||||
- schedule
|
||||
description: get all schedules of today
|
||||
summary: get today's schedules
|
||||
responses:
|
||||
200:
|
||||
description: Operation successfull
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/ScheduleInfo'
|
||||
|
||||
components:
|
||||
securitySchemes:
|
||||
API_TOKEN:
|
||||
@ -1712,7 +1730,12 @@ components:
|
||||
required:
|
||||
- scheduleID
|
||||
- scheduleType
|
||||
- startTime
|
||||
- finishTime
|
||||
- activeMinutes
|
||||
- schedule
|
||||
- task
|
||||
- taskgroupPath
|
||||
additionalProperties: false
|
||||
properties:
|
||||
scheduleID:
|
||||
@ -1727,7 +1750,41 @@ components:
|
||||
- BASIC
|
||||
- MODERATE
|
||||
- ADVANCED
|
||||
startTime:
|
||||
type: string
|
||||
format: date-time
|
||||
description: date on which the task schedule was started
|
||||
finishedTime:
|
||||
type: string
|
||||
format: date-time
|
||||
description: date on which the tasks schedule was finished
|
||||
activeMinutes:
|
||||
type: number
|
||||
description: number in minutes that the schedule was active
|
||||
example: 10
|
||||
schedule:
|
||||
type: object
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/BasicScheduleEntityInfo'
|
||||
- $ref: '#/components/schemas/BasicScheduleFieldInfo'
|
||||
task:
|
||||
type: object
|
||||
$ref: '#/components/schemas/TaskShortInfo'
|
||||
taskgroupPath:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/TaskgroupEntityInfo'
|
||||
|
||||
TaskShortInfo:
|
||||
required:
|
||||
- taskID
|
||||
- taskName
|
||||
additionalProperties: false
|
||||
properties:
|
||||
taskID:
|
||||
type: number
|
||||
description: internal id of task
|
||||
example: 1
|
||||
taskName:
|
||||
type: string
|
||||
description: name of task
|
||||
example: "Vorlesung zusammenfassen"
|
Loading…
Reference in New Issue
Block a user