From 14d7110b1d3c6e81480702eafa020c352f4178c9 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Fri, 8 Jul 2022 14:29:51 +0200 Subject: [PATCH] ui --- .../main/resources/static/js/wf_history.js | 53 ++++++++++++++++++- .../main/resources/templates/wf_history.html | 6 +++ 2 files changed, 58 insertions(+), 1 deletion(-) 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 1ba6fa1b..71ea1728 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 @@ -21,6 +21,8 @@ app.controller('wfHistoryController', function($scope, $http) { $scope.currDetailsKey = ''; $scope.currDetailsValue = ''; $scope.currentWf.arrayDetails = []; + $scope.currentWf.duration = $scope.calculateDateDiff(parseInt(wf.details['system:startDate']), parseInt(wf.details['system:endDate'])); + angular.forEach(wf.details, function(v,k) { $scope.currentWf.arrayDetails.push({'k':k, 'v':v}); }); @@ -29,7 +31,56 @@ app.controller('wfHistoryController', function($scope, $http) { $scope.setCurrentDetailParam = function(k, v) { $scope.currDetailsKey = k; $scope.currDetailsValue = v; - } + } + + + $scope.calculateDateDiff = function(start, end) { + if (start <= 0 || end <= 0) { + return '-'; + } + var seconds = 0; + var minutes = 0; + var hours = 0; + var days = 0; + + if (end > start) { + seconds = Math.round((end - start) / 1000); + if (seconds > 60) { + minutes = Math.floor(seconds / 60); + seconds = seconds % 60; + if (minutes > 60) { + hours = Math.floor(minutes / 60); + minutes = minutes % 60; + if (hours > 24) { + days = Math.floor(hours / 24); + hours = hours % 24; + } + } + } + } + var res = ''; + if (days > 0) { + if (res) { res += ', '; } + res += days + " day(s)" + } + if (hours > 0) { + if (res) { res += ', '; } + res += hours + " hour(s)" + } + if (minutes > 0) { + if (res) { res += ', '; } + res += minutes + " minute(s)" + } + if (seconds > 0) { + if (res) { res += ', '; } + res += seconds + " second(s)" + } + if (!res) { + res = '0 seconds'; + } + + return res; + } $scope.reload(); }); 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 5265ec41..72358512 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 @@ -104,6 +104,12 @@