Skip to content

Commit

Permalink
Improve logic for hiding/showing spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-mgd committed Nov 21, 2024
1 parent 40fd19d commit fccde1f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions apps/dashboard/app/javascript/files/data_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const EVENTNAME = {
};

const CONTENTID = '#directory-contents';
const BUSYID = '#tloading-spinner';
const SPINNERID = '#tloading_spinner';

let table = null;

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

$(CONTENTID).hide();
$(BUSYID).show();
this.toggleSpinner();

try {
const response = await fetch(request_url, { headers: { 'Accept': 'application/json' }, cache: 'no-store' });
Expand Down Expand Up @@ -303,8 +302,7 @@ class DataTable {
}
});

$(BUSYID).hide();
$(CONTENTID).show();
this.toggleSpinner();

return result;
} catch (e) {
Expand All @@ -316,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

0 comments on commit fccde1f

Please sign in to comment.