treewide: import utility classes explicitly
[project/luci.git] / modules / luci-mod-status / luasrc / view / admin_status / index.htm
1 <%#
2 Copyright 2008 Steven Barth <steven@midlink.org>
3 Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
4 Licensed to the public under the Apache License 2.0.
5 -%>
6
7 <%+header%>
8
9 <h2 name="content"><%:Status%></h2>
10
11 <div id="view">
12 <div class="spinning"><%:Loading view…%></div>
13 </div>
14
15 <script type="text/javascript">//<![CDATA[
16 function progressbar(query, value, max, byte)
17 {
18 var pg = document.querySelector(query),
19 vn = parseInt(value) || 0,
20 mn = parseInt(max) || 100,
21 fv = byte ? String.format('%1024.2mB', value) : value,
22 fm = byte ? String.format('%1024.2mB', max) : max,
23 pc = Math.floor((100 / mn) * vn);
24
25 if (pg) {
26 pg.firstElementChild.style.width = pc + '%';
27 pg.setAttribute('title', '%s / %s (%d%%)'.format(fv, fm, pc));
28 }
29 }
30
31 function renderBox(title, active, childs) {
32 childs = childs || [];
33 childs.unshift(L.itemlist(E('span'), [].slice.call(arguments, 3)));
34
35 return E('div', { class: 'ifacebox' }, [
36 E('div', { class: 'ifacebox-head center ' + (active ? 'active' : '') },
37 E('strong', title)),
38 E('div', { class: 'ifacebox-body left' }, childs)
39 ]);
40 }
41
42 function renderBadge(icon, title) {
43 return E('span', { class: 'ifacebadge' }, [
44 E('img', { src: icon, title: title || '' }),
45 L.itemlist(E('span'), [].slice.call(arguments, 2))
46 ]);
47 }
48
49 //]]></script>
50
51 <div class="includes" style="display:none">
52 <%-
53 local util = require "luci.util"
54 local fs = require "nixio.fs"
55
56 local incdir = util.libpath() .. "/view/admin_status/index/"
57 if fs.access(incdir) then
58 local _, inc
59 local includes = {}
60 for inc in fs.dir(incdir) do
61 if inc:match("%.htm$") then
62 includes[#includes + 1] = inc:gsub("%.htm$", "")
63 end
64 end
65 for _, inc in luci.util.vspairs(includes) do
66 include("admin_status/index/" .. inc)
67 end
68 end
69 -%>
70 </div>
71
72 <script type="text/javascript">L.require('view.status.index').catch(function(err) {
73 dom.content(document.querySelector('#view'), null);
74 L.error(err);
75 });</script>
76
77 <%+footer%>