Add option to disable and enable access to instance

This commit is contained in:
Marvin Martinson 2021-07-07 13:10:32 +00:00
parent 10da614d49
commit a6787dae6c
2 changed files with 47 additions and 0 deletions

View File

@ -281,6 +281,24 @@ function onHashChanged() {
} }
function onToggleAccessButtonClicked(e) {
e.preventDefault();
var cn = $(e.target).attr("data-cn");
var id = $(e.target).attr("data-id");
var value = $(e.target).attr("data-value") == 'True';
var confirm = window.confirm("Do you want to disable " + cn);
if (confirm) {
$.ajax({
method: "POST",
url: "/api/toggleaccess/id/" + id + "/?disable=" + !value
});
}
}
function onTagClicked(e) { function onTagClicked(e) {
e.preventDefault(); e.preventDefault();
var cn = $(e.target).attr("data-cn"); var cn = $(e.target).attr("data-cn");
@ -543,6 +561,29 @@ function onIssueToken() {
}); });
} }
function onInstanceAvailabilityUpdated(e) {
var id = e.data;
$.ajax({
method: "GET",
dataType: "text",
url: "/api/toggleaccess/id/"+id,
success: function(data) {
var value = data == 'True'
if(value) {
$("#availability-"+id).html("Enable");
$("#availability-"+id).attr("data-value","True");
} else {
$("#availability-"+id).html("Disable");
$("#availability-"+id).attr("data-value","False");
}
}
});
}
function filterSigned() { function filterSigned() {
if ($("#search").val() != "") { if ($("#search").val() != "") {
console.info("Not filtering by state since keyword filter is active"); console.info("Not filtering by state since keyword filter is active");
@ -642,6 +683,7 @@ function loadAuthority(query) {
source.addEventListener("attribute-update", onAttributeUpdated); source.addEventListener("attribute-update", onAttributeUpdated);
source.addEventListener("server-started", onServerStarted); source.addEventListener("server-started", onServerStarted);
source.addEventListener("server-stopped", onServerStopped); source.addEventListener("server-stopped", onServerStopped);
source.addEventListener("instance-access-update", onInstanceAvailabilityUpdated);
} }

View File

@ -40,6 +40,11 @@
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-secondary" data-toggle="collapse" data-target="#details-{{ certificate.sha256sum }}"><i class="fa fa-list"></i> Details</button> <button type="button" class="btn btn-secondary" data-toggle="collapse" data-target="#details-{{ certificate.sha256sum }}"><i class="fa fa-list"></i> Details</button>
{% if certificate.disabled %}
<button id="availability-{{ certificate.id }}" type="button" class="btn btn-secondary" onclick="onToggleAccessButtonClicked(event);" data-value="{{ certificate.disabled}}" data-id="{{ certificate.id }}" data-cn="{{ certificate.common_name }}">Enable</button>
{% else %}
<button id="availability-{{ certificate.id }}" type="button" class="btn btn-secondary" onclick="onToggleAccessButtonClicked(event);" data-value="{{ certificate.disabled}}" data-id="{{ certificate.id }}" data-cn="{{ certificate.common_name }}">Disable</button>
{% endif %}
<button type="button" class="btn btn-danger" <button type="button" class="btn btn-danger"
onclick="javascript:$(this).button('loading');$.ajax({url:'/api/signed/id/{{certificate.id}}/?sha256sum={{ certificate.sha256sum }}',type:'delete'});"> onclick="javascript:$(this).button('loading');$.ajax({url:'/api/signed/id/{{certificate.id}}/?sha256sum={{ certificate.sha256sum }}',type:'delete'});">
<i class="fa fa-ban"></i> Revoke</button> <i class="fa fa-ban"></i> Revoke</button>