Skip to content

Commit

Permalink
Files busy signal (#3973)
Browse files Browse the repository at this point in the history
Add a spinner to the files app that spins while the request is being made.
  • Loading branch information
ahmed-mgd authored Nov 27, 2024
1 parent 049daeb commit 676275c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
15 changes: 14 additions & 1 deletion apps/dashboard/app/javascript/files/data_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const EVENTNAME = {
};

const CONTENTID = '#directory-contents';
const SPINNERID = '#tloading_spinner';

let table = null;

Expand Down Expand Up @@ -269,6 +270,8 @@ class DataTable {
async reloadTable(url) {
var request_url = url || history.state.currentDirectoryUrl;

this.toggleSpinner();

try {
const response = await fetch(request_url, { headers: { 'Accept': 'application/json' }, cache: 'no-store' });
const data = await this.dataFromJsonResponse(response);
Expand Down Expand Up @@ -297,7 +300,10 @@ class DataTable {
table.getTable().row(this.closest('tr')).deselect();
}
}
})
});

this.toggleSpinner();

return result;
} catch (e) {
const eventData = {
Expand All @@ -308,12 +314,19 @@ class DataTable {
$(CONTENTID).trigger(SWAL_EVENTNAME.showError, eventData);

$('#open-in-terminal-btn').addClass('disabled');

this.toggleSpinner()

// Removed this as it was causing a JS Error and there is no reprocution from removing it.
// return await Promise.reject(e);
}
}

toggleSpinner() {
document.querySelector(SPINNERID).classList.toggle('d-none');
document.querySelector(CONTENTID).classList.toggle('d-none');
}

updateDotFileVisibility() {
this.reloadTable();
}
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/app/views/files/_files_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<tbody>
</tbody>
</table>
<%= render partial: "spinner" %>
</div>
</div>

Expand Down
5 changes: 5 additions & 0 deletions apps/dashboard/app/views/files/_spinner.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="text-center text-primary d-none p-5" id="tloading_spinner">
<div class="spinner-border">
<span class="sr-only">Loading...</span>
</div>
</div>
3 changes: 3 additions & 0 deletions apps/dashboard/test/system/remote_files_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ def setup
find('#delete-btn').click
find('button.swal2-confirm').click

# Allow time for file to be removed
sleep 1

# verify app dir deleted according to UI
assert_no_selector 'tbody a', exact_text: 'app', wait: 10
assert_no_selector 'tbody a', exact_text: 'foo.txt', wait: 10
Expand Down

0 comments on commit 676275c

Please sign in to comment.