Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/components/FlatmapVuer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ Please use `const` to assign meaningful names to them...
:tooltipEntry="tooltipEntry"
:annotationDisplay="viewingMode === 'Annotation'"
@annotation="commitAnnotationEvent"
@onActionClick="onActionClick"
/>
</div>
</div>
Expand Down Expand Up @@ -641,6 +642,7 @@ import { mapState } from 'pinia'
import { useMainStore } from '@/store/index'
import { DrawToolbar, Tooltip, TreeControls } from '@abi-software/map-utilities'
import '@abi-software/map-utilities/dist/style.css'
import EventBus from './EventBus.js'

const ERROR_MESSAGE = 'cannot be found on the map.';

Expand Down Expand Up @@ -1899,6 +1901,14 @@ export default {
}
});
},
changeConnectivitySource: function (payload) {
const { featureId, connectivitySource } = payload;
const newwPromise = this.flatmapQueries.queryForConnectivityNew(this.mapImp, featureId, null, connectivitySource);
Promise.resolve(newwPromise).then((result) => {
this.tooltipEntry = this.flatmapQueries.updateTooltipData(this.tooltipEntry);
this.$emit('connectivity-info-open', this.tooltipEntry);
})
},
/**
* @public
* Function to create/display tooltips from the provided ``data``.
Expand Down Expand Up @@ -2221,6 +2231,10 @@ export default {
// Get connectivity knowledge source | SCKAN release
if (this.mapImp.provenance?.connectivity) {
this.tooltipEntry['knowledge-source'] = getKnowledgeSource(this.mapImp);

// Map id and uuid to load connectivity information from the map
this.tooltipEntry['mapId'] = this.mapImp.provenance.id;
this.tooltipEntry['mapuuid'] = this.mapImp.provenance.uuid;
}
this.$emit('connectivity-info-open', this.tooltipEntry);
}
Expand Down Expand Up @@ -2742,6 +2756,9 @@ export default {
if (this.mapImp) return this.mapImp.search(term)
return []
},
onActionClick: function (data) {
EventBus.emit('onActionClick', data)
},
},
props: {
/**
Expand Down
5 changes: 4 additions & 1 deletion src/services/flatmapKnowledge.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ function loadAndStoreKnowledge(mapImp, flatmapQueries) {
where source="${knowledgeSource}"
order by source desc`;
const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
const flatmapKnowledgeSource = sessionStorage.getItem('flatmap-knowledge-source');

if (!flatmapKnowledge) {
if (!flatmapKnowledge || flatmapKnowledgeSource !== knowledgeSource) {
flatmapQueries.flatmapQuery(sql).then((response) => {
const mappedData = response.values.map(x => x[0]);
const parsedData = mappedData.map(x => JSON.parse(x));
sessionStorage.setItem('flatmap-knowledge', JSON.stringify(parsedData));
sessionStorage.setItem('flatmap-knowledge-source', knowledgeSource);
updateFlatmapKnowledgeCache();
});
}
Expand All @@ -69,6 +71,7 @@ function removeFlatmapKnowledgeCache() {
const keys = [
'flatmap-knowledge',
'flatmap-knowledge-expiry',
'flatmap-knowledge-source',
];
keys.forEach((key) => {
sessionStorage.removeItem(key);
Expand Down
41 changes: 38 additions & 3 deletions src/services/flatmapQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ let FlatmapQueries = function () {
return tooltipData
}

this.updateTooltipData = function (tooltipEntry) {
return {
...tooltipEntry,
origins: this.origins,
originsWithDatasets: this.originsWithDatasets,
components: this.components,
componentsWithDatasets: this.componentsWithDatasets,
destinations: this.destinations,
destinationsWithDatasets: this.destinationsWithDatasets,
};
}

this.createComponentsLabelList = function (components, lookUp) {
let labelList = []
components.forEach((n) => {
Expand Down Expand Up @@ -266,14 +278,22 @@ let FlatmapQueries = function () {
this.rawURLs = []
if (!keastIds || keastIds.length == 0 || !keastIds[0]) return

let prom1 = this.queryForConnectivityNew(mapImp, keastIds, signal) // This on returns a promise so dont need 'await'
// set connectivity source if available
const connectivitySource = localStorage.getItem('connectivity-source');

let prom1 = this.queryForConnectivityNew(mapImp, keastIds, signal, connectivitySource) // This on returns a promise so dont need 'await'
let results = await Promise.all([prom1])
return results
}

this.queryForConnectivityNew = function (mapImp, keastIds, signal, processConnectivity=true) {
this.queryForConnectivityNew = function (mapImp, keastIds, signal, connectivitySource, processConnectivity=true) {
return new Promise((resolve) => {
mapImp.queryKnowledge(keastIds[0])
const mapuuid = mapImp.provenance.uuid;
const queryAPI = connectivitySource === 'map'
? this.queryMapConnectivity(mapuuid, keastIds[0])
: mapImp.queryKnowledge(keastIds[0]);

queryAPI
.then((response) => {
if (this.checkConnectivityExists(response)) {
let connectivity = response;
Expand Down Expand Up @@ -308,6 +328,21 @@ let FlatmapQueries = function () {
})
}

this.queryMapConnectivity = async function (mapuuid, pathId) {
const url = this.flatmapApi + `flatmap/${mapuuid}/connectivity/${pathId}`;

try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}

return await response.json();
} catch (error) {
throw new Error(error);
}
},

this.queryForConnectivity = function (mapImp, keastIds, signal, processConnectivity=true) {
const data = { sql: this.buildConnectivitySqlStatement(keastIds) }
const headers = {
Expand Down