Merge pull request 'issue-23' (#24) from issue-23 into issue-18
Reviewed-on: Sebastian/TimeManager#24
This commit is contained in:
commit
eb1f5275b7
@ -5,8 +5,9 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Delete Schedules">
|
<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 afterPath="$PROJECT_DIR$/src/main/java/core/api/models/timemanager/tasks/TaskShortInfo.java" 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 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" />
|
<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>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@ -96,6 +97,8 @@
|
|||||||
<workItem from="1697969480767" duration="6407000" />
|
<workItem from="1697969480767" duration="6407000" />
|
||||||
<workItem from="1697989716016" duration="3814000" />
|
<workItem from="1697989716016" duration="3814000" />
|
||||||
<workItem from="1698067098771" duration="4770000" />
|
<workItem from="1698067098771" duration="4770000" />
|
||||||
|
<workItem from="1698127431684" duration="2039000" />
|
||||||
|
<workItem from="1698164397550" duration="2329000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
|
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
@ -180,7 +183,7 @@
|
|||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java</url>
|
<url>file://$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java</url>
|
||||||
<line>36</line>
|
<line>41</line>
|
||||||
<option name="timeStamp" value="2" />
|
<option name="timeStamp" value="2" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
|
@ -3,9 +3,11 @@ package core.api.controller;
|
|||||||
import core.api.models.auth.SimpleStatusResponse;
|
import core.api.models.auth.SimpleStatusResponse;
|
||||||
import core.api.models.timemanager.taskSchedule.BasicTaskScheduleEntityInfo;
|
import core.api.models.timemanager.taskSchedule.BasicTaskScheduleEntityInfo;
|
||||||
import core.api.models.timemanager.taskSchedule.BasicTaskScheduleFieldInfo;
|
import core.api.models.timemanager.taskSchedule.BasicTaskScheduleFieldInfo;
|
||||||
|
import core.api.models.timemanager.taskSchedule.ScheduleInfo;
|
||||||
import core.entities.timemanager.BasicTaskSchedule;
|
import core.entities.timemanager.BasicTaskSchedule;
|
||||||
import core.entities.timemanager.ScheduleType;
|
import core.entities.timemanager.ScheduleType;
|
||||||
import core.entities.timemanager.Task;
|
import core.entities.timemanager.Task;
|
||||||
|
import core.repositories.timemanager.BasicTaskScheduleRepository;
|
||||||
import core.services.*;
|
import core.services.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@ -24,10 +26,13 @@ public class ScheduleController {
|
|||||||
|
|
||||||
private final TaskService taskService;
|
private final TaskService taskService;
|
||||||
private final TaskScheduleService taskScheduleService;
|
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.taskService = taskService;
|
||||||
this.taskScheduleService = taskScheduleService;
|
this.taskScheduleService = taskScheduleService;
|
||||||
|
this.basicTaskScheduleRepository = basicTaskScheduleRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/schedules/{taskID}/{scheduleType}")
|
@GetMapping("/schedules/{taskID}/{scheduleType}")
|
||||||
@ -96,4 +101,24 @@ public class ScheduleController {
|
|||||||
taskScheduleService.deleteBasicSchedule(permissionResult.getResult());
|
taskScheduleService.deleteBasicSchedule(permissionResult.getResult());
|
||||||
return ResponseEntity.ok(new SimpleStatusResponse("success"));
|
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;
|
package core.repositories.timemanager;
|
||||||
|
|
||||||
|
import core.entities.User;
|
||||||
import core.entities.timemanager.BasicTaskSchedule;
|
import core.entities.timemanager.BasicTaskSchedule;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
@ -7,6 +8,8 @@ import org.springframework.data.repository.CrudRepository;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface BasicTaskScheduleRepository extends CrudRepository<BasicTaskSchedule, Long> {
|
public interface BasicTaskScheduleRepository extends CrudRepository<BasicTaskSchedule, Long> {
|
||||||
@ -15,4 +18,10 @@ public interface BasicTaskScheduleRepository extends CrudRepository<BasicTaskSch
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Query(value = "DELETE FROM BasicTaskSchedule bts WHERE bts.scheduleID = ?1")
|
@Query(value = "DELETE FROM BasicTaskSchedule bts WHERE bts.scheduleID = ?1")
|
||||||
void deleteBasicTaskScheduleByID(long id);
|
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;
|
package core.services;
|
||||||
|
|
||||||
import core.api.models.timemanager.taskSchedule.BasicTaskScheduleFieldInfo;
|
import core.api.models.timemanager.taskSchedule.BasicTaskScheduleFieldInfo;
|
||||||
|
import core.entities.User;
|
||||||
import core.entities.timemanager.BasicTaskSchedule;
|
import core.entities.timemanager.BasicTaskSchedule;
|
||||||
import core.entities.timemanager.Task;
|
import core.entities.timemanager.Task;
|
||||||
|
import core.repositories.UserRepository;
|
||||||
import core.repositories.timemanager.BasicTaskScheduleRepository;
|
import core.repositories.timemanager.BasicTaskScheduleRepository;
|
||||||
import core.repositories.timemanager.TaskRepository;
|
import core.repositories.timemanager.TaskRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -15,11 +19,14 @@ public class TaskScheduleService {
|
|||||||
|
|
||||||
private final BasicTaskScheduleRepository basicTaskScheduleRepository;
|
private final BasicTaskScheduleRepository basicTaskScheduleRepository;
|
||||||
private final TaskRepository taskRepository;
|
private final TaskRepository taskRepository;
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
public TaskScheduleService(@Autowired BasicTaskScheduleRepository basicTaskScheduleRepository,
|
public TaskScheduleService(@Autowired BasicTaskScheduleRepository basicTaskScheduleRepository,
|
||||||
@Autowired TaskRepository taskRepository) {
|
@Autowired TaskRepository taskRepository,
|
||||||
|
UserRepository userRepository) {
|
||||||
this.basicTaskScheduleRepository = basicTaskScheduleRepository;
|
this.basicTaskScheduleRepository = basicTaskScheduleRepository;
|
||||||
this.taskRepository = taskRepository;
|
this.taskRepository = taskRepository;
|
||||||
|
this.userRepository = userRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceResult<BasicTaskSchedule> createBasicTaskSchedule(Task task, BasicTaskScheduleFieldInfo basicTaskScheduleFieldInfo) {
|
public ServiceResult<BasicTaskSchedule> createBasicTaskSchedule(Task task, BasicTaskScheduleFieldInfo basicTaskScheduleFieldInfo) {
|
||||||
@ -44,4 +51,16 @@ public class TaskScheduleService {
|
|||||||
public void deleteBasicSchedule(BasicTaskSchedule basicTaskSchedule) {
|
public void deleteBasicSchedule(BasicTaskSchedule basicTaskSchedule) {
|
||||||
basicTaskScheduleRepository.deleteBasicTaskScheduleByID(basicTaskSchedule.getScheduleID());
|
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/simpleStatusResponse.ts
|
||||||
model/taskEntityInfo.ts
|
model/taskEntityInfo.ts
|
||||||
model/taskFieldInfo.ts
|
model/taskFieldInfo.ts
|
||||||
|
model/taskShortInfo.ts
|
||||||
model/taskgroupDetailInfo.ts
|
model/taskgroupDetailInfo.ts
|
||||||
model/taskgroupEntityInfo.ts
|
model/taskgroupEntityInfo.ts
|
||||||
model/taskgroupFieldInfo.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 './simpleStatusResponse';
|
||||||
export * from './taskEntityInfo';
|
export * from './taskEntityInfo';
|
||||||
export * from './taskFieldInfo';
|
export * from './taskFieldInfo';
|
||||||
|
export * from './taskShortInfo';
|
||||||
export * from './taskgroupDetailInfo';
|
export * from './taskgroupDetailInfo';
|
||||||
export * from './taskgroupEntityInfo';
|
export * from './taskgroupEntityInfo';
|
||||||
export * from './taskgroupFieldInfo';
|
export * from './taskgroupFieldInfo';
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
* https://openapi-generator.tech
|
* https://openapi-generator.tech
|
||||||
* Do not edit the class manually.
|
* 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 {
|
export interface ScheduleInfo {
|
||||||
@ -21,7 +23,21 @@ export interface ScheduleInfo {
|
|||||||
* type of schedule
|
* type of schedule
|
||||||
*/
|
*/
|
||||||
scheduleType: ScheduleInfo.ScheduleTypeEnum;
|
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 namespace ScheduleInfo {
|
||||||
export type ScheduleTypeEnum = 'BASIC' | 'MODERATE' | 'ADVANCED';
|
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,
|
TaskEntityInfo,
|
||||||
TaskgroupEntityInfo,
|
TaskgroupEntityInfo,
|
||||||
TaskgroupService,
|
TaskgroupService,
|
||||||
TaskService
|
TaskService, TaskShortInfo
|
||||||
} from "../../../api";
|
} from "../../../api";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {CalendarDateFormatter, CalendarEvent, CalendarView} from "angular-calendar";
|
import {CalendarDateFormatter, CalendarEvent, CalendarView} from "angular-calendar";
|
||||||
@ -49,6 +49,7 @@ export class SchedulerComponent implements OnInit{
|
|||||||
taskgroup: TaskgroupEntityInfo | undefined
|
taskgroup: TaskgroupEntityInfo | undefined
|
||||||
taskgroupPath: TaskgroupEntityInfo[] = []
|
taskgroupPath: TaskgroupEntityInfo[] = []
|
||||||
taskgroupID: number = -1;
|
taskgroupID: number = -1;
|
||||||
|
scheduleID: number = -1;
|
||||||
@ViewChild('navLinkList') navLinkListComponent: NavigationLinkListComponent | undefined
|
@ViewChild('navLinkList') navLinkListComponent: NavigationLinkListComponent | undefined
|
||||||
|
|
||||||
task: TaskEntityInfo | undefined
|
task: TaskEntityInfo | undefined
|
||||||
@ -92,10 +93,14 @@ export class SchedulerComponent implements OnInit{
|
|||||||
next: resp => {
|
next: resp => {
|
||||||
this.task = resp;
|
this.task = resp;
|
||||||
this.initializeNavigationLinkList()
|
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();
|
this.refresh.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchBasicSchedules() {
|
fetschSchedules() {
|
||||||
this.activatedRoute.paramMap.subscribe(params => {
|
this.scheduleService.schedulesGet().subscribe({
|
||||||
if(params.has('scheduleID')) {
|
next: resp => {
|
||||||
this.scheduleService.schedulesTaskIDScheduleTypeGet(this.task!.taskID, "BASIC").subscribe({
|
resp.forEach(schedule => {
|
||||||
next: resp => {
|
let color: EventColor = colors['red']
|
||||||
resp.forEach(basicSchedule => {
|
if(schedule.scheduleID === this.scheduleID) {
|
||||||
if(basicSchedule.scheduleID === Number(params.get('scheduleID'))) {
|
color = colors['yellow']
|
||||||
this.events.push({
|
}
|
||||||
start: new Date(basicSchedule.scheduleDate),
|
|
||||||
title: this.computeTaskPath(),
|
if(schedule.scheduleType === 'BASIC') {
|
||||||
color: colors['yellow'],
|
this.events.push({
|
||||||
allDay: true,
|
start: new Date(schedule.schedule.scheduleDate),
|
||||||
})
|
title: this.computeTaskPath(schedule.taskgroupPath, schedule.task),
|
||||||
this.basicScheduler?.setEditedBasicSchedule(basicSchedule);
|
color: color,
|
||||||
} else {
|
allDay: true,
|
||||||
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,
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
this.refresh.next();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
this.refresh.next();
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
eventClicked({ event }: { event: CalendarEvent }): void {
|
eventClicked({ event }: { event: CalendarEvent }): void {
|
||||||
this.router.navigateByUrl("/taskgroups/" + this.taskgroupID.toString() + "/tasks/" + this.task!.taskID )
|
this.router.navigateByUrl("/taskgroups/" + this.taskgroupID.toString() + "/tasks/" + this.task!.taskID )
|
||||||
}
|
}
|
||||||
|
|
||||||
computeTaskPath() {
|
computeTaskPath(taskgroupPath: TaskgroupEntityInfo[], task: TaskShortInfo | TaskEntityInfo) {
|
||||||
let result = "";
|
let result = "";
|
||||||
this.taskgroupPath.forEach(taskgroupPathPart => {
|
taskgroupPath.forEach(taskgroupPathPart => {
|
||||||
result += taskgroupPathPart.taskgroupName + "/"
|
result += taskgroupPathPart.taskgroupName + "/"
|
||||||
});
|
});
|
||||||
result += this.taskgroup!.taskgroupName + "/"
|
result += task!.taskName
|
||||||
result += this.task!.taskName
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
59
openapi.yaml
59
openapi.yaml
@ -1355,6 +1355,24 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
$ref: "#/components/schemas/SimpleStatusResponse"
|
$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:
|
components:
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
API_TOKEN:
|
API_TOKEN:
|
||||||
@ -1712,7 +1730,12 @@ components:
|
|||||||
required:
|
required:
|
||||||
- scheduleID
|
- scheduleID
|
||||||
- scheduleType
|
- scheduleType
|
||||||
|
- startTime
|
||||||
|
- finishTime
|
||||||
|
- activeMinutes
|
||||||
- schedule
|
- schedule
|
||||||
|
- task
|
||||||
|
- taskgroupPath
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
properties:
|
properties:
|
||||||
scheduleID:
|
scheduleID:
|
||||||
@ -1727,7 +1750,41 @@ components:
|
|||||||
- BASIC
|
- BASIC
|
||||||
- MODERATE
|
- MODERATE
|
||||||
- ADVANCED
|
- 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:
|
schedule:
|
||||||
type: object
|
type: object
|
||||||
oneOf:
|
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