128 lines
2.8 KiB
JavaScript
128 lines
2.8 KiB
JavaScript
function renameNode(nodeId) {
|
|
var newName = $("#newName").val();
|
|
var url = `${nodeId}/rename/${newName}`;
|
|
$.ajax({
|
|
url: url,
|
|
xhrFields: {
|
|
withCredentials: true,
|
|
},
|
|
success: function (data) {
|
|
$("#renameModal").modal("hide");
|
|
$("#givenName").html(data.newName);
|
|
},
|
|
});
|
|
}
|
|
|
|
function createPKA(username) {
|
|
var url = `${username}/pakcreate`;
|
|
var ephemereal = $("#ephemereal").is(":checked");
|
|
var reusable = $("#reusable").is(":checked");
|
|
var expiration = $("#expiration").val();
|
|
$.ajax({
|
|
url: url,
|
|
method: "POST",
|
|
dataType: "json",
|
|
contentType: "application/json; charset=utf-8",
|
|
xhrFields: {
|
|
withCredentials: true,
|
|
},
|
|
data: JSON.stringify({
|
|
ephemeral: ephemereal,
|
|
reusable: reusable,
|
|
expiration: expiration,
|
|
}),
|
|
|
|
success: function (data) {
|
|
$("#createPKA").modal("hide");
|
|
location.reload();
|
|
},
|
|
});
|
|
}
|
|
|
|
function copyToClipboard(obj) {
|
|
var span = $(obj);
|
|
var value = span.attr("value");
|
|
var original = span.html();
|
|
try {
|
|
navigator.clipboard.writeText(value);
|
|
span.html("copied!");
|
|
setTimeout(function () {
|
|
span.html(original);
|
|
}, 500);
|
|
} catch (error) {
|
|
span.html("error");
|
|
console.error(error);
|
|
}
|
|
}
|
|
|
|
function toggleExpired(obj) {
|
|
var toggle = $(obj);
|
|
if (toggle.is(":checked")) {
|
|
$(".pka-expired").removeClass("pka-hide");
|
|
} else {
|
|
$(".pka-expired").addClass("pka-hide");
|
|
}
|
|
}
|
|
|
|
function backfillips(obj) {
|
|
var url = "backfillips";
|
|
var button = $(obj);
|
|
var original = button.html();
|
|
$.ajax({
|
|
url: url,
|
|
method: "POST",
|
|
dataType: "json",
|
|
contentType: "application/json; charset=utf-8",
|
|
xhrFields: {
|
|
withCredentials: true,
|
|
},
|
|
data: {},
|
|
success: function (data) {
|
|
if (data.length) {
|
|
button.html("Updated");
|
|
} else {
|
|
button.html("Done");
|
|
}
|
|
setTimeout(function () {
|
|
button.html(original);
|
|
}, 500);
|
|
},
|
|
});
|
|
}
|
|
|
|
function uploadACL(obj) {
|
|
var fd = new FormData();
|
|
var files = $("#upload")[0].files[0];
|
|
fd.append("file", files);
|
|
|
|
// When we close the modal, we reload the page
|
|
$("#uploadACL").on("hidden.bs.modal", function (event) {
|
|
location.reload();
|
|
});
|
|
|
|
$.ajax({
|
|
url: "policy/upload",
|
|
type: "POST",
|
|
xhrFields: {
|
|
withCredentials: true,
|
|
},
|
|
data: fd,
|
|
contentType: false,
|
|
processData: false,
|
|
success: function (response) {
|
|
if (response != 0) {
|
|
$("#output").html("acl updated");
|
|
} else {
|
|
$("#output").html("acl not updated");
|
|
}
|
|
setTimeout(() => {
|
|
$("#uploadACL").modal("hide");
|
|
}, 5000);
|
|
},
|
|
error: function (response) {
|
|
console.log(response.responseJSON.message);
|
|
$("#output").html(response.responseJSON.message);
|
|
},
|
|
});
|
|
}
|