[TASK] Define complete subst

This commit is contained in:
Xaver Maierhofer 2017-11-06 18:54:50 +01:00 committed by Xaver Maierhofer
parent d0b6031d5f
commit 18a2a17d97
4 changed files with 22 additions and 18 deletions

View File

@ -3,13 +3,14 @@ define(['helper', 'snabbdom'], function (helper, V) {
V = V.default;
function showStatImg(o, d, time) {
var subst = {};
subst['{SOURCE_ID}'] = d.source.node_id;
subst['{SOURCE_NAME}'] = d.source.hostname.replace(/[^a-z0-9\-]/ig, '_');
subst['{TARGET_ID}'] = d.target.node_id;
subst['{TARGET_NAME}'] = d.target.hostname.replace(/[^a-z0-9\-]/ig, '_');
subst['{TIME}'] = time;
subst['{LOCALE}'] = _.locale();
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()
};
return helper.showStat(V, o, subst);
}

View File

@ -4,11 +4,12 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper', 'utils/no
V = V.default;
function showStatImg(o, d) {
var subst = {};
subst['{NODE_ID}'] = d.node_id;
subst['{NODE_NAME}'] = d.hostname.replace(/[^a-z0-9\-]/ig, '_');
subst['{TIME}'] = d.lastseen.format('DDMMYYYYHmmss');
subst['{LOCALE}'] = _.locale();
var subst = {
'{NODE_ID}': d.node_id,
'{NODE_NAME}': d.hostname.replace(/[^a-z0-9\-]/ig, '_'),
'{TIME}': d.lastseen.format('DDMMYYYYHmmss'),
'{LOCALE}': _.locale()
};
return helper.showStat(V, o, subst);
}
@ -138,7 +139,6 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper', 'utils/no
}
});
children.push(V.h('tr', [
V.h('th', _.t('node.gateway')),
showGateway(d)

View File

@ -6,6 +6,7 @@ define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'],
return function (filterManager) {
var self = this;
var scale = d3Interpolate.interpolate(config.forceGraph.tqFrom, config.forceGraph.tqTo);
var time;
var statusTable;
var fwTable;
@ -78,6 +79,7 @@ define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'],
self.setData = function setData(data) {
var onlineNodes = data.nodes.online;
var nodes = onlineNodes.concat(data.nodes.lost);
time = data.timestamp;
function hostnameOfNodeID(nodeid) {
var gateway = data.nodeDict[nodeid];
@ -163,9 +165,13 @@ define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'],
var images = document.createElement('div');
el.appendChild(images);
var img = [];
var subst = {
'{TIME}': time,
'{LOCALE}': _.locale()
};
config.globalInfos.forEach(function (globalInfo) {
img.push(V.h('h2', globalInfo.name));
img.push(helper.showStat(V, globalInfo));
img.push(helper.showStat(V, globalInfo, subst));
});
V.patch(images, V.h('div', img));
}

View File

@ -117,10 +117,7 @@ define({
}
},
showStat: function showStat(V, o, subst) {
var content;
subst = typeof subst !== 'undefined' ? subst : {};
content = V.h('img', { attrs: { src: require('helper').listReplace(o.image, subst) } });
var content = V.h('img', { attrs: { src: require('helper').listReplace(o.image, subst) } });
if (o.href) {
return V.h('p', V.h('a', {