|
|
@ -2,25 +2,26 @@ function edit(clientId){ |
|
|
|
redirect("edit_client.html?id="+clientId); |
|
|
|
redirect("edit_client.html?id="+clientId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function handleClients(response){ |
|
|
|
function handleClients(response){ |
|
|
|
if (response.status == UNAUTHORIZED) { |
|
|
|
if (response.status == UNAUTHORIZED) { |
|
|
|
redirect('login.html?return_to='+encodeURI(window.location.href)) |
|
|
|
redirect('login.html?return_to='+encodeURI(window.location.href)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var clients = await response.json(); |
|
|
|
var clients = response.json().then(clients => { |
|
|
|
var bottom = document.getElementById('bottom'); |
|
|
|
var bottom = document.getElementById('bottom'); |
|
|
|
for (let id in clients){ |
|
|
|
for (let id in clients){ |
|
|
|
var row = document.createElement("tr"); |
|
|
|
var row = document.createElement("tr"); |
|
|
|
var client = clients[id]; |
|
|
|
var client = clients[id]; |
|
|
|
row.innerHTML = `<td>${client.name}</td>
|
|
|
|
row.innerHTML = `<td>${client.name}</td>
|
|
|
|
<td>${id}</td> |
|
|
|
<td>${id}</td> |
|
|
|
<td>${client.redirect_uris.join("<br/>")}</td> |
|
|
|
<td>${client.redirect_uris.join("<br/>")}</td> |
|
|
|
<td> |
|
|
|
<td> |
|
|
|
<button type="button" onclick="edit('${id}')">Edit</button> |
|
|
|
<button type="button" onclick="edit('${id}')">Edit</button> |
|
|
|
<button class="danger" onclick="remove('${id}')" type="button">Remove</button> |
|
|
|
<button class="danger" onclick="remove('${id}')" type="button">Remove</button> |
|
|
|
</td>`; |
|
|
|
</td>`; |
|
|
|
bottom.parentNode.insertBefore(row,bottom); |
|
|
|
bottom.parentNode.insertBefore(row,bottom); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function handleRemove(response){ |
|
|
|
function handleRemove(response){ |
|
|
@ -32,11 +33,10 @@ function remove(clientId){ |
|
|
|
if (confirm(message.replace("{}",clientId))) { |
|
|
|
if (confirm(message.replace("{}",clientId))) { |
|
|
|
fetch(client_controller+"/delete",{ |
|
|
|
fetch(client_controller+"/delete",{ |
|
|
|
method: 'DELETE', |
|
|
|
method: 'DELETE', |
|
|
|
body : JSON.stringify({ client_id : clientId }) |
|
|
|
body : JSON.stringify({ client_id : clientId }), |
|
|
|
|
|
|
|
credentials:'include' |
|
|
|
}).then(handleRemove); |
|
|
|
}).then(handleRemove); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fetch(client_controller+"/list",{method:'POST',credentials:'include'}).then(handleClients); |
|
|
|
|
|
|
|
|
|
|
|
fetch(client_controller+"/list",{method:'POST'}).then(handleClients); |
|
|
|
|