From 78bda245f2b588d9777bc0815938742cf8173b31 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Fri, 8 Jul 2022 15:08:50 +0200 Subject: [PATCH] wf history by date --- .../eu/dnetlib/is/wfs/WfHistoryController.java | 9 +++++++-- .../dnetlib/is/wfs/WfHistoryRestController.java | 12 +++++++----- .../src/main/resources/static/js/wf_history.js | 15 ++++++++++++--- .../main/resources/templates/wf_history.html | 17 +++++++++++++++-- 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryController.java index f1f25f57..5e58c41d 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryController.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryController.java @@ -3,12 +3,17 @@ package eu.dnetlib.is.wfs; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; @Controller public class WfHistoryController { @GetMapping("/wf_history") - public void wfHistory(final ModelMap map) { - + public void wfHistory(final ModelMap map, + @RequestParam(required = false, defaultValue = "-1") final Long from, + @RequestParam(required = false, defaultValue = "-1") final Long to) { + map.put("maxNumberOfRecentWfs", WfHistoryRestController.MAX_NUMBER_OF_RECENT_WFS); + map.put("fromDate", from); + map.put("toDate", to); } } diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryRestController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryRestController.java index d863bee6..f3e8480a 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryRestController.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryRestController.java @@ -26,16 +26,18 @@ public class WfHistoryRestController { @Autowired private WfHistoryImporter wfHistoryImporter; + public static final int MAX_NUMBER_OF_RECENT_WFS = 100; + @GetMapping("/") - public List history(@RequestParam(required = false) final Date from, @RequestParam(required = false) final Date to) { + public List history(@RequestParam(required = false) final Long from, @RequestParam(required = false) final Long to) { if (from == null && to == null) { - return wfProcessExecutionRepository.findAll(PageRequest.of(0, 100, Sort.by("endDate").descending())).toList(); + return wfProcessExecutionRepository.findAll(PageRequest.of(0, MAX_NUMBER_OF_RECENT_WFS, Sort.by("endDate").descending())).toList(); } else if (from == null) { - return wfProcessExecutionRepository.findByEndDateBetweenOrderByEndDateDesc(new Date(0), to); + return wfProcessExecutionRepository.findByEndDateBetweenOrderByEndDateDesc(new Date(0), new Date(to)); } else if (to == null) { - return wfProcessExecutionRepository.findByEndDateBetweenOrderByEndDateDesc(from, new Date()); + return wfProcessExecutionRepository.findByEndDateBetweenOrderByEndDateDesc(new Date(from), new Date()); } else { - return wfProcessExecutionRepository.findByEndDateBetweenOrderByEndDateDesc(from, to); + return wfProcessExecutionRepository.findByEndDateBetweenOrderByEndDateDesc(new Date(from), new Date(to)); } } diff --git a/apps/dnet-is-application/src/main/resources/static/js/wf_history.js b/apps/dnet-is-application/src/main/resources/static/js/wf_history.js index 71ea1728..48dcd833 100644 --- a/apps/dnet-is-application/src/main/resources/static/js/wf_history.js +++ b/apps/dnet-is-application/src/main/resources/static/js/wf_history.js @@ -1,6 +1,11 @@ var app = angular.module('wfHistoryApp', []); -app.controller('wfHistoryController', function($scope, $http) { +app.controller('wfHistoryController', function($scope, $http) { + + $scope.fromDate = fromDate(); + $scope.toDate = toDate(); + $scope.maxNumberOfRecentWfs = maxNumberOfRecentWfs(); + $scope.workflows = []; $scope.currentWf = {}; $scope.currDetailsKey = ''; @@ -8,8 +13,12 @@ app.controller('wfHistoryController', function($scope, $http) { $scope.sortField = 'processId'; $scope.sortReverse = false; - $scope.reload = function() { - $http.get('./api/wfs/?' + $.now()).then(function successCallback(res) { + $scope.reload = function() { + var url = './api/wfs/?' + $.now(); + if ($scope.fromDate > 0) { url += "&from=" + $scope.fromDate; } + if ($scope.toDate > 0) { url += "&to=" + $scope.toDate; } + + $http.get(url).then(function successCallback(res) { $scope.workflows = res.data; }, function errorCallback(res) { alert('ERROR: ' + res.data.message); diff --git a/apps/dnet-is-application/src/main/resources/templates/wf_history.html b/apps/dnet-is-application/src/main/resources/templates/wf_history.html index 72358512..9ea0a3f8 100644 --- a/apps/dnet-is-application/src/main/resources/templates/wf_history.html +++ b/apps/dnet-is-application/src/main/resources/templates/wf_history.html @@ -3,6 +3,14 @@ + + @@ -14,8 +22,13 @@

-

- Total workflows : {{(workflows | filter:wfFilter).length}} +

+ Recent workflows (max {{maxNumberOfRecentWfs}}) + Workflows from {{fromDate | date:"yyyy-MM-dd HH:mm:ss"}} to {{toDate | date:"yyyy-MM-dd HH:mm:ss"}} + Workflows from {{fromDate | date:"yyyy-MM-dd HH:mm:ss"}} to undefined + Workflows from undefined to {{toDate | date:"yyyy-MM-dd HH:mm:ss"}} +
+ Count : {{(workflows | filter:wfFilter).length}}