Skip to content

Commit

Permalink
Use orhaned list in tree
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Dec 2, 2024
1 parent f674f2d commit 570d871
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
43 changes: 28 additions & 15 deletions api/web/src/components/CloudTAK/Menu/Mission/MissionLayers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,29 @@
</template>
</div>
</MenuTemplate>
<MissionLayerTree
v-else
:orphaned='orphaned'
:layers='layers'
:feats='feats'
:mission='mission'
:role='role'
:token='token'
@refresh='refresh'
/>
<template v-else>
<TablerLoading
v-if='loading'
class='mx-2'
desc='Loading Layers...'
/>
<TablerNone
v-else-if='!layers.length && !orphaned.size'
:create='false'
:compact='true'
label='Layers'
/>
<MissionLayerTree
v-else
:orphaned='orphaned'
:layers='layers'
:feats='feats'
:mission='mission'
:role='role'
:token='token'
@refresh='refresh'
/>
</template>
</template>

<script setup lang='ts'>
Expand Down Expand Up @@ -117,7 +130,6 @@ async function refresh() {
loading.value = true;
await fetchFeats();
await fetchLayers();
loading.value = false;
}
Expand All @@ -130,7 +142,7 @@ async function fetchFeats() {
}
}
async function removeFeatures(mlayers: MissionLayer[]) {
function removeFeatures(mlayers: MissionLayer[]): void {
for (const layer of mlayers) {
if (layer.type === 'UID' && layer.uids && layer.uids.length) {
for (const cot of layer.uids) {
Expand All @@ -145,11 +157,12 @@ async function removeFeatures(mlayers: MissionLayer[]) {
}
}
async function fetchLayers() {
async function fetchLayers(): Promise<void> {
layers.value = (await Subscription.layerList(props.mission.name, props.token)).data;
// @ts-expect-error Mission Layers is currently untyped due to recursive type limits
if (layers.value.mission_layers) {
removeFeatures(layers.value.mission_layers);
if (layers.value) {
removeFeatures(layers.value);
}
}
</script>
14 changes: 1 addition & 13 deletions api/web/src/components/CloudTAK/Menu/Overlays/TreeMission.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</template>

<script setup lang='ts'>
import { ref, computed } from 'vue';
import { ref } from 'vue';
import {
TablerLoading
} from '@tak-ps/vue-tabler';
Expand All @@ -27,17 +27,5 @@ const props = defineProps<{
overlay: Overlay
}>()
const feats = computed<Map<string, Feature>>(() => {
const map = new Map();
if (!subscription.value) return map;
Array.from(subscription.value.cots.values()).forEach((cot) => {
const feat = cot.as_feature();
map.set(feat.id, feat);
})
return map;
})
const subscription = ref(cotStore.subscriptions.get(props.overlay.mode_id || ''));
</script>

0 comments on commit 570d871

Please sign in to comment.