issue-95 #101

Merged
sebastian merged 4 commits from issue-95 into master 2024-03-14 07:29:48 +01:00
4 changed files with 43 additions and 0 deletions
Showing only changes of commit fc742a3526 - Show all commits

View File

@ -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"));
}
}

View File

@ -0,0 +1,16 @@
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
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
private LocalDateTime endTime;
public LocalDateTime getEndTime() {
return endTime;
}
}

View File

@ -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;
@ -237,4 +238,9 @@ public class TaskScheduleService {
}
return filteredSchedules;
}
public void finishScheduleManual(AbstractSchedule schedule, ManualScheduleStopInfo manualScheduleStopInfo) {
schedule.setStopTime(manualScheduleStopInfo.getEndTime());
scheduleRepository.save(schedule);
}
}

View File

@ -90,6 +90,11 @@ export class ActiveScheduleComponent implements OnInit{
}
abortSchedule() {
this.scheduleService.schedulesScheduleIDDelete(this.activeSchedule!.scheduleID).subscribe({
next: resp => {
this.activeSchedule = undefined;
}
})
}