-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
127 lines (122 loc) · 4.22 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
{{define "StatCard"}}
<article class="stat">
<h6>{{ .Title }}</h6>
{{if not .Data}}
<span class="no-data">No data</span>
{{else}}
<table class="linestat">
<thead>
<th scope="col">{{ .UnitDisplayLabel }}</th>
<th scope="col">{{ .CountLabel }}</th>
</thead>
<tbody>
{{ $max := (index .Data 0).Value }}
{{range .Data }}
<tr>
<th scope="row">
<span class="label">{{ .Label }}</span>
<progress max="{{ $max }}" value="{{ .Value }}"></progress>
</th>
<td>{{ printf "%.0f" .Value }}</td>
</tr>
{{end}}
</tbody>
{{if (gt (len .Data) 5)}}
<tfoot>
<tr>
<td colspan="2"><a href="#" class="show-all">Show all {{ len .Data }}</a></td>
</tr>
</tfoot>
{{end}}
</table>
{{end}}
</article>
{{end}}
{{define "VerticalBarChart"}}
<div class="vertical-bars">
{{ range . }}
<div class="bar" style="height: {{ .Percent }}%" data-tooltip="{{ .FormattedTimestamp }}: {{ .Value }}"></div>
{{ end }}
</div>
{{end}}
{{define "TrendLabel"}}
<span class="big-number" data-localize-number>{{.CurrentValue}}</span>
{{if (eq .PercentChange 0.0)}}
<small class="trend same" data-tooltip="No change from previous period">±0%</small>
{{else}}
{{if (gt .PreviousValue 0) }}
<small
class="trend {{if (gt .PercentChange 0.0)}}up{{else}}down{{end}}"
data-tooltip="{{ .PreviousValue }} in previous period">
{{ printf "%+.2f" .PercentChange }}%
</small>
{{end}}
{{end}}
{{end}}
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Kero</title>
<link rel="stylesheet" href="{{.BasePath}}/assets/css/pico.min.css" />
<link rel="stylesheet" href="{{.BasePath}}/assets/css/app.css" />
<script src="{{.BasePath}}/assets/js/index.js" type="module"></script>
</head>
<body>
<div id="navbar-wrapper">
<nav class="container">
<ul>
<li><strong>{{ .Title }}</strong></li>
</ul>
<ul>
<li>
<details role="list" dir="rtl" id="timeframe-selector">
<summary aria-haspopup="listbox" role="link" id="selected-timeframe-label">Timeframe</summary>
<ul role="listbox">
<li><a href="?t=t">Today</a></li>
<li><a href="?t=24h">Past 24 hours</a></li>
<li><a href="?t=7d">Past 7 days</a></li>
<li><a href="?t=30d">Past 30 days</a></li>
<li><a href="?t=12m">Past 12 months</a></li>
<li><a href="?t=mtd">Month to date</a></li>
<li><a href="?t=ytd">Year to date</a></li>
</ul>
</details>
</li>
</ul>
</nav>
</div>
<main class="container">
<br/>
<div class="grid">
<article>
<hgroup>
<h6>Visitors</h6>
{{ template "TrendLabel" .VisitorsTrend }}
</hgroup>
{{ template "VerticalBarChart" .VisitorsChartData }}
</article>
<article>
<hgroup>
<h6>Views</h6>
{{ template "TrendLabel" .ViewsTrend }}
</hgroup>
{{ template "VerticalBarChart" .ViewsChartData }}
</article>
</div>
{{range .Rows}}
<div class="grid">
{{range .}}
{{ template "StatCard" . }}
{{end}}
</div>
{{end}}
{{if .ShowFooter}}
<footer>
<hr/>
<small>Dashboard by <a href="https://github.com/josip/kero" target="_blank" rel="noreferrer">Kero</a></small>
</footer>
{{end}}
</main>
</body>
</html>