diff --git a/document_roots/webhost/assets/js/panelHandlers/publicServer/maintenance.js b/document_roots/webhost/assets/js/panelHandlers/publicServer/maintenance.js new file mode 100644 index 0000000..23734b8 --- /dev/null +++ b/document_roots/webhost/assets/js/panelHandlers/publicServer/maintenance.js @@ -0,0 +1,16 @@ +jQuery('._js_public-server-maintenance-mode').on('click', function(e){ + e.preventDefault(); + + var xhr = new XMLHttpRequest(); + xhr.open('UPDATE', 'api/server/maintenance', true); + xhr.send(); + + xhr.onloadend = function() { + if(xhr.status == 204) { + getPublicServerStatus(); + } + else { + alert('An error has occurred, please contact your webhost administrator.'); + } + } +}); diff --git a/document_roots/webhost/assets/js/panelHandlers/publicServer/restart.js b/document_roots/webhost/assets/js/panelHandlers/publicServer/restart.js new file mode 100644 index 0000000..e468d14 --- /dev/null +++ b/document_roots/webhost/assets/js/panelHandlers/publicServer/restart.js @@ -0,0 +1,30 @@ +jQuery('._js_public-server-restart-graceful, ._js_public-server-restart-forceful').on('click', function(e){ + e.preventDefault(); + var requestData = {}; + + if(jQuery(this).hasClass('_js_public-server-restart-graceful')) { + requestData["graceful"] = true; + } + else { + requestData["graceful"] = false; + } + + var xhr = new XMLHttpRequest(); + xhr.open('UPDATE', 'api/server/restart', true); + xhr.send(JSON.stringify(requestData)); + + xhr.onloadend = function() { + if(xhr.status == 204) { + getPublicServerStatus(); + alert('Server successfully restarted.'); + } + else { + if(xhr.response) { + alert(xhr.response); + } + else { + alert('An error has occurred, please contact your webhost administrator.'); + } + } + } +}); diff --git a/document_roots/webhost/assets/js/panelHandlers/publicServer/shutdown.js b/document_roots/webhost/assets/js/panelHandlers/publicServer/shutdown.js new file mode 100644 index 0000000..81e1fc7 --- /dev/null +++ b/document_roots/webhost/assets/js/panelHandlers/publicServer/shutdown.js @@ -0,0 +1,29 @@ +jQuery('._js_public-server-shutdown-graceful, ._js_public-server-shutdown-forceful').on('click', function(e){ + e.preventDefault(); + var requestData = {}; + + if(jQuery(this).hasClass('_js_public-server-shutdown-graceful')) { + requestData["graceful"] = true; + } + else { + requestData["graceful"] = false; + } + + var xhr = new XMLHttpRequest(); + xhr.open('UPDATE', 'api/server/shutdown', true); + xhr.send(JSON.stringify(requestData)); + + xhr.onloadend = function() { + if(xhr.status == 204) { + getPublicServerStatus(); + } + else { + if(xhr.response) { + alert(xhr.response); + } + else { + alert('An error has occurred, please contact your webhost administrator.'); + } + } + } +}); diff --git a/document_roots/webhost/assets/js/panelHandlers/publicServer/start.js b/document_roots/webhost/assets/js/panelHandlers/publicServer/start.js new file mode 100644 index 0000000..3bb62be --- /dev/null +++ b/document_roots/webhost/assets/js/panelHandlers/publicServer/start.js @@ -0,0 +1,21 @@ +jQuery('._js_public-server-start').on('click', function(e){ + e.preventDefault(); + + var xhr = new XMLHttpRequest(); + xhr.open('UPDATE', 'api/server/start', true); + xhr.send(); + + xhr.onloadend = function() { + if(xhr.status == 204) { + getPublicServerStatus(); + } + else { + if(xhr.response) { + alert(xhr.response); + } + else { + alert('An error has occurred, please contact your webhost administrator.'); + } + } + } +}); diff --git a/document_roots/webhost/assets/js/panelHandlers/publicServer/status.js b/document_roots/webhost/assets/js/panelHandlers/publicServer/status.js new file mode 100644 index 0000000..f44f14d --- /dev/null +++ b/document_roots/webhost/assets/js/panelHandlers/publicServer/status.js @@ -0,0 +1,38 @@ +var statusSpan = jQuery("._js_public-server-status"); + +function getPublicServerStatus() { + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'api/server/status', true); + xhr.send(); + + xhr.onloadend = function() { + if(xhr.status == 200) { + statusSpan.attr('class', '_js_public-server-status'); + + switch(parseInt(xhr.response)) { + case 0: + statusSpan.addClass('text-danger').html("OFF"); + break; + case 1: + statusSpan.addClass('text-success').html("ON"); + break; + case 2: + statusSpan.addClass('text-warning').html("MAINTENANCE"); + break; + case 3: + statusSpan.addClass('text-info').html("RESTARTING"); + break; + default: + console.log(xhr.response); + statusSpan.addClass('text-danger').html('ERROR'); + break; + } + } + else { + statusSpan.attr('class', '_js_public-server-status').addClass('text-danger').html('ERROR'); + } + } +} + +// Run it once on load +getPublicServerStatus(); diff --git a/document_roots/webhost/gPanel.html b/document_roots/webhost/gPanel.html index 7b58171..d938ccc 100644 --- a/document_roots/webhost/gPanel.html +++ b/document_roots/webhost/gPanel.html @@ -21,7 +21,7 @@ -
@@ -34,13 +34,15 @@