diff --git a/api/web/src/components/CloudTAK/Map.vue b/api/web/src/components/CloudTAK/Map.vue
index 0b5420998..30fac2f41 100644
--- a/api/web/src/components/CloudTAK/Map.vue
+++ b/api/web/src/components/CloudTAK/Map.vue
@@ -240,110 +240,9 @@
width: 380px;
'
>
-
+
+
+
+
diff --git a/api/web/src/stores/cots.ts b/api/web/src/stores/cots.ts
index 13597c390..ea243996a 100644
--- a/api/web/src/stores/cots.ts
+++ b/api/web/src/stores/cots.ts
@@ -413,18 +413,17 @@ export const useCOTStore = defineStore('cots', {
if (is_mission_cot) return;
- const exists = this.cots.get(feat.id);
+ let exists = this.cots.get(feat.id);
if (exists) {
exists.update(feat)
// TODO condition update depending on diff results
this.pending.set(String(feat.id), exists);
+ await exists.save();
} else {
- this.pending.set(String(feat.id), new COT(feat));
- }
-
- if (feat.properties && feat.properties.archived) {
- await std('/api/profile/feature', { method: 'PUT', body: feat })
+ const cot = new COT(feat);
+ this.pending.set(String(feat.id), cot);
+ await cot.save();
}
}
}
diff --git a/api/web/src/stores/cots/cot.ts b/api/web/src/stores/cots/cot.ts
index 3b83bb9e0..a7d7cd1b8 100644
--- a/api/web/src/stores/cots/cot.ts
+++ b/api/web/src/stores/cots/cot.ts
@@ -1,3 +1,4 @@
+import { std } from '../../std.ts';
import { bbox } from '@turf/bbox'
import { useMapStore } from '../map.ts';
import pointOnFeature from '@turf/point-on-feature';
@@ -34,10 +35,10 @@ export default class COT implements Feature {
geometry: Feature["geometry"];
constructor(feat: Feature) {
- this.id = feat.id;
- this.type = feat.type;
- this.path = feat.path;
- this.properties = feat["properties"];
+ this.id = feat.id || crypto.randomUUID();
+ this.type = feat.type || 'Feature';
+ this.path = feat.path || '/';
+ this.properties = feat["properties"] || {};
this.geometry = feat["geometry"];
}
@@ -61,6 +62,28 @@ export default class COT implements Feature {
return changed;
}
+ /**
+ * Attempt to save the CoT to the database if necessary
+ */
+ async save(): Promise
{
+ if (this.properties.archived) {
+ await std('/api/profile/feature', {
+ method: 'PUT',
+ body: this.as_feature()
+ })
+ }
+ }
+
+ as_feature(): GeoJSONFeature> {
+ return {
+ id: this.id,
+ type: this.type,
+ path: this.path,
+ properties: this.properties,
+ geometry: this.geometry
+ }
+ }
+
/**
* The slimmer we can get the Features, the better
* This returns the minium feature we need to actually style the COT in the vector tiles
@@ -88,7 +111,7 @@ export default class COT implements Feature {
}
bounds(): GeoJSONBBox {
- return bbox(this.geometry)
+ return bbox(this.geometry)
}
/**