implemented client removal

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2024-07-22 20:55:35 +02:00
parent 1c0ef0e257
commit 2158d62da1
7 changed files with 103 additions and 37 deletions

View File

@@ -11,19 +11,25 @@
<nav>
<a id="clients" href="clients.html">Clients</a>
</nav>
<h1>Welcome!</h1>
<h2>Clients</h2>
<h1>Clients</h1>
These are clients that are registered with LightOIDC:
<table>
<tr>
<th>Client</th>
<th>ID</th>
<th>Redirect URLs</th>
<th>Actions</th>
</tr>
<tr>
<tr id="bottom">
<td></td>
<td></td>
<td></td>
<td>
<button onclick="window.location.href='newclient.html';">Add new client…</button>
</td>
</tr>
</table>
<span class="hidden" id="message">Really remove client "{}"?</span>
</body>
</html>

View File

@@ -1,11 +1,30 @@
async function handleClients(response){
if (response.status == UNAUTHORIZED) {
redirect('login.html?return_to='+encodeURI(window.location.href))
return;
}
var clients = await response.json();
get()
var bottom = document.getElementById('bottom');
for (let id in clients){
var row = document.createElement("tr");
var client = clients[id];
row.innerHTML = "<td>"+client.name+"</td>\n<td>"+id+"</td>\n<td>"+client.redirect_uris.join("<br/>")+'</td>\n<td><button onclick="remove(\''+id+'\')" type="button">remove '+client.name+'</button></td>';
bottom.parentNode.insertBefore(row,bottom);
}
}
function handleRemove(response){
redirect("clients.html");
}
function remove(clientId){
var message = document.getElementById('message').innerHTML;
if (confirm(message.replace("{}",clientId))) {
fetch(api+"/client",{
method: 'DELETE',
body : JSON.stringify({ client_id : clientId })
}).then(handleRemove);
}
}
fetch(api+"/clients",{method:'POST'}).then(handleClients);

View File

@@ -14,4 +14,8 @@ a {
fieldset th,
form th{
text-align: right;
}
.hidden{
display: none;
}