summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/cbi.js78
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/luci.js186
-rw-r--r--modules/luci-base/luasrc/view/cbi/map.htm34
-rw-r--r--modules/luci-base/luasrc/view/cbi/nsection.htm1
-rw-r--r--modules/luci-base/luasrc/view/cbi/tabcontainer.htm15
-rw-r--r--modules/luci-base/luasrc/view/cbi/tabmenu.htm12
-rw-r--r--modules/luci-base/luasrc/view/cbi/tsection.htm2
-rw-r--r--modules/luci-mod-status/luasrc/controller/admin/status.lua22
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index.htm122
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm29
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm31
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm17
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm14
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm20
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm26
15 files changed, 379 insertions, 230 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index 635740a70c..61b83e8294 100644
--- a/modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js
@@ -12,7 +12,6 @@
*/
var cbi_d = [];
-var cbi_t = [];
var cbi_strings = { path: {}, label: {} };
function s8(bytes, off) {
@@ -727,13 +726,13 @@ function cbi_d_update() {
parent.parentNode.style.display = (parent.options.length <= 1) ? 'none' : '';
}
- if (entry && entry.parent) {
- if (!cbi_t_update())
- cbi_tag_last(parent);
- }
+ if (entry && entry.parent)
+ cbi_tag_last(parent);
if (state)
cbi_d_update();
+ else if (parent)
+ parent.dispatchEvent(new CustomEvent('dependency-update', { bubbles: true }));
}
function cbi_init() {
@@ -1045,75 +1044,6 @@ function cbi_dynlist_init(dl, datatype, optional, choices)
cbi_dynlist_init.prototype = CBIDynamicList;
-function cbi_t_add(section, tab) {
- var t = document.getElementById('tab.' + section + '.' + tab);
- var c = document.getElementById('container.' + section + '.' + tab);
-
- if (t && c) {
- cbi_t[section] = (cbi_t[section] || [ ]);
- cbi_t[section][tab] = { 'tab': t, 'container': c, 'cid': c.id };
- }
-}
-
-function cbi_t_switch(section, tab) {
- if (cbi_t[section] && cbi_t[section][tab]) {
- var o = cbi_t[section][tab];
- var h = document.getElementById('tab.' + section);
-
- for (var tid in cbi_t[section]) {
- var o2 = cbi_t[section][tid];
-
- if (o.tab.id != o2.tab.id) {
- o2.tab.classList.remove('cbi-tab');
- o2.tab.classList.add('cbi-tab-disabled');
- o2.container.style.display = 'none';
- }
- else {
- if(h)
- h.value = tab;
-
- o2.tab.classList.remove('cbi-tab-disabled');
- o2.tab.classList.add('cbi-tab');
- o2.container.style.display = 'block';
- }
- }
- }
-
- return false;
-}
-
-function cbi_t_update() {
- var hl_tabs = [ ];
- var updated = false;
-
- for (var sid in cbi_t)
- for (var tid in cbi_t[sid]) {
- var t = cbi_t[sid][tid].tab;
- var c = cbi_t[sid][tid].container;
-
- if (!c.firstElementChild) {
- t.style.display = 'none';
- }
- else if (t.style.display == 'none') {
- t.style.display = '';
- t.classList.add('cbi-tab-highlighted');
- hl_tabs.push(t);
- }
-
- cbi_tag_last(c);
- updated = true;
- }
-
- if (hl_tabs.length > 0)
- window.setTimeout(function() {
- for (var i = 0; i < hl_tabs.length; i++)
- hl_tabs[i].classList.remove('cbi-tab-highlighted');
- }, 750);
-
- return updated;
-}
-
-
function cbi_validate_form(form, errmsg)
{
/* if triggered by a section removal or addition, don't validate */
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js
index 04c460182f..4cb8bf4e5d 100644
--- a/modules/luci-base/htdocs/luci-static/resources/luci.js
+++ b/modules/luci-base/htdocs/luci-static/resources/luci.js
@@ -129,10 +129,16 @@
tooltipDiv.style.top = y + 'px';
tooltipDiv.style.left = x + 'px';
tooltipDiv.style.opacity = 1;
+
+ tooltipDiv.dispatchEvent(new CustomEvent('tooltip-open', {
+ bubbles: true,
+ detail: { target: target }
+ }));
},
hideTooltip: function(ev) {
- if (ev.target === tooltipDiv || ev.relatedTarget === tooltipDiv)
+ if (ev.target === tooltipDiv || ev.relatedTarget === tooltipDiv ||
+ tooltipDiv.contains(ev.target) || tooltipDiv.contains(ev.relatedTarget))
return;
if (tooltipTimeout !== null) {
@@ -142,6 +148,8 @@
tooltipDiv.style.opacity = 0;
tooltipTimeout = window.setTimeout(function() { tooltipDiv.removeAttribute('style'); }, 250);
+
+ tooltipDiv.dispatchEvent(new CustomEvent('tooltip-close', { bubbles: true }));
},
@@ -173,6 +181,175 @@
}
};
+ /* Tabs */
+ LuCI.prototype.tabs = {
+ init: function() {
+ var groups = [], prevGroup = null, currGroup = null;
+
+ document.querySelectorAll('[data-tab]').forEach(function(tab) {
+ var parent = tab.parentNode;
+
+ if (!parent.hasAttribute('data-tab-group'))
+ parent.setAttribute('data-tab-group', groups.length);
+
+ currGroup = +parent.getAttribute('data-tab-group');
+
+ if (currGroup !== prevGroup) {
+ prevGroup = currGroup;
+
+ if (!groups[currGroup])
+ groups[currGroup] = [];
+ }
+
+ groups[currGroup].push(tab);
+ });
+
+ for (var i = 0; i < groups.length; i++)
+ this.initTabGroup(groups[i]);
+
+ document.addEventListener('dependency-update', this.updateTabs.bind(this));
+
+ this.updateTabs();
+
+ if (!groups.length)
+ this.setActiveTabId(-1, -1);
+ },
+
+ initTabGroup: function(panes) {
+ if (!Array.isArray(panes) || panes.length === 0)
+ return;
+
+ var menu = E('ul', { 'class': 'cbi-tabmenu' }),
+ group = panes[0].parentNode,
+ groupId = +group.getAttribute('data-tab-group'),
+ selected = null;
+
+ for (var i = 0, pane; pane = panes[i]; i++) {
+ var name = pane.getAttribute('data-tab'),
+ title = pane.getAttribute('data-tab-title'),
+ active = pane.getAttribute('data-tab-active') === 'true';
+
+ menu.appendChild(E('li', {
+ 'class': active ? 'cbi-tab' : 'cbi-tab-disabled',
+ 'data-tab': name
+ }, E('a', {
+ 'href': '#',
+ 'click': this.switchTab.bind(this)
+ }, title)));
+
+ if (active)
+ selected = i;
+ }
+
+ group.parentNode.insertBefore(menu, group);
+
+ if (selected === null) {
+ selected = this.getActiveTabId(groupId);
+
+ if (selected < 0 || selected >= panes.length)
+ selected = 0;
+
+ menu.childNodes[selected].classList.add('cbi-tab');
+ menu.childNodes[selected].classList.remove('cbi-tab-disabled');
+ panes[selected].setAttribute('data-tab-active', 'true');
+
+ this.setActiveTabId(groupId, selected);
+ }
+ },
+
+ getActiveTabState: function() {
+ var page = document.body.getAttribute('data-page');
+
+ try {
+ var val = JSON.parse(window.sessionStorage.getItem('tab'));
+ if (val.page === page && Array.isArray(val.groups))
+ return val;
+ }
+ catch(e) {}
+
+ window.sessionStorage.removeItem('tab');
+ return { page: page, groups: [] };
+ },
+
+ getActiveTabId: function(groupId) {
+ return +this.getActiveTabState().groups[groupId] || 0;
+ },
+
+ setActiveTabId: function(groupId, tabIndex) {
+ try {
+ var state = this.getActiveTabState();
+ state.groups[groupId] = tabIndex;
+
+ window.sessionStorage.setItem('tab', JSON.stringify(state));
+ }
+ catch (e) { return false; }
+
+ return true;
+ },
+
+ updateTabs: function(ev) {
+ document.querySelectorAll('[data-tab-title]').forEach(function(pane) {
+ var menu = pane.parentNode.previousElementSibling,
+ tab = menu.querySelector('[data-tab="%s"]'.format(pane.getAttribute('data-tab'))),
+ n_errors = pane.querySelectorAll('.cbi-input-invalid').length;
+
+ if (!pane.firstElementChild) {
+ tab.style.display = 'none';
+ tab.classList.remove('flash');
+ }
+ else if (tab.style.display === 'none') {
+ tab.style.display = '';
+ requestAnimationFrame(function() { tab.classList.add('flash') });
+ }
+
+ if (n_errors) {
+ tab.setAttribute('data-errors', n_errors);
+ tab.setAttribute('data-tooltip', _('%d invalid field(s)').format(n_errors));
+ tab.setAttribute('data-tooltip-style', 'error');
+ }
+ else {
+ tab.removeAttribute('data-errors');
+ tab.removeAttribute('data-tooltip');
+ }
+ });
+ },
+
+ switchTab: function(ev) {
+ var tab = ev.target.parentNode,
+ name = tab.getAttribute('data-tab'),
+ menu = tab.parentNode,
+ group = menu.nextElementSibling,
+ groupId = +group.getAttribute('data-tab-group'),
+ index = 0;
+
+ ev.preventDefault();
+
+ if (!tab.classList.contains('cbi-tab-disabled'))
+ return;
+
+ menu.querySelectorAll('[data-tab]').forEach(function(tab) {
+ tab.classList.remove('cbi-tab');
+ tab.classList.remove('cbi-tab-disabled');
+ tab.classList.add(
+ tab.getAttribute('data-tab') === name ? 'cbi-tab' : 'cbi-tab-disabled');
+ });
+
+ group.childNodes.forEach(function(pane) {
+ if (L.dom.matches(pane, '[data-tab]')) {
+ if (pane.getAttribute('data-tab') === name) {
+ pane.setAttribute('data-tab-active', 'true');
+ L.tabs.setActiveTabId(groupId, index);
+ }
+ else {
+ pane.setAttribute('data-tab-active', 'false');
+ }
+
+ index++;
+ }
+ });
+ }
+ };
+
/* DOM manipulation */
LuCI.prototype.dom = {
elem: function(e) {
@@ -308,6 +485,11 @@
}
};
+ /* Setup */
+ LuCI.prototype.setupDOM = function(ev) {
+ this.tabs.init();
+ };
+
function LuCI(env) {
this.env = env;
@@ -321,6 +503,8 @@
document.addEventListener('mouseout', this.hideTooltip.bind(this), true);
document.addEventListener('focus', this.showTooltip.bind(this), true);
document.addEventListener('blur', this.hideTooltip.bind(this), true);
+
+ document.addEventListener('DOMContentLoaded', this.setupDOM.bind(this));
}
window.LuCI = LuCI;
diff --git a/modules/luci-base/luasrc/view/cbi/map.htm b/modules/luci-base/luasrc/view/cbi/map.htm
index d65a161673..cda4d3530c 100644
--- a/modules/luci-base/luasrc/view/cbi/map.htm
+++ b/modules/luci-base/luasrc/view/cbi/map.htm
@@ -3,25 +3,25 @@
<%- end end -%>
<div class="cbi-map" id="cbi-<%=self.config%>">
- <% if self.title and #self.title > 0 then %><h2 name="content"><%=self.title%></h2><% end %>
- <% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
+ <% if self.title and #self.title > 0 then %>
+ <h2 name="content"><%=self.title%></h2>
+ <% end %>
+ <% if self.description and #self.description > 0 then %>
+ <div class="cbi-map-descr"><%=self.description%></div>
+ <% end %>
<% if self.tabbed then %>
- <ul class="cbi-tabmenu map">
- <%- self.selected_tab = luci.http.formvalue("tab.m-" .. self.config) %>
- <% for i, section in ipairs(self.children) do %>
- <%- if not self.selected_tab then self.selected_tab = section.sectiontype end %>
- <li id="tab.m-<%=self.config%>.<%=section.section or section.sectiontype%>" class="cbi-tab<%=(section.sectiontype == self.selected_tab) and '' or '-disabled'%>">
- <a onclick="this.blur(); return cbi_t_switch('m-<%=self.config%>', '<%=section.section or section.sectiontype%>')" href="<%=REQUEST_URI%>?tab.m-<%=self.config%>=<%=section.section or section.sectiontype%>"><%=section.title or section.section or section.sectiontype %></a>
- <% if section.sectiontype == self.selected_tab then %><input type="hidden" id="tab.m-<%=self.config%>" name="tab.m-<%=self.config%>" value="<%=section.section or section.sectiontype%>" /><% end %>
- </li>
+ <div>
+ <% for i, section in ipairs(self.children) do
+ tab = section.section or section.sectiontype %>
+ <div class="cbi-tabcontainer"<%=
+ attr("id", "container.m-%s.%s" %{ self.config, tab }) ..
+ attr("data-tab", tab) ..
+ attr("data-tab-title", section.title or tab)
+ %>>
+ <% section:render() %>
+ </div>
<% end %>
- </ul>
- <% for i, section in ipairs(self.children) do %>
- <div class="cbi-tabcontainer" id="container.m-<%=self.config%>.<%=section.section or section.sectiontype%>"<% if section.sectiontype ~= self.selected_tab then %> style="display:none"<% end %>>
- <% section:render() %>
- </div>
- <script type="text/javascript">cbi_t_add('m-<%=self.config%>', '<%=section.section or section.sectiontype%>')</script>
- <% end %>
+ </div>
<% if not self.save then -%>
<div class="cbi-section-error">
diff --git a/modules/luci-base/luasrc/view/cbi/nsection.htm b/modules/luci-base/luasrc/view/cbi/nsection.htm
index 63abc57734..14232e3d94 100644
--- a/modules/luci-base/luasrc/view/cbi/nsection.htm
+++ b/modules/luci-base/luasrc/view/cbi/nsection.htm
@@ -11,7 +11,6 @@
<input type="submit" class="cbi-button" name="cbi.rns.<%=self.config%>.<%=section%>" value="<%:Delete%>" />
</div>
<%- end %>
- <%+cbi/tabmenu%>
<div class="cbi-section-node<% if self.tabs then %> cbi-section-node-tabbed<% end %>" id="cbi-<%=self.config%>-<%=section%>">
<%+cbi/ucisection%>
</div>
diff --git a/modules/luci-base/luasrc/view/cbi/tabcontainer.htm b/modules/luci-base/luasrc/view/cbi/tabcontainer.htm
index 38c435d6a1..7fcb835783 100644
--- a/modules/luci-base/luasrc/view/cbi/tabcontainer.htm
+++ b/modules/luci-base/luasrc/view/cbi/tabcontainer.htm
@@ -1,7 +1,14 @@
-<% for tab, data in pairs(self.tabs) do %>
- <div class="cbi-tabcontainer" id="container.<%=self.config%>.<%=section%>.<%=tab%>"<% if tab ~= self.selected_tab then %> style="display:none"<% end %>>
- <% if data.description then %><div class="cbi-tab-descr"><%=data.description%></div><% end %>
+<% for _, tab in ipairs(self.tab_names) do data = self.tabs[tab] %>
+ <div class="cbi-tabcontainer"<%=
+ attr("id", "container.%s.%s.%s" %{ self.config, section, tab }) ..
+ attr("data-tab", tab) ..
+ attr("data-tab-title", data.title) ..
+ attr("data-tab-active", tostring(tab == self.selected_tab))
+ %>>
+ <% if data.description then %>
+ <div class="cbi-tab-descr"><%=data.description%></div>
+ <% end %>
+
<% self:render_tab(tab, section, scope or {}) %>
</div>
- <script type="text/javascript">cbi_t_add('<%=self.config%>.<%=section%>', '<%=tab%>')</script>
<% end %>
diff --git a/modules/luci-base/luasrc/view/cbi/tabmenu.htm b/modules/luci-base/luasrc/view/cbi/tabmenu.htm
deleted file mode 100644
index 06c1414bf3..0000000000
--- a/modules/luci-base/luasrc/view/cbi/tabmenu.htm
+++ /dev/null
@@ -1,12 +0,0 @@
-<%- if self.tabs then %>
- <ul class="cbi-tabmenu">
- <%- self.selected_tab = luci.http.formvalue("tab." .. self.config .. "." .. section) %>
- <%- for _, tab in ipairs(self.tab_names) do if #self.tabs[tab].childs > 0 then %>
- <%- if not self.selected_tab then self.selected_tab = tab end %>
- <li id="tab.<%=self.config%>.<%=section%>.<%=tab%>" class="cbi-tab<%=(tab == self.selected_tab) and '' or '-disabled'%>">
- <a onclick="this.blur(); return cbi_t_switch('<%=self.config%>.<%=section%>', '<%=tab%>')" href="<%=REQUEST_URI%>?tab.<%=self.config%>.<%=section%>=<%=tab%>"><%=self.tabs[tab].title%></a>
- <% if tab == self.selected_tab then %><input type="hidden" id="tab.<%=self.config%>.<%=section%>" name="tab.<%=self.config%>.<%=section%>" value="<%=tab%>" /><% end %>
- </li>
- <% end end -%>
- </ul>
-<% end -%>
diff --git a/modules/luci-base/luasrc/view/cbi/tsection.htm b/modules/luci-base/luasrc/view/cbi/tsection.htm
index 1a13df0c04..547a793329 100644
--- a/modules/luci-base/luasrc/view/cbi/tsection.htm
+++ b/modules/luci-base/luasrc/view/cbi/tsection.htm
@@ -18,8 +18,6 @@
<h3><%=section:upper()%></h3>
<%- end %>
- <%+cbi/tabmenu%>
-
<div class="cbi-section-node<% if self.tabs then %> cbi-section-node-tabbed<% end %>" id="cbi-<%=self.config%>-<%=section%>">
<%+cbi/ucisection%>
</div>
diff --git a/modules/luci-mod-status/luasrc/controller/admin/status.lua b/modules/luci-mod-status/luasrc/controller/admin/status.lua
index 63b9390775..0d955c95fe 100644
--- a/modules/luci-mod-status/luasrc/controller/admin/status.lua
+++ b/modules/luci-mod-status/luasrc/controller/admin/status.lua
@@ -52,22 +52,12 @@ function dump_iptables(family, table)
local s
for s in lines do
if s == table then
- local ipt = io.popen(
- "/usr/sbin/%stables -w -t %s --line-numbers -nxvL"
- %{ prefix, table })
-
- if ipt then
- luci.http.prepare_content("text/plain")
-
- while true do
- s = ipt:read(1024)
- if not s then break end
- luci.http.write(s)
- end
-
- ipt:close()
- return
- end
+ luci.http.prepare_content("text/plain")
+ luci.sys.process.exec({
+ "/usr/sbin/%stables" % prefix, "-w", "-t", table,
+ "--line-numbers", "-nxvL"
+ }, luci.http.write)
+ return
end
end
end
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index.htm b/modules/luci-mod-status/luasrc/view/admin_status/index.htm
index b11956a8af..465226fe09 100644
--- a/modules/luci-mod-status/luasrc/view/admin_status/index.htm
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index.htm
@@ -11,29 +11,24 @@
local stat = require "luci.tools.status"
local ver = require "luci.version"
- local has_ipv6 = fs.access("/proc/net/ipv6_route")
- local has_dhcp = fs.access("/etc/config/dhcp")
- local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0)
+ if luci.http.formvalue("status") == "1" then
- local sysinfo = luci.util.ubus("system", "info") or { }
- local boardinfo = luci.util.ubus("system", "board") or { }
- local unameinfo = nixio.uname() or { }
+ local sysinfo = luci.util.ubus("system", "info") or { }
- local meminfo = sysinfo.memory or {
- total = 0,
- free = 0,
- buffered = 0,
- shared = 0
- }
+ local meminfo = sysinfo.memory or {
+ total = 0,
+ free = 0,
+ buffered = 0,
+ shared = 0
+ }
- local swapinfo = sysinfo.swap or {
- total = 0,
- free = 0
- }
+ local swapinfo = sysinfo.swap or {
+ total = 0,
+ free = 0
+ }
- local has_dsl = fs.access("/etc/init.d/dsl_control")
+ local has_dsl = fs.access("/etc/init.d/dsl_control")
- if luci.http.formvalue("status") == "1" then
local ntm = require "luci.model.network".init()
local wan_nets = ntm:get_wan_networks()
local wan6_nets = ntm:get_wan6_networks()
@@ -133,98 +128,19 @@
<h2 name="content"><%:Status%></h2>
-<div class="cbi-section">
- <h3><%:System%></h3>
-
- <div class="table" width="100%">
- <div class="tr"><div class="td left" width="33%"><%:Hostname%></div><div class="td left"><%=luci.sys.hostname() or "?"%></div></div>
- <div class="tr"><div class="td left" width="33%"><%:Model%></div><div class="td left"><%=pcdata(boardinfo.model or "?")%></div></div>
- <div class="tr"><div class="td left" width="33%"><%:Architecture%></div><div class="td left"><%=pcdata(boardinfo.system or "?")%></div></div>
- <div class="tr"><div class="td left" width="33%"><%:Firmware Version%></div><div class="td left">
- <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> /
- <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>)
- </div></div>
- <div class="tr"><div class="td left" width="33%"><%:Kernel Version%></div><div class="td left"><%=unameinfo.release or "?"%></div></div>
- <div class="tr"><div class="td left" width="33%"><%:Local Time%></div><div class="td left" id="localtime">-</div></div>
- <div class="tr"><div class="td left" width="33%"><%:Uptime%></div><div class="td left" id="uptime">-</div></div>
- <div class="tr"><div class="td left" width="33%"><%:Load Average%></div><div class="td left" id="loadavg">-</div></div>
- </div>
-</div>
-
-<div class="cbi-section">
- <h3><%:Memory%></h3>
-
- <div class="table" width="100%">
- <div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left"><div id="memtotal" class="cbi-progressbar" title="-"><div></div></div></div></div>
- <div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left"><div id="memfree" class="cbi-progressbar" title="-"><div></div></div></div></div>
- <div class="tr"><div class="td left" width="33%"><%:Buffered%></div><div class="td left"><div id="membuff" class="cbi-progressbar" title="-"><div></div></div></div></div>
- </div>
-</div>
-
-<% if swapinfo.total > 0 then %>
-<div class="cbi-section">
- <h3><%:Swap%></h3>
-
- <div class="table" width="100%">
- <div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left"><div id="swaptotal" class="cbi-progressbar" title="-"><div></div></div></div></div>
- <div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left"><div id="swapfree" class="cbi-progressbar" title="-"><div></div></div></div></div>
- </div>
-</div>
-<% end %>
-
-<div class="cbi-section">
- <h3><%:Network%></h3>
-
- <div id="upstream_status_table" class="network-status-table">
- <p><em><%:Collecting data...%></em></p>
- </div>
-
- <div class="table" width="100%">
- <div class="tr"><div class="td left" width="33%"><%:Active Connections%></div><div class="td left"><div id="conns" class="cbi-progressbar" title="-"><div></div></div></div></div>
- </div>
-</div>
-
-<%
- if has_dhcp then
- include("lease_status")
- end
-%>
-
-<% if has_dsl then %>
-<div class="cbi-section">
- <h3><%:DSL%></h3>
-
- <div id="dsl_status_table" class="network-status-table">
- <p><em><%:Collecting data...%></em></p>
- </div>
-</div>
-<% end %>
-
-<% if has_wifi then %>
-<div class="cbi-section">
- <h3><%:Wireless%></h3>
-
- <div id="wifi_status_table" class="network-status-table">
- <p><em><%:Collecting data...%></em></p>
- </div>
-</div>
-
-<div class="cbi-section">
- <h3><%:Associated Stations%></h3>
-
- <%+wifi_assoclist%>
-</div>
-<% end %>
-
<%-
local incdir = util.libpath() .. "/view/admin_status/index/"
if fs.access(incdir) then
- local inc
+ local _, inc
+ local includes = {}
for inc in fs.dir(incdir) do
if inc:match("%.htm$") then
- include("admin_status/index/" .. inc:gsub("%.htm$", ""))
+ includes[#includes + 1] = inc:gsub("%.htm$", "")
end
end
+ for _, inc in luci.util.vspairs(includes) do
+ include("admin_status/index/" .. inc)
+ end
end
-%>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm
new file mode 100644
index 0000000000..994550ec2b
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm
@@ -0,0 +1,29 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<%
+ local boardinfo = luci.util.ubus("system", "board") or { }
+ local unameinfo = nixio.uname() or { }
+ local ver = require "luci.version"
+%>
+
+<div class="cbi-section">
+ <h3><%:System%></h3>
+
+ <div class="table" width="100%">
+ <div class="tr"><div class="td left" width="33%"><%:Hostname%></div><div class="td left"><%=luci.sys.hostname() or "?"%></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Model%></div><div class="td left"><%=pcdata(boardinfo.model or "?")%></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Architecture%></div><div class="td left"><%=pcdata(boardinfo.system or "?")%></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Firmware Version%></div><div class="td left">
+ <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> /
+ <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>)
+ </div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Kernel Version%></div><div class="td left"><%=unameinfo.release or "?"%></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Local Time%></div><div class="td left" id="localtime">-</div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Uptime%></div><div class="td left" id="uptime">-</div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Load Average%></div><div class="td left" id="loadavg">-</div></div>
+ </div>
+</div>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm
new file mode 100644
index 0000000000..13774704fe
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm
@@ -0,0 +1,31 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<%
+ local sysinfo = luci.util.ubus("system", "info") or { }
+ local has_swap = sysinfo.swap and sysinfo.swap.total > 0 or false
+%>
+
+<div class="cbi-section">
+ <h3><%:Memory%></h3>
+
+ <div class="table" width="100%">
+ <div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left"><div id="memtotal" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left"><div id="memfree" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Buffered%></div><div class="td left"><div id="membuff" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ </div>
+</div>
+
+<% if has_swap then %>
+<div class="cbi-section">
+ <h3><%:Swap%></h3>
+
+ <div class="table" width="100%">
+ <div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left"><div id="swaptotal" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left"><div id="swapfree" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ </div>
+</div>
+<% end %>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm
new file mode 100644
index 0000000000..945a31b2e5
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm
@@ -0,0 +1,17 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<div class="cbi-section">
+ <h3><%:Network%></h3>
+
+ <div id="upstream_status_table" class="network-status-table">
+ <p><em><%:Collecting data...%></em></p>
+ </div>
+
+ <div class="table" width="100%">
+ <div class="tr"><div class="td left" width="33%"><%:Active Connections%></div><div class="td left"><div id="conns" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ </div>
+</div>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm
new file mode 100644
index 0000000000..aaf3661442
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm
@@ -0,0 +1,14 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<%
+ local fs = require "nixio.fs"
+ local has_dhcp = fs.access("/etc/config/dhcp")
+
+ if has_dhcp then
+ include("lease_status")
+ end
+%>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm
new file mode 100644
index 0000000000..f37bf147a3
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm
@@ -0,0 +1,20 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<%
+ local fs = require "nixio.fs"
+ local has_dsl = fs.access("/etc/init.d/dsl_control")
+%>
+
+<% if has_dsl then %>
+<div class="cbi-section">
+ <h3><%:DSL%></h3>
+
+ <div id="dsl_status_table" class="network-status-table">
+ <p><em><%:Collecting data...%></em></p>
+ </div>
+</div>
+<% end %>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm
new file mode 100644
index 0000000000..7338bc77f1
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm
@@ -0,0 +1,26 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<%
+ local fs = require "nixio.fs"
+ local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0)
+%>
+
+<% if has_wifi then %>
+<div class="cbi-section">
+ <h3><%:Wireless%></h3>
+
+ <div id="wifi_status_table" class="network-status-table">
+ <p><em><%:Collecting data...%></em></p>
+ </div>
+</div>
+
+<div class="cbi-section">
+ <h3><%:Associated Stations%></h3>
+
+ <%+wifi_assoclist%>
+</div>
+<% end %>