-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
358 lines (310 loc) · 12.7 KB
/
index.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
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<html>
<head>
<title>wavy.fm status</title>
<link href="https://fonts.googleapis.com/css2?family=Cabin:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.1.0/dygraph.min.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 0;
background-color: #23292F;
font-family: 'Cabin', sans-serif;
color: #FAFAFA;
}
.content {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
max-width: 1040px;
margin: 0 auto;
padding: 0 20px;
box-sizing: border-box;
}
.global-status {
margin: 100px 0 25px 0;
width: 100%;
height: 65px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 30px;
border-radius: 5px;
box-sizing: border-box;
background-color: #555555;
transition: background-color 0.25s;
}
.global-status-title {
font-size: 22px;
font-weight: bold;
}
.global-status-time {
font-size: 16px;
}
.green-background {
background-color: #1CDEA1 !important;
}
.yellow-background {
background-color: #FFC738 !important;
}
.red-background {
background-color: #DE3F1C !important;
}
.green-text {
color: #1CDEA1 !important;
}
.yellow-text {
color: #FFC738 !important;
}
.red-text {
color: #DE3F1C !important;
}
.logo {
margin-top: 20px;
display: block;
height: 40px;
}
.system-list {
width: 100%;
}
.system-row {
width: 100%;
display: flex;
justify-content: space-between;
margin-top: 75px;
padding-right: 30px;
box-sizing: border-box;
}
.system-icon {
width: 32px;
height: 32px;
min-width: 32px;
border-radius: 5px;
background-color: #555555;
transition: background-color 0.25s;
margin-right: 20px;
}
.system-title {
font-size: 22px;
font-weight: bold;
}
.system-status {
font-size: 22px;
font-weight: 500;
transition: background-color 0.25s;
}
.system-description {
font-size: 16px;
}
.metrics {
border-top: solid 1px #CCC;
width: 100%;
margin-top: 105px;
padding: 50px 0;
}
#listens-graph {
width: 100%;
height: 400px;
}
.dygraph-axis-label {
color: #CCCCCC;
}
</style>
</head>
<body>
<div class="content">
<a href="https://wavy.fm">
<svg class="logo" id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1735.87 331.93"><defs><style>.cls-1{fill:#fafbfb;}.cls-2{fill:#48c3d2;}</style></defs><path class="cls-1" d="M325.72,76.06c-91.31,0-165.33,74.31-165.33,166s74,166,165.33,166S491,333.69,491,242,417,76.06,325.72,76.06Zm0,297.86A131.9,131.9,0,1,1,457.61,242,131.89,131.89,0,0,1,325.72,373.92Z" transform="translate(-105.64 -76.06)"/><path class="cls-2" d="M537.3,273.85s-23.57,102.64-230.39,46.23c-27.52-7.51-58.17-21.78-93.43-32-49.3-14.34-107.84,15.88-107.84,15.88s15.21-39.72,44.23-49.35C206.18,235.89,251,264.07,314.51,285c46.37,15.27,104.63,21.72,152.29,11.07" transform="translate(-105.64 -76.06)"/><path class="cls-1" d="M818.82,171.58h40.61l-47.82,164H770.14l-31-99.39-31,99.39H666.62l-48.2-164h44.74l28.07,100.69L721.1,171.58h40l29.86,101Z" transform="translate(-105.64 -76.06)"/><path class="cls-1" d="M1004.8,171.58h42.31v164H1004.8V316.23q-19,23.94-53.47,23.94-32.79,0-56.25-25.09t-23.45-61.5q0-36.4,23.45-61.5T951.33,167q34.44,0,53.47,23.94ZM926.74,286.87q12.78,13,32.47,13t32.63-13q13-13,13-33.29t-13-33.29q-13-13-32.63-13t-32.47,13q-12.79,13-12.8,33.29T926.74,286.87Z" transform="translate(-105.64 -76.06)"/><path class="cls-1" d="M1193.4,171.58H1240l-62.32,164h-48.21l-62.32-164h46.57l39.76,114.77Z" transform="translate(-105.64 -76.06)"/><path class="cls-1" d="M1367.23,171.58h45.27l-59.8,164.26q-12.79,35.13-33.91,51.05t-52.58,14.29V361.82q17.05.31,27.06-7.22t15.91-24.27l-67.24-158.75h46.24L1331,281.81Z" transform="translate(-105.64 -76.06)"/><path class="cls-1" d="M1446.94,331.64a27.72,27.72,0,1,1,8.2-19.68A26.84,26.84,0,0,1,1446.94,331.64Z" transform="translate(-105.64 -76.06)"/><path class="cls-1" d="M1578.79,142.06Q1544,139.44,1544,169.94v1.64h34.77v40.67H1544V335.58h-42.31V212.25H1478.1V171.58h23.61v-1.64q0-34.77,19.35-52.81t57.73-15.74Z" transform="translate(-105.64 -76.06)"/><path class="cls-1" d="M1779.52,167q28.21,0,45.1,18.36t16.9,49.2v101H1799.2V237.51q0-14.76-7.21-23t-20.34-8.2q-14.43,0-22.47,9.51t-8,27.55v92.17h-42.31V237.51q0-14.76-7.22-23t-20.34-8.2q-14.1,0-22.46,9.51t-8.37,27.55v92.17h-42.31v-164h42.31V189q14.76-22,45.59-22,30.18,0,44.61,23.61Q1747,167,1779.52,167Z" transform="translate(-105.64 -76.06)"/></svg>
</a>
<div class="global-status">
<div class="global-status-title"></div>
<div class="global-status-time"></div>
</div>
<div class="system-list">
<div class="system-row" id="system-website">
<div style="display: flex; flex-grow: 1">
<div class="system-icon"></div>
<div class="system-meta">
<div class="system-title">Website</div>
<div class="system-description">The wavy.fm website. Pretty straightforward.</div>
</div>
</div>
<div class="system-status"></div>
</div>
<div class="system-row" id="system-api">
<div style="display: flex; flex-grow: 1">
<div class="system-icon"></div>
<div class="system-meta">
<div class="system-title">wavy.fm API</div>
<div class="system-description">The API that backs the wavy.fm website.</div>
</div>
</div>
<div class="system-status"></div>
</div>
<!-- <div class="system-row" id="system-spotify_tracking">-->
<!-- <div style="display: flex; flex-grow: 1">-->
<!-- <div class="system-icon"></div>-->
<!-- <div class="system-meta">-->
<!-- <div class="system-title">Spotify Tracking</div>-->
<!-- <div class="system-description">The systems that automatically track your Spotify history on-->
<!-- wavy.fm-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="system-status"></div>-->
<!-- </div>-->
</div>
<div class="metrics">
<div id="listens-graph"></div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.1.0/dygraph.min.js"></script>
<script type="application/javascript">
let graph;
function getIncidentName(systemId) {
switch (systemId) {
case "website":
return "Website is Unavailable";
case "api":
return "wavy.fm API is Unavailable"
case "spotify_tracking":
return "Spotify Tracking is Delayed"
}
}
function getStatus(system) {
return fetch("/status/" + system + ".json")
.then(resp => {
if (resp.ok) {
return resp.json()
} else {
return undefined;
}
})
.catch(err => {
return undefined;
})
}
function getAllStatuses() {
return Promise.all([getStatus("website"), getStatus("api"), getStatus("spotify_tracking")]);
}
function getGlobalStatusTitle(statuses) {
let title = undefined;
let multiple = false;
statuses.forEach(status => {
if (status && status.status !== "Green") {
if (!title) {
title = getIncidentName(status.id);
} else {
multiple = true;
}
}
})
if (multiple) {
return "Multiple Systems Failing";
} else {
return title || "All Systems Operational"
}
}
function resetColors() {
let nodes;
nodes = document.getElementsByClassName("green-text");
while (nodes.length) nodes[0].classList.remove("green-text");
nodes = document.getElementsByClassName("yellow-text");
while (nodes.length) nodes[0].classList.remove("yellow-text");
nodes = document.getElementsByClassName("red-text");
while (nodes.length) nodes[0].classList.remove("red-text");
nodes = document.getElementsByClassName("green-background");
while (nodes.length) nodes[0].classList.remove("green-background");
nodes = document.getElementsByClassName("yellow-background");
while (nodes.length) nodes[0].classList.remove("yellow-background");
nodes = document.getElementsByClassName("red-background");
while (nodes.length) nodes[0].classList.remove("red-background");
}
function getGlobalStatusColor(statuses) {
if (statuses.every(status => !status || status.status === "Green")) return "green";
if (statuses.find(status => status && status.status === "Red")) return "red";
return "yellow";
}
function updateGlobalStatus(color, title, time) {
document.getElementsByClassName("global-status-title").item(0).innerText = title;
document.getElementsByClassName("global-status-time").item(0).innerText = time;
document.getElementsByClassName("global-status").item(0).classList.add(color + "-background");
}
function updateSystemStatus(status) {
if (!status) {
return;
}
const color = status.status.toLowerCase();
const icon = document.querySelector(`#system-${status.id} .system-icon`);
const statusText = document.querySelector(`#system-${status.id} .system-status`);
if (icon) {
icon.classList.add(color + "-background");
}
if (statusText) {
statusText.classList.add(color + "-text");
switch (color) {
case "green":
statusText.innerText = "Operational"
break;
case "yellow":
statusText.innerText = "Incident"
break;
case "red":
statusText.innerText = "Critical"
break;
}
}
}
function getMetrics() {
return fetch("/metrics")
.then(resp => {
if (resp.ok) {
return resp.json()
} else {
return undefined;
}
})
.catch(err => {
return undefined;
})
}
function update() {
getAllStatuses()
.then(statuses => {
resetColors();
const color = getGlobalStatusColor(statuses);
const title = getGlobalStatusTitle(statuses);
const time = "A few moments ago";
updateGlobalStatus(color, title, time);
statuses.forEach(updateSystemStatus);
})
getMetrics()
.then(metrics => {
const data = metrics.map(row => {
return [new Date(row._id), row.count]
})
// Remove edges because of partial data
data.shift();
data.pop();
if (graph) {
graph.updateOptions({file: data});
} else {
const div = document.getElementById("listens-graph");
if (div) {
div.innerHTML = "";
graph = new Dygraph(div, data, {
legend: 'never',
title: 'Listens per minute (past 48h) -- UTC',
colors: ["#48c3d2"],
includeZero: true
});
}
}
})
.catch(console.error)
}
setInterval(update, 15000);
update();
</script>
</body>
</html>