1
|
var module = angular.module('wfJournalUI', ['ngGrid']);
|
2
|
|
3
|
module.controller('wfJournalCtrl', function($scope, $http, $sce) {
|
4
|
commonInitialize($scope, $http, $sce);
|
5
|
|
6
|
initSpinner();
|
7
|
|
8
|
$scope.journal = [];
|
9
|
|
10
|
$scope.currentProcId = '';
|
11
|
|
12
|
$scope.family = getFamily();
|
13
|
|
14
|
$scope.filterJournal = {filterText: ''};
|
15
|
|
16
|
$scope.maxDate = new Date();
|
17
|
$scope.minDate = new Date(2014, 0, 1);
|
18
|
|
19
|
$scope.endDate = new Date();
|
20
|
$scope.startDate = new Date();
|
21
|
|
22
|
$scope.updateDates = function (start, end) {
|
23
|
$scope.startDate = start;
|
24
|
$scope.endDate = end;
|
25
|
$scope.$apply();
|
26
|
$scope.refresh();
|
27
|
}
|
28
|
|
29
|
// Set date range to [7 days before today, today] inclusive
|
30
|
$scope.startDate.setDate($scope.endDate.getDate() - 7);
|
31
|
|
32
|
// Grid configuration
|
33
|
$scope.gridWfJournal = {
|
34
|
data: 'journal',
|
35
|
enableCellSelection: false,
|
36
|
enableRowSelection: false,
|
37
|
enableCellEditOnFocus: false,
|
38
|
enablePaging: false,
|
39
|
enableHighlighting: true,
|
40
|
sortInfo: {fields: ['date'], directions: ['desc']},
|
41
|
filterOptions: $scope.filterJournal,
|
42
|
columnDefs: [{
|
43
|
field: 'procId',
|
44
|
displayName: 'Process ID',
|
45
|
width: '15%',
|
46
|
cellTemplate: '<div class="ngCellText"><a href="javascript:void(0)" ng-click="showProcess(row.getProperty(col.field))">{{row.getProperty(col.field)}}</a></div>'
|
47
|
},
|
48
|
{field: 'name', displayName: 'Workflow name', width: '20%',},
|
49
|
{field: 'family', displayName: 'Workflow family', width: '15%'},
|
50
|
{field: 'datasource', displayName: 'Datasource'},
|
51
|
{
|
52
|
field: 'status',
|
53
|
displayName: 'Status',
|
54
|
width: '10%',
|
55
|
cellTemplate: '<div class="ngCellText"><span class="label label-default" ng-class="{ \'label-success\': row.getProperty(col.field) == \'SUCCESS\', \'label-danger\': row.getProperty(col.field) == \'FAILURE\', \'label-info\': row.getProperty(col.field) == \'EXECUTING\'}">{{row.getProperty(col.field)}}</span></div>'
|
56
|
},
|
57
|
{
|
58
|
field: 'date',
|
59
|
displayName: 'Date',
|
60
|
width: '10%',
|
61
|
cellTemplate: '<div class="ngCellText">{{ (row.getProperty("date") > 0 && row.getProperty("date") < 9999999999999) ? (row.getProperty("date") | date:"yyyy-MM-dd HH:mm:ss") : "not yet started" }}</div>'
|
62
|
}
|
63
|
]
|
64
|
};
|
65
|
|
66
|
$scope.formatDate = function (date) {
|
67
|
var year = date.getFullYear();
|
68
|
var month = ("00" + (date.getMonth() + 1)).slice(-2);
|
69
|
var day = ("00" + date.getDate()).slice(-2);
|
70
|
return year + '-' + month + '-' + day;
|
71
|
}
|
72
|
|
73
|
$scope.refresh = function () {
|
74
|
$scope.showSpinner();
|
75
|
var url = '';
|
76
|
|
77
|
if ($scope.family) {
|
78
|
url = 'wf/journal_byFamily.find?family=' + $scope.family;
|
79
|
} else {
|
80
|
url = 'wf/journal.range?start=' + $scope.formatDate($scope.startDate) + '&end=' + $scope.formatDate($scope.endDate);
|
81
|
}
|
82
|
$http.get(url).success(
|
83
|
function (data) {
|
84
|
$scope.journal = data;
|
85
|
$scope.hideSpinner();
|
86
|
}
|
87
|
).error(
|
88
|
function () {
|
89
|
$scope.showError('Something really bad must have happened to our fellow hamster..');
|
90
|
$scope.hideSpinner();
|
91
|
}
|
92
|
);
|
93
|
}
|
94
|
|
95
|
$scope.resizeMainElement = function (elem) {
|
96
|
var height = 0;
|
97
|
var body = window.document.body;
|
98
|
if (window.innerHeight) {
|
99
|
height = window.innerHeight;
|
100
|
} else if (body.parentElement.clientHeight) {
|
101
|
height = body.parentElement.clientHeight;
|
102
|
} else if (body && body.clientHeight) {
|
103
|
height = body.clientHeight;
|
104
|
}
|
105
|
elem.style.height = ((height - elem.offsetTop - 280) + "px");
|
106
|
}
|
107
|
|
108
|
$scope.refresh();
|
109
|
$scope.resizeMainElement(document.getElementById('wfJournalTable'));
|
110
|
|
111
|
if (initProcId()) {
|
112
|
$scope.showProcess(initProcId());
|
113
|
}
|
114
|
});
|
115
|
|
116
|
window.onresize = function () {
|
117
|
var elem = document.getElementById('wfJournalTable');
|
118
|
angular.element(elem).scope().resizeMainElement(elem);
|
119
|
};
|