|
@@ -31,19 +31,21 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="ui basic segment">
|
|
|
+ <p style="float: right; color: #21ba45; display:none;" id="enableToggleSucc"><i class="green checkmark icon"></i> Setting Updated</p>
|
|
|
<div class="ui toggle checkbox">
|
|
|
<input type="checkbox" id="enableCertAutoRenew">
|
|
|
<label>Enable Certificate Auto Renew</label>
|
|
|
</div>
|
|
|
<br>
|
|
|
<h3>ACME Email</h3>
|
|
|
- <p>Email is generally required for renewing via ACME. Zoraxy do not support no-email renew due to security reasons.</p>
|
|
|
+ <p>Email is required by many CAs for renewing via ACME protocol</p>
|
|
|
<div class="ui fluid action input">
|
|
|
<input id="caRegisterEmail" type="text" placeholder="[email protected]">
|
|
|
- <button class="ui icon basic button">
|
|
|
+ <button class="ui icon basic button" onclick="saveEmailToConfig();">
|
|
|
<i class="blue save icon"></i>
|
|
|
</button>
|
|
|
</div>
|
|
|
+ <small>If you don't want to share your private email address, you can also fill in an email address that point to a mailbox not exists on your domain.</small>
|
|
|
</div>
|
|
|
<div class="ui basic segment" style="background-color: #f7f7f7; border-radius: 1em;">
|
|
|
<div class="ui accordion advanceSettings">
|
|
@@ -57,14 +59,14 @@
|
|
|
<input type="checkbox" id="renewAllSupported" onchange="setAutoRenewIfCASupportMode(this.checked);" checked>
|
|
|
<label>Auto renew if CA is supported</label>
|
|
|
</div><br>
|
|
|
- <button class="ui basic right floated button" style="margin-top: -2em;"><i class="yellow refresh icon"></i> Renew Now</button>
|
|
|
+ <button id="renewNowBtn" onclick="renewNow();" class="ui basic right floated button" style="margin-top: -2em;"><i class="yellow refresh icon"></i> Renew Now</button>
|
|
|
<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>Match Rule</th>
|
|
|
<th>Auto-Renew</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
@@ -75,7 +77,7 @@
|
|
|
Certificate Renew only works on the certification authority (CA) supported by Zoraxy. Check Zoraxy wiki for more information on supported list of CAs.
|
|
|
</div>
|
|
|
<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 Selected</button>
|
|
|
+ <button id="renewSelectedButton" onclick="renewNow();" class="ui basic right floated disabled button"><i class="yellow refresh icon"></i> Renew Selected</button>
|
|
|
<br><br>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -126,13 +128,61 @@
|
|
|
function setAutoRenewIfCASupportMode(useAutoMode = true){
|
|
|
if (useAutoMode){
|
|
|
$("#domainCertFileTable").addClass("disabled");
|
|
|
+ $("#renewNowBtn").removeClass("disabled");
|
|
|
+ $("#renewSelectedButton").addClass("disabled");
|
|
|
}else{
|
|
|
$("#domainCertFileTable").removeClass("disabled");
|
|
|
+ $("#renewNowBtn").addClass("disabled");
|
|
|
+ $("#renewSelectedButton").removeClass("disabled");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function initRenewerConfigFromFile(){
|
|
|
+ $.get("/api/acme/autoRenew/enable", function(data){
|
|
|
+ if (data == true){
|
|
|
+ $("#enableCertAutoRenew").parent().checkbox("set checked");
|
|
|
+ }
|
|
|
+
|
|
|
+ $("#enableCertAutoRenew").on("change", function(){
|
|
|
+ toggleAutoRenew();
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ $.get("/api/acme/autoRenew/email", function(data){
|
|
|
+ if (data != "" && data != undefined && data != null){
|
|
|
+ $("#caRegisterEmail").val(data);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ initRenewerConfigFromFile();
|
|
|
+
|
|
|
+ function saveEmailToConfig(){
|
|
|
+ $.ajax({
|
|
|
+ url: "/api/acme/autoRenew/email",
|
|
|
+ data: {set: $("#caRegisterEmail").val()},
|
|
|
+ success: function(data){
|
|
|
+ if (data.error != undefined){
|
|
|
+ parent.msgbox(data.error, false, 5000);
|
|
|
+ }else{
|
|
|
+ parent.msgbox("Email updated");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function toggleAutoRenew(){
|
|
|
+ var enabled = $("#enableCertAutoRenew").parent().checkbox("is checked");
|
|
|
+ $.post("/api/acme/autoRenew/enable?enable=" + enabled, function(data){
|
|
|
+ if (data.error){
|
|
|
+ parent.msgbox(data.error, false, 5000);
|
|
|
+ }else{
|
|
|
+ $("#enableToggleSucc").stop().finish().fadeIn("fast").delay(3000).fadeOut("fast");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
//Render the domains table that exists in this zoraxy host
|
|
|
- function renderDomainTable(domains) {
|
|
|
+ function renderDomainTable(domainFileList) {
|
|
|
// Get the table body element
|
|
|
var tableBody = $('#domainTableBody');
|
|
|
|
|
@@ -141,25 +191,30 @@
|
|
|
|
|
|
// Iterate over the domain names
|
|
|
var counter = 0;
|
|
|
- for (const [domain, srcfile] of Object.entries(domains)) {
|
|
|
+ for (const [srcfile, domains] of Object.entries(domainFileList)) {
|
|
|
|
|
|
// Create a table row
|
|
|
var row = $('<tr>');
|
|
|
|
|
|
// Create the domain name cell
|
|
|
var domainClass = "validDomain";
|
|
|
- if (expiredDomains.includes(domain)){
|
|
|
- domainClass = "expiredDomain";
|
|
|
+ for (var i = 0; i < domains.length; i++){
|
|
|
+ let thisDomain = domains[i];
|
|
|
+ if (expiredDomains.includes(thisDomain)){
|
|
|
+ domainClass = "expiredDomain";
|
|
|
+ }
|
|
|
}
|
|
|
- var domainCell = $('<td class="' + domainClass +'">').text(domain);
|
|
|
+
|
|
|
+ var domainCell = $('<td class="' + domainClass +'">').html(domains.join("<br>"));
|
|
|
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');
|
|
|
+ let domainsEncoded = encodeURIComponent(JSON.stringify(domains));
|
|
|
+ var checkboxCell = $(`<td domain="${domainsEncoded}" srcfile="${srcfile}">`);
|
|
|
+ var checkbox = $(`<input name="${srcfile}">`).attr('type', 'checkbox');
|
|
|
checkboxCell.append(checkbox);
|
|
|
row.append(checkboxCell);
|
|
|
|
|
@@ -173,12 +228,13 @@
|
|
|
//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){
|
|
|
+ $.get("/api/cert/listdomains?compact=true", function(data){
|
|
|
if (data.error != undefined){
|
|
|
parent.msgbox(data.error, false);
|
|
|
}else{
|
|
|
renderDomainTable(data);
|
|
|
}
|
|
|
+ initAutoRenewPolicy();
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -261,6 +317,8 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //Grab the longest common suffix of all domains
|
|
|
+ //not that smart technically
|
|
|
function autoDetectMatchingRules(){
|
|
|
var domainsString = $("#domainsInput").val();
|
|
|
if (!domainsString.includes(",")){
|
|
@@ -312,6 +370,39 @@
|
|
|
$("#filenameInput").val(longestSuffix);
|
|
|
}
|
|
|
|
|
|
+ //Handle the renew now btn click
|
|
|
+ function renewNow(){
|
|
|
+ alert("wip");
|
|
|
+ return
|
|
|
+ $.get("/api/acme/autoRenew/renewNow", function(data){
|
|
|
+ alert(data);
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function initAutoRenewPolicy(){
|
|
|
+ $.get("/api/acme/autoRenew/listDomains", function(data){
|
|
|
+ if (data.error != undefined){
|
|
|
+ parent.msgbox(data.error, false)
|
|
|
+ }else{
|
|
|
+ if (data[0] == "*"){
|
|
|
+ //Auto select and renew is enabled
|
|
|
+ $("#renewAllSupported").parent().checkbox("set checked");
|
|
|
+ }else{
|
|
|
+ //This is a list of domain files
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ function saveAutoRenewPolicy(){
|
|
|
+ let autoRenewAll = $("#renewAllSupported").parent().checkbox("is checked");
|
|
|
+ if (autoRenewAll == true){
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//Clear up the input field when page load
|
|
|
$("#filenameInput").val("");
|