Browse Source

auto update script executed

Toby Chui 1 year ago
parent
commit
417c099a41
3 changed files with 24 additions and 63 deletions
  1. 14 0
      web/components/rules.html
  2. 10 4
      web/components/status.html
  3. 0 59
      web/index.html

+ 14 - 0
web/components/rules.html

@@ -83,4 +83,18 @@
         });
         
     }
+
+    //Generic functions for delete rp endpoints 
+    function deleteEndpoint(ptype, epoint){
+                if (confirm("Confirm remove proxy for :" + epoint + " (type: " + ptype + ")?")){
+                    $.ajax({
+                        url: "/api/proxy/del",
+                        data: {ep: epoint, ptype: ptype},
+                        success: function(){
+                            listVdirs();
+                            listSubd();
+                        }
+                    })
+                }
+            }
 </script>

+ 10 - 4
web/components/status.html

@@ -69,7 +69,7 @@
 <Br>
 <button id="startbtn" class="ui teal button" onclick="startService();">Start Service</button>
 <button id="stopbtn" class="ui red disabled button" onclick="stopService();">Stop Service</button>
-
+<div id="statusErrmsg" class="ui red message" style="display: none;"></div>
 <script>
     //Get the latest server status from proxy server
     function initRPStaste(){
@@ -95,7 +95,7 @@
     function startService(){
         $.post("/api/proxy/enable", {enable: true}, function(data){
             if (data.error != undefined){
-                errmsg(data.error);
+                statusErrmsg(data.error);
             }
             initRPStaste();
         });
@@ -104,12 +104,18 @@
     function stopService(){
         $.post("/api/proxy/enable", {enable: false}, function(data){
             if (data.error != undefined){
-                errmsg(data.error);
+                statusErrmsg(data.error);
             }
             initRPStaste();
         });
     }
 
+    //Show error message
+    function statusErrmsg(message){
+        $("#statusErrmsg").html(`<i class="red remove icon"></i> ${message}`);
+        $("#statusErrmsg").slideDown('fast').delay(5000).slideUp('fast');
+    }
+
     function handlePortChange(){
         var newPortValue = $("#incomingPort").val();
         if (isNaN(newPortValue - 1)){
@@ -119,7 +125,7 @@
 
         $.post("/api/proxy/setIncoming", {incoming: newPortValue}, function(data){
             if (data.error != undefined){
-                errmsg(data.error);
+                statusErrmsg(data.error);
             }
             $("#portUpdateSucc").stop().finish().slideDown("fast").delay(3000).slideUp("fast");
             initRPStaste();

+ 0 - 59
web/index.html

@@ -95,7 +95,6 @@
                 <button class="ui basic icon button" onclick="logout();"><i class="sign-out icon"></i></button>
             </div>
         </div>
-        <div id="errmsg" class="ui red message" style="display: none;"></div>
         <div class="wrapper">
             <div class="toolbar">
                 <div id="mainmenu" class="ui secondary vertical pointing menu">
@@ -287,65 +286,7 @@
                 window.location.hash = tabID;
             }
 
-            
-
-           //Generic functions  
-            function deleteEndpoint(ptype, epoint){
-                if (confirm("Confirm remove proxy for :" + epoint + " (type: " + ptype + ")?")){
-                    $.ajax({
-                        url: "./del",
-                        data: {ep: epoint, ptype: ptype},
-                        success: function(){
-                            listVdirs();
-                            listSubd();
-                        }
-                    })
-                }
-               
-            }
-
-            
-            
-
-           
-           
-
-            
-
-            function setProxyRoot(){
-                var newpr = $("#proxyRoot").val();
-                if (newpr.trim() == ""){
-                    $("#proxyRoot").parent().addClass('error');
-                    return
-                }else{
-                    $("#proxyRoot").parent().removeClass('error');
-                }
 
-                var rootReqTls = $("#rootReqTLS")[0].checked;
-
-                //Create the endpoint by calling add
-                $.ajax({
-                    url: "./add",
-                    data: {"type": "root", tls: rootReqTls, ep: newpr},
-                    success: function(data){
-                        if (data.error != undefined){
-                            alert(data.error);
-                        }else{
-                            //OK
-                            initRootInfo();
-                            $("#ProxyRootUpdate").stop().slideDown('fast').delay(3000).slideUp('fast');
-                        }
-                    }
-                });
-
-            }
-
-           
-            //Show error message
-            function errmsg(message){
-                $("#errmsg").html(`<i class="red remove icon"></i> ${message}`);
-                $("#errmsg").slideDown('fast').delay(5000).slideUp('fast');
-            }
         </script>
     </body>
 </html>