Skip to content

Commit

Permalink
genotype-search : Show a Loading message
Browse files Browse the repository at this point in the history
part of #447
genotype-search.hbs : if .vcfGenotypeSearchTask.isRunning, display Loading ...
genotype-search.js :
 vcfGenotypeSearchDisabled() : add vcfGenotypeSearchTask.isRunning
 vcfGenotypeSearch() rename to vcfGenotypeSearchP(), return resultP,  and wrap with vcfGenotypeSearch() -> vcfGenotypeSearchTask().
  • Loading branch information
Don-Isdale committed Dec 8, 2024
1 parent 81818ba commit 65156a4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
3 changes: 3 additions & 0 deletions frontend/app/components/panel/genotype-search.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
>Search</button>
{{!-- Effect: request the vcfFiles for the selected dataset --}}
<div style="display:none">{{this.datasetVcfFiles}}</div>
{{#if this.vcfGenotypeSearchTask.isRunning}}
<div class="margin-1em">Loading ...</div>
{{/if}}
<div class="clearfix"></div>

{{#if this.resultCounts.blocks}}
Expand Down
32 changes: 29 additions & 3 deletions frontend/app/components/panel/genotype-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { later } from '@ember/runloop';

import { tracked } from '@glimmer/tracking';

import { task } from 'ember-concurrency';

//------------------------------------------------------------------------------

import { statusToMatrix } from '../../utils/data/vcf-files';
Expand Down Expand Up @@ -251,12 +253,14 @@ export default class PanelGenotypeSearchComponent extends Component {
disabled =
! this.selectedSamplesText?.length ||
! this.selectedFeaturesText?.length ||
! this.vcfFiles?.length;
! this.vcfFiles?.length ||
this.vcfGenotypeSearchTask.isRunning;
dLog(
fnName, disabled,
this.selectedSamplesText?.length,
this.selectedFeaturesText?.length,
this.vcfFiles?.length,
this.vcfGenotypeSearchTask.isRunning,
!! this.manageGenotype);
return disabled;
}
Expand Down Expand Up @@ -295,9 +299,29 @@ export default class PanelGenotypeSearchComponent extends Component {
return promise;
}

@action

/** if vcfGenotypeSearchTask is not running, perform it. */
vcfGenotypeSearch() {
const fnName = 'vcfGenotypeSearch';
if (! this.vcfGenotypeSearchTask.isRunning) {
this.vcfGenotypeSearchTaskInstance = this.vcfGenotypeSearchTask.perform();
}
}
/** Call vcfGenotypeSearchP() in a task - yield the result.
* This function and vcfGenotypeSearch() are based on the equivalent vcfGenotypeLookup in manage-genotype.js
*/
vcfGenotypeSearchTask = task({ drop: true }, async () => {
console.log('vcfGenotypeSearchTask');
let block = await this.vcfGenotypeSearchP();

return block;
});

//------------------------------------------------------------------------------

@action
vcfGenotypeSearchP() {
const fnName = 'vcfGenotypeSearchP';
dLog(fnName, this.vcfGenotypeSearchTask.isRunning, 'vcfGenotypeSearchTask.isRunning');
const snpNames = namesTrimUniq(this.selectedFeaturesText);
const searchScope = {datasetVcfFiles : this.vcfFiles, snpNames};
/** Called from vcfGenotypeSearchAfterNavigate() which ensures that this.manageGenotype?.isDestroying === false
Expand Down Expand Up @@ -351,6 +375,8 @@ export default class PanelGenotypeSearchComponent extends Component {
dLog(fnName, 'resultCount', this.resultCount); }));

dLog(fnName, searchScope, this.args.userSettings.dialogMode);

return resultP;
}

@action
Expand Down

0 comments on commit 65156a4

Please sign in to comment.