Browse Source

auto update script executed

Toby Chui 1 year ago
parent
commit
db2a953b5b
4 changed files with 25 additions and 3 deletions
  1. 1 1
      reverseproxy.go
  2. 1 1
      web/components/subd.html
  3. 1 1
      web/components/vdir.html
  4. 22 0
      web/snippet/basicAuthEditor.html

+ 1 - 1
reverseproxy.go

@@ -482,7 +482,7 @@ func UpdateProxyBasicAuthCredentials(w http.ResponseWriter, r *http.Request) {
 
 		//Try to marshal the content of creds into the suitable structure
 		newCredentials := []*dynamicproxy.BasicAuthUnhashedCredentials{}
-		err = json.Unmarshal([]byte(creds), newCredentials)
+		err = json.Unmarshal([]byte(creds), &newCredentials)
 		if err != nil {
 			utils.SendErrorResponse(w, "Malformed credential data")
 			return

+ 1 - 1
web/components/subd.html

@@ -25,8 +25,8 @@
 
 <script>
     function listSubd(){
-        $("#subdList").html(``);
         $.get("/api/proxy/list?type=subd", function(data){
+            $("#subdList").html(``);
             if (data.error !== undefined){
                     $("#subdList").append(`<tr>
                     <td data-label="" colspan="3"><i class="remove icon"></i> ${data.error}</td>

+ 1 - 1
web/components/vdir.html

@@ -27,8 +27,8 @@
 <script>
     //Virtual directories functions
     function listVdirs(){
-        $("#vdirList").html(``);
         $.get("/api/proxy/list?type=vdir", function(data){
+            $("#vdirList").html(``);
             if (data.error !== undefined){
                 $("#vdirList").append(`<tr>
                     <td data-label="" colspan="3"><i class="remove icon"></i> ${data.error}</td>

+ 22 - 0
web/snippet/basicAuthEditor.html

@@ -52,6 +52,7 @@
         </div>
         <script>
             let editingCredentials = [];
+            let editingEndpoint = {};
 
             if (window.location.hash.length > 1){
                 let payloadHash = window.location.hash.substr(1);
@@ -59,6 +60,7 @@
                     payloadHash = JSON.parse(decodeURIComponent(payloadHash));
                     loadBasicAuthCredentials(payloadHash.ept, payloadHash.ep);
                     $("#epname").text(payloadHash.ep);
+                    editingEndpoint = payloadHash;
                 }catch(ex){
                     console.log("Unable to load endpoint data from hash")
                 }
@@ -169,6 +171,26 @@
             function cancelCredentialEdit(){
                 parent.hideSideWrapper(true);
             }
+
+            function saveCredentials(){
+                $.ajax({
+                    url: "/api/proxy/updateCredentials",
+                    method: "POST",
+                    data: {
+                        ep: editingEndpoint.ep, 
+                        ptype: editingEndpoint.ept,
+                        creds: JSON.stringify(editingCredentials)
+                    },
+                    success: function(data){
+                        if (data.error != undefined){
+                            parent.msgbox(data.error, false, 6000);
+                        }else{
+                            parent.msgbox("Credentials Updated");
+                            parent.hideSideWrapper(true);
+                        }
+                    }
+                })
+            }
         </script>
     </body>
 </html>