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
{ ifaces, hostname }:
let
pkgs = import <nixpkgs> {};
lib = pkgs.lib;
ifacesL = lib.splitString "\n" ifaces;
types = [
{ name = "summary"; title = "Summary"; }
{ name = "hourly"; title = "Hourly"; }
{ name = "daily"; title = "Daily"; }
{ name = "monthly"; title = "Monthly"; }
{ name = "top10"; title = "Top 10"; }
];
in {
html = ''
<!DOCTYPE html>
<html lang="en">
<head>
<title>${hostname} - stats</title>
<meta charset="utf-8">
<meta name="robots" content="none">
<link rel="icon" href="static/favicon.ico" type="image/x-icon">
<style>
body {
padding: 0;
margin: 0;
background: #eee;
font-family: monospace;
min-height: 100vh;
}
img:not(:last-child) {
margin-bottom: 15px;
}
img {
flex-shrink: 0;
}
.ui.segment {
margin: 0 1em 10px 1em;
padding: 1em;
background-color: white;
box-shadow: 0 1px 2px 0 rgba(34,36,38,.15);
border-radius: .286rem;
border: 1px solid rgba(34,36,38,.15);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
div.heading {
min-width: 100vw;
height: 70px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
div.table.vertical {
overflow-y: auto;
min-width: 100vw;
height: calc(100vh - 70px);
display: flex;
flex-direction: row;
}
div.iface {
display: flex;
flex-direction: column;
align-items: center;
flex-grow: 1;
}
</style>
</head>
<body>
<div class="heading">
<h1>${hostname}</h1>
</div>
<div class="table vertical">
${lib.concatMapStringsSep "\n" (iface: ''
<div class="iface">
<h3>${iface}</h3>
${lib.concatMapStrings (type: ''
<div class="ui segment">
<img src="${iface}-${type.name}.png" alt="${type.title}">
</div>
'') types}
</div>
'') ifacesL}
</div>
</body>
</html>
'';
}