From a6787dae6c934a5c96bc357f19bd97320b274568 Mon Sep 17 00:00:00 2001 From: Marvin Martinson Date: Wed, 7 Jul 2021 13:10:32 +0000 Subject: [PATCH] Add option to disable and enable access to instance --- static/js/certidude.js | 42 +++++++++++++++++++++++++++++++++++++ templates/views/signed.html | 5 +++++ 2 files changed, 47 insertions(+) diff --git a/static/js/certidude.js b/static/js/certidude.js index d61c8b0..9293611 100644 --- a/static/js/certidude.js +++ b/static/js/certidude.js @@ -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) { e.preventDefault(); 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() { if ($("#search").val() != "") { 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("server-started", onServerStarted); source.addEventListener("server-stopped", onServerStopped); + source.addEventListener("instance-access-update", onInstanceAvailabilityUpdated); } diff --git a/templates/views/signed.html b/templates/views/signed.html index 516cd37..a732ba6 100644 --- a/templates/views/signed.html +++ b/templates/views/signed.html @@ -40,6 +40,11 @@
+ {% if certificate.disabled %} + + {% else %} + + {% endif %}