Browse Source

auto update script executed

Toby Chui 1 year ago
parent
commit
d573ac1ca9
4 changed files with 45 additions and 7 deletions
  1. 30 1
      web/components/cert.html
  2. 9 3
      web/components/rproot.html
  3. 4 2
      web/components/rules.html
  4. 2 1
      web/components/webserv.html

+ 30 - 1
web/components/cert.html

@@ -77,7 +77,6 @@
         </tbody>
         </table>
         <button class="ui basic button" onclick="initManagedDomainCertificateList();"><i class="green refresh icon"></i> Refresh List</button>
-        <button class="ui basic button" onclick="openACMEManager();"><i class="yellow refresh icon"></i> Auto Renew (ACME) Settings</button>
     </div>
     <div class="ui message">
         <h4><i class="info circle icon"></i> Sub-domain Certificates</h4>
@@ -85,11 +84,36 @@
         depending on your certificates coverage, you might need to setup them one by one (i.e. having two seperate certificate for <code>a.example.com</code> and <code>b.example.com</code>).<br>
         If you have a wildcard certificate that covers <code>*.example.com</code>, you can just enter <code>example.com</code> as server name in the form below to add a certificate.
     </div>
+    <div class="ui divider"></div>
+    <h4>Certificate Authority (CA) and Auto Renew (ACME)</h4>
+    <p>Management features regarding CA and ACME</p>
+    <p>The default CA to use when create a new subdomain proxy endpoint with TLS certificate</p>
+    <div class="ui fluid form">
+        <div class="field">
+            <div class="ui selection dropdown" id="defaultCA">
+                <input type="hidden" name="defaultCA">
+                <i class="dropdown icon"></i>
+                <div class="default text">Let's Encrypt</div>
+                <div class="menu">
+                  <div class="item" data-value="Let's Encrypt">Let's Encrypt</div>
+                  <div class="item" data-value="Buypass">Buypass</div>
+                  <div class="item" data-value="ZeroSSL">ZeroSSL</div>
+                </div>
+            </div>
+        </div>
+        <button class="ui basic icon button" onclick="saveDefaultCA();"><i class="ui blue save icon"></i> Save Settings</button>
+    </div><br>
+    
+    <h5>Certificate Renew / Generation (ACME) Settings</h5>
+    <p>This tool provide you a graphical interface to setup auto certificate renew on your (sub)domains. You can also manually generate a certificate if one of your domain do not have certificate.</p>
+    <button class="ui basic button" onclick="openACMEManager();"><i class="yellow external icon"></i> Open ACME Tool</button>
 </div>
 <script>
     var uploadPendingPublicKey = undefined;
     var uploadPendingPrivateKey = undefined;
 
+    $("#defaultCA").dropdown();
+
     //Delete the certificate by its domain
     function deleteCertificate(domain){
         if (confirm("Confirm delete certificate for " + domain + " ?")){
@@ -110,6 +134,11 @@
         
     }
 
+    function saveDefaultCA(){
+        //TODO: Add an endpoint to handle default CA set and load
+        alert("WIP");
+    }
+
     //List the stored certificates
     function initManagedDomainCertificateList(){
         $.get("/api/cert/list?date=true", function(data){

+ 9 - 3
web/components/rproot.html

@@ -73,12 +73,19 @@
             $("#proxyRoot").parent().addClass("disabled");
             $("#rootReqTLS").parent().checkbox("set unchecked");
             $("#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")){
+                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");
             initRootInfo();
-
-            //TODO UPDATE THE SAVE FUNTION
         }
     }
     
@@ -91,7 +98,6 @@
                 checkRootRequireTLS(data.Domain);
             }
         });
-
         
     }
     initRootInfo();

+ 4 - 2
web/components/rules.html

@@ -188,6 +188,8 @@
                                 msgbox("Requesting certificate via Let's Encrypt...");
                                 console.log("Trying to get a new certificate via ACME");
                                 obtainCertificate(rootname);
+                            }else{
+                                msgbox("Proxy Endpoint Added");
                             }
                         });
                     }else{
@@ -467,7 +469,7 @@
     });
 
    // Obtain certificate from API, only support one domain
-    function obtainCertificate(domains) {
+    function obtainCertificate(domains, usingCa = "Let's Encrypt") {
         let filename = "";
         let email = acmeEmail;
         if (acmeEmail == ""){
@@ -494,7 +496,7 @@
                 domains: domains,
                 filename: filename,
                 email: email,
-                ca: "Let's Encrypt",
+                ca: usingCa,
             },
             success: function(response) {
                 if (response.error) {

+ 2 - 1
web/components/webserv.html

@@ -100,6 +100,7 @@
                 $("#webservRunningState").find(".webserv_status").text("Stopped");
             }
         }
+
         function updateWebServState(){
             $.get("/api/webserv/status", function(data){
                 //Clear all event listeners
@@ -146,8 +147,8 @@
                             }
                         });
                     }
-                   
                 });
+
                 $("#webserv_enableDirList").off("change").on("change", function(){
                     let enable = $(this)[0].checked;
                     $.ajax({