diff --git a/.gitignore b/.gitignore index 496a1e0..c5dab9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,11 @@ +# Ignore executables generated main - gpanel +# Ignore database files datastore.db +datastore.db.lock -datastore.db.lock \ No newline at end of file +# Ignore log files +logs/* +!logs/README.md diff --git a/document_roots/webhost/assets/css/style.css b/document_roots/webhost/assets/css/style.css index f653b57..e9b2c0a 100644 --- a/document_roots/webhost/assets/css/style.css +++ b/document_roots/webhost/assets/css/style.css @@ -27,3 +27,9 @@ body { cursor:pointer; } /* Navbar End */ + +/* General Start */ +.btn { + cursor:pointer; +} +/* General End */ diff --git a/document_roots/webhost/assets/js/panelHandlers/diagnostics/deleteLog.js b/document_roots/webhost/assets/js/panelHandlers/diagnostics/deleteLog.js new file mode 100644 index 0000000..21b07ba --- /dev/null +++ b/document_roots/webhost/assets/js/panelHandlers/diagnostics/deleteLog.js @@ -0,0 +1,50 @@ +var logModal = jQuery('.view-log-modal'); + +jQuery('._js_diagnostics-clear-log').on('click', function(e){ + e.preventDefault(); + + var logName = jQuery(this).attr('data'); + + var title; + switch(logName) { + case "client_errors": + title = "Client Error Log (4xx)"; + break; + case "server_errors": + title = "Server Error Log (5xx)"; + break; + case "load_time": + title = "Load Time Log"; + break; + default: + return; + break; + } + + var ensure = confirm('Are you sure you want to clear ' + title + '?'); + if (ensure) { + var requestData = {}; + requestData["name"] = logName+".log"; + + var xhr = new XMLHttpRequest(); + xhr.open('UPDATE', 'api/logs/delete', true); + xhr.send(JSON.stringify(requestData)); + + xhr.onloadend = function() { + if(xhr.status == 204) { + jQuery(logModal).find('.modal-body textarea').html('The log is currently empty.'); + } + else { + if(xhr.response != undefined && xhr.response.length != 0) { + alert(xhr.response); + } + else { + alert("An error has occurred, please contact your webhost administrator."); + } + } + } + } + else { + return; + } +}); diff --git a/document_roots/webhost/assets/js/panelHandlers/diagnostics/viewLog.js b/document_roots/webhost/assets/js/panelHandlers/diagnostics/viewLog.js new file mode 100644 index 0000000..d3e6bc9 --- /dev/null +++ b/document_roots/webhost/assets/js/panelHandlers/diagnostics/viewLog.js @@ -0,0 +1,57 @@ +var logModal = jQuery('.view-log-modal'); + +jQuery('._js_diagnostics-view-log').on('click', function(e){ + e.preventDefault(); + + var logName = jQuery(this).attr('data'); + + var title; + switch(logName) { + case "client_errors": + title = "Client Error Log (4xx)"; + break; + case "server_errors": + title = "Server Error Log (5xx)"; + break; + case "load_time": + title = "Load Time Log"; + break; + default: + return; + break; + } + jQuery(logModal).find('.modal-title').html(title); + jQuery(logModal).find('._js_diagnostics-clear-log').attr('data', logName); + + var requestData = {}; + requestData["name"] = logName+".log"; + + var xhr = new XMLHttpRequest(); + xhr.open('POST', 'api/logs/read', true); + xhr.send(JSON.stringify(requestData)); + + xhr.onloadend = function() { + if(xhr.status == 200) { + var responseData; + + if(xhr.response != undefined && xhr.response.length != 0) { + responseData = xhr.response; + } + else { + responseData = "The log is currently empty." + } + + jQuery(logModal).find('.modal-body textarea').html(responseData); + jQuery(logModal).modal('show'); + } + else { + if(xhr.response != undefined && xhr.response.length != 0) { + alert(xhr.response); + } + else { + alert('An error has occurred, please contact your webhost administrator.'); + } + } + } + +}); diff --git a/document_roots/webhost/gPanel.html b/document_roots/webhost/gPanel.html index d938ccc..87681ca 100644 --- a/document_roots/webhost/gPanel.html +++ b/document_roots/webhost/gPanel.html @@ -27,6 +27,26 @@ + +
@@ -47,6 +67,20 @@
+ +
+
+
+
+

Diagnostics

+
View various server data pools that may help pinpoint issues
+ + + +
+
+
+