Fix optimize ui maintenance window (#668)
* Optimize maintenance window UI Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com> * Refactor Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com> * Add new downloaded status to UI. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Changed Accordion to Tabsheet for better visualization of action types and maintanance window. Signed-off-by: Markus Block <markus.block@bosch-si.com> * Refined UI for maintenance window, refactoring Added ENTER shortcut for save button in dialog windows Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * Extended validation for maintenance window, refactored the maintenance window helper class Added text change listeners for the schedule and duration text fields in order to activate "save all" button Added client Locale identification for cron expression translation Moved maintenance window validation from TargetWithActionType constructor to saveAll method of assignment tab Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * Added SupressWarnings annotation for exception handling cases Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * Fixed Sonar issue: added private constructor to Maintenance schedule helper class Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * Sonar Issue: make utility class Maintenance Schedule final Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * Added Maintenance Window validation to Distribution Set and Target Management API Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * Added unit tests for MaintenanceScheduleHelper class Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * Added the license header to MaintenanceScheduleHelperTest class Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * Small changes after PR review Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * Added Id for Maintenance Window layout for UI Tests Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>
This commit is contained in:
committed by
Dominic Schabel
parent
8fd601f8b9
commit
4c28c4d905
@@ -252,12 +252,10 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
*/
|
||||
EventTimer(final String defaultEventInterval, final String minimumEventInterval, final TemporalUnit timeUnit) {
|
||||
this.defaultEventInterval = defaultEventInterval;
|
||||
this.defaultEventIntervalDuration = Duration
|
||||
.parse(MaintenanceScheduleHelper.convertToISODuration(defaultEventInterval));
|
||||
this.defaultEventIntervalDuration = MaintenanceScheduleHelper.convertToISODuration(defaultEventInterval);
|
||||
|
||||
this.minimumEventInterval = minimumEventInterval;
|
||||
this.minimumEventIntervalDuration = Duration
|
||||
.parse(MaintenanceScheduleHelper.convertToISODuration(minimumEventInterval));
|
||||
this.minimumEventIntervalDuration = MaintenanceScheduleHelper.convertToISODuration(minimumEventInterval);
|
||||
|
||||
this.timeUnit = timeUnit;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collections;
|
||||
@@ -127,11 +126,6 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
@Column(name = "maintenance_time_zone", updatable = false, length = Action.MAINTENANCE_WINDOW_TIMEZONE_LENGTH)
|
||||
private String maintenanceWindowTimeZone;
|
||||
|
||||
/**
|
||||
* A transient (non serialized) maintenance schedule helper.
|
||||
*/
|
||||
private transient MaintenanceScheduleHelper scheduleHelper = null;
|
||||
|
||||
@Override
|
||||
public DistributionSet getDistributionSet() {
|
||||
return distributionSet;
|
||||
@@ -271,28 +265,6 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
this.maintenanceWindowTimeZone = maintenanceWindowTimeZone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transient schedule helper. Instantiate one if not already done
|
||||
* after deserialization.
|
||||
*
|
||||
* @return the {@link MaintenanceScheduleHelper} object.
|
||||
*/
|
||||
private MaintenanceScheduleHelper getScheduler() {
|
||||
if (this.scheduleHelper == null) {
|
||||
this.scheduleHelper = new MaintenanceScheduleHelper(maintenanceSchedule);
|
||||
}
|
||||
return this.scheduleHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the duration of each maintenance window in ISO 8601 format.
|
||||
*
|
||||
* @return the {@link Duration} of each maintenance window.
|
||||
*/
|
||||
private Duration getMaintenanceWindowDuration() {
|
||||
return Duration.parse(MaintenanceScheduleHelper.convertToISODuration(this.maintenanceWindowDuration));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the start time of next available maintenance window for the
|
||||
* {@link Action} as {@link ZonedDateTime}. If a maintenance window is
|
||||
@@ -301,8 +273,8 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
* @return the start time as {@link Optional<ZonedDateTime>}.
|
||||
*/
|
||||
public Optional<ZonedDateTime> getMaintenanceWindowStartTime() {
|
||||
final ZonedDateTime now = ZonedDateTime.now(ZoneOffset.of(maintenanceWindowTimeZone));
|
||||
return getScheduler().nextExecution(now.minus(getMaintenanceWindowDuration()));
|
||||
return MaintenanceScheduleHelper.getNextMaintenanceWindow(maintenanceSchedule, maintenanceWindowDuration,
|
||||
maintenanceWindowTimeZone);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -313,7 +285,8 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
* @return the end time of window as {@link Optional<ZonedDateTime>}.
|
||||
*/
|
||||
private Optional<ZonedDateTime> getMaintenanceWindowEndTime() {
|
||||
return getMaintenanceWindowStartTime().map(start -> start.plus(getMaintenanceWindowDuration()));
|
||||
return getMaintenanceWindowStartTime()
|
||||
.map(start -> start.plus(MaintenanceScheduleHelper.convertToISODuration(maintenanceWindowDuration)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -323,8 +296,7 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
||||
|
||||
@Override
|
||||
public boolean isMaintenanceScheduleLapsed() {
|
||||
final ZonedDateTime now = ZonedDateTime.now(ZoneOffset.of(maintenanceWindowTimeZone));
|
||||
return !getScheduler().nextExecution(now.minus(getMaintenanceWindowDuration())).isPresent();
|
||||
return !getMaintenanceWindowStartTime().isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user