Przeglądaj źródła

Added shutdown countdown page

TC pushbot 5 4 lat temu
rodzic
commit
3b0e70b9d3

+ 4 - 5
web/SystemAO/boot/poweroff.html

@@ -50,16 +50,15 @@
         <script>
             $("#lastupdateTime").text(ao_module_utils.timeConverter(Date.now()/1000));
 
-            
-
             function shutdown(){
                 var apiObject = {
-                    api: "/system/power/shutdown",
+                    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"
+                    method: "GET",
+                    success: "systemAO/boot/shutdown.html"
                 }
 
                 apiObject = encodeURIComponent(JSON.stringify(apiObject));
@@ -77,7 +76,7 @@
 
             function restart(){
                 var apiObject = {
-                    api: "/system/power/restart",
+                    api: "system/power/restart",
                     data: {},
                     title: "Password Required",
                     desc: "for restarting the ArozOS Host",

+ 71 - 0
web/SystemAO/boot/shutdown.html

@@ -0,0 +1,71 @@
+<html>
+    <head>
+        <title>Shutting Down</title>
+        <meta charset="UTF-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
+        <script type="text/javascript" src="../../script/jquery.min.js"></script>
+        <style>
+            body{
+                background-color: #0f0f0f;
+            }
+
+            .main{
+                width: 400px;
+                height: 100px;
+                padding: 20px;
+                position: absolute;
+                top: 30%;
+                left: calc(50% - 200px);
+                color: white;
+                font-family: monospace;
+                text-align: center;
+            }
+
+            .brandicon{
+                width: 70%;
+
+            }
+        </style>
+    </head>
+    <body>
+        <br><br><br>
+        <div class="main">
+            <img class="brandicon" src="../../img/vendor/vendor_icon.png">
+            <p id="countdown">Host server is shutting down in 60 seconds</p>
+        </div>
+        <script>
+            //ArozOS default shutdown after 60 seconds after shutdown request has been made.
+            //Shut it down
+            let counter = 60;
+            function handleCountdown(){
+                setTimeout(function(){
+                    counter--;
+                    if (counter == 0){
+                        setTimeout(function(){
+                            $.ajax({
+                                url: "../../system/auth/checkLogin",
+                                success: function(data){
+                                    $("#countdown").text("Shutdown failed. Please try again later");
+                                    document.title = "Shutdown Failed";
+                                },
+                                error: function(){
+                                    //Server connection lost. Should have been shutted down
+                                    $("#countdown").text("Shutdown Succeed: Host offline");
+                                    document.title = "Offline";
+                                },
+                                timeout: 2000
+                            });
+                        }, 3000);
+                        $("#countdown").text("Checking Connection State...");
+                    }else{
+                        $("#countdown").text(`Host server is shutting down in ${counter} seconds`);
+                        handleCountdown();
+                    
+                    }
+                }, 1000);
+            }
+
+            handleCountdown();
+        </script>
+    </body>
+</html>

+ 8 - 2
web/SystemAO/security/authreq.html

@@ -57,12 +57,13 @@
         /*
             Usage Example:
             var apiObject = {
-                api: "/system/myfunction",
+                api: "system/myfunction",
                 data: {message: "Hello World"},
                 title: "<i class='red exclamation triangle icon'></i> Danger Operation <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 allowing other user name to be entered
-                method: "GET"
+                method: "GET",
+                success: "systemAO/myfunction/succ.html" //Redirection if success
             }
 
             ao_module_newfw({
@@ -128,11 +129,16 @@
                         if ($("#username").parent().hasClass("disabled") == false){
                             $("#username").parent().addClass("error");
                         }
+
                     }else{
                         if (ao_module_hasParentCallback()){
                             ao_module_parentCallback(data);
                         }
 
+                        if (actionObject.success != undefined){
+                            window.top.location = "../../" + actionObject.success;
+                        }
+
                         ao_module_close();
                     }
                     

+ 3 - 2
web/desktop.system

@@ -5419,12 +5419,13 @@
             }
 
             var apiObject = {
-                api: "/system/power/shutdown",
+                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"
+                method: "GET",
+                success: "systemAO/boot/shutdown.html" //Success redirection
             }
             apiObject = encodeURIComponent(JSON.stringify(apiObject));