From f5607f802384dd06f099fbc114d35108037d5014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 17 Mar 2024 09:33:20 +0100 Subject: [PATCH 1/2] Delete Schedules in ScheduleHistory --- .../schedule-history.component.css | 5 +++++ .../schedule-history.component.html | 4 ++++ .../schedule-history.component.ts | 15 ++++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/statistics/schedule-history/schedule-history.component.css b/frontend/src/app/statistics/schedule-history/schedule-history.component.css index 11b4a81..8ff1553 100644 --- a/frontend/src/app/statistics/schedule-history/schedule-history.component.css +++ b/frontend/src/app/statistics/schedule-history/schedule-history.component.css @@ -23,3 +23,8 @@ table { width: 100%; } + +.mat-column-delete { + width: 32px; + text-align: center; +} diff --git a/frontend/src/app/statistics/schedule-history/schedule-history.component.html b/frontend/src/app/statistics/schedule-history/schedule-history.component.html index c63091d..7268b91 100644 --- a/frontend/src/app/statistics/schedule-history/schedule-history.component.html +++ b/frontend/src/app/statistics/schedule-history/schedule-history.component.html @@ -35,6 +35,10 @@ Duration {{calcDuration(element.startTime, element.finishedTime)}} + + + + diff --git a/frontend/src/app/statistics/schedule-history/schedule-history.component.ts b/frontend/src/app/statistics/schedule-history/schedule-history.component.ts index c2b1dad..7df2c9a 100644 --- a/frontend/src/app/statistics/schedule-history/schedule-history.component.ts +++ b/frontend/src/app/statistics/schedule-history/schedule-history.component.ts @@ -1,5 +1,5 @@ import {Component, OnInit} from '@angular/core'; -import {HistoryService, ScheduleInfo, TaskgroupEntityInfo} from "../../../api"; +import {HistoryService, ScheduleInfo, ScheduleService, TaskgroupEntityInfo} from "../../../api"; import * as moment from "moment"; import {NavigationLink} from "../../navigation-link-list/navigation-link-list.component"; @@ -27,7 +27,7 @@ export class ScheduleHistoryComponent implements OnInit{ selectedDate: Date = new Date(); schedules: ScheduleInfo[] = [] - displayedColumns: string[] = ['taskgroup', 'task', 'start', 'end', 'duration']; + displayedColumns: string[] = ['taskgroup', 'task', 'start', 'end', 'duration', 'delete']; ngOnInit() { this.historyService.historySchedulesDateGet(moment(this.selectedDate).format("YYYY-MM-DD")).subscribe({ @@ -37,7 +37,8 @@ export class ScheduleHistoryComponent implements OnInit{ }) } - constructor(private historyService: HistoryService) { + constructor(private historyService: HistoryService, + private scheduleService: ScheduleService) { } computeTaskgroupPath(taskgroupPath: TaskgroupEntityInfo[]) { @@ -67,4 +68,12 @@ export class ScheduleHistoryComponent implements OnInit{ } }) } + + deleteSchedule(deletedSchedule: ScheduleInfo) { + this.scheduleService.schedulesScheduleIDDelete(deletedSchedule.scheduleID).subscribe({ + next: resp => { + this.schedules = this.schedules.filter(schedule => schedule.scheduleID !== deletedSchedule.scheduleID) + } + }) + } } From b4a82c745dee0f840a766683de54bce325b93fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 17 Mar 2024 09:33:49 +0100 Subject: [PATCH 2/2] Only send ntfy-msg when ntfy-data is specified --- .../services/ntfy/TaskSchedulingService.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/core/services/ntfy/TaskSchedulingService.java b/backend/src/main/java/core/services/ntfy/TaskSchedulingService.java index 62702b5..4f8cbd9 100644 --- a/backend/src/main/java/core/services/ntfy/TaskSchedulingService.java +++ b/backend/src/main/java/core/services/ntfy/TaskSchedulingService.java @@ -55,19 +55,22 @@ public class TaskSchedulingService { public void sendRunningTaskNotification(AbstractSchedule abstractSchedule) { HttpClient httpClient = HttpClient.newHttpClient(); User user = abstractSchedule.getTask().getTaskgroup().getUser(); - try { - HttpRequest request = HttpRequest.newBuilder() - .uri(new URI(user.getNtfy_host()+ "/" + user.getNtfy_topic())) - .POST(HttpRequest.BodyPublishers.ofString("Running Task " + abstractSchedule.getTask().getTaskName())) - .header("Tags", "heavy_check_mark") - .header("Title", "Task Running") - .header("Actions", "view, Open TimeScheduler, "+frontend_domain+", clear=true") - .build(); + if(user.getNtfy_host() != null && user.getNtfy_topic() != null) { + try { + HttpRequest request = HttpRequest.newBuilder() + .uri(new URI(user.getNtfy_host()+ "/" + user.getNtfy_topic())) + .POST(HttpRequest.BodyPublishers.ofString("Running Task " + abstractSchedule.getTask().getTaskName())) + .header("Tags", "heavy_check_mark") + .header("Title", "Task Running") + .header("Actions", "view, Open TimeScheduler, "+frontend_domain+", clear=true") + .build(); - httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString()); - } catch (URISyntaxException e) { - throw new RuntimeException(e); + httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString()); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } } + } private static Date calculateDelayInMillis(LocalDateTime executionTime) {