2017-10-29 14:11:24 +00:00
|
|
|
|
define(['helper', 'snabbdom'], function (helper, V) {
|
2017-01-29 23:51:08 +00:00
|
|
|
|
'use strict';
|
2017-10-29 14:11:24 +00:00
|
|
|
|
V = V.default;
|
2016-05-27 21:59:01 +00:00
|
|
|
|
|
2017-02-01 21:04:04 +00:00
|
|
|
|
function showStatImg(o, d, time) {
|
2016-05-22 11:23:43 +00:00
|
|
|
|
var subst = {};
|
2017-02-01 21:04:04 +00:00
|
|
|
|
subst['{SOURCE_ID}'] = d.source.node_id;
|
2017-10-29 14:11:24 +00:00
|
|
|
|
subst['{SOURCE_NAME}'] = d.source.hostname.replace(/[^a-z0-9\-]/ig, '_');
|
2017-02-01 21:04:04 +00:00
|
|
|
|
subst['{TARGET_ID}'] = d.target.node_id;
|
2017-10-29 14:11:24 +00:00
|
|
|
|
subst['{TARGET_NAME}'] = d.target.hostname.replace(/[^a-z0-9\-]/ig, '_');
|
2017-01-29 23:51:08 +00:00
|
|
|
|
subst['{TIME}'] = time;
|
2017-01-28 14:33:13 +00:00
|
|
|
|
subst['{LOCALE}'] = _.locale();
|
2017-10-29 14:11:24 +00:00
|
|
|
|
return helper.showStat(V, o, subst);
|
2016-03-08 19:01:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-03 21:07:22 +00:00
|
|
|
|
return function (el, d, linkScale) {
|
2017-10-29 14:11:24 +00:00
|
|
|
|
var self = this;
|
|
|
|
|
var header = document.createElement('div');
|
|
|
|
|
var table = document.createElement('table');
|
|
|
|
|
var images = document.createElement('div');
|
|
|
|
|
el.appendChild(header);
|
|
|
|
|
el.appendChild(table);
|
|
|
|
|
el.appendChild(images);
|
|
|
|
|
|
|
|
|
|
self.render = function render() {
|
|
|
|
|
var children = [];
|
|
|
|
|
var headers = [];
|
|
|
|
|
headers.push(V.h('h2', [
|
|
|
|
|
V.h('a', {
|
|
|
|
|
props: { href: router.generateLink({ node: d.source.node_id }) }
|
|
|
|
|
}, d.source.hostname),
|
|
|
|
|
V.h('span', ' - '),
|
|
|
|
|
V.h('a', {
|
|
|
|
|
props: { href: router.generateLink({ node: d.target.node_id }) }
|
|
|
|
|
}, d.target.hostname)
|
|
|
|
|
]));
|
|
|
|
|
|
|
|
|
|
header = V.patch(header, V.h('div', headers));
|
|
|
|
|
|
|
|
|
|
children.push(helper.attributeEntry(V, 'node.connectionType', d.type));
|
|
|
|
|
children.push(helper.attributeEntry(V, 'node.tq', V.h('span',
|
|
|
|
|
{
|
|
|
|
|
style:
|
|
|
|
|
{
|
|
|
|
|
color: linkScale((d.source_tq + d.target_tq) / 2)
|
|
|
|
|
}
|
|
|
|
|
}, helper.showTq(d.source_tq) + ' - ' + helper.showTq(d.target_tq))));
|
|
|
|
|
children.push(helper.attributeEntry(V, 'node.distance', helper.showDistance(d)));
|
2017-10-29 19:52:17 +00:00
|
|
|
|
children.push(helper.attributeEntry(V, 'node.hardware', (d.source.model ? d.source.model + ' – ' : '') +
|
|
|
|
|
(d.target.model ? d.target.model : '')));
|
2017-10-29 14:11:24 +00:00
|
|
|
|
|
|
|
|
|
var elNew = V.h('table', children);
|
|
|
|
|
table = V.patch(table, elNew);
|
|
|
|
|
table.elm.classList.add('attributes');
|
|
|
|
|
|
|
|
|
|
if (config.linkInfos) {
|
|
|
|
|
var time = d.target.lastseen.format('DDMMYYYYHmmss');
|
|
|
|
|
var img = [];
|
|
|
|
|
config.linkInfos.forEach(function (linkInfo) {
|
|
|
|
|
img.push(V.h('h4', linkInfo.name));
|
|
|
|
|
img.push(showStatImg(linkInfo, d, time));
|
|
|
|
|
});
|
|
|
|
|
images = V.patch(images, V.h('div', img));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.setData = function setData(data) {
|
|
|
|
|
d = data.links.find(function (a) {
|
|
|
|
|
return a.id === d.id;
|
2016-05-22 11:23:43 +00:00
|
|
|
|
});
|
2017-10-29 14:11:24 +00:00
|
|
|
|
self.render();
|
|
|
|
|
};
|
|
|
|
|
return self;
|
2016-05-22 11:23:43 +00:00
|
|
|
|
};
|
|
|
|
|
});
|