summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-apinger/htdocs/luci-static/resources/view/apinger/graphs.js
diff options
context:
space:
mode:
authorJaymin Patel <jem.patel@gmail.com>2022-07-16 18:42:47 +0530
committerJaymin Patel <jem.patel@gmail.com>2022-08-01 02:24:52 +0530
commit6c151fcddbabc0fcdd9de8c5088153e84f5b0ccd (patch)
treeb2a031eb04b09fc5c36c50231dd16b0aa4d4110d /applications/luci-app-apinger/htdocs/luci-static/resources/view/apinger/graphs.js
parentb0b9a34f8b75f9c2c91cb6a4badcc4e8e4122821 (diff)
luci-app-apinger: Add LuCI for Apinger
LuCI Support for Apinger Signed-off-by: Jaymin Patel <jem.patel@gmail.com>
Diffstat (limited to 'applications/luci-app-apinger/htdocs/luci-static/resources/view/apinger/graphs.js')
-rw-r--r--applications/luci-app-apinger/htdocs/luci-static/resources/view/apinger/graphs.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/applications/luci-app-apinger/htdocs/luci-static/resources/view/apinger/graphs.js b/applications/luci-app-apinger/htdocs/luci-static/resources/view/apinger/graphs.js
new file mode 100644
index 0000000000..18b0f0a339
--- /dev/null
+++ b/applications/luci-app-apinger/htdocs/luci-static/resources/view/apinger/graphs.js
@@ -0,0 +1,61 @@
+'use strict';
+'require view';
+'require uci';
+'require rpc';
+'require fs';
+'require ui';
+
+return view.extend({
+ callServiceList: rpc.declare({
+ object: 'service',
+ method: 'list',
+ params: [ 'name' ],
+ expect: { 'apinger': {} }
+ }),
+
+ callApingerUpdateGraphs: rpc.declare({
+ object: 'apinger',
+ method: 'update_graphs',
+ expect: { '': {} }
+ }),
+
+ load: function() {
+ return Promise.all([
+ this.callServiceList('apinger'),
+ this.callApingerUpdateGraphs(),
+ ]);
+ },
+
+ render: function(res) {
+ var running = Object.keys(res[0].instances || {}).length > 0;
+ var script = res[1]['rrdcgi'];
+
+ if (!running) {
+ return ui.addNotification(null, E('h3', _('Service is not running'), 'danger'));
+ }
+
+ return fs.stat(script).then(function(res) {
+ if ((res.type == "file") && (res.size > 100)) {
+ return E([
+ E('h3', _('Apinger Targets RRD Graph')),
+ E('br'),
+ E('div', [
+ E('iframe', {
+ src: script.replace(/^\/www/g, ''),
+ scrolling: 'yes',
+ style : 'width: 85vw; height: 100vh; border: none;'
+ })
+ ])
+ ]);
+ } else {
+ return ui.addNotification(null, E('h3', _('No data available'), 'danger'));
+ }
+ }).catch(function(err) {
+ return ui.addNotification(null, E('h3', _('No access to server file'), 'danger'));
+ });
+ },
+
+ handleSaveApply: null,
+ handleSave: null,
+ handleReset: null
+});