From b05517360d1794369a7b9de359bed85ac63fb319 Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Fri, 10 Feb 2017 00:19:41 +0100 Subject: [PATCH] [TASK] Rename parameters and require image --- README.md | 42 ++++++++++++++++++++++-------------------- config.json | 12 ++++++------ lib/utils/helper.js | 19 ++++--------------- 3 files changed, 32 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 9281f11..9546abe 100644 --- a/README.md +++ b/README.md @@ -181,13 +181,13 @@ Examples for `fixedCenter`: This option allows to show node statistics depending on following case-sensitive parameters: -- `name` caption of statistics segment in infobox +- `name` header of statistics segment in infobox - `href` absolute or relative URL to statistics image -- `thumbnail` absolute or relative URL to thumbnail image, +- `image` `(required)` absolute or relative URL to image, can be the same like `href` -- `caption` is shown, if `thumbnail` is not present (no thumbnail in infobox) +- `title` for the image -To insert current node-id in either `href`, `thumbnail` or `caption` +To insert current variables in either `href`, `image` or `title` you can use the case-sensitive template string `{NODE_ID}`, `{NODE_NAME}`, `{LOCALE}` and `{TIME}` as cache-breaker. Examples for `nodeInfos`: @@ -196,13 +196,13 @@ Examples for `nodeInfos`: { "name": "Clientstatistik", "href": "stats/dashboard/db/node-byid?var-nodeid={NODE_ID}", - "thumbnail": "stats/render/dashboard-solo/db/node-byid?panelId=1&fullscreen&theme=light&width=600&height=300&var-nodeid={NODE_ID}&var-host={NODE_NAME}&_t={TIME}", - "caption": "Knoten {NODE_ID}" + "image": "stats/render/dashboard-solo/db/node-byid?panelId=1&fullscreen&theme=light&width=600&height=300&var-nodeid={NODE_ID}&var-host={NODE_NAME}&_t={TIME}", + "title": "Knoten {NODE_ID}" }, { "name": "Uptime", "href": "stats/dashboard/db/node-byid?var-nodeid={NODE_ID}", - "thumbnail": "stats/render/dashboard-solo/db/node-byid?panelId=2&fullscreen&theme=light&width=600&height=300&var-nodeid={NODE_ID}&_t={TIME}", - "caption": "Knoten {NODE_ID}" + "image": "stats/render/dashboard-solo/db/node-byid?panelId=2&fullscreen&theme=light&width=600&height=300&var-nodeid={NODE_ID}&_t={TIME}", + "title": "Knoten {NODE_ID}" } ] @@ -212,21 +212,21 @@ In order to have statistics images available, you have to set up an instance of This option allows to show global statistics on statistics page depending on following case-sensitive parameters: -- `name` caption of statistics segment in infobox +- `name` header of statistics segment in infobox - `href` absolute or relative URL to statistics image -- `thumbnail` absolute or relative URL to thumbnail image, +- `image` `(required)` absolute or relative URL to image, can be the same like `href` -- `caption` is shown, if `thumbnail` is not present (no thumbnail in infobox) +- `title` for the image -In contrast to `nodeInfos` there is no template substitution in `href`, `thumbnail` or `caption`. +In contrast to `nodeInfos` there is no template substitution in `href`, `image` or `title`. Examples for `globalInfos` using Grafana server rendering: "globalInfos": [ { "name": "Wochenstatistik", "href": "stats/render/render/dashboard-solo/db/global?panelId=1&fullscreen&theme=light&width=600&height=300", - "thumbnail": "nodes/globalGraph.png", - "caption": "Bild mit Wochenstatistik" + "image": "nodes/globalGraph.png", + "title": "Bild mit Wochenstatistik" } ] @@ -234,18 +234,20 @@ Examples for `globalInfos` using Grafana server rendering: This option allows to show link statistics depending on the following case-sensitive parameters: -- `name` caption of statistics segment in infobox +- `name` header of statistics segment in infobox - `href` absolute or relative URL to statistics image -- `thumbnail` absolute or relative URL to thumbnail image, +- `image` `(required)` absolute or relative URL to image, can be the same like `href` -- `caption` is shown, if `thumbnail` is not present (no thumbnail in infobox) +- `title` for the image -To insert the source or target node-id in either `href`, `thumbnail` or `caption` +To insert the source or target variable in either `href`, `image` or `title` 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_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}" + { "name": "Linkstatistik", + "href": "stats/dashboard/db/links?var-source={SOURCE_ID}&var-target={TARGET_ID}", + "image": "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}", + "title": "Bild mit Linkstatistik" } ] diff --git a/config.json b/config.json index cef8b04..8d73e5e 100644 --- a/config.json +++ b/config.json @@ -5,22 +5,22 @@ { "name": "Clientstatistik", "href": "https://regensburg.freifunk.net/netz/statistik/node/{NODE_ID}/", - "thumbnail": "https://grafana.regensburg.freifunk.net/render/dashboard-solo/db/ffrgb-all-nodes?panelId=1&from=now-7d&var-nodeid={NODE_ID}&var-host={NODE_NAME}&width=650&height=350&theme=light&_t={TIME}", - "caption": "Knoten {NODE_ID} - weiteren Statistiken" + "image": "https://grafana.regensburg.freifunk.net/render/dashboard-solo/db/ffrgb-all-nodes?panelId=1&from=now-7d&var-nodeid={NODE_ID}&var-host={NODE_NAME}&width=650&height=350&theme=light&_t={TIME}", + "title": "Knoten {NODE_ID} - weiteren Statistiken" }, { "name": "Trafficstatistik", "href": "https://regensburg.freifunk.net/netz/statistik/node/{NODE_ID}/", - "thumbnail": "https://grafana.regensburg.freifunk.net/render/dashboard-solo/db/ffrgb-all-nodes?panelId=2&from=now-7d&var-nodeid={NODE_ID}&var-host={NODE_NAME}&width=650&height=350&theme=light&_t={TIME}", - "caption": "Knoten {NODE_ID} - weiteren Statistiken" + "image": "https://grafana.regensburg.freifunk.net/render/dashboard-solo/db/ffrgb-all-nodes?panelId=2&from=now-7d&var-nodeid={NODE_ID}&var-host={NODE_NAME}&width=650&height=350&theme=light&_t={TIME}", + "title": "Knoten {NODE_ID} - weiteren Statistiken" } ], "globalInfos": [ { "name": "Statistik", "href": "https://regensburg.freifunk.net/netz/statistik/", - "thumbnail": "https://grafana.regensburg.freifunk.net/render/dashboard-solo/db/ffrgb-network-wide-stats?panelId=11&from=now-1y&width=600&height=350&theme=light", - "caption": "Jahresstatistik - weiteren Statistiken" + "image": "https://grafana.regensburg.freifunk.net/render/dashboard-solo/db/ffrgb-network-wide-stats?panelId=11&from=now-1y&width=600&height=350&theme=light", + "title": "Jahresstatistik - weiteren Statistiken" } ], // String or array of data provider are supported diff --git a/lib/utils/helper.js b/lib/utils/helper.js index 2cd8cc8..ddcbc04 100644 --- a/lib/utils/helper.js +++ b/lib/utils/helper.js @@ -154,21 +154,10 @@ define({ showStat: function showStat(o, subst) { var content; - var caption; subst = typeof subst !== 'undefined' ? subst : {}; - if (o.thumbnail) { - content = document.createElement('img'); - content.src = require('helper').listReplace(o.thumbnail, subst); - } - - if (o.caption) { - caption = require('helper').listReplace(o.caption, subst); - - if (!content) { - content = document.createTextNode(caption); - } - } + content = document.createElement('img'); + content.src = require('helper').listReplace(o.image, subst); var p = document.createElement('p'); @@ -178,8 +167,8 @@ define({ link.href = require('helper').listReplace(o.href, subst); link.appendChild(content); - if (caption && o.thumbnail) { - link.title = caption; + if (o.title) { + link.title = require('helper').listReplace(o.title, subst); } p.appendChild(link);