From fd6c7c7f1e2f8b9eec8cb68fcb094f4d0750d987 Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Sat, 4 Nov 2017 16:23:17 +0100 Subject: [PATCH] [TASK] Pass children to attributeEntry --- config.default.json | 8 ++++---- lib/infobox/link.js | 13 +++++++------ lib/infobox/node.js | 6 +++++- lib/utils/helper.js | 20 +++++++++----------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/config.default.json b/config.default.json index f59737d..367aaa0 100644 --- a/config.default.json +++ b/config.default.json @@ -20,10 +20,10 @@ "name": "node.coordinates", "value": "GeoURI" }, -// { -// "name": "node.contact", -// "value": "owner" -// }, + // { + // "name": "node.contact", + // "value": "owner" + // }, { "name": "node.hardware", "value": "model" diff --git a/lib/infobox/link.js b/lib/infobox/link.js index 27e3827..a019d94 100644 --- a/lib/infobox/link.js +++ b/lib/infobox/link.js @@ -37,17 +37,18 @@ define(['helper', 'snabbdom'], function (helper, V) { 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', + helper.attributeEntry(V, children, 'node.connectionType', d.type); + helper.attributeEntry(V, children, '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))); - children.push(helper.attributeEntry(V, 'node.hardware', (d.source.model ? d.source.model + ' – ' : '') + - (d.target.model ? d.target.model : ''))); + }, 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 : '')); var elNew = V.h('table', children); table = V.patch(table, elNew); diff --git a/lib/infobox/node.js b/lib/infobox/node.js index e997106..bc5ac69 100644 --- a/lib/infobox/node.js +++ b/lib/infobox/node.js @@ -138,7 +138,11 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper', 'utils/no } }); - children.push(helper.attributeEntry(V, 'node.gateway', showGateway(d))); + + children.push(V.h('tr', [ + V.h('th', _.t('node.gateway')), + showGateway(d) + ])); var elNew = V.h('table', children); table = V.patch(table, elNew); diff --git a/lib/utils/helper.js b/lib/utils/helper.js index 6dd04b5..e53caa8 100644 --- a/lib/utils/helper.js +++ b/lib/utils/helper.js @@ -104,19 +104,17 @@ define({ return (d * 100).toFixed(0) + '%'; }, - attributeEntry: function attributeEntry(V, label, value) { - if (value === undefined) { - return ''; - } + attributeEntry: function attributeEntry(V, children, label, value) { + if (value !== undefined) { + if (typeof value !== 'object') { + value = V.h('td', value); + } - if (typeof value !== 'object') { - value = V.h('td', value); + children.push(V.h('tr', [ + V.h('th', _.t(label)), + value + ])); } - - return V.h('tr', [ - V.h('th', _.t(label)), - value - ]); }, showStat: function showStat(V, o, subst) { var content;