poweroff.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <html>
  2. <head>
  3. <title>Host Power Options</title>
  4. <style>
  5. </style>
  6. </head>
  7. <body>
  8. <div class="ui container">
  9. <div class="ui basic segment">
  10. <h3 class="ui header">
  11. <i class="power icon"></i>
  12. <div class="content">
  13. Host Power
  14. <div class="sub header">Change power state of your device</div>
  15. </div>
  16. </h3>
  17. </div>
  18. <div class="ui divider"></div>
  19. <div class="ui segment">
  20. <h3 class="ui header">
  21. <i id="sysConnStateIcon" class="green check circle icon"></i>
  22. <div class="content">
  23. <span id="sysConnState">System Online</span>
  24. <div class="sub header">Last update: <span id="lastupdateTime"></span></div>
  25. </div>
  26. </h3>
  27. </div>
  28. <div class="ui divider"></div>
  29. <p>Power Options</p>
  30. <button class="ui red button" onclick="shutdown();"><i class="power off icon"></i> Power Off</button>
  31. <button class="ui yellow button" onclick="restart();"><i class="refresh icon"></i> Restart</button>
  32. <div id="msgbox" class="ui green message" style="display:none;">
  33. <p><i class="checkmark icon"></i> <span id="succmsg"></span></p>
  34. </div>
  35. <div class="ui divider"></div>
  36. <div class="ui icon message">
  37. <i class="yellow exclamation circle icon"></i>
  38. <div class="content">
  39. <div class="header">
  40. Restart / Shutdown is risky
  41. </div>
  42. <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>
  43. <b>Please make sure you are shutting it down in a location where you can physcically power on the host again.</b></p>
  44. </div>
  45. </div>
  46. </div>
  47. <script>
  48. $("#lastupdateTime").text(ao_module_utils.timeConverter(Date.now()/1000));
  49. function shutdown(){
  50. var apiObject = {
  51. api: "system/power/shutdown",
  52. data: {},
  53. title: "<i class='red exclamation triangle icon'></i> Shutdown Host <i class='red exclamation triangle icon'></i>",
  54. desc: "Please enter your password to confirm operation.",
  55. thisuser: true, //This username as default, set to false for entering other user
  56. method: "GET",
  57. success: "SystemAO/boot/shutdown.html"
  58. }
  59. apiObject = encodeURIComponent(JSON.stringify(apiObject));
  60. ao_module_newfw({
  61. url: "SystemAO/security/authreq.html#" + apiObject,
  62. width: 480,
  63. height: 300,
  64. appicon: "SystemAO/security/img/lock.svg",
  65. title: "Shutdown - Authentication Required",
  66. parent: ao_module_windowID,
  67. callback: "handleShutdownCallback"
  68. });
  69. }
  70. function restart(){
  71. var apiObject = {
  72. api: "system/power/restart",
  73. data: {},
  74. title: "Password Required",
  75. desc: "for restarting the ArozOS Host",
  76. thisuser: true, //This username as default, set to false for entering other user
  77. method: "GET"
  78. }
  79. apiObject = encodeURIComponent(JSON.stringify(apiObject));
  80. ao_module_newfw({
  81. url: "SystemAO/security/authreq.html#" + apiObject,
  82. width: 480,
  83. height: 300,
  84. appicon: "SystemAO/security/img/lock.svg",
  85. title: "Restart - Authentication Required",
  86. parent: ao_module_windowID,
  87. callback: "handleRestartCallback"
  88. });
  89. }
  90. function handleRestartCallback(data){
  91. if (data != false){
  92. //Not cancelled. Continue
  93. $("#msgbox").slideDown("fast").delay(5000).slideUp("fast");
  94. $("#succmsg").text("Host restarting...");
  95. }
  96. }
  97. function handleShutdownCallback(data){
  98. if (data != false){
  99. //Not cancelled. Continue
  100. $("#msgbox").slideDown("fast").delay(5000).slideUp("fast");
  101. $("#succmsg").text("Host will start shutdown sequence in 60 seconds");
  102. }
  103. }
  104. handleConnectionStateCheck();
  105. setTimeout(function(){
  106. handleConnectionStateCheck();
  107. }, 3000)
  108. function handleConnectionStateCheck(){
  109. if ($("#sysConnState").length > 0){
  110. $.ajax({
  111. url: "../../system/auth/checkLogin",
  112. data: {},
  113. success: function(){
  114. //Online
  115. $("#sysConnState").text("System Online");
  116. $("#lastupdateTime").text(ao_module_utils.timeConverter(Date.now()/1000));
  117. $("#sysConnStateIcon").attr("class","green check circle icon");
  118. setTimeout(function(){
  119. handleConnectionStateCheck();
  120. }, 3000)
  121. },
  122. error: function(){
  123. //Timeout
  124. $("#sysConnState").text("Disconnected");
  125. $("#lastupdateTime").text(ao_module_utils.timeConverter(Date.now()/1000));
  126. $("#sysConnStateIcon").attr("class","yellow exclamation circle icon");
  127. setTimeout(function(){
  128. handleConnectionStateCheck();
  129. }, 3000)
  130. },
  131. timeout: 1000
  132. });
  133. }
  134. }
  135. </script>
  136. </body>
  137. </html>