aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/html
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-04-11 11:36:31 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2022-04-11 11:36:31 +0200
commit1a3a8f1ec191d3811730fd149521abcb2205a018 (patch)
tree7905c1e2ebb681dd2302f1eb1af34d2fe8237f73 /html
parentapp.py: print HTTP status when CGIing (diff)
downloadlinux-status-1a3a8f1ec191d3811730fd149521abcb2205a018.tar.gz
linux-status-1a3a8f1ec191d3811730fd149521abcb2205a018.zip
support disallowing power requestsv2.1
Diffstat (limited to 'html')
-rw-r--r--html/index.html37
1 files changed, 35 insertions, 2 deletions
diff --git a/html/index.html b/html/index.html
index 944005c..89882b9 100644
--- a/html/index.html
+++ b/html/index.html
@@ -61,6 +61,22 @@
</div>
<div id="users">
</div>
+ <div class="modal" id="power_request_modal" tabindex="-1" aria-labelledby="power_request_modal_header" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title" id="power_request_modal_header">Forbidden</h5>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
+ </div>
+ <div class="modal-body">Sorry, power management is turned off on this instance.</div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
+ </div>
+ </div>
+ </div>
+ </div>
</div>
<footer class="mt-auto py-3 border-top bg-light text-center text-muted small">
<div class="container">
@@ -110,12 +126,29 @@ function get(url, success_callback) {
$.get(url, success_callback).fail(dump_fail);
}
+function on_power_request_forbidden() {
+ $('#power_request_modal').modal();
+}
+
+function power_request(url) {
+ $.get(url).fail(function(data) {
+ switch (data.status) {
+ case 403:
+ on_power_request_forbidden();
+ break;
+ default:
+ dump_fail(data);
+ break;
+ }
+ });
+}
+
function reboot() {
- get('reboot');
+ power_request('reboot');
}
function shutdown() {
- get('poweroff');
+ power_request('poweroff');
}
function set_hostname(data) {