mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Add bulk actions (delete) for client certificates.
This commit is contained in:
47
js/certificate_edit_modal.js
Normal file
47
js/certificate_edit_modal.js
Normal file
@@ -0,0 +1,47 @@
|
||||
function populateCertificateEditModal(client_id, certificate_id) {
|
||||
|
||||
// Send a GET request to post.php as post.php?certificate_get_json_details=true&client_id=NUM&certificate_id=NUM
|
||||
jQuery.get(
|
||||
"ajax.php",
|
||||
{certificate_get_json_details: 'true', client_id: client_id, certificate_id: certificate_id},
|
||||
function(data) {
|
||||
|
||||
// If we get a response from post.php, parse it as JSON
|
||||
const response = JSON.parse(data);
|
||||
|
||||
// Access the certificate (one) and domains (multiple)
|
||||
const certificate = response.certificate[0];
|
||||
const domains = response.domains;
|
||||
|
||||
// Populate the cert modal fields
|
||||
document.getElementById("editHeader").innerText = certificate.certificate_name;
|
||||
document.getElementById("editCertificateId").value = certificate_id;
|
||||
document.getElementById("editCertificateName").value = certificate.certificate_name;
|
||||
document.getElementById("editDomain").value = certificate.certificate_domain;
|
||||
document.getElementById("editIssuedBy").value = certificate.certificate_issued_by;
|
||||
document.getElementById("editExpire").value = certificate.certificate_expire;
|
||||
document.getElementById("editPublicKey").value = certificate.certificate_public_key;
|
||||
|
||||
// Select the domain dropdown
|
||||
var domainDropdown = document.getElementById("editDomainId");
|
||||
|
||||
// Clear domain dropdown
|
||||
var i, L = domainDropdown.options.length -1;
|
||||
for(i = L; i >= 0; i--) {
|
||||
domainDropdown.remove(i);
|
||||
}
|
||||
domainDropdown[domainDropdown.length] = new Option('- Domain -', '0');
|
||||
|
||||
// Populate domain dropdown
|
||||
domains.forEach(domain => {
|
||||
if (parseInt(domain.domain_id) == parseInt(certificate.certificate_domain_id)) {
|
||||
// Selected domain
|
||||
domainDropdown[domainDropdown.length] = new Option(domain.domain_name, domain.domain_id, true, true);
|
||||
}
|
||||
else{
|
||||
domainDropdown[domainDropdown.length] = new Option(domain.domain_name, domain.domain_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
37
js/certificate_fetch_ssl.js
Normal file
37
js/certificate_fetch_ssl.js
Normal file
@@ -0,0 +1,37 @@
|
||||
function fetchSSL(type)
|
||||
{
|
||||
// Get the domain name input & issued/expire/key fields, based on whether this is a new cert or updating an existing
|
||||
if (type == 'new') {
|
||||
var domain = document.getElementById("domain").value;
|
||||
var issuedBy = document.getElementById("issuedBy");
|
||||
var expire = document.getElementById("expire");
|
||||
var publicKey = document.getElementById("publicKey");
|
||||
|
||||
}
|
||||
if (type == 'edit') {
|
||||
var domain = document.getElementById("editDomain").value;
|
||||
var issuedBy = document.getElementById("editIssuedBy");
|
||||
var expire = document.getElementById("editExpire");
|
||||
var publicKey = document.getElementById("editPublicKey");
|
||||
}
|
||||
|
||||
//Send a GET request to post.php as post.php?certificate_fetch_parse_json_details=TRUE&domain=DOMAIN
|
||||
jQuery.get(
|
||||
"ajax.php",
|
||||
{certificate_fetch_parse_json_details: 'TRUE', domain: domain},
|
||||
function(data) {
|
||||
//If we get a response from post.php, parse it as JSON
|
||||
const ssl_data = JSON.parse(data);
|
||||
|
||||
if (ssl_data.success == "TRUE") {
|
||||
// Fill the form fields with the cert data
|
||||
issuedBy.value = ssl_data.issued_by;
|
||||
expire.value = ssl_data.expire;
|
||||
publicKey.value = ssl_data.public_key;
|
||||
}
|
||||
else{
|
||||
alert("Error whilst parsing/retrieving details for domain")
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user