Renamed functions to match
This commit is contained in:
+41
-47
@@ -35,13 +35,12 @@
|
|||||||
border-top-right-radius: 5px !important;
|
border-top-right-radius: 5px !important;
|
||||||
border-bottom-right-radius: 5px !important;
|
border-bottom-right-radius: 5px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var $editHostForm;
|
var $editHostForm;
|
||||||
|
|
||||||
function parseHostRow(host) {
|
function hostParseRow(host) {
|
||||||
host['updated_on_text'] = moment(host['updated_on'], "x").fromNow();
|
host['updated_on_text'] = moment(host['updated_on'], "x").fromNow();
|
||||||
host['wildcard_expires_text'] = moment(host['wildcard_expires'], "x").fromNow();
|
host['wildcard_expires_text'] = moment(host['wildcard_expires'], "x").fromNow();
|
||||||
host['targetssl_text'] = host['targetssl'] ? 'https://' : 'http://';
|
host['targetssl_text'] = host['targetssl'] ? 'https://' : 'http://';
|
||||||
@@ -62,12 +61,12 @@
|
|||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateHosts(){
|
function hostPopulate(){
|
||||||
app.host.list(function(error, res){
|
app.host.list(function(error, res){
|
||||||
if(error) return app.util.actionMessage(error, $.scope.hosts.$this, 'danger');
|
if(error) return app.util.actionMessage(error, $.scope.hosts.$this, 'danger');
|
||||||
|
|
||||||
for(let host of res){
|
for(let host of res){
|
||||||
$.scope.hosts.push(parseHostRow(host));
|
$.scope.hosts.push(hostParseRow(host));
|
||||||
}
|
}
|
||||||
|
|
||||||
$.scope.hosts.__setPut(function($el, item, list){
|
$.scope.hosts.__setPut(function($el, item, list){
|
||||||
@@ -79,17 +78,17 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancleHostEdit(){
|
function hostEditCancle(){
|
||||||
$('#hostsTable').find('tr').each(function(idx, el){
|
$('tr.jq-repeat-hosts').each(function(idx, el){
|
||||||
$(el).removeClass('table-warning');
|
$(el).removeClass('table-warning');
|
||||||
});
|
});
|
||||||
$.scope.editHost.remove();
|
$.scope.editHost.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function editHost(btn, host){
|
function hostEditOpen(btn, host){
|
||||||
cancleHostEdit();
|
hostEditCancle();
|
||||||
$(btn).closest('tr').addClass('table-warning');
|
|
||||||
host = $.scope.hosts.getByKey(host);
|
host = $.scope.hosts.getByKey(host);
|
||||||
|
host.__jq_$el.addClass('table-warning');
|
||||||
$.scope.editHost.update({...host, form: $editHostForm.html()});
|
$.scope.editHost.update({...host, form: $editHostForm.html()});
|
||||||
|
|
||||||
$.each(host, function( key, value ) { if(typeof value == "boolean"){
|
$.each(host, function( key, value ) { if(typeof value == "boolean"){
|
||||||
@@ -100,25 +99,36 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function deleteHost(host){
|
function hostDownloadCert(host, type){
|
||||||
app.host.remove({host: host}, function(error, data){
|
|
||||||
if(error) app.util.actionMessage(error.message, $.scope.hosts.$this, 'danger');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function downloadCert(host, type){
|
|
||||||
app.host.getCert({host}, function(error, data){
|
app.host.getCert({host}, function(error, data){
|
||||||
if(error) app.util.actionMessage(error.message, $.scope.hosts.$this, 'danger');
|
if(error) app.util.actionMessage(error.message, $.scope.hosts.$this, 'danger');
|
||||||
app.util.downloadFile(`${host}-${type}.crt`, data[type])
|
app.util.downloadFile(`${host}-${type}.crt`, data[type])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hostSearchInput(){
|
||||||
|
//search bar html event logic stolen from here
|
||||||
|
// https://github.com/WebDevSimplified/js-search-bar/blob/main/script.js
|
||||||
|
let inputValue = $(event.target).val().toLowerCase();
|
||||||
|
|
||||||
|
// on each input detected we need to get all host list that was called by the hostPopulate function which is store in
|
||||||
|
// $.scope.hosts and then we need to loop through each host and check if the host name is equal to the input value
|
||||||
|
// if it is we will display the host if not we will hide it
|
||||||
|
for(let hostObj of $.scope.hosts){
|
||||||
|
if (hostObj.host.toLowerCase().includes(inputValue)) {
|
||||||
|
hostObj.__jq_$el.show();
|
||||||
|
} else {
|
||||||
|
hostObj.__jq_$el.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$editHostForm = $('#addHost').clone();
|
$editHostForm = $('#addHost').clone();
|
||||||
$editHostForm.find('hr.buttonBreak').nextAll().remove();
|
$editHostForm.find('hr.buttonBreak').nextAll().remove();
|
||||||
// $editHostForm.find('.autoSll').addClass('bg-secondary');
|
// $editHostForm.find('.autoSll').addClass('bg-secondary');
|
||||||
$editHostForm.find('[name=is_wildcard').attr('disabled', true);
|
$editHostForm.find('[name=is_wildcard').attr('disabled', true);
|
||||||
populateHosts(); //populate the table
|
hostPopulate(); //populate the table
|
||||||
|
|
||||||
$.scope.hosts.__setTake(function($el, item, list){
|
$.scope.hosts.__setTake(function($el, item, list){
|
||||||
$el.addClass('table-danger');
|
$el.addClass('table-danger');
|
||||||
@@ -148,9 +158,9 @@
|
|||||||
let [a,b, action, host] = topic.split(':');
|
let [a,b, action, host] = topic.split(':');
|
||||||
|
|
||||||
if($.scope.hosts.indexOf(host) >= 0){
|
if($.scope.hosts.indexOf(host) >= 0){
|
||||||
$.scope.hosts.update(host, parseHostRow(data));
|
$.scope.hosts.update(host, hostParseRow(data));
|
||||||
}else{
|
}else{
|
||||||
$.scope.hosts.unshift(parseHostRow(data));
|
$.scope.hosts.unshift(hostParseRow(data));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -158,9 +168,9 @@
|
|||||||
let [a,b, action, host] = topic.split(':');
|
let [a,b, action, host] = topic.split(':');
|
||||||
|
|
||||||
if($.scope.hosts.indexOf(host) >= 0){
|
if($.scope.hosts.indexOf(host) >= 0){
|
||||||
$.scope.hosts.update(host, parseHostRow(data));
|
$.scope.hosts.update(host, hostParseRow(data));
|
||||||
}else{
|
}else{
|
||||||
$.scope.hosts.unshift(parseHostRow(data));
|
$.scope.hosts.unshift(hostParseRow(data));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -170,22 +180,6 @@
|
|||||||
$.scope.hosts.remove(host);
|
$.scope.hosts.remove(host);
|
||||||
});
|
});
|
||||||
|
|
||||||
//search bar html event logic stolen from here
|
|
||||||
// https://github.com/WebDevSimplified/js-search-bar/blob/main/script.js
|
|
||||||
$('[host-search]').on("input", function() {
|
|
||||||
let inputValue = $(this).val().toLowerCase();
|
|
||||||
|
|
||||||
// on each input detected we need to get all host list that was called by the populateHosts function which is store in
|
|
||||||
// $.scope.hosts and then we need to loop through each host and check if the host name is equal to the input value
|
|
||||||
// if it is we will display the host if not we will hide it
|
|
||||||
for(let hostObj of $.scope.hosts){
|
|
||||||
if (hostObj.host.toLowerCase().includes(inputValue)) {
|
|
||||||
hostObj.__jq_$el.show();
|
|
||||||
} else {
|
|
||||||
hostObj.__jq_$el.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<div class="row" style="display:none">
|
<div class="row" style="display:none">
|
||||||
@@ -206,19 +200,19 @@
|
|||||||
</span>
|
</span>
|
||||||
<span class="float-end">
|
<span class="float-end">
|
||||||
<i class="fa-solid fa-circle-minus"></i>
|
<i class="fa-solid fa-circle-minus"></i>
|
||||||
<i class="fa-solid fa-circle-xmark" onclick="cancleHostEdit()"></i>
|
<i class="fa-solid fa-circle-xmark" onclick="hostEditCancle()"></i>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form class="addHost" method="PUT" action="/host/{{ host }}" onsubmit="formAJAX(this)" evalAJAX="cancleHostEdit()">
|
<form class="addHost" method="PUT" action="/host/{{ host }}" onsubmit="formAJAX(this)" evalAJAX="hostEditCancle()">
|
||||||
{{{ form }}}
|
{{{ form }}}
|
||||||
<input type="hidden" name="edit_host" />
|
<input type="hidden" name="edit_host" />
|
||||||
<button type="submit" data-type="edit" class="btn btn-warning">
|
<button type="submit" data-type="edit" class="btn btn-warning">
|
||||||
<i class="fa-solid fa-pencil"></i>
|
<i class="fa-solid fa-pencil"></i>
|
||||||
Update
|
Update
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-secondary" type="reset" onclick="cancleHostEdit()">
|
<button class="btn btn-secondary" type="reset" onclick="hostEditCancle()">
|
||||||
<i class="fa-solid fa-ban"></i>
|
<i class="fa-solid fa-ban"></i>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
@@ -363,7 +357,7 @@
|
|||||||
<label class="form-label" for="search" style="margin-left: -5px;">
|
<label class="form-label" for="search" style="margin-left: -5px;">
|
||||||
Search Hosts:
|
Search Hosts:
|
||||||
</label>
|
</label>
|
||||||
<input type="search" id="search" host-search>
|
<input type="search" oninput="hostSearchInput()">
|
||||||
</div>
|
</div>
|
||||||
<table class="card-body table table-striped" style="margin-bottom:0">
|
<table class="card-body table table-striped" style="margin-bottom:0">
|
||||||
|
|
||||||
@@ -385,7 +379,7 @@
|
|||||||
</th>
|
</th>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody id="hostsTable">
|
<tbody class="card-body" id="hostsTable">
|
||||||
<tr action="api" jq-repeat="hosts" jq-repeat-index='host' style="display:none">
|
<tr action="api" jq-repeat="hosts" jq-repeat-index='host' style="display:none">
|
||||||
<td class="table-{{wildcard_text_bg}}">
|
<td class="table-{{wildcard_text_bg}}">
|
||||||
{{{ wildcard_text }}}
|
{{{ wildcard_text }}}
|
||||||
@@ -414,21 +408,21 @@
|
|||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
<button type="button" class="dropdown-item" onclick="downloadCert('{{host}}', 'cert_pem')">
|
<button type="button" class="dropdown-item" onclick="hostDownloadCert('{{host}}', 'cert_pem')">
|
||||||
<i class="fa-solid fa-certificate"></i>
|
<i class="fa-solid fa-certificate"></i>
|
||||||
Cert
|
Cert
|
||||||
<i class="fa-solid fa-file-arrow-down float-end"></i>
|
<i class="fa-solid fa-file-arrow-down float-end"></i>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button type="button" class="dropdown-item" onclick="downloadCert('{{host}}', 'fullchain_pem')">
|
<button type="button" class="dropdown-item" onclick="hostDownloadCert('{{host}}', 'fullchain_pem')">
|
||||||
<i class="fa-solid fa-link"></i>
|
<i class="fa-solid fa-link"></i>
|
||||||
Full Chain
|
Full Chain
|
||||||
<i class="fa-solid fa-file-arrow-down float-end"></i>
|
<i class="fa-solid fa-file-arrow-down float-end"></i>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button type="button" class="dropdown-item" onclick="downloadCert('{{host}}', 'privkey_pem')">
|
<button type="button" class="dropdown-item" onclick="hostDownloadCert('{{host}}', 'privkey_pem')">
|
||||||
<i class="fa-solid fa-key"></i>
|
<i class="fa-solid fa-key"></i>
|
||||||
Private key
|
Private key
|
||||||
<i class="fa-solid fa-file-arrow-down float-end"></i>
|
<i class="fa-solid fa-file-arrow-down float-end"></i>
|
||||||
@@ -437,11 +431,11 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="button" onclick="editHost(this, '{{ host }}');" class="btn btn-sm btn-warning">
|
<button type="button" onclick="hostEditOpen(this, '{{ host }}');" class="btn btn-sm btn-warning">
|
||||||
<i class="fa-solid fa-pencil"></i>
|
<i class="fa-solid fa-pencil"></i>
|
||||||
Edit
|
Edit
|
||||||
</button>
|
</button>
|
||||||
<button type="button" onclick="deleteHost('{{ host }}')" class="btn btn-sm btn-danger">
|
<button type="button" method="DELETE" action="host/{{host}}" onclick="formAJAX()" class="btn btn-sm btn-danger">
|
||||||
<i class="fa-solid fa-trash-can"></i>
|
<i class="fa-solid fa-trash-can"></i>
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user