wf history by date
This commit is contained in:
parent
14d7110b1d
commit
78bda245f2
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,16 +26,18 @@ public class WfHistoryRestController {
|
|||
@Autowired
|
||||
private WfHistoryImporter wfHistoryImporter;
|
||||
|
||||
public static final int MAX_NUMBER_OF_RECENT_WFS = 100;
|
||||
|
||||
@GetMapping("/")
|
||||
public List<WfProcessExecution> history(@RequestParam(required = false) final Date from, @RequestParam(required = false) final Date to) {
|
||||
public List<WfProcessExecution> 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
var app = angular.module('wfHistoryApp', []);
|
||||
|
||||
app.controller('wfHistoryController', function($scope, $http) {
|
||||
|
||||
$scope.fromDate = fromDate();
|
||||
$scope.toDate = toDate();
|
||||
$scope.maxNumberOfRecentWfs = maxNumberOfRecentWfs();
|
||||
|
||||
$scope.workflows = [];
|
||||
$scope.currentWf = {};
|
||||
$scope.currDetailsKey = '';
|
||||
|
@ -9,7 +14,11 @@ app.controller('wfHistoryController', function($scope, $http) {
|
|||
$scope.sortReverse = false;
|
||||
|
||||
$scope.reload = function() {
|
||||
$http.get('./api/wfs/?' + $.now()).then(function successCallback(res) {
|
||||
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);
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
|
||||
<head th:replace="fragments/mainParts.html :: htmlHeader('Workflow history')"></head>
|
||||
|
||||
<script th:inline="javascript">
|
||||
/*<![CDATA[*/
|
||||
function maxNumberOfRecentWfs() { return /*[[${maxNumberOfRecentWfs}]]*/ -1; }
|
||||
function fromDate() { return /*[[${fromDate}]]*/ -1; }
|
||||
function toDate() { return /*[[${toDate}]]*/ -1; }
|
||||
/*]]>*/
|
||||
</script>
|
||||
|
||||
<body ng-app="wfHistoryApp" ng-controller="wfHistoryController">
|
||||
|
||||
<nav th:replace="fragments/mainParts.html :: mainMenu('Workflow history')"></nav>
|
||||
|
@ -14,8 +22,13 @@
|
|||
<p ng-show="workflows.length > 0">
|
||||
<input type="text" class="form-control form-control-sm" ng-model="wfFilter" placeholder="Filter..."/>
|
||||
</p>
|
||||
<p>
|
||||
<span class="text-muted"><b>Total workflows :</b> {{(workflows | filter:wfFilter).length}}</span>
|
||||
<p class="text-muted">
|
||||
<span ng-show="fromDate < 0 && toDate < 0"><b>Recent workflows</b> (max {{maxNumberOfRecentWfs}})</span>
|
||||
<span ng-show="fromDate >= 0 && toDate >= 0"><b>Workflows from </b>{{fromDate | date:"yyyy-MM-dd HH:mm:ss"}} <b>to</b> {{toDate | date:"yyyy-MM-dd HH:mm:ss"}}</span>
|
||||
<span ng-show="fromDate >= 0 && toDate < 0"><b>Workflows from </b>{{fromDate | date:"yyyy-MM-dd HH:mm:ss"}} <b>to</b> <i>undefined</i></span>
|
||||
<span ng-show="fromDate < 0 && toDate >= 0"><b>Workflows from </b><i>undefined</i> <b>to</b> {{toDate | date:"yyyy-MM-dd HH:mm:ss"}}</span>
|
||||
<br />
|
||||
<span><b>Count :</b> {{(workflows | filter:wfFilter).length}}</span>
|
||||
</p>
|
||||
<table class="table table-sm table-striped small">
|
||||
<thead>
|
||||
|
|
Loading…
Reference in New Issue