[TASK] Remove outdated code
This commit is contained in:
parent
d6b84eba22
commit
af589ee227
@ -16,7 +16,7 @@ define(function () {
|
||||
}
|
||||
|
||||
function run(d) {
|
||||
return (d !== undefined ? d.hostname.toLowerCase().includes(input.value.toLowerCase()) : '');
|
||||
return d.hostname.toLowerCase().includes(input.value.toLowerCase());
|
||||
}
|
||||
|
||||
function setRefresh(f) {
|
||||
|
@ -46,9 +46,8 @@ define(['helper', 'snabbdom'], function (helper, V) {
|
||||
}
|
||||
}, helper.showTq(d.source_tq) + ' - ' + helper.showTq(d.target_tq))));
|
||||
children.push(helper.attributeEntry(V, 'node.distance', helper.showDistance(d)));
|
||||
children.push(helper.attributeEntry(V, 'node.hardware',
|
||||
helper.dictGet(d.source, ['model']) + ' – ' + helper.dictGet(d.target, ['model']))
|
||||
);
|
||||
children.push(helper.attributeEntry(V, 'node.hardware', (d.source.model ? d.source.model + ' – ' : '') +
|
||||
(d.target.model ? d.target.model : '')));
|
||||
|
||||
var elNew = V.h('table', children);
|
||||
table = V.patch(table, elNew);
|
||||
|
@ -18,7 +18,7 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
|
||||
|
||||
function showStatus(d) {
|
||||
return V.h('td',
|
||||
{ props: { className: d.is_unseen ? 'unseen' : (d.is_online ? 'online' : 'offline') } },
|
||||
{ props: { className: d.is_online ? 'online' : 'offline' } },
|
||||
_.t((d.is_online ? 'node.lastOnline' : 'node.lastOffline'), {
|
||||
time: d.lastseen.fromNow(),
|
||||
date: d.lastseen.format('DD.MM.YYYY, H:mm:ss')
|
||||
@ -35,32 +35,15 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
|
||||
}
|
||||
|
||||
function showSite(d, config) {
|
||||
var site = helper.dictGet(d, ['site_code']);
|
||||
var rt = site;
|
||||
var rt = d.site_code;
|
||||
if (config.siteNames) {
|
||||
config.siteNames.forEach(function (t) {
|
||||
if (site === t.site) {
|
||||
if (d.site_code === t.site) {
|
||||
rt = t.name;
|
||||
}
|
||||
});
|
||||
}
|
||||
return rt || undefined;
|
||||
}
|
||||
|
||||
function showUptime(d) {
|
||||
if (!('uptime' in d)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return moment.utc(d.uptime).local().fromNow(true);
|
||||
}
|
||||
|
||||
function showFirstseen(d) {
|
||||
if (!('firstseen' in d)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return d.firstseen.fromNow(true);
|
||||
return rt;
|
||||
}
|
||||
|
||||
function showClients(d) {
|
||||
@ -101,22 +84,15 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
|
||||
}
|
||||
|
||||
function showIPs(d) {
|
||||
var ips = helper.dictGet(d, ['network', 'addresses']);
|
||||
if (ips === null) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
ips.sort();
|
||||
|
||||
var string = [];
|
||||
var ips = d.network.addresses;
|
||||
ips.sort();
|
||||
ips.forEach(function (ip, i) {
|
||||
var link = !ip.startsWith('fe80:');
|
||||
|
||||
if (i > 0) {
|
||||
string.push(V.h('br'));
|
||||
}
|
||||
|
||||
if (link) {
|
||||
if (!ip.startsWith('fe80:')) {
|
||||
string.push(V.h('a', { props: { href: 'http://[' + ip + ']/', target: '_blank' } }, ip));
|
||||
} else {
|
||||
string.push(ip);
|
||||
@ -142,37 +118,18 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
|
||||
if (!('loadavg' in d)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var value = d.loadavg.toFixed(2);
|
||||
var width = d.loadavg % 1;
|
||||
var warning = false;
|
||||
if (d.loadavg >= d.nproc) {
|
||||
warning = true;
|
||||
}
|
||||
return showBar(value, width, warning);
|
||||
return showBar(d.loadavg.toFixed(2), d.loadavg % 1, d.loadavg >= d.nproc);
|
||||
}
|
||||
|
||||
function showRAM(d) {
|
||||
if (!('memory_usage' in d)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var value = Math.round(d.memory_usage * 100) + ' %';
|
||||
var width = d.memory_usage;
|
||||
var warning = false;
|
||||
if (d.memory_usage >= 0.8) {
|
||||
warning = true;
|
||||
}
|
||||
return showBar(value, width, warning);
|
||||
return showBar(Math.round(d.memory_usage * 100) + ' %', d.memory_usage, d.memory_usage >= 0.8);
|
||||
}
|
||||
|
||||
function showAutoupdate(d) {
|
||||
var au = helper.dictGet(d, ['autoupdater']);
|
||||
if (!au) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return au.enabled ? _.t('node.activated', { branch: au.branch }) : _.t('node.deactivated');
|
||||
return d.autoupdater.enabled ? _.t('node.activated', { branch: d.autoupdater.branch }) : _.t('node.deactivated');
|
||||
}
|
||||
|
||||
function showStatImg(o, d) {
|
||||
@ -198,28 +155,28 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
|
||||
}, node.hostname);
|
||||
}
|
||||
|
||||
function nodeidLink(nodeid) {
|
||||
if (nodeDict[nodeid]) {
|
||||
return nodeLink(nodeDict[nodeid]);
|
||||
function nodeIdLink(nodeId) {
|
||||
if (nodeDict[nodeId]) {
|
||||
return nodeLink(nodeDict[nodeId]);
|
||||
}
|
||||
return nodeid;
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
function showGateway(node) {
|
||||
var gatewayCols = [
|
||||
V.h('span', [
|
||||
nodeidLink(node.gateway_nexthop),
|
||||
nodeIdLink(node.gateway_nexthop),
|
||||
V.h('br'),
|
||||
_.t('node.nexthop')
|
||||
]),
|
||||
V.h('span', { props: { className: 'ion-arrow-right-c' } }),
|
||||
V.h('span', [
|
||||
nodeidLink(node.gateway),
|
||||
nodeIdLink(node.gateway),
|
||||
V.h('br'),
|
||||
'IPv4'
|
||||
]),
|
||||
V.h('span', [
|
||||
nodeidLink(node.gateway6),
|
||||
nodeIdLink(node.gateway6),
|
||||
V.h('br'),
|
||||
'IPv6'
|
||||
])
|
||||
@ -234,13 +191,13 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
|
||||
icons = V.h('span', { props: { className: 'ion-location' } });
|
||||
}
|
||||
|
||||
var td1 = V.h('td', icons);
|
||||
var td2 = V.h('td', nodeLink(n.node));
|
||||
var td3 = V.h('td', (n.node.clients ? n.node.clients.toString() : '0'));
|
||||
var td4 = V.h('td', { style: { color: linkScale((n.link.source_tq + n.link.target_tq) / 2) } }, helper.showTq(n.link.source_tq) + ' - ' + helper.showTq(n.link.target_tq));
|
||||
var td5 = V.h('td', helper.showDistance(n.link));
|
||||
|
||||
return V.h('tr', [td1, td2, td3, td4, td5]);
|
||||
return V.h('tr', [
|
||||
V.h('td', icons),
|
||||
V.h('td', nodeLink(n.node)),
|
||||
V.h('td', n.node.clients),
|
||||
V.h('td', { style: { color: linkScale((n.link.source_tq + n.link.target_tq) / 2) } }, helper.showTq(n.link.source_tq) + ' - ' + helper.showTq(n.link.target_tq)),
|
||||
V.h('td', helper.showDistance(n.link))
|
||||
]);
|
||||
}
|
||||
|
||||
var self = this;
|
||||
@ -260,8 +217,7 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
|
||||
name: 'node.clients',
|
||||
class: 'ion-people',
|
||||
sort: function (a, b) {
|
||||
return ('clients' in a.node ? a.node.clients : -1) -
|
||||
('clients' in b.node ? b.node.clients : -1);
|
||||
return a.node.clients - b.node.clients;
|
||||
},
|
||||
reverse: true
|
||||
}, {
|
||||
@ -294,19 +250,19 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
|
||||
var children = [];
|
||||
|
||||
children.push(helper.attributeEntry(V, 'node.status', showStatus(d)));
|
||||
children.push(helper.attributeEntry(V, 'node.gateway', d.is_gateway ? 'ja' : null));
|
||||
children.push(helper.attributeEntry(V, 'node.gateway', d.is_gateway ? 'ja' : undefined));
|
||||
children.push(helper.attributeEntry(V, 'node.coordinates', showGeoURI(d)));
|
||||
|
||||
if (config.nodeInfobox && config.nodeInfobox.contact) {
|
||||
children.push(helper.attributeEntry(V, 'node.contact', helper.dictGet(d, ['owner', 'contact'])));
|
||||
}
|
||||
|
||||
children.push(helper.attributeEntry(V, 'node.hardware', helper.dictGet(d, ['model'])));
|
||||
children.push(helper.attributeEntry(V, 'node.primaryMac', helper.dictGet(d, ['network', 'mac'])));
|
||||
children.push(helper.attributeEntry(V, 'node.hardware', d.model));
|
||||
children.push(helper.attributeEntry(V, 'node.primaryMac', d.network.mac));
|
||||
children.push(helper.attributeEntry(V, 'node.firmware', showFirmware(d)));
|
||||
children.push(helper.attributeEntry(V, 'node.site', showSite(d, config)));
|
||||
children.push(helper.attributeEntry(V, 'node.uptime', showUptime(d)));
|
||||
children.push(helper.attributeEntry(V, 'node.firstSeen', showFirstseen(d)));
|
||||
children.push(helper.attributeEntry(V, 'node.uptime', moment.utc(d.uptime).local().fromNow(true)));
|
||||
children.push(helper.attributeEntry(V, 'node.firstSeen', d.firstseen.fromNow(true)));
|
||||
if (config.nodeInfobox && config.nodeInfobox.hardwareUsage) {
|
||||
children.push(helper.attributeEntry(V, 'node.systemLoad', showLoad(d)));
|
||||
children.push(helper.attributeEntry(V, 'node.ram', showRAM(d)));
|
||||
|
@ -10,7 +10,7 @@ define(['helper'], function (helper) {
|
||||
var totalNodes = helper.sum(d.nodes.all.map(helper.one));
|
||||
var totalOnlineNodes = helper.sum(d.nodes.all.filter(helper.online).map(helper.one));
|
||||
var totalClients = helper.sum(d.nodes.all.filter(helper.online).map(function (n) {
|
||||
return n.clients ? n.clients : 0;
|
||||
return n.clients;
|
||||
}));
|
||||
var totalGateways = helper.sum(d.nodes.all.filter(helper.online).filter(function (n) {
|
||||
return n.is_gateway;
|
||||
|
@ -43,11 +43,11 @@ define(['sorttable', 'snabbdom', 'helper'], function (SortTable, V, helper) {
|
||||
}
|
||||
}, linkName(d))];
|
||||
|
||||
var td1 = V.h('td', td1Content);
|
||||
var td2 = V.h('td', { style: { color: linkScale((d.source_tq + d.target_tq) / 2) } }, helper.showTq(d.source_tq) + ' - ' + helper.showTq(d.target_tq));
|
||||
var td3 = V.h('td', helper.showDistance(d));
|
||||
|
||||
return V.h('tr', [td1, td2, td3]);
|
||||
return V.h('tr', [
|
||||
V.h('td', td1Content),
|
||||
V.h('td', { style: { color: linkScale((d.source_tq + d.target_tq) / 2) } }, helper.showTq(d.source_tq) + ' - ' + helper.showTq(d.target_tq)),
|
||||
V.h('td', helper.showDistance(d))
|
||||
]);
|
||||
}
|
||||
|
||||
this.render = function render(d) {
|
||||
|
@ -47,7 +47,7 @@ define(['map/clientlayer', 'map/labellayer', 'map/button', 'leaflet'],
|
||||
var layers = config.mapLayers.map(function (d) {
|
||||
return {
|
||||
'name': d.name,
|
||||
'layer': 'url' in d ? L.tileLayer(d.url.replace('{retina}', L.Browser.retina ? '@2x' : ''), d.config) : console.warn('Missing map url')
|
||||
'layer': L.tileLayer(d.url.replace('{retina}', L.Browser.retina ? '@2x' : ''), d.config)
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -42,40 +42,36 @@ define(['sorttable', 'snabbdom', 'helper'], function (SortTable, V, helper) {
|
||||
name: 'node.clients',
|
||||
class: 'ion-people',
|
||||
sort: function (a, b) {
|
||||
return ('clients' in a ? a.clients : -1) -
|
||||
('clients' in b ? b.clients : -1);
|
||||
return a.clients - b.clients;
|
||||
},
|
||||
reverse: true
|
||||
}];
|
||||
|
||||
return function (router) {
|
||||
function renderRow(d) {
|
||||
var td0Content = [];
|
||||
var td1Content = [];
|
||||
var aClass = ['hostname', d.is_online ? 'online' : 'offline'];
|
||||
var td0Content = '';
|
||||
if (helper.hasLocation(d)) {
|
||||
td0Content = V.h('span', { props: { className: 'icon ion-location' } });
|
||||
}
|
||||
|
||||
td1Content.push(V.h('a', {
|
||||
var td1Content = V.h('a', {
|
||||
props: {
|
||||
className: aClass.join(' '),
|
||||
className: ['hostname', d.is_online ? 'online' : 'offline'].join(' '),
|
||||
href: router.generateLink({ node: d.node_id })
|
||||
}, on: {
|
||||
click: function (e) {
|
||||
router.fullUrl({ node: d.node_id }, e);
|
||||
}
|
||||
}
|
||||
}, d.hostname));
|
||||
}, d.hostname);
|
||||
|
||||
if (helper.hasLocation(d)) {
|
||||
td0Content.push(V.h('span', { props: { className: 'icon ion-location' } }));
|
||||
}
|
||||
|
||||
var td0 = V.h('td', td0Content);
|
||||
var td1 = V.h('td', td1Content);
|
||||
var td2 = V.h('td', showUptime(d.uptime));
|
||||
var td3 = V.h('td', d.neighbours.length);
|
||||
var td4 = V.h('td', Number('clients' in d ? d.clients : 0).toFixed(0));
|
||||
|
||||
return V.h('tr', [td0, td1, td2, td3, td4]);
|
||||
return V.h('tr', [
|
||||
V.h('td', td0Content),
|
||||
V.h('td', td1Content),
|
||||
V.h('td', showUptime(d.uptime)),
|
||||
V.h('td', d.neighbours.length),
|
||||
V.h('td', d.clients)
|
||||
]);
|
||||
}
|
||||
|
||||
var table = new SortTable(headings, 1, renderRow);
|
||||
|
@ -34,32 +34,27 @@ define(['moment', 'snabbdom', 'helper'], function (moment, V, helper) {
|
||||
}
|
||||
|
||||
var items = list.map(function (d) {
|
||||
var time = moment(d[field]).from(data.now);
|
||||
var td0Content = [];
|
||||
var td1Content = [];
|
||||
var td0Content = '';
|
||||
if (helper.hasLocation(d)) {
|
||||
td0Content = V.h('span', { props: { className: 'icon ion-location' } });
|
||||
}
|
||||
|
||||
var aClass = ['hostname', d.is_online ? 'online' : 'offline'];
|
||||
|
||||
td1Content.push(V.h('a', {
|
||||
var td1Content = V.h('a', {
|
||||
props: {
|
||||
className: aClass.join(' '),
|
||||
className: ['hostname', d.is_online ? 'online' : 'offline'].join(' '),
|
||||
href: router.generateLink({ node: d.node_id })
|
||||
}, on: {
|
||||
click: function (e) {
|
||||
router.fullUrl({ node: d.node_id }, e);
|
||||
}
|
||||
}
|
||||
}, d.hostname));
|
||||
}, d.hostname);
|
||||
|
||||
if (helper.hasLocation(d)) {
|
||||
td0Content.push(V.h('span', { props: { className: 'icon ion-location' } }));
|
||||
}
|
||||
|
||||
var td0 = V.h('td', td0Content);
|
||||
var td1 = V.h('td', td1Content);
|
||||
var td2 = V.h('td', time);
|
||||
|
||||
return V.h('tr', [td0, td1, td2]);
|
||||
return V.h('tr', [
|
||||
V.h('td', td0Content),
|
||||
V.h('td', td1Content),
|
||||
V.h('td', moment(d[field]).from(data.now))
|
||||
]);
|
||||
});
|
||||
|
||||
var tbodyNew = V.h('tbody', items);
|
||||
|
@ -114,7 +114,7 @@ define({
|
||||
},
|
||||
|
||||
attributeEntry: function attributeEntry(V, label, value) {
|
||||
if (value === null || value === undefined) {
|
||||
if (value === undefined) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,3 @@
|
||||
.offline {
|
||||
color: $color-offline;
|
||||
}
|
||||
|
||||
.unseen {
|
||||
color: $color-unseen;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ $color-primary: #dc0067 !default;
|
||||
$color-new: #459c18 !default;
|
||||
$color-online: #1566a9 !default;
|
||||
$color-offline: #cf3e2a !default;
|
||||
$color-unseen: #d89100 !default;
|
||||
|
||||
$color-24ghz: $color-primary !default;
|
||||
$color-5ghz: #e3a619 !default;
|
||||
|
Loading…
Reference in New Issue
Block a user