forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathad_list.html
More file actions
293 lines (279 loc) · 11.7 KB
/
Copy pathad_list.html
File metadata and controls
293 lines (279 loc) · 11.7 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
{% extends "base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin static %}
{% load ietf_filters %}
{% block pagehead %}
<link rel="stylesheet" href="{% static 'ietf/css/list.css' %}">
<link rel="stylesheet" href="{% static 'ietf/css/highcharts.css' %}">
{% endblock %}
{% block morecss %}
table .border-bottom { border-bottom-color: var(--highcharts-neutral-color-80) !important; }
.highcharts-container .highcharts-axis-labels {
font-size: .7rem;
fill: var(--bs-body-color)
}
.highcharts-container .highcharts-graph { stroke-width: 2.5; }
.highcharts-container .highcharts-color-0 {
fill: var(--bs-body-color);
stroke: var(--bs-primary);
}
.highcharts-container .highcharts-data-label text {
font-size: 1rem;
font-weight: inherit;
fill: var(--bs-body-color)
}
{% endblock %}
{% block title %}IESG Dashboard{% endblock %}
{% block content %}
{% origin %}
<h1>IESG Dashboard</h1>
{% if user|has_role:"Area Director,Secretariat" %}
<div class="alert alert-info my-3">
{{ delta }}-day trend graphs
are only shown to logged-in Area Directors.
</div>
{% endif %}
<p>
<a class="btn btn-primary" href="{% url 'ietf.doc.views_search.docs_for_iesg' %}">Documents in IESG Processing</a>
<a class="btn btn-primary" href="{% url 'ietf.iesg.views.working_groups' %}">IESG view of Working Groups</a>
</p>
{% for dt in metadata %}
<h2 class="mt-5" id="{{ dt.type.0 }}">{{ dt.type.1 }} State Counts</h2>
<table class="table table-sm table-striped table-bordered tablesorter navskip">
<thead class="wrap-anywhere">
<tr>
<th scope="col" data-sort="name">Area Director</th>
{% if dt.type.1 == "Internet-Draft" %}
<th scope="col" data-sort="pre-pubreq">Pre pubreq</th>
{% endif %}
{% for state, state_name in dt.states %}
<th scope="col" class="col-1" data-sort="{{ state }}-num"
>
<a href="{% url 'ietf.doc.views_help.state_help' type='draft-iesg' %}#{{ state }}">
{{ state_name|split:'/'|join:'/<wbr>' }}
</a>
</th>
{% endfor %}
</tr>
</thead>
<tbody class="table-group-divider">
{% for ad in dt.ads %}
<tr>
<td>
<a href="{{ ad.dashboard }}">{{ ad.name }}</a>
</td>
{% if dt.type.1 == "Internet-Draft" %}
<td
class="col-1 align-bottom"
data-sum="pre-pubreq"
{% if user|has_role:"Area Director,Secretariat" %}
data-series-graph
{% endif %}
>
{{ ad.pre_pubreq }}
</td>
{% endif %}
{% for state, state_name in dt.states %}
<td class="col-1 align-bottom"
id="{{ dt.type.0 }}-{{ ad|slugify }}-{{ state }}">
<div id="chart-{{ dt.type.0 }}-{{ ad|slugify }}-{{ state }}"></div>
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
<tfoot class="table-group-divider">
<tr>
<th scope="row">Sum</th>
{% if dt.type.1 == "Internet-Draft" %}
<td class="align-bottom">
<div
data-sum-result="pre-pubreq"
{% if user|has_role:"Area Director,Secretariat" %}
data-series-graph
{% endif %}
></div>
</td>
{% endif %}
{% for state, state_name in dt.states %}
<td class="align-bottom">
<div id="chart-{{ dt.type.0 }}-sum-{{ state }}"></div>
</td>
{% endfor %}
</tr>
</tfoot>
</table>
{% endfor %}
{% endblock %}
{% block js %}
<script src="{% static "ietf/js/list.js" %}"></script>
<script>
$(document)
.ready(function () {
$("[data-bs-toggle='popover']")
.popover({
html: true,
trigger: "hover focus click"
});
});
</script>
<script src="{% static "ietf/js/highcharts.js" %}"></script>
{{ data|json_script:"data" }}
<script>
function highchartsConfigFactory({ element, ymax, series }){
return {
title: { text: undefined },
chart: {
type: "line",
animation: false,
renderTo: element,
panning: { enabled: false },
spacing: [4, 0, 5, 0],
height: "45%"
},
scrollbar: { enabled: false },
tooltip: { enabled: false },
navigator: { enabled: false },
exporting: { enabled: false },
legend: { enabled: false },
credits: { enabled: false },
xAxis: {
title: { text: undefined},
labels: { enabled: false },
zoomEnabled: false,
tickLength: 0
},
yAxis: {
title: { text: undefined},
zoomEnabled: false,
tickLength: 0,
labels: { x: -3 },
min: 0,
max: ymax,
tickInterval: ymax
},
plotOptions: {
series: {
animation: false,
dataLabels: {
enabled: true,
inside: true,
padding: 0,
formatter: function() {
// only label the last
// (= current-day) point in
// the curve with today's
// value
if (this.point.index + 1 ==
this.series.points.length) {
return this.y
}
return undefined
}
}
}
},
series: [{
name: undefined,
data: series,
enableMouseTracking: false
}]
}
}
</script>
<script>
const GRAPH_BUFFER = 2;
function safeParseFloat(text) {
const trimNumber = text.trim()
if(!trimNumber.match(/^[0-9.]+$/)) {
console.warn(`Unable to parse "${trimNumber}" as a number.`)
return Number.NaN
}
return parseFloat(text)
}
Array.from(document.querySelectorAll("table"))
.filter(table => Boolean(table.querySelector("[data-sum]")))
.forEach(table => {
const sums = Array.from(table.querySelectorAll("[data-sum]")).reduce((
sumsAccumulator,
cell
) => {
const key = cell.dataset.sum
const value = safeParseFloat(cell.textContent)
if(key && !isNaN(value)) {
sumsAccumulator[key] = (sumsAccumulator[key] || 0) + (value || 0)
}
return sumsAccumulator
}, {})
Array.from(table.querySelectorAll('[data-sum-result]')).forEach(result => {
const key = result.dataset.sumResult
const value = sums[key]
if(value) {
result.innerText = value
}
})
Array.from(table.querySelectorAll('[data-series-graph]')).forEach(element => {
const endValue = safeParseFloat(element.innerText)
if(isNaN(endValue)) throw Error("Can't render Highcharts chart with non-numerical " + element.innerText)
const ymax = Math.max(1, endValue + GRAPH_BUFFER)
Highcharts.chart(
highchartsConfigFactory({
element,
ymax,
series: [endValue]
})
)
})
})
</script>
<script>
const data = JSON.parse(document.getElementById("data").textContent)
Object.entries(data).forEach(([dt, ads]) => {
max = {}
Object.entries(ads).forEach(([ad, states]) => {
Object.entries(states).forEach(([state, buckets]) => {
buckets.series = buckets.map((x) => x.length)
if (ad != "sum") {
max[state] = Math.max(...buckets.series, max[state] ? max[state] : 0)
}
})
})
Object.entries(ads).forEach(([ad, states]) => {
Object.entries(states).forEach(([state, buckets]) => {
const cell = `chart-${dt}-${ad}-${state}`
// if there is only a single datapoint in the
// bucket, display it without a graph
if (buckets.series.length == 1) {
document.getElementById(cell).innerHTML = buckets.series[0]
return
}
// if a bucket has all zeroes, fake a Highcharts
// plot with HTML, to reduce the number of plot
// objects on the page
if (buckets.series.every((x) => x === 0)) {
// document.getElementById(cell).innerHTML = `
// <div class="position-relative">
// <div class="position-absolute bottom-0 start-0">
// <div style="font-size: .7rem;" class="ms-1">0</div>
// </div>
// <div class="position-absolute bottom-0 end-0 w-100 ps-1">
// <div class="border-bottom mb-1 ms-3">0</div>
// </div>
// </div>
// `;
return
}
// else actually create a graph
const ymax = Math.max(1, ad !== "sum" ? max[state] : Math.max(...buckets.series))
Highcharts.chart(
highchartsConfigFactory({
element: cell,
ymax,
series: buckets.series
})
)
})
})
})
</script>
{% endblock %}