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) {
|
2017-11-06 17:54:50 +00:00
|
|
|
|
var subst = {
|
|
|
|
|
'{SOURCE_ID}': d.source.node_id,
|
|
|
|
|
'{SOURCE_NAME}': d.source.hostname.replace(/[^a-z0-9\-]/ig, '_'),
|
|
|
|
|
'{TARGET_ID}': d.target.node_id,
|
|
|
|
|
'{TARGET_NAME}': d.target.hostname.replace(/[^a-z0-9\-]/ig, '_'),
|
|
|
|
|
'{TIME}': time,
|
|
|
|
|
'{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));
|
|
|
|
|
|
2017-11-04 15:23:17 +00:00
|
|
|
|
helper.attributeEntry(V, children, 'node.connectionType', d.type);
|
|
|
|
|
helper.attributeEntry(V, children, 'node.tq', V.h('span',
|
2017-10-29 14:11:24 +00:00
|
|
|
|
{
|
|
|
|
|
style:
|
|
|
|
|
{
|
|
|
|
|
color: linkScale((d.source_tq + d.target_tq) / 2)
|
|
|
|
|
}
|
2017-11-04 15:23:17 +00:00
|
|
|
|
}, helper.showTq(d.source_tq) + ' - ' + helper.showTq(d.target_tq))
|
|
|
|
|
);
|
|
|
|
|
helper.attributeEntry(V, children, 'node.distance', helper.showDistance(d));
|
|
|
|
|
helper.attributeEntry(V, children, '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
|
|
|
|
};
|
|
|
|
|
});
|