123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <html>
- <head>
- <title>Host Power Options</title>
- <style>
- </style>
- </head>
- <body>
- <div class="ui container">
- <div class="ui basic segment">
- <h3 class="ui header">
- <i class="power icon"></i>
- <div class="content">
- Host Power
- <div class="sub header">Change power state of your device</div>
- </div>
- </h3>
- </div>
- <div class="ui divider"></div>
- <div class="ui segment">
- <h3 class="ui header">
- <i id="sysConnStateIcon" class="green check circle icon"></i>
- <div class="content">
- <span id="sysConnState">System Online</span>
- <div class="sub header">Last update: <span id="lastupdateTime"></span></div>
- </div>
- </h3>
- </div>
-
- <div class="ui divider"></div>
- <p>Power Options</p>
- <button class="ui red button" onclick="shutdown();"><i class="power off icon"></i> Power Off</button>
- <button class="ui yellow button" onclick="restart();"><i class="refresh icon"></i> Restart</button>
- <div id="msgbox" class="ui green message" style="display:none;">
- <p><i class="checkmark icon"></i> <span id="succmsg"></span></p>
- </div>
- <div class="ui divider"></div>
- <div class="ui icon message">
- <i class="yellow exclamation circle icon"></i>
- <div class="content">
- <div class="header">
- Restart / Shutdown is risky
- </div>
- <p>If you decided to shutdown your host server, ArozOS will pass the shutdown sequence to the host operating system and there is no way to know from the web interface if the shutdown / restart process has completed. <br>
- <b>Please make sure you are shutting it down in a location where you can physcically power on the host again.</b></p>
- </div>
- </div>
-
- </div>
- <script>
- $("#lastupdateTime").text(ao_module_utils.timeConverter(Date.now()/1000));
- function shutdown(){
- var apiObject = {
- api: "system/power/shutdown",
- data: {},
- title: "<i class='red exclamation triangle icon'></i> Shutdown Host <i class='red exclamation triangle icon'></i>",
- desc: "Please enter your password to confirm operation.",
- thisuser: true, //This username as default, set to false for entering other user
- method: "GET",
- success: "SystemAO/boot/shutdown.html"
- }
- apiObject = encodeURIComponent(JSON.stringify(apiObject));
- ao_module_newfw({
- url: "SystemAO/security/authreq.html#" + apiObject,
- width: 480,
- height: 300,
- appicon: "SystemAO/security/img/lock.svg",
- title: "Shutdown - Authentication Required",
- parent: ao_module_windowID,
- callback: "handleShutdownCallback"
- });
- }
- function restart(){
- var apiObject = {
- api: "system/power/restart",
- data: {},
- title: "Password Required",
- desc: "for restarting the ArozOS Host",
- thisuser: true, //This username as default, set to false for entering other user
- method: "GET"
- }
- apiObject = encodeURIComponent(JSON.stringify(apiObject));
- ao_module_newfw({
- url: "SystemAO/security/authreq.html#" + apiObject,
- width: 480,
- height: 300,
- appicon: "SystemAO/security/img/lock.svg",
- title: "Restart - Authentication Required",
- parent: ao_module_windowID,
- callback: "handleRestartCallback"
- });
- }
- function handleRestartCallback(data){
- if (data != false){
- //Not cancelled. Continue
- $("#msgbox").slideDown("fast").delay(5000).slideUp("fast");
- $("#succmsg").text("Host restarting...");
- }
- }
- function handleShutdownCallback(data){
- if (data != false){
- //Not cancelled. Continue
- $("#msgbox").slideDown("fast").delay(5000).slideUp("fast");
- $("#succmsg").text("Host will start shutdown sequence in 60 seconds");
- }
- }
- handleConnectionStateCheck();
- setTimeout(function(){
- handleConnectionStateCheck();
- }, 3000)
- function handleConnectionStateCheck(){
- if ($("#sysConnState").length > 0){
- $.ajax({
- url: "../../system/auth/checkLogin",
- data: {},
- success: function(){
- //Online
- $("#sysConnState").text("System Online");
- $("#lastupdateTime").text(ao_module_utils.timeConverter(Date.now()/1000));
- $("#sysConnStateIcon").attr("class","green check circle icon");
- setTimeout(function(){
- handleConnectionStateCheck();
- }, 3000)
- },
- error: function(){
- //Timeout
- $("#sysConnState").text("Disconnected");
- $("#lastupdateTime").text(ao_module_utils.timeConverter(Date.now()/1000));
- $("#sysConnStateIcon").attr("class","yellow exclamation circle icon");
- setTimeout(function(){
- handleConnectionStateCheck();
- }, 3000)
- },
- timeout: 1000
- });
- }
- }
- </script>
- </body>
- </html>
|