From 8a73d5bb5dedf3c88450b6d677742f8b3e7a0b27 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sat, 2 Sep 2017 08:45:55 -0500 Subject: [PATCH] DHCP Server start / stop / restart - Fix dashboard refresh --- app.js | 1 + public/assets/js/glass-core.js | 14 ++++ public/templates/dhcp_start_stop_restart.html | 59 ++++++++++++++++ public/templates/index.html | 40 +++++++---- routes/dhcp_config_save.js | 2 +- routes/dhcp_start_stop_restart.js | 70 +++++++++++++++++++ 6 files changed, 170 insertions(+), 16 deletions(-) create mode 100644 public/templates/dhcp_start_stop_restart.html create mode 100644 routes/dhcp_start_stop_restart.js diff --git a/app.js b/app.js index 08bad73..a1ab72a 100644 --- a/app.js +++ b/app.js @@ -30,6 +30,7 @@ app.use('/dhcp_config', require('./routes/dhcp_config')); app.use('/dhcp_config_snapshots', require('./routes/dhcp_config_snapshots')); app.use('/dhcp_config_snapshot_view', require('./routes/dhcp_config_snapshot_view')); app.use('/dhcp_config_save', require('./routes/dhcp_config_save')); +app.use('/dhcp_start_stop_restart', require('./routes/dhcp_start_stop_restart')); app.use('/api_examples', require('./routes/api_examples')); app.use('/glass_settings', require('./routes/glass_settings')); app.use('/glass_settings_save', require('./routes/glass_settings_save')); diff --git a/public/assets/js/glass-core.js b/public/assets/js/glass-core.js index bb9cc78..ee1b434 100644 --- a/public/assets/js/glass-core.js +++ b/public/assets/js/glass-core.js @@ -2,7 +2,21 @@ * Created by cmiles on 8/9/2017. */ +$( document ).ajaxComplete(function( event, request, settings ) { + check_dashboard_active(); +}); + +function check_dashboard_active() { + if(window.location.pathname == "/" && in_dashboard != 1) { + in_dashboard = 1; + } + else { + in_dashboard = 0; + } +} + function modal (title, content, buttons) { + $('#modal-buttons').html(''); $('#modal-title').html(title); $('#modal-body').html(content); diff --git a/public/templates/dhcp_start_stop_restart.html b/public/templates/dhcp_start_stop_restart.html new file mode 100644 index 0000000..dda2a8b --- /dev/null +++ b/public/templates/dhcp_start_stop_restart.html @@ -0,0 +1,59 @@ +
+
+
+
+

+ [title] +

+
+
+ [c_content] +
+
+
+
+
+ + \ No newline at end of file diff --git a/public/templates/index.html b/public/templates/index.html index 3eca6be..b068822 100644 --- a/public/templates/index.html +++ b/public/templates/index.html @@ -105,7 +105,7 @@
  • - + refresh Start / Stop / Restart @@ -119,6 +119,13 @@
  • +
  • + + add_alert + Glass Alerts + +
  • +
  • Glass API
  • @@ -155,7 +162,7 @@ @@ -212,6 +219,8 @@ "); + break; + case "start": + dhcp_exec = execSync('service isc-dhcp-server start'); + res.send(""); + break; + case "restart": + dhcp_exec = execSync('service isc-dhcp-server restart && sleep 1'); + res.send(""); + break; + default: + break; + } + + console.log(request); + +}); + +module.exports = router; \ No newline at end of file