/
nx-parallel-workflow-dashboard.html
130 lines (112 loc) · 4.48 KB
/
nx-parallel-workflow-dashboard.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!--
(C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors.
All rights reserved. This program and the accompanying materials
are made available under the terms of the GNU Lesser General Public License
(LGPL) version 2.1 which accompanies this distribution, and is available at
http://www.gnu.org/licenses/lgpl.html
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
Contributors:
André Justo <ajusto@nuxeo.com>
-->
<dom-module id="nx-parallel-workflow-dashboard">
<link rel="import" type="css" href="nx-workflow-dashboard.css">
<template>
<nuxeo-workflow-data workflow="ParallelDocumentReview"
event="afterWorkflowFinish"
metrics="avg(timeSinceWfStarted)"
start-date="[[startDate]]" end-date="[[endDate]]"
data="{{avgWorkflowLength}}">
</nuxeo-workflow-data>
<paper-card heading="Average Workflow Duration" elevation="2">
<div class="card-content">
<iron-icon icon="image:timer"></iron-icon>
<span class="workflow-length-label">[[_asDuration(avgWorkflowLength)]]</span>
</div>
</paper-card>
<nuxeo-workflow-data workflow="ParallelDocumentReview"
event="afterWorkflowStarted"
grouped-by="workflowInitiator"
start-date="[[startDate]]" end-date="[[endDate]]"
data="{{initiators}}">
</nuxeo-workflow-data>
<paper-card heading="Workflow Initiators" elevation="2">
<div class="card-content">
<chart-pie values=[[_values(initiators)]]
series=[[_series(initiators)]]
options='{"responsive": true}'>
</chart-pie>
</div>
</paper-card>
<nuxeo-workflow-data workflow="ParallelDocumentReview"
event="afterWorkflowTaskEnded"
task="wf.parallelDocumentReview.give_opinion.title"
grouped-by="taskActor, action"
start-date="[[startDate]]" end-date="[[endDate]]"
data="{{numberOfActionsPerUser}}">
</nuxeo-workflow-data>
<paper-card heading="Actions Per User" elevation="2">
<div class="card-content">
<chart-bar labels=[[_labels(numberOfActionsPerUser)]]
series=[[_series(numberOfActionsPerUser)]]
values=[[_values(numberOfActionsPerUser)]]
options='{"responsive": true}'>
</chart-bar>
</div>
</paper-card>
<nuxeo-workflow-data workflow="ParallelDocumentReview"
task="wf.parallelDocumentReview.give_opinion.title"
grouped-by="taskActor"
metrics="avg(timeSinceTaskStarted)"
start-date="[[startDate]]" end-date="[[endDate]]"
data="{{avgTaskDurationPerUser}}">
</nuxeo-workflow-data>
<paper-card heading="Average Task Duration Per User" elevation="2">
<div class="card-content">
<nuxeo-data-table columns='[{"key": "key", "title": "User"}, {"key": "value", "title": "Average duration"}]'
data="[[_table(avgTaskDurationPerUser)]]">
</nuxeo-data-table>
</div>
</paper-card>
</template>
</dom-module>
<script>
Polymer({
is: 'nx-parallel-workflow-dashboard',
behaviors: [Nuxeo.DataDrivenBehavior],
properties: {
startDate: String,
endDate: String
},
_table: function(data) {
return data.map(function (e) {
return {key: e.key, value: this._asDuration(e.value)};
}.bind(this));
},
_asDuration: function (duration) {
var seconds = Math.floor(duration/1000),
minutes = Math.floor(seconds/60),
hours = Math.floor(minutes/60),
days = Math.floor(hours/24),
hours = hours-(days*24),
minutes = minutes-(days*24*60)-(hours*60),
seconds = seconds-(days*24*60*60)-(hours*60*60)-(minutes*60),
result = "";
if (days > 0) {
result += days + " Days ";
}
if (hours > 0) {
result += hours + " h ";
}
if (minutes > 0) {
result += minutes + " m ";
}
if (seconds > 0) {
result += seconds + " s ";
}
return result;
}
});
</script>