Skip to content

Commit

Permalink
Add Subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Feb 16, 2024
1 parent c9b6b89 commit fd93e07
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
5 changes: 3 additions & 2 deletions api/web/src/components/CloudTAK/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ export default {
const turl = window.stdurl('/api/basemap');
turl.searchParams.append('type', 'raster-dem');
/*
/* Disabled for now
const terrains = await window.std(turl);
if (terrains.items.length > 0) {
terrain = terrains.items[0];
Expand All @@ -383,7 +384,7 @@ export default {
mapStore.init(this.$refs.map, basemap);
mapStore.map.once('load', async () => {
mapStore.initLayers(basemap);
await mapStore.initLayers(basemap);
const iconsets = await window.std('/api/iconset');
for (const iconset of iconsets.items) {
Expand Down
36 changes: 15 additions & 21 deletions api/web/src/stores/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const useMapStore = defineStore('cloudtak', {
}

if (layer.save && !config.initial) {
await overlayStore.saveOverlay({
layer.overlay = await overlayStore.saveOverlay({
...layer,
url: layer.type === 'vector' ? new URL(layer.url).pathname : layer.url,
visible: layer.visible === 'visible' ? true : false
Expand Down Expand Up @@ -115,13 +115,7 @@ export const useMapStore = defineStore('cloudtak', {
if (pos === false) return
const layer = this.layers[pos];

for (const l of layer.layers) {
this.map.removeLayer(l.id);
}

await this.map.removeSource(source);

this.layers.splice(pos, 1)
await this.removeLayer(layer.name);
},
getLayerPos: function(name, key='name') {
for (let i = 0; i < this.layers.length; i++) {
Expand Down Expand Up @@ -278,7 +272,6 @@ export const useMapStore = defineStore('cloudtak', {
type: 'raster',
source: layer.id
}]);

}
},
initLayers: async function(basemap) {
Expand Down Expand Up @@ -341,20 +334,21 @@ export const useMapStore = defineStore('cloudtak', {
});
},
initOverlays: async function() {
for (const layer of (await window.std('/api/profile/overlay')).items) {
if (layer.mode == 'mission') {
layer.overlay = layer.id;
layer.id = `${layer.mode}-${layer.mode_id}-${layer.id}`;
layer.save = true;
await this.addDefaultLayer(layer, true)
await overlayStore.list();
for (const overlay of overlayStore.overlays) {
if (overlay.mode == 'mission') {
overlay.overlay = overlay.id;
overlay.id = `${overlay.mode}-${overlay.mode_id}-${overlay.id}`;
overlay.save = true;
await this.addDefaultLayer(overlay, true)
} else {
const url = window.stdurl(layer.url);
const url = window.stdurl(overlay.url);
url.searchParams.append('token', localStorage.token);
layer.url = String(url);
layer.overlay = layer.id;
layer.id = `${layer.mode}-${layer.mode_id}-${layer.id}`;
layer.save = true;
await this.addDefaultLayer(layer, true)
overlay.url = String(url);
overlay.overlay = overlay.id;
overlay.id = `${overlay.mode}-${overlay.mode_id}-${overlay.id}`;
overlay.save = true;
await this.addDefaultLayer(overlay, true)
}
}
},
Expand Down
7 changes: 5 additions & 2 deletions api/web/src/stores/overlays.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const useOverlayStore = defineStore('overlays', {
state: () => {
return {
initialized: false,
overlays: [],
subscriptions: new Map()
}
},
Expand All @@ -30,14 +31,16 @@ export const useOverlayStore = defineStore('overlays', {
await this.list()
},
list: async function() {
const list = await window.std(`/api/profile/overlay`);
this.overlays = (await window.std(`/api/profile/overlay`)).items;

this.subscriptions.clear();
for (const sub of list.items) {
for (const sub of this.overlays) {
if (sub.mode === 'mission') {
// mode_id is GUID for mission type
this.subscriptions.set(sub.mode_id, sub);
}
}

this.initialized = true;
}
},
Expand Down

0 comments on commit fd93e07

Please sign in to comment.