Skip to content

Commit

Permalink
sequence search : view added dataset
Browse files Browse the repository at this point in the history
sequence-search.js : dnaSequenceInput() : after refreshDatasets, if viewDatasetFlag then viewDataset.
block.js : getCountsForInterval() :  handle interval undefined.
sequence-search.hbs : add checkbox : viewDatasetFlag.
mapview: add viewDataset() and pass to left-panel, which passes it to sequence-search.
updateModel() : return datasetsTask.
  • Loading branch information
Don-Isdale committed May 31, 2021
1 parent 3b9e7ce commit 66d59ba
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 2 deletions.
17 changes: 16 additions & 1 deletion frontend/app/components/panel/sequence-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,22 @@ export default Component.extend({
/* On complete, trigger dataset list reload.
* refreshDatasets is passed from controllers/mapview (updateModel ).
*/
promise.then(() => this.get('refreshDatasets')());
promise.then(() => {
const viewDataset = this.get('viewDatasetFlag');
let refreshed = this.get('refreshDatasets')();
if (viewDataset) {
refreshed
.then(() => {
/** same as convertSearchResults2Json() in dnaSequenceSearch.bash and
* backend/common/models/feature.js : Feature.dnaSequenceSearch() */
let
datasetName = this.get('newDatasetName'),
datasetNameFull=`${parent}.${datasetName}`;
dLog(fnName, 'viewDataset', datasetNameFull);
this.get('viewDataset')(datasetNameFull, viewDataset);
});
}
});
}

let searchData = sequenceSearchData.create({promise, seq, parent, searchType});
Expand Down
33 changes: 33 additions & 0 deletions frontend/app/controllers/mapview.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default Controller.extend(Evented, {

/** Change the state of the named block to viewed.
* If this block has a parent block, also add the parent.
* This is replaced by loadBlock().
* @param mapName
* (named map for consistency, but mapsToView really means block, and "name" is db ID)
* Also @see components/record/entry-block.js : action get
Expand Down Expand Up @@ -238,6 +239,7 @@ export default Controller.extend(Evented, {
this.get('block').getBlocksLimits();
});
}
return datasetsTask;
}
},

Expand Down Expand Up @@ -348,6 +350,37 @@ export default Controller.extend(Evented, {
}
},

/*--------------------------------------------------------------------------*/

/* copied from file-drop-zone.js, can factor if this is retained. */
/** View/Unview the blocks of the given dataset.
* View is used to view a dataset added by sequence-sequence.
* Unview is used when the datasets has been replaced by successful upload.
* @param datasetName id
* @param view true for view, false for unview
*/
viewDataset(datasetName, view) {
let
store = this.get('apiServers').get('primaryServer').get('store'),
dataset = store.peekRecord('dataset', datasetName);
if (dataset) {
let
blocksToChange = dataset.get('blocks').toArray().filter((b) => b.get('isViewed') !== view),
blockService = this.get('block'),
blockIds = blocksToChange.map((b) => b.id);
dLog('viewDataset', datasetName, view, blockIds);
// blockService.setViewed(blockIds, view);
let loadBlock = this.actions.loadBlock.bind(this);
blocksToChange.forEach((b) => loadBlock(b));
} else {
dLog('viewDataset', datasetName, 'not found', view);
}
},


/*--------------------------------------------------------------------------*/


/** Provide a class for the div which wraps the right panel.
*
* The class indicates which of the tabs in the right panel is currently
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/services/data/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ export default Service.extend(Evented, {
}
let getCountsForInterval = (interval) => {
let countsP;
if (interval[0] === interval[1]) {
if (interval && (interval[0] === interval[1])) {
dLog('getCountsForInterval', interval);
countsP = Promise.resolve([]);
} else {
Expand Down
1 change: 1 addition & 0 deletions frontend/app/templates/components/panel/left-panel.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
datasets=datasets
view=view
refreshDatasets=refreshDatasets
viewDataset=viewDataset
}}
</tab.pane>

Expand Down
5 changes: 5 additions & 0 deletions frontend/app/templates/components/panel/sequence-search.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ AGCTGGGTGTCGTTGATCTTCAGGTCCTTCTGGATGTACAGCGACGCTCC" }}
<label>Replace Dataset</label>
</span>

<span class="filter-group-col">
{{input type="checkbox" name="viewDatasetFlag" checked=viewDatasetFlag }}
<label>View</label>
</span>

<div id="new_dataset_options">
{{input
id="dataset_new"
Expand Down
1 change: 1 addition & 0 deletions frontend/app/templates/mapview.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
model=model
datasets=datasets
refreshDatasets=(action "updateModel")
viewDataset=(action this.viewDataset)
selectedBlock=selectedBlock
controls=controls
isShowUnique=isShowUnique
Expand Down

0 comments on commit 66d59ba

Please sign in to comment.