2017-01-29 23:51:08 +00:00
|
|
|
|
define(['helper'], function (helper) {
|
|
|
|
|
'use strict';
|
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-02-18 22:13:29 +00:00
|
|
|
|
subst['{SOURCE_NAME}'] = d.source.node.nodeinfo.hostname.replace(/[^a-z0-9\-]/ig, '_');
|
2017-02-01 21:04:04 +00:00
|
|
|
|
subst['{TARGET_ID}'] = d.target.node_id;
|
2017-02-18 22:13:29 +00:00
|
|
|
|
subst['{TARGET_NAME}'] = d.target.node.nodeinfo.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();
|
2016-05-26 16:37:24 +00:00
|
|
|
|
return helper.showStat(o, subst);
|
2016-03-08 19:01:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-25 18:45:21 +00:00
|
|
|
|
return function (config, el, router, d) {
|
2017-01-29 23:51:08 +00:00
|
|
|
|
var h2 = document.createElement('h2');
|
2017-02-18 22:13:29 +00:00
|
|
|
|
var a1 = document.createElement('a');
|
|
|
|
|
a1.href = router.generateLink({ node: d.source.node_id });
|
|
|
|
|
a1.textContent = d.source.node.nodeinfo.hostname;
|
2016-05-22 11:23:43 +00:00
|
|
|
|
h2.appendChild(a1);
|
2016-05-26 23:34:42 +00:00
|
|
|
|
|
2017-03-18 13:36:11 +00:00
|
|
|
|
var arrow = document.createElement('span');
|
2017-02-04 19:01:49 +00:00
|
|
|
|
arrow.classList.add('ion-arrow-right-c');
|
2016-05-26 23:34:42 +00:00
|
|
|
|
h2.appendChild(arrow);
|
|
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
|
var a2 = document.createElement('a');
|
2017-03-05 11:29:21 +00:00
|
|
|
|
a2.href = router.generateLink({ node: d.target.node_id });
|
2016-05-22 11:23:43 +00:00
|
|
|
|
a2.textContent = d.target.node.nodeinfo.hostname;
|
|
|
|
|
h2.appendChild(a2);
|
|
|
|
|
el.appendChild(h2);
|
2015-03-25 10:21:09 +00:00
|
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
|
var attributes = document.createElement('table');
|
|
|
|
|
attributes.classList.add('attributes');
|
2015-03-25 10:21:09 +00:00
|
|
|
|
|
2017-01-28 14:33:13 +00:00
|
|
|
|
helper.attributeEntry(attributes, 'node.tq', helper.showTq(d));
|
|
|
|
|
helper.attributeEntry(attributes, 'node.distance', helper.showDistance(d));
|
2017-02-18 22:13:29 +00:00
|
|
|
|
var hw1 = helper.dictGet(d.source.node.nodeinfo, ['hardware', 'model']);
|
2017-01-29 23:51:08 +00:00
|
|
|
|
var hw2 = helper.dictGet(d.target.node.nodeinfo, ['hardware', 'model']);
|
2017-02-18 22:13:29 +00:00
|
|
|
|
helper.attributeEntry(attributes, 'node.hardware', hw1 + ' – ' + hw2);
|
2017-01-28 14:33:13 +00:00
|
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
|
el.appendChild(attributes);
|
2016-03-08 19:01:38 +00:00
|
|
|
|
|
|
|
|
|
if (config.linkInfos) {
|
2017-01-29 23:51:08 +00:00
|
|
|
|
var time = d.target.node.lastseen.format('DDMMYYYYHmmss');
|
2016-05-22 12:51:30 +00:00
|
|
|
|
config.linkInfos.forEach(function (linkInfo) {
|
2017-01-29 23:51:08 +00:00
|
|
|
|
var h4 = document.createElement('h4');
|
2016-05-22 11:23:43 +00:00
|
|
|
|
h4.textContent = linkInfo.name;
|
|
|
|
|
el.appendChild(h4);
|
2017-02-01 21:04:04 +00:00
|
|
|
|
el.appendChild(showStatImg(linkInfo, d, time));
|
2016-05-22 11:23:43 +00:00
|
|
|
|
});
|
2016-03-08 19:01:38 +00:00
|
|
|
|
}
|
2016-05-22 11:23:43 +00:00
|
|
|
|
};
|
|
|
|
|
});
|