From 65156a45572b0dd143153a6aaff1246ddd6a0295 Mon Sep 17 00:00:00 2001 From: Don Date: Mon, 9 Dec 2024 10:14:05 +1100 Subject: [PATCH] genotype-search : Show a Loading message 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(). --- .../app/components/panel/genotype-search.hbs | 3 ++ .../app/components/panel/genotype-search.js | 32 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/frontend/app/components/panel/genotype-search.hbs b/frontend/app/components/panel/genotype-search.hbs index 3cfc9d79..d3cbc419 100644 --- a/frontend/app/components/panel/genotype-search.hbs +++ b/frontend/app/components/panel/genotype-search.hbs @@ -66,6 +66,9 @@ >Search {{!-- Effect: request the vcfFiles for the selected dataset --}}
{{this.datasetVcfFiles}}
+ {{#if this.vcfGenotypeSearchTask.isRunning}} +
Loading ...
+ {{/if}}
{{#if this.resultCounts.blocks}} diff --git a/frontend/app/components/panel/genotype-search.js b/frontend/app/components/panel/genotype-search.js index e7751a51..6d0b2880 100644 --- a/frontend/app/components/panel/genotype-search.js +++ b/frontend/app/components/panel/genotype-search.js @@ -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'; @@ -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; } @@ -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 @@ -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