Skip to content

Commit

Permalink
#885 - refactoring when things load
Browse files Browse the repository at this point in the history
  • Loading branch information
adkinsrs committed Sep 11, 2024
1 parent a63078e commit 5329f2e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
3 changes: 0 additions & 3 deletions www/js/classes/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ class Analysis {
*/
async loadPreliminaryFigures() {

document.querySelector(UI.primaryInitialPlotContainer).classList.remove("is-hidden");
try {
const {data} = await axios.post("./cgi/h5ad_preview_primary_filter.cgi", convertToFormData({
dataset_id: this.dataset.id,
Expand All @@ -508,8 +507,6 @@ class Analysis {
session_id: this.analysisSessionId
}));

document.querySelector(UI.primaryInitialLoadingPlotElt).classList.add("is-hidden");

if (!data.success || data.success < 1) {
document.querySelector(UI.primaryInitialViolinContainer).textContent = "Preliminary figures not yet generated. Continue your analysis.";
createToast("Preliminary figures not found. You can still continue the analysis though.", "is-warning");
Expand Down
21 changes: 13 additions & 8 deletions www/js/sc_workbench.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,24 @@ const datasetTree = new DatasetTree({
// This is a placeholder to retrieve preliminary figures which are stored in the "primary" directory
currentAnalysis = new Analysis({id: datasetId, type: "primary", datasetIsRaw: true});

// Technically these could load asynchronously, but logically the progress logs make more sense sequentially
try {
analysisLabels = await currentAnalysis.getSavedAnalysesList(datasetId, -1, 'sc_workbench');
document.querySelector(UI.analysisSelect).disabled = false;
} catch (error) {
createToast("Failed to access analyses for this dataset");
logErrorInConsole(error);
document.querySelector(UI.analysisSelect).disabled = true;
}

document.querySelector(UI.primaryInitialPlotContainer).classList.remove("is-hidden");
try {
await getDatasetInfo(datasetId);
await currentAnalysis.loadPreliminaryFigures();
await currentAnalysis.loadPreliminaryFigures(); // depends on dataset.id from getDatasetInfo
} catch (error) {
logErrorInConsole(error);
// pass
} finally {
document.querySelector(UI.primaryInitialPlotContainer).classList.add("is-hidden");
}

})
Expand Down Expand Up @@ -159,8 +170,6 @@ const downloadTableAsExcel = (tableId, filename) => {
* @returns {Promise<void>} - A promise that resolves when the dataset information is retrieved and UI updates are complete.
*/
const getDatasetInfo = async (datasetId) => {
document.querySelector(UI.analysisSelect).disabled = true;

try {
const data = await apiCallsMixin.fetchDatasetInfo(datasetId);

Expand All @@ -169,8 +178,6 @@ const getDatasetInfo = async (datasetId) => {
currentAnalysis.dataset = ds;

document.querySelector(UI.primaryFilterSection).classList.remove("is-hidden");
analysisLabels = await currentAnalysis.getSavedAnalysesList(ds.id, -1, 'sc_workbench'); // select first "selct an analysis" option
document.querySelector(UI.analysisSelect).disabled = false;

document.querySelector(UI.primaryInitialInfoSection).classList.remove("is-hidden");
document.querySelector(UI.selectedDatasetShapeInitialElt).textContent = currentAnalysis.dataset.shape();
Expand All @@ -179,8 +186,6 @@ const getDatasetInfo = async (datasetId) => {
} catch (error) {
createToast("Failed to access dataset");
logErrorInConsole(`Failed ID was: ${datasetId} because msg: ${error.message}`);
document.querySelector(UI.analysisSelect).disabled = true;

}
}

Expand Down

0 comments on commit 5329f2e

Please sign in to comment.