Skip to content

Commit

Permalink
Merge pull request #234 from alan-wu/reduce-get-organ-curies
Browse files Browse the repository at this point in the history
Call get organ curies once only.
  • Loading branch information
alan-wu authored Jul 19, 2024
2 parents ddc9642 + 5650d61 commit 3dad80c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 34 deletions.
6 changes: 3 additions & 3 deletions cypress/component/MapContent.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ describe('MapContent', () => {
//Wait for the curie response before continuing
// cy.wait('@categoryResponse');

//Wait for curie response
cy.wait('@curieResponse', {timeout: 20000});

//Check if mapcontent is mounted correctly
cy.get('.mapcontent').invoke('attr', 'style', 'height: 880px').should(
'have.attr', 'style', 'height: 880px');
Expand All @@ -91,9 +94,6 @@ describe('MapContent', () => {
//Sidebar should not be visbile
cy.get('.el-drawer.rtl.my-drawer').should('not.be.visible');

//Wait for curie response
cy.wait('@curieResponse', {timeout: 20000});

//Wait for curie response
cy.wait('@featuredDatasetResponse', {timeout: 20000});

Expand Down
1 change: 1 addition & 0 deletions src/components/MapContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ export default {
this.options.rootUrl ? this.settingsStore.updateRootUrl(this.options.rootUrl) : null
}
this.splitFlowStore?.reset();
this.splitFlowStore?.getAvailableTerms(this.settingsStore.sparcApi);
},
mounted: async function() {
EventBus.on("updateShareLinkRequested", () => {
Expand Down
2 changes: 0 additions & 2 deletions src/components/viewers/Flatmap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export default {
let provClone = {id: this.entry.id, prov: this.getFlatmapImp().provenance}; //create clone of provenance and add id
EventBus.emit("mapImpProv", provClone); // send clone to context card
this.$emit("flatmap-provenance-ready", provClone);
this.getAvailableTerms();
if (this.entry.resource === "FunctionalConnectivity"){
this.flatmapReadyForMarkerUpdates(flatmap);
}
Expand Down Expand Up @@ -166,7 +165,6 @@ export default {
},
},
mounted: function() {
this.getAvailableTerms();
EventBus.on("markerUpdate", () => {
this.flatmapMarkerUpdate(undefined);
});
Expand Down
2 changes: 0 additions & 2 deletions src/components/viewers/MultiFlatmap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,7 @@ export default {
},
},
mounted: function () {
this.getAvailableTerms();
this.getFeaturedDatasets();
EventBus.on('show-connectivity', (payload) => {
const { featureIds, offset } = payload;
if (this.flatmapReady && this.$refs.multiflatmap) {
Expand Down
30 changes: 3 additions & 27 deletions src/mixins/ContentMixin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
getAvailableTermsForSpecies,
getInteractiveAction,
getNerveNames,
getParentsRegion,
Expand Down Expand Up @@ -35,6 +34,9 @@ export default {
},
computed: {
...mapStores(useSettingsStore, useSplitFlowStore),
idNamePair() {
return this.splitFlowStore.idNamePair;
},
syncMode() {
return this.splitFlowStore.syncMode;
},
Expand Down Expand Up @@ -397,31 +399,6 @@ export default {
requestSynchronisedEvent: function () {
return;
},
getAvailableTerms: function () {
//Use the default list of uberons before we get the list from
//the api
let terms = getAvailableTermsForSpecies();
for (let i = 0; i < terms.length; i++) {
this.idNamePair[terms[i].id] = terms[i].name;
}
if (this.apiLocation) {
if (this._controller) this._controller.abort();
this._controller = new AbortController();
let signal = this._controller.signal;
fetch(`${this.apiLocation}get-organ-curies`, {
signal,
})
.then(response => response.json())
.then(data => {
this._controller = undefined;
data.uberon.array.forEach(pair => {
this.idNamePair[pair.id.toUpperCase()] =
pair.name.charAt(0).toUpperCase() + pair.name.slice(1);
});
return;
});
}
},
flatmapMarkerUpdate() {
return;
},
Expand Down Expand Up @@ -536,7 +513,6 @@ export default {
multiflatmapRef: null,
flatmapRef: null,
scaffoldRef: null,
idNamePair: {},
scaffoldLoaded: false,
isInHelp: false,
hoverDelay: undefined
Expand Down
28 changes: 28 additions & 0 deletions src/stores/splitFlow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { defineStore } from 'pinia';
import {
getAvailableTermsForSpecies,
} from "../components/SimulatedData.js";

/* eslint-disable no-alert, no-console */
const presetLayouts = (view) => {
Expand Down Expand Up @@ -130,6 +133,7 @@ const findKeyWithId = (layout, id) => {
const getOriginalState = () => {
return {
activeView: "singlepanel",
idNamePair: {},
viewIcons: [
{ icon: "singlepanel", name: "Single view", min: 1 },
{ icon: "2horpanel", name: "Horizontal split", min: 2 },
Expand Down Expand Up @@ -195,6 +199,30 @@ export const useSplitFlowStore = defineStore('splitFlow', {
this.customLayout[sourceKey].id = payload.target;
}
},
getAvailableTerms(apiLocation) {
let terms = getAvailableTermsForSpecies();
for (let i = 0; i < terms.length; i++) {
this.idNamePair[terms[i].id] = terms[i].name;
}
if (apiLocation) {
if (this._controller) this._controller.abort();
this._controller = new AbortController();
let signal = this._controller.signal;
console.log("getAvailableTerms")
fetch(`${apiLocation}get-organ-curies`, {
signal,
})
.then(response => response.json())
.then(data => {
this._controller = undefined;
data.uberon.array.forEach(pair => {
this.idNamePair[pair.id.toUpperCase()] =
pair.name.charAt(0).toUpperCase() + pair.name.slice(1);
});
return;
});
}
},
toggleGlobalCallback(flag) {
this.globalCallback = flag;
},
Expand Down

0 comments on commit 3dad80c

Please sign in to comment.