Bläddra i källkod

auto update script executed

Toby Chui 1 år sedan
förälder
incheckning
d0d5230b43
2 ändrade filer med 44 tillägg och 11 borttagningar
  1. 42 9
      web/components/rproot.html
  2. 2 2
      web/components/webserv.html

+ 42 - 9
web/components/rproot.html

@@ -75,13 +75,13 @@
             $("#rootReqTLS").parent().addClass("disabled");
 
             //Check if web server is enabled. If not, ask if the user want to enable it
-            if (!$("#webserv_enable").parent().checkbox("is checked")){
+            /*if (!$("#webserv_enable").parent().checkbox("is checked")){
                 confirmBox("Enable static web server now?", function(choice){
                     if (choice == true){
                         $("#webserv_enable").parent().checkbox("set checked");
                     }
                 });
-            }
+            }*/
         }else{
             $("#rootReqTLS").parent().removeClass("disabled");
             $("#proxyRoot").parent().removeClass("disabled");
@@ -89,7 +89,7 @@
         }
     }
     
-    function initRootInfo(){
+    function initRootInfo(callback=undefined){
         $.get("/api/proxy/list?type=root", function(data){
             if (data == null){
 
@@ -97,11 +97,30 @@
                 $("#proxyRoot").val(data.Domain);
                 checkRootRequireTLS(data.Domain);
             }
+
+            if (callback != undefined){
+                callback();
+            }
         });
-        
     }
-    initRootInfo();
-
+    initRootInfo(function(){
+        updateWebServerLinkSettings();
+    });
+
+
+    function updateWebServerLinkSettings(){
+        let currentProxyRoot = $("#proxyRoot").val().trim();
+        $.get("/api/webserv/status", function(webservStatus){
+            if (currentProxyRoot == "127.0.0.1:" + webservStatus.ListeningPort || currentProxyRoot == "localhost:" + webservStatus.ListeningPort){
+                //The root is pointing to the static web server
+                $("#useStaticWebServer").parent().checkbox("set checked");
+                $(".webservRootDisabled").addClass("disabled");
+            }else{
+                $(".webservRootDisabled").removeClass("disabled");
+            }
+        });
+    }
+    
     function updateRootSettingStates(){
         $.get("/api/cert/tls", function(data){
             if (data == true){
@@ -137,7 +156,7 @@
                 let useRedirect = $("#unsetRedirect")[0].checked;
                 updateRedirectionDomainSettingInputBox(useRedirect);
             });
-        })
+        });
        
     }
     checkCustomRedirectForUnsetSubd();
@@ -189,8 +208,22 @@
                     msgbox(data.error, false, 5000);
                 }else{
                     //OK
-                    initRootInfo();
-                    msgbox("Proxy Root Updated")
+                    initRootInfo(function(){
+                        //Check if WebServ is enabled
+                        let currentProxyRoot = $("#proxyRoot").val().trim();
+                        $.get("/api/webserv/status", function(webservStatus){
+                            if (!webservStatus.Running){
+                                //Force enable static web server
+                                $("#webserv_enable").parent().checkbox("set checked");
+                            }
+
+                            setTimeout(function(){
+                                updateWebServerLinkSettings();
+                                msgbox("Proxy Root Updated");
+                            }, 1000);
+                        });
+                    });
+                    
                 }
             }
         });

+ 2 - 2
web/components/webserv.html

@@ -17,7 +17,7 @@
     <h3>Web Server Settings</h3>
     <div class="ui form">
         <div class="inline field">
-            <div class="ui toggle checkbox">
+            <div class="ui toggle checkbox webservRootDisabled">
                 <input id="webserv_enable" type="checkbox" class="hidden">
                 <label>Enable Static Web Server</label>
             </div>
@@ -37,7 +37,7 @@
                 See the -webserv flag for more details.
             </small>
         </div>
-        <div class="field">
+        <div class="field webservRootDisabled">
             <label>Port Number</label>
             <input id="webserv_listenPort" type="number" step="1" min="0" max="65535" value="8081" onchange="updateWebServLinkExample(this.value);">
             <small>Use <code>http://127.0.0.1:<span class="webserv_port">8081</span></code> in proxy rules to access the web server</small>