diff --git a/README.md b/README.md index 83857c3..fb9b3dd 100644 --- a/README.md +++ b/README.md @@ -224,11 +224,11 @@ This option allows to show link statistics depending on the following case-sensi - `caption` is shown, if `thumbnail` is not present (no thumbnail in infobox) To insert the source or target node-id in either `href`, `thumbnail` or `caption` -you can use the case-sensitive template strings `{SOURCE}`, `{LOCALE}`, `{TARGET}` and `{TIME}` as cache-breaker. +you can use the case-sensitive template strings `{SOURCE_ID}`, `{TARGET_ID}`, `{SOURCE_NAME}`, `{TARGET_NAME}`, `{LOCALE}` and `{TIME}` as cache-breaker. "linkInfos": [ - { "href": "stats/dashboard/db/links?var-source={SOURCE}&var-target={TARGET}", - "thumbnail": "stats/render/dashboard-solo/db/links?panelId=1&fullscreen&theme=light&width=800&height=600&var-source={SOURCE}&var-target={TARGET}&_t={TIME}" + { "href": "stats/dashboard/db/links?var-source={SOURCE_ID}&var-target={TARGET_ID}", + "thumbnail": "stats/render/dashboard-solo/db/links?panelId=1&fullscreen&theme=light&width=800&height=600&var-source={SOURCE_ID}&var-target={TARGET_ID}&_t={TIME}" } ] diff --git a/lib/infobox/link.js b/lib/infobox/link.js index 1dd5c76..a271fa7 100644 --- a/lib/infobox/link.js +++ b/lib/infobox/link.js @@ -1,10 +1,12 @@ define(['helper'], function (helper) { 'use strict'; - function showStatImg(o, source, target, time) { + function showStatImg(o, d, time) { var subst = {}; - subst['{SOURCE}'] = source; - subst['{TARGET}'] = target; + subst['{SOURCE_ID}'] = d.source.node_id; + subst['{SOURCE_NAME}'] = d.source.node.nodeinfo.hostname ? d.source.node.nodeinfo.hostname.replace(/[^a-z0-9\-]/ig, '_') : _.t('unknown'); + subst['{TARGET_ID}'] = d.target.node_id; + subst['{TARGET_NAME}'] = d.target.node.nodeinfo.hostname ? d.target.node.nodeinfo.hostname.replace(/[^a-z0-9\-]/ig, '_') : _.t('unknown'); subst['{TIME}'] = time; subst['{LOCALE}'] = _.locale(); return helper.showStat(o, subst); @@ -47,14 +49,12 @@ define(['helper'], function (helper) { el.appendChild(attributes); if (config.linkInfos) { - var source = d.source.node_id; - var target = d.target.node_id; var time = d.target.node.lastseen.format('DDMMYYYYHmmss'); config.linkInfos.forEach(function (linkInfo) { var h4 = document.createElement('h4'); h4.textContent = linkInfo.name; el.appendChild(h4); - el.appendChild(showStatImg(linkInfo, source, target, time)); + el.appendChild(showStatImg(linkInfo, d, time)); }); } };