[TASK] Add hostname to link variables
This commit is contained in:
parent
9628409409
commit
7d7fc1ac5a
@ -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)
|
- `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`
|
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": [
|
"linkInfos": [
|
||||||
{ "href": "stats/dashboard/db/links?var-source={SOURCE}&var-target={TARGET}",
|
{ "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}&var-target={TARGET}&_t={TIME}"
|
"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}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
define(['helper'], function (helper) {
|
define(['helper'], function (helper) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function showStatImg(o, source, target, time) {
|
function showStatImg(o, d, time) {
|
||||||
var subst = {};
|
var subst = {};
|
||||||
subst['{SOURCE}'] = source;
|
subst['{SOURCE_ID}'] = d.source.node_id;
|
||||||
subst['{TARGET}'] = target;
|
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['{TIME}'] = time;
|
||||||
subst['{LOCALE}'] = _.locale();
|
subst['{LOCALE}'] = _.locale();
|
||||||
return helper.showStat(o, subst);
|
return helper.showStat(o, subst);
|
||||||
@ -47,14 +49,12 @@ define(['helper'], function (helper) {
|
|||||||
el.appendChild(attributes);
|
el.appendChild(attributes);
|
||||||
|
|
||||||
if (config.linkInfos) {
|
if (config.linkInfos) {
|
||||||
var source = d.source.node_id;
|
|
||||||
var target = d.target.node_id;
|
|
||||||
var time = d.target.node.lastseen.format('DDMMYYYYHmmss');
|
var time = d.target.node.lastseen.format('DDMMYYYYHmmss');
|
||||||
config.linkInfos.forEach(function (linkInfo) {
|
config.linkInfos.forEach(function (linkInfo) {
|
||||||
var h4 = document.createElement('h4');
|
var h4 = document.createElement('h4');
|
||||||
h4.textContent = linkInfo.name;
|
h4.textContent = linkInfo.name;
|
||||||
el.appendChild(h4);
|
el.appendChild(h4);
|
||||||
el.appendChild(showStatImg(linkInfo, source, target, time));
|
el.appendChild(showStatImg(linkInfo, d, time));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user