Select Git revision
node.js 9.78 KiB
define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper'],
function (SortTable, V, d3Interpolate, moment, helper) {
'use strict';
V = V.default;
function showGeoURI(d) {
if (!helper.hasLocation(d)) {
return undefined;
}
return V.h('td',
V.h('a',
{ props: { href: 'geo:' + d.location.latitude + ',' + d.location.longitude } },
Number(d.location.latitude.toFixed(6)) + ', ' + Number(d.location.longitude.toFixed(6))
)
);
}
function showStatus(d) {
return V.h('td',
{ props: { className: d.is_unseen ? 'unseen' : (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')
}));
}
function showFirmware(d) {
return [
helper.dictGet(d, ['firmware', 'release']),
helper.dictGet(d, ['firmware', 'base'])
].filter(function (n) {
return n !== null;
}).join(' / ') || undefined;
}
function showSite(d, config) {
var site = helper.dictGet(d, ['site_code']);
var rt = site;
if (config.siteNames) {
config.siteNames.forEach(function (t) {
if (site === 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);
}
function showClients(d) {
if (!d.is_online) {
return undefined;
}