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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
{#
/*
* Spring Signage Ltd - http://www.springsignage.com
* Copyright (C) 2017 Spring Signage Ltd
* (stats-library-page.twig)
*/
#}
{% extends "authed.twig" %}
{% import "inline.twig" as inline %}
{% block pageContent %}
<div class="row">
<div class="col-md-12">
<div class="widget">
<div class="widget-title">{% trans "Library Usage" %}</div>
<div class="widget-body">
<div class="XiboGrid" id="{{ random() }}">
<div class="XiboFilter well">
<div class="FilterDiv" id="Filter">
<form class="form-inline">
{% set title %}{% trans "User" %}{% endset %}
{% set userFilterOptions = [{userId: null, user: ""}]|merge(users) %}
{{ inline.dropdown("userId", "single", title, "", userFilterOptions, "userId", "userName", "", "selectPicker", "", "u", "", [{name: "data-live-search", value:"true"}, {name: "data-selected-text-format", value: "count > 3"}]) }}
{% set title %}{% trans "User Group" %}{% endset %}
{% set groupFilterOptions = [{groupId: null, group: ""}]|merge(groups) %}
{{ inline.dropdown("groupId", "single", title, "", groupFilterOptions, "groupId", "group", "", "selectPicker", "", "g", "", [{name: "data-live-search", value:"true"}, {name: "data-selected-text-format", value: "count > 3"}]) }}
</form>
</div>
</div>
<div class="XiboData">
<table id="libraryUsage" class="table table-striped">
<thead>
<tr>
<th>{% trans "ID" %}</th>
<th>{% trans "User" %}</th>
<th>{% trans "Usage" %}</th>
<th>{% trans "Count Files" %}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="widget">
<div class="widget-title">
<i class="fa fa-tasks"></i>
{% if libraryLimitSet != "" %}
{% trans %}Library Usage. Limit {{ libraryLimit }}{% endtrans %}
{% else %}
{% trans "Library Usage" %}
{% endif %}
<div class="clearfix"></div>
</div>
<div class="widget-body medium no-padding">
<canvas id="libraryChart" style="clear:both;" width="350" height="220"></canvas>
</div>
</div>
</div>
<div class="col-md-6">
<div class="widget">
<div class="widget-title">
<i class="fa fa-user"></i>
{% trans "User Percentage Usage" %}
<div class="clearfix"></div>
</div>
<div class="widget-body medium no-padding">
<canvas id="userChart" style="clear:both;" width="350" height="220"></canvas>
</div>
</div>
</div>
</div>
{% endblock %}
{% block javaScript %}
<script type="text/javascript">
var userChart = null;
var table = $("#libraryUsage").DataTable({
"language": dataTablesLanguage,
serverSide: true,
stateSave: true, stateDuration: 0,
filter: false,
searchDelay: 3000,
ajax: {
url: "{{ urlFor("stats.library.grid") }}",
data: function (d) {
$.extend(d, $("#libraryUsage").closest(".XiboGrid").find(".FilterDiv form").serializeObject());
}
},
"columns": [
{ data: "userId" },
{ data: "userName" },
{ data: "bytesUsedFormatted" },
{ data: "numFiles" }
]
});
table.on('draw', dataTableDraw);
table.on('processing.dt', function(e, settings, processing) {
dataTableProcessing(e, settings, processing);
if (!processing) {
// Render a pie chart
if (userChart !== undefined && userChart !== null) {
console.log('Destroying Chart');
userChart.destroy();
}
// Organise our rows into datasets for the chart
var totalSize = 0;
var userData = new Array();
var userLabels = new Array();
$.each(table.data(), function(index, el) {
totalSize += el.bytesUsed;
});
$.each(table.data(), function(index, el) {
userData.push(((el.bytesUsed/totalSize)*100).toFixed(2));
userLabels.push(el.userName);
});
var colours = new Array();
for(var i = 0; i < userData.length; i++) {
colours.push($c.rand());
}
userChart = new Chart($("#userChart"), {
type: 'pie',
data: {
datasets: [{
data: userData,
backgroundColor: colours
}],
labels: userLabels
},
options: {
maintainAspectRatio: false
}
});
}
});
// Create a lovely library pie chart
var libraryData = {{ libraryWidgetData|raw }};
var colours = new Array();
for(var i = 0; i < libraryData.length; i++) {
colours.push($c.rand());
}
var libraryChart = new Chart($("#libraryChart"), {
type: 'pie',
data: {
datasets: [{
data: libraryData,
backgroundColor: colours
}],
labels: {{ libraryWidgetLabels|raw }}
},
options: {
maintainAspectRatio: false
}
});
</script>
{% endblock %}
|