From: Vásáry Dániel Date: Tue, 5 Dec 2023 22:53:15 +0000 (+0100) Subject: Process status X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=fe7910130fe051aa09e044571365d6e3aa777e45;p=mediacube.git Process status --- diff --git a/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/config/ScheduledTasks.java b/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/config/ScheduledTasks.java index 6407ade8..6746aa9d 100644 --- a/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/config/ScheduledTasks.java +++ b/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/config/ScheduledTasks.java @@ -23,13 +23,6 @@ import java.time.Instant; @Component public class ScheduledTasks { - @Getter - private ImportSummary importSummary; - - public ScheduledTasks() { - log.info("ScheduledTasks created"); - } - @Autowired private ServiceProperties serviceProperties; @@ -45,6 +38,12 @@ public class ScheduledTasks { @Autowired private ScheduledSunriseChacker scheduledSunriseChacker; + @Getter + private ImportSummary importSummary; + + @Getter + private String status; + @PostConstruct public void scheduleTasks() { //new CronTrigger("0 0 4 1/1 * ? *") @@ -76,6 +75,7 @@ public class ScheduledTasks { public void handleEvent(ImportStartedEvent evt) { log.info("ImportStartedEvent handle"); importSummary = null; + status = String.format("Import from %s started", evt.getFileName()); } @Async @@ -83,5 +83,6 @@ public class ScheduledTasks { public void handleEvent(ImportCompletedEvent evt) { log.info("ImportCompletedEvent handle"); importSummary = evt.getSummary(); + status = "Import completed"; } } diff --git a/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/event/ImportCompletedEvent.java b/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/event/ImportCompletedEvent.java index 6e1a8f11..1ef84d95 100644 --- a/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/event/ImportCompletedEvent.java +++ b/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/event/ImportCompletedEvent.java @@ -11,7 +11,7 @@ public class ImportCompletedEvent extends ApplicationEvent { private final ImportSummary summary; - public ImportCompletedEvent(ImportSummary summary, Object source) { + public ImportCompletedEvent(Object source, ImportSummary summary) { super(source); this.summary = summary; } diff --git a/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/event/ImportStartedEvent.java b/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/event/ImportStartedEvent.java index 0c8bc09c..0e931386 100644 --- a/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/event/ImportStartedEvent.java +++ b/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/event/ImportStartedEvent.java @@ -8,7 +8,10 @@ import org.springframework.context.ApplicationEvent; @Setter public class ImportStartedEvent extends ApplicationEvent { - public ImportStartedEvent(Object source) { + private String fileName; + + public ImportStartedEvent(Object source, String fileName) { super(source); + this.fileName = fileName; } } diff --git a/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/schedule/ScheduledImport.java b/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/schedule/ScheduledImport.java index 4ad3f22c..f268bffe 100644 --- a/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/schedule/ScheduledImport.java +++ b/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/schedule/ScheduledImport.java @@ -27,18 +27,18 @@ public class ScheduledImport implements Runnable { @Override public void run() { - applicationEventPublisher.publishEvent(new ImportStartedEvent(this)); ImportSummary summary = null; try { - log.info("ScheduledImport started"); Optional opUploadFile = uploadFileRepository.findFirstByOrderByCreatedDesc(); if (opUploadFile.isPresent()) { + log.info("ScheduledImport started from {}", opUploadFile.get().getName()); + applicationEventPublisher.publishEvent(new ImportStartedEvent(this, opUploadFile.get().getName())); summary = vodXlsProcessor.process(opUploadFile.get().getName(), opUploadFile.get().getFile()); } } catch (Exception e) { log.error("ScheduledImport error!", e); } finally { - applicationEventPublisher.publishEvent(new ImportCompletedEvent(summary, this)); + applicationEventPublisher.publishEvent(new ImportCompletedEvent(this, summary)); log.info("ScheduledImport finished"); } diff --git a/mc-vod-sync/mc-vod-sync-ui/src/main/java/hu/user/mcvodsync/ui/view/IndexViewModel.java b/mc-vod-sync/mc-vod-sync-ui/src/main/java/hu/user/mcvodsync/ui/view/IndexViewModel.java index 87b12f35..27df65f8 100644 --- a/mc-vod-sync/mc-vod-sync-ui/src/main/java/hu/user/mcvodsync/ui/view/IndexViewModel.java +++ b/mc-vod-sync/mc-vod-sync-ui/src/main/java/hu/user/mcvodsync/ui/view/IndexViewModel.java @@ -8,6 +8,7 @@ import hu.user.mcvodsync.db.repository.AssetRepository; import hu.user.mcvodsync.db.repository.AssetSyncRepository; import hu.user.mcvodsync.db.repository.PlaylistSyncRepository; import hu.user.mcvodsync.db.repository.UploadFileRepository; +import hu.user.mcvodsync.service.config.ScheduledTasks; import hu.user.mcvodsync.ui.Constants; import hu.user.mcvodsync.ui.auth.CurrentProfile; import hu.user.mcvodsync.ui.session.SessionSettings; @@ -54,6 +55,9 @@ public class IndexViewModel { @WireVariable private UploadFileRepository uploadFileRepository; + @WireVariable + private ScheduledTasks scheduledTasks; + private String page; @Init @@ -64,6 +68,11 @@ public class IndexViewModel { log.info("Init {}", path); } + @Command + public void onTimer() { + BindUtils.postNotifyChange(scheduledTasks, "status"); + } + @Command public void route(String path) { if (Constants.NAV_ROOT.equals(path)) diff --git a/mc-vod-sync/mc-vod-sync-ui/src/main/resources/web/index.zul b/mc-vod-sync/mc-vod-sync-ui/src/main/resources/web/index.zul index d569f89e..b863493f 100644 --- a/mc-vod-sync/mc-vod-sync-ui/src/main/resources/web/index.zul +++ b/mc-vod-sync/mc-vod-sync-ui/src/main/resources/web/index.zul @@ -26,6 +26,7 @@ } +
@@ -87,9 +88,10 @@ - -
-
+ +