|
|
@ -2,12 +2,12 @@ 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"); |
|
|
@ -21,6 +21,7 @@ async function handleClients(response){ |
|
|
|
</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); |
|
|
|
|