Преглед на файлове

Added shutdown code and action object decode

tobychui преди 4 години
родител
ревизия
ba36655b76
променени са 2 файла, в които са добавени 25 реда и са изтрити 2 реда
  1. 18 1
      web/SystemAO/boot/poweroff.html
  2. 7 1
      web/SystemAO/security/authreq.html

+ 18 - 1
web/SystemAO/boot/poweroff.html

@@ -48,12 +48,29 @@
             
 
             function shutdown(){
+                var apiObject = {
+                    api: "/system/power/shutdown",
+                    data: {},
+                    title: "Shutdown Host",
+                    desc: "Authentication is required in order to proceed the shutdown process. Make sure you have access to the host hardware before shutdown.",
+                    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: 380,
+                    height: 200,
+                    appicon: "SystemAO/security/img/lock.svg",
+                    title: "Shutdown - Authentication Required"
+                });
             }
 
             function restart(){
                 var apiObject = {
-                    api: "system/power/restart",
+                    api: "/system/power/restart",
                     data: {},
                     title: "Restart Host",
                     desc: "Authentication is required in order to proceed the restart process",

+ 7 - 1
web/SystemAO/security/authreq.html

@@ -18,7 +18,13 @@
     </div>
     
     <script>
-       
+       var actionObject = {};
+       if (window.location.hash.length > 1){
+            var object = JSON.parse(decodeURIComponent(window.location.hash.substr(1)));
+            console.log(object);
+       }else{
+           //Invalid usage
+       }
     </script>
 </body>
 </html>