diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-04-29 23:50:38 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-04-29 23:50:38 +0200 |
commit | d972a621f7a050ad0089a540ded3c7e4e0b83061 (patch) | |
tree | 65686838b19014ac75b9f99dbdabf31aff8f9610 /html/index.html | |
parent | debian: 2.1.3-1 (diff) | |
parent | html: show modals for power mgmt failures (diff) | |
download | linux-status-d972a621f7a050ad0089a540ded3c7e4e0b83061.tar.gz linux-status-d972a621f7a050ad0089a540ded3c7e4e0b83061.zip |
Merge tag 'v2.2' into debian
Diffstat (limited to '')
-rw-r--r-- | html/index.html | 74 |
1 files changed, 57 insertions, 17 deletions
diff --git a/html/index.html b/html/index.html index 205861f..ebd805b 100644 --- a/html/index.html +++ b/html/index.html @@ -17,7 +17,7 @@ </div> <div class="btn-group" role="group" id="power_buttons"> <button type="button" class="btn btn-sm btn-warning" onclick="reboot();">Reboot</button> - <button type="button" class="btn btn-sm btn-danger" onclick="shutdown();">Shutdown</button> + <button type="button" class="btn btn-sm btn-danger" onclick="poweroff();">Shutdown</button> </div> </div> </div> @@ -61,11 +61,11 @@ </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" id="power_request_modal_forbidden" tabindex="-1" aria-labelledby="power_request_modal_forbidden_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> + <h5 class="modal-title" id="power_request_modal_forbidden_header">Forbidden</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> @@ -77,6 +77,38 @@ </div> </div> </div> + <div class="modal" id="reboot_modal_success" tabindex="-1" aria-labelledby="reboot_modal_success_header" aria-hidden="true"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <h5 class="modal-title" id="reboot_modal_success_header">Reboot</h5> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <div class="modal-body">Done! Please give some time for the machine to come back up.</div> + <div class="modal-footer"> + <button type="button" class="btn btn-primary" data-dismiss="modal">OK</button> + </div> + </div> + </div> + </div> + <div class="modal" id="poweroff_modal_success" tabindex="-1" aria-labelledby="poweroff_modal_success_header" aria-hidden="true"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <h5 class="modal-title" id="poweroff_modal_success_header">Shutdown</h5> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <div class="modal-body">Done! Please give some time for the machine to shut down gracefully.</div> + <div class="modal-footer"> + <button type="button" class="btn btn-primary" data-dismiss="modal">OK</button> + </div> + </div> + </div> + </div> </div> <footer class="mt-auto py-3 border-top bg-light text-center text-muted small"> <div class="container"> @@ -122,32 +154,40 @@ function dump_fail(data) { console.log('Response was:\n' + data.responseText); } -function get(url, success_callback) { - $.get(url, success_callback).fail(dump_fail); +function get(url, success_callback, fail_callback = dump_fail) { + $.get(url, success_callback).fail(fail_callback); +} + +function on_power_request_success(url) { + $('#' + url + '_modal_success').modal(); } function on_power_request_forbidden() { - $('#power_request_modal').modal(); + $('#power_request_modal_forbidden').modal(); +} + +function on_power_request_fail(data) { + switch (data.status) { + case 403: + on_power_request_forbidden(); + break; + default: + dump_fail(data); + break; + } } function power_request(url) { - $.get(url).fail(function(data) { - switch (data.status) { - case 403: - on_power_request_forbidden(); - break; - default: - dump_fail(data); - break; - } - }); + get(url, function() { + on_power_request_success(url); + }, on_power_request_fail); } function reboot() { power_request('reboot'); } -function shutdown() { +function poweroff() { power_request('poweroff'); } |