diff --git a/src/main/angular/src/app/pages/schedule/schedule.component.html b/src/main/angular/src/app/pages/schedule/schedule.component.html index 605dde1..8fdcbdd 100644 --- a/src/main/angular/src/app/pages/schedule/schedule.component.html +++ b/src/main/angular/src/app/pages/schedule/schedule.component.html @@ -10,9 +10,18 @@ - + + diff --git a/src/main/angular/src/app/shared/edit-field/edit-field.component.html b/src/main/angular/src/app/shared/edit-field/edit-field.component.html index 954cdfd..f1c22ca 100644 --- a/src/main/angular/src/app/shared/edit-field/edit-field.component.html +++ b/src/main/angular/src/app/shared/edit-field/edit-field.component.html @@ -1,5 +1,5 @@ - -
+ +
{{initial}} - LEER -
diff --git a/src/main/angular/src/app/shared/edit-field/edit-field.component.ts b/src/main/angular/src/app/shared/edit-field/edit-field.component.ts index df52a14..a1ae3bb 100644 --- a/src/main/angular/src/app/shared/edit-field/edit-field.component.ts +++ b/src/main/angular/src/app/shared/edit-field/edit-field.component.ts @@ -1,4 +1,4 @@ -import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; +import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; @Component({ selector: 'app-edit-field', @@ -7,6 +7,9 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; }) export class EditFieldComponent implements OnInit { + @ViewChild('input') + input?: ElementRef; + @Input() initial!: string; @@ -38,4 +41,9 @@ export class EditFieldComponent implements OnInit { this.finish(); } } + + start(): void { + this.editing = true; + setTimeout(() => this.input?.nativeElement.focus(), 0); + } } diff --git a/src/main/java/de/ph87/homeautomation/DemoDataService.java b/src/main/java/de/ph87/homeautomation/DemoDataService.java index abc6e89..ec0da66 100644 --- a/src/main/java/de/ph87/homeautomation/DemoDataService.java +++ b/src/main/java/de/ph87/homeautomation/DemoDataService.java @@ -101,7 +101,6 @@ public class DemoDataService { schedule.setEnabled(true); schedule.setName(s); schedule.setPropertyName(knxGroupDto.propertyName); - schedule.setPropertyType(knxGroupDto.getPropertyType()); return schedule; } diff --git a/src/main/java/de/ph87/homeautomation/schedule/Schedule.java b/src/main/java/de/ph87/homeautomation/schedule/Schedule.java index ce3f59a..f39a633 100644 --- a/src/main/java/de/ph87/homeautomation/schedule/Schedule.java +++ b/src/main/java/de/ph87/homeautomation/schedule/Schedule.java @@ -27,11 +27,10 @@ public class Schedule { @Column(nullable = false, unique = true) private String name; - @Column(nullable = false) private String propertyName; @Column(nullable = false) - private PropertyType propertyType; + private PropertyType propertyType = PropertyType.ON_OFF; @ToString.Exclude @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) diff --git a/src/main/java/de/ph87/homeautomation/schedule/ScheduleController.java b/src/main/java/de/ph87/homeautomation/schedule/ScheduleController.java index 3fb9040..8b9d2cb 100644 --- a/src/main/java/de/ph87/homeautomation/schedule/ScheduleController.java +++ b/src/main/java/de/ph87/homeautomation/schedule/ScheduleController.java @@ -1,5 +1,6 @@ package de.ph87.homeautomation.schedule; +import de.ph87.homeautomation.property.PropertyType; import de.ph87.homeautomation.schedule.entry.ScheduleNextExecutionDto; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; @@ -50,4 +51,14 @@ public class ScheduleController { return scheduleWriteService.set(id, Schedule::setName, name); } + @PostMapping("set/{id}/propertyName") + public ScheduleDto setPropertyName(@PathVariable final long id, @RequestBody final String propertyName) { + return scheduleWriteService.set(id, Schedule::setPropertyName, propertyName); + } + + @PostMapping("set/{id}/propertyType") + public ScheduleDto setPropertyType(@PathVariable final long id, @RequestBody final String propertyType) { + return scheduleWriteService.set(id, Schedule::setPropertyType, PropertyType.valueOf(propertyType)); + } + } diff --git a/src/main/java/de/ph87/homeautomation/schedule/ScheduleExecutionService.java b/src/main/java/de/ph87/homeautomation/schedule/ScheduleExecutionService.java index 9e09183..2adabe7 100644 --- a/src/main/java/de/ph87/homeautomation/schedule/ScheduleExecutionService.java +++ b/src/main/java/de/ph87/homeautomation/schedule/ScheduleExecutionService.java @@ -29,6 +29,10 @@ public class ScheduleExecutionService { } private void executeLastDue(final Schedule schedule, final ZonedDateTime now) { + if (schedule.getPropertyName() == null || schedule.getPropertyName().isEmpty()) { + log.error("Cannot execute Schedule {}: No property set!", schedule); + return; + } schedule.getEntries().stream() .filter(entry -> entry.getNextFuzzyTimestamp() != null && !entry.getNextFuzzyTimestamp().isAfter(now)) .max(Comparator.comparing(ScheduleEntry::getNextFuzzyTimestamp))
+ + + + +