123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <!DOCTYPE html>
- <html>
- <head>
- <!-- Notes: This should be open in its original path-->
- <link rel="stylesheet" href="../script/semantic/semantic.min.css">
- <script src="../script/jquery-3.6.0.min.js"></script>
- <script src="../script/semantic/semantic.min.js"></script>
- <style>
- .disabled.table{
- opacity: 0.5;
- pointer-events: none;
- user-select: none;
- }
- .expiredDomain{
- color: rgb(238, 31, 31);
- }
- .validDomain{
- color: rgb(49, 192, 113);
- }
- </style>
- </head>
- <body>
- <br>
- <div class="ui container">
- <div class="ui header">
- <div class="content">
- Certificates Auto Renew Settings
- <div class="sub header">Fetch and renew your certificates with Automated Certificate Management Environment (ACME) protocol</div>
- </div>
- </div>
- <div class="ui basic segment">
- <div class="ui toggle checkbox">
- <input type="checkbox" id="enableCertAutoRenew" checked>
- <label>Enable Certificate Auto Renew</label>
- </div>
- </div>
- <div class="ui yellow message">
- Certificate Renew only works on the certification authority (CA) supported by Zoraxy. Check Zoraxy wiki for more information on supported list of CAs.
- </div>
- <div class="ui basic segment" style="background-color: #f7f7f7; border-radius: 1em;">
- <div class="ui accordion advanceSettings">
- <div class="title">
- <i class="dropdown icon"></i>
- Advance Renew Policy
- </div>
- <div class="content">
- <p>Renew all certificates with ACME supported CAs</p>
- <div class="ui toggle checkbox">
- <input type="checkbox" id="renewAllSupported" onchange="setAutoRenewIfCASupportMode(this.checked);" checked>
- <label>Auto renew if CA is supported</label>
- </div>
- <div class="ui horizontal divider"> OR </div>
- <p>Select the certificates to automatic renew in the list below</p>
- <table id="domainCertFileTable" class="ui very compact unstackable basic disabled table">
- <thead>
- <tr>
- <th>Domain Name</th>
- <th>Filename</th>
- <th>Auto-Renew</th>
- </tr>
- </thead>
- <tbody id="domainTableBody"></tbody>
- </table>
- <button class="ui basic right floated button"><i class="blue save icon"></i> Save Changes</button>
- <button class="ui basic right floated button"><i class="yellow refresh icon"></i> Renew All</button>
- <br><br>
- </div>
- </div>
- </div>
- <div class="ui divider"></div>
- <h3>Manual Renew</h3>
- <p>Pick a certificate below to force renew</p>
- <div class="ui form">
- <div class="field">
- <label>Domains</label>
- <input id="domainsInput" type="text" placeholder="example.com">
- <small>If you have more than one domain in a single certificate, enter the domains separated by commas (e.g. test.example.com,example.com)</small>
- </div>
- <div class="field">
- <label>Filename</label>
- <input id="filenameInput" type="text" placeholder="Enter filename">
- </div>
- <div class="field">
- <label>Certificate Authority (CA)</label>
- <div class="ui selection dropdown">
- <input type="hidden" name="ca">
- <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 class="item" data-value="Google">Google</div>
- </div>
- </div>
- </div>
- <button id="obtainButton" class="ui basic button" type="submit"><i class="yellow refresh icon"></i> Renew Certificate</button>
- </div>
- <button class="ui basic button" style="float: right;" onclick="parent.hideSideWrapper();"><i class="remove icon"></i> Cancel</button>
- <br><br><br><br>
- </div>
- <script>
- let expiredDomains = [];
- $(".accordion").accordion();
- $(".dropdown").dropdown();
- function setAutoRenewIfCASupportMode(useAutoMode = true){
- if (useAutoMode){
- $("#domainCertFileTable").addClass("disabled");
- }else{
- $("#domainCertFileTable").removeClass("disabled");
- }
- }
- //Render the domains table that exists in this zoraxy host
- function renderDomainTable(domains) {
- // Get the table body element
- var tableBody = $('#domainTableBody');
-
- // Clear the table body
- tableBody.empty();
-
- // Iterate over the domain names
- var counter = 0;
- for (const [domain, srcfile] of Object.entries(domains)) {
- // Create a table row
- var row = $('<tr>');
-
- // Create the domain name cell
- var domainClass = "validDomain";
- if (expiredDomains.includes(domain)){
- domainClass = "expiredDomain";
- }
- var domainCell = $('<td class="' + domainClass +'">').text(domain);
- row.append(domainCell);
- var srcFileCell = $('<td>').text(srcfile);
- row.append(srcFileCell);
-
- // Create the auto-renew checkbox cell
- var checkboxCell = $(`<td domain="${domain}" srcfile="${srcfile}">`);
- var checkbox = $('<input>').attr('type', 'checkbox');
- checkboxCell.append(checkbox);
- row.append(checkboxCell);
-
- // Add the row to the table body
- tableBody.append(row);
- counter++;
- }
- }
- //Initiate domain table. If you needs to update the expired domain as well
- //call from initDomainFileList() instead
- function initDomainTable(){
- $.get("/api/cert/listdomains", function(data){
- if (data.error != undefined){
- parent.msgbox(data.error, false);
- }else{
- renderDomainTable(data);
- }
- })
- }
- function initDomainFileList() {
- $.ajax({
- url: "/api/acme/listExpiredDomains",
- method: "GET",
- success: function(response) {
- // Render domain table
- expiredDomains = response.domain;
- initDomainTable();
- //renderDomainTable(response.domain);
- },
- error: function(error) {
- console.log("Failed to fetch expired domains:", error);
- }
- });
- }
- initDomainFileList();
- // Button click event handler for obtaining certificate
- $("#obtainButton").click(function() {
- obtainCertificate();
- });
- // Obtain certificate from API
- function obtainCertificate() {
- var domains = $("#domainsInput").val();
- var filename = $("#filenameInput").val();
- $.ajax({
- url: "/api/acme/obtainCert",
- method: "GET",
- data: {
- domains: domains,
- filename: filename
- },
- success: function(response) {
- if (response.error) {
- console.log("Error:", response.error);
- // Show error message
- parent.msgbox(response.error, false, 12000);
- } else {
- console.log("Certificate renewed successfully");
- // Show success message
- parent.msgbox("Certificate renewed successfully");
- }
- },
- error: function(error) {
- console.log("Failed to renewed certificate:", error);
- }
- });
- }
- </script>
- </body>
- </html>
|