Skip to content

Commit

Permalink
Add loading spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
leepeuker committed Apr 12, 2023
1 parent 8df8576 commit f1f0f72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions public/js/settings-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,22 @@ function setUserManagementAlert(message, type = 'success') {
}

async function reloadTable() {
table.rows = []

table.getElementsByTagName('tbody')[0].innerHTML = ''
document.getElementById('userTableLoadingSpinner').classList.remove('d-none')

const response = await fetch('/api/users');

if (response.status !== 200) {
setUserManagementAlert('Could not load users', 'danger')
document.getElementById('userTableLoadingSpinner').classList.add('d-none')

return
}

const users = await response.json();

document.getElementById('userTableLoadingSpinner').classList.add('d-none')

users.forEach((user) => {
let row = document.createElement('tr');
row.innerHTML = '<td>' + user.id + '</td>';
Expand Down
3 changes: 3 additions & 0 deletions templates/page/settings-users.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<tbody></tbody>
</table>
</div>
<div class="spinner-border d-none" role="status" id="userTableLoadingSpinner">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</div>

Expand Down

0 comments on commit f1f0f72

Please sign in to comment.