Browse Source

auto update script executed

Toby Chui 1 year ago
parent
commit
2b9a4929b8
4 changed files with 45 additions and 22 deletions
  1. 2 2
      acme.go
  2. 31 18
      web/components/cert.html
  3. 7 2
      web/components/rules.html
  4. 5 0
      web/snippet/acme.html

+ 2 - 2
acme.go

@@ -122,15 +122,15 @@ func HandleACMEPreferredCA(w http.ResponseWriter, r *http.Request) {
 	if err != nil {
 		//Return the current ca to user
 		prefCA := "Let's Encrypt"
-		sysdb.Read("acmepref", "prefca", prefCA)
+		sysdb.Read("acmepref", "prefca", &prefCA)
 		js, _ := json.Marshal(prefCA)
 		utils.SendJSONResponse(w, string(js))
 	} else {
 		//Check if the CA is supported
 		acme.IsSupportedCA(ca)
-
 		//Set the new config
 		sysdb.Write("acmepref", "prefca", ca)
+		log.Println("Updating prefered ACME CA to " + ca)
 		utils.SendOK(w)
 	}
 

+ 31 - 18
web/components/cert.html

@@ -65,17 +65,20 @@
     </div>
     <br>
     <div>
-        <table class="ui sortable unstackable celled table">
-            <thead>
-            <tr><th>Domain</th>
-            <th>Last Update</th>
-            <th>Expire At</th>
-            <th class="no-sort">Remove</th>
-            </tr></thead>
-        <tbody id="certifiedDomainList">
-
-        </tbody>
-        </table>
+        <div style="width: 100%; overflow-x: auto; margin-bottom: 1em;">
+            <table class="ui sortable unstackable celled table">
+                <thead>
+                <tr><th>Domain</th>
+                <th>Last Update</th>
+                <th>Expire At</th>
+                <th class="no-sort">Remove</th>
+                </tr></thead>
+            <tbody id="certifiedDomainList">
+    
+            </tbody>
+            </table>
+        </div>
+        
         <button class="ui basic button" onclick="initManagedDomainCertificateList();"><i class="green refresh icon"></i> Refresh List</button>
     </div>
     <div class="ui message">
@@ -154,7 +157,7 @@
         });
 
         $.get("/api/acme/autoRenew/ca", function(data){
-            $("#defaultCA").dropdown("set selected", data);
+            $("#defaultCA").dropdown("set value", data);
         });
 
         $.get("/api/acme/autoRenew/enable", function(data){
@@ -177,15 +180,25 @@
             return;
         }
 
-        $.post("/api/acme/autoRenew/email?set=" + newDefaultEmail, function(data){
-            if (data.error != undefined){
-                msgbox(data.error, false);
+        $.ajax({
+            url: "/api/acme/autoRenew/email",
+            method: "POST",
+            data: {"set": newDefaultEmail},
+            success: function(data){
+                if (data.error != undefined){
+                    msgbox(data.error, false);
+                }
             }
         });
 
-        $.post("/api/acme/autoRenew/ca?set=" + newDefaultCA, function(data){
-            if (data.error != undefined){
-                msgbox(data.error, false);
+        $.ajax({
+            url: "/api/acme/autoRenew/ca",
+            data: {"set": newDefaultCA},
+            method: "POST",
+            success: function(data){
+                if (data.error != undefined){
+                    msgbox(data.error, false);
+                }
             }
         });
 

+ 7 - 2
web/components/rules.html

@@ -184,10 +184,15 @@
                     if (type == "subd" && $("#tls").checkbox("is checked")){
                         confirmBox("Request new SSL Cert for this subdomain?", function(choice){
                             if (choice == true){
+                                //Load the prefer CA from TLS page
+                                let defaultCA = $("#defaultCA").dropdown("get value");
+                                if (defaultCA.trim() == ""){
+                                    defaultCA = "Let's Encrypt";
+                                }
                                 //Get a new cert using ACME
-                                msgbox("Requesting certificate via Let's Encrypt...");
+                                msgbox("Requesting certificate via " + defaultCA  +"...");
                                 console.log("Trying to get a new certificate via ACME");
-                                obtainCertificate(rootname);
+                                obtainCertificate(rootname, defaultCA.trim());
                             }else{
                                 msgbox("Proxy Endpoint Added");
                             }

+ 5 - 0
web/snippet/acme.html

@@ -218,6 +218,11 @@
           $("#enableToggleSucc").stop().finish().fadeIn("fast").delay(3000).fadeOut("fast");
         }
       });
+
+      if (parent && parent.setACMEEnableStates){
+        parent.setACMEEnableStates(enabled);
+      }
+      
     }
 
     //Render the domains table that exists in this zoraxy host