1
|
var module = angular.module('wfJournalUI', ['ngGrid','ui.bootstrap']);
|
2
|
|
3
|
module.directive('sliderDateRange', function($compile) {
|
4
|
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"];
|
5
|
|
6
|
return {
|
7
|
restrict: 'A',
|
8
|
scope: {
|
9
|
min : '=',
|
10
|
max : '=',
|
11
|
start : '=',
|
12
|
end : '=',
|
13
|
updateFunction: '='
|
14
|
},
|
15
|
link: function(scope, elem, attrs) {
|
16
|
$(elem).dateRangeSlider({
|
17
|
valueLabels: "change",
|
18
|
delayOut: 1000,
|
19
|
"bounds" : {
|
20
|
min: scope.min,
|
21
|
max: scope.max
|
22
|
},
|
23
|
"defaultValues" : {
|
24
|
min: scope.start,
|
25
|
max: scope.end
|
26
|
},
|
27
|
"scales": [{
|
28
|
first: function(value) {
|
29
|
return value;
|
30
|
},
|
31
|
end: function(value) {
|
32
|
return value;
|
33
|
},
|
34
|
next: function(value) {
|
35
|
var next = new Date(value);
|
36
|
return new Date(next.setMonth(value.getMonth() + 1));
|
37
|
},
|
38
|
label: function(value) {
|
39
|
return months[value.getMonth()];
|
40
|
},
|
41
|
format: function(tickContainer, tickStart, tickEnd) {
|
42
|
tickContainer.addClass("myCustomClass");
|
43
|
}
|
44
|
}]
|
45
|
});
|
46
|
$(elem).bind("valuesChanged", function(e, data){
|
47
|
scope.updateFunction(data.values.min, data.values.max);
|
48
|
});
|
49
|
}
|
50
|
}
|
51
|
});
|
52
|
|
53
|
function wfJournalCtrl($scope, $http, $sce) {
|
54
|
|
55
|
commonInitialize($scope, $http, $sce);
|
56
|
|
57
|
initSpinner();
|
58
|
|
59
|
$scope.journal = [];
|
60
|
|
61
|
$scope.currentProcId = '';
|
62
|
|
63
|
$scope.family = getFamily();
|
64
|
|
65
|
$scope.filterJournal = { filterText: '' };
|
66
|
|
67
|
$scope.maxDate = new Date();
|
68
|
$scope.minDate = new Date(2014, 0, 1);
|
69
|
|
70
|
$scope.endDate = new Date();
|
71
|
$scope.startDate = new Date();
|
72
|
|
73
|
$scope.updateDates = function(start, end) {
|
74
|
$scope.startDate = start;
|
75
|
$scope.endDate = end;
|
76
|
$scope.$apply();
|
77
|
$scope.refresh();
|
78
|
}
|
79
|
|
80
|
// Set date range to [7 days before today, today] inclusive
|
81
|
$scope.startDate.setDate($scope.endDate.getDate()-7);
|
82
|
|
83
|
// Grid configuration
|
84
|
$scope.gridWfJournal = {
|
85
|
data: 'journal',
|
86
|
enableCellSelection: false,
|
87
|
enableRowSelection: false,
|
88
|
enableCellEditOnFocus: false,
|
89
|
enablePaging: false,
|
90
|
enableHighlighting: true,
|
91
|
sortInfo: { fields: ['date'], directions: ['desc']},
|
92
|
filterOptions: $scope.filterJournal,
|
93
|
columnDefs: [{field: 'procId', displayName: 'Process ID' , width: '15%', cellTemplate: '<div class="ngCellText"><a href="javascript:void(0)" ng-click="showProcess(row.getProperty(col.field))">{{row.getProperty(col.field)}}</a></div>'},
|
94
|
{field: 'name' , displayName: 'Workflow name' , width: '20%',},
|
95
|
{field: 'family', displayName: 'Workflow family' , width: '15%' },
|
96
|
{field: 'repo' , displayName: 'Datasource', cellTemplate: '<div class="ngCellText"><a href="repoApis.do#/api/{{row.getProperty(\'repoId\')}}/{{row.getProperty(\'apiId\')}}/ALL/ALL" ng-if="row.getProperty(\'repoId\') && row.getProperty(\'apiId\') && row.getProperty(\'repo\')">{{row.getProperty(col.field)}}</a><span ng-if="!(row.getProperty(\'repoId\') && row.getProperty(\'apiId\'))">{{row.getProperty(col.field)}}</span></div>'},
|
97
|
{field: 'status', displayName: 'Status' , width: '10%', 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>'},
|
98
|
{field: 'date' , displayName: 'Date' , width: '10%', 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>'}
|
99
|
]
|
100
|
};
|
101
|
|
102
|
$scope.formatDate = function(date) {
|
103
|
var year = date.getFullYear();
|
104
|
var month = ("00" + (date.getMonth() + 1)).slice(-2);
|
105
|
var day = ("00" + date.getDate()).slice(-2);
|
106
|
return year + '-' + month + '-' + day;
|
107
|
}
|
108
|
|
109
|
$scope.refresh = function() {
|
110
|
$scope.showSpinner();
|
111
|
var url = '';
|
112
|
|
113
|
if ($scope.family) {
|
114
|
url = 'wf_journal_byFamily.find?family=' + $scope.family;
|
115
|
} else {
|
116
|
url = 'wf_journal.range?start=' + $scope.formatDate($scope.startDate) + '&end=' + $scope.formatDate($scope.endDate);
|
117
|
}
|
118
|
$http.get(url).success(
|
119
|
function(data) {
|
120
|
$scope.journal = data;
|
121
|
$scope.hideSpinner();
|
122
|
}
|
123
|
).error(
|
124
|
function() {
|
125
|
$scope.showError('Something really bad must have happened to our fellow hamster..');
|
126
|
$scope.hideSpinner();
|
127
|
}
|
128
|
);
|
129
|
}
|
130
|
|
131
|
$scope.resizeMainElement = function(elem) {
|
132
|
var height = 0;
|
133
|
var body = window.document.body;
|
134
|
if (window.innerHeight) {
|
135
|
height = window.innerHeight;
|
136
|
} else if (body.parentElement.clientHeight) {
|
137
|
height = body.parentElement.clientHeight;
|
138
|
} else if (body && body.clientHeight) {
|
139
|
height = body.clientHeight;
|
140
|
}
|
141
|
elem.style.height = ((height - elem.offsetTop - 280) + "px");
|
142
|
}
|
143
|
|
144
|
$scope.refresh();
|
145
|
$scope.resizeMainElement(document.getElementById('wfJournalTable'));
|
146
|
|
147
|
if (initProcId()) {
|
148
|
$scope.showProcess(initProcId());
|
149
|
}
|
150
|
}
|
151
|
|
152
|
window.onresize = function() {
|
153
|
var elem = document.getElementById('wfJournalTable');
|
154
|
angular.element(elem).scope().resizeMainElement(elem);
|
155
|
};
|