diff --git a/CHANGELOG.md b/CHANGELOG.md index 8abe5a5c6..7d05bad63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ ### Pending Release +- :rocket: `API` Ensure `mission_groups` is set if `All Groups` function is used when creating Data Sync +- :rocket: `UI` Disable Mission Role and set value to READONLY + ### v2.39.0 - 2024-06-13 - :rocket: `API` Add indexes to Iconsets & Basemaps for user based lookup diff --git a/api/lib/api/mission.ts b/api/lib/api/mission.ts index 8e9c65dea..2711f2fbe 100644 --- a/api/lib/api/mission.ts +++ b/api/lib/api/mission.ts @@ -583,6 +583,7 @@ export default class { }); if (!missions.data.length) throw new Err(404, null, `No Mission for Name: ${name}`); + return missions.data[0]; } @@ -594,14 +595,19 @@ export default class { async create( name: string, query: Static - ): Promise>> { + ): Promise> { const url = new URL(`/Marti/api/missions/${this.#encodeName(name)}`, this.api.url); if (query.group && Array.isArray(query.group)) query.group = query.group.join(','); for (const q in query) url.searchParams.append(q, String(query[q])); - return await this.api.fetch(url, { + const missions = await this.api.fetch(url, { method: 'POST' }); + + if (!missions.data.length) throw new Error('Create Mission didn\'t return a mission or an error'); + const mission = missions.data[0]; + + return mission; } /** diff --git a/api/lib/data-mission.ts b/api/lib/data-mission.ts index 2fd12410d..f5a2541d2 100644 --- a/api/lib/data-mission.ts +++ b/api/lib/data-mission.ts @@ -52,15 +52,18 @@ export default class DataMission { data.mission_groups = groups.data.map((group) => { return group.name }); } - const missions = await api.Mission.create(data.name, { + let mission = await api.Mission.create(data.name, { creatorUid: `connection-${data.connection}-data-${data.id}`, description: data.description, defaultRole: data.mission_role, group: data.mission_groups, }); - if (!missions.data.length) throw new Error('Create Mission didn\'t return a mission or an error'); - mission = missions.data[0]; + // The groups property isn't returned by Create + // Make this second call to get the groups - TODO Talk to Josh + mission = await api.Mission.get(data.name, {}, { + token: data.mission_token + }); await config.models.Data.commit(data.id, { mission_token: mission.token diff --git a/api/routes/connection-data.ts b/api/routes/connection-data.ts index 4b61e095e..e2f031111 100644 --- a/api/routes/connection-data.ts +++ b/api/routes/connection-data.ts @@ -189,6 +189,8 @@ export default async function router(schema: Schema, config: Config) { throw new Err(400, null, 'MissionDiff can only be enabled with a single layer') } + // TODO: Don't allow mission_diff to be turned on if there are non MISSION_READONLY subscribers + let data = await config.models.Data.from(req.params.dataid); if (data.connection !== connection.id) throw new Err(400, null, 'Data Sync does not belong to given Connection'); diff --git a/api/routes/marti-mission.ts b/api/routes/marti-mission.ts index d998ab48d..ce9a5a336 100644 --- a/api/routes/marti-mission.ts +++ b/api/routes/marti-mission.ts @@ -149,7 +149,7 @@ export default async function router(schema: Schema, config: Config) { inviteOnly: Type.Optional(Type.Boolean()), allowDupe: Type.Optional(Type.Boolean()), }), - res: GenericMartiResponse + res: Mission }, async (req, res) => { try { const user = await Auth.as_user(config, req); @@ -163,6 +163,7 @@ export default async function router(schema: Schema, config: Config) { bbox: req.query.bbox ? req.query.bbox.split(',') : req.query.bbox, creatorUid: user.email }); + return res.json(mission); } catch (err) { return Err.respond(err, res); diff --git a/api/web/src/components/CloudTAK/Menu/Mission/MissionCreate.vue b/api/web/src/components/CloudTAK/Menu/Mission/MissionCreate.vue index f7f343b6e..44feedb9b 100644 --- a/api/web/src/components/CloudTAK/Menu/Mission/MissionCreate.vue +++ b/api/web/src/components/CloudTAK/Menu/Mission/MissionCreate.vue @@ -213,7 +213,7 @@ export default { method: 'POST', }); - this.$emit('mission', res.data[0]); + this.$emit('mission', res); } catch (err) { this.err = err; } diff --git a/api/web/src/components/DataEdit.vue b/api/web/src/components/DataEdit.vue index 09aa903b9..132539a4a 100644 --- a/api/web/src/components/DataEdit.vue +++ b/api/web/src/components/DataEdit.vue @@ -72,7 +72,7 @@ @@ -193,6 +193,11 @@ export default { handler: function() { this.mission_groups = this.data.mission_groups.length === 0 ? "All Groups" : this.data.mission_groups.join(","); } + }, + 'data.mission_diff': function() { + if (!this.data.id && this.data.mission_diff) { + this.data.mission_role = 'MISSION_READONLY_SUBSCRIBER'; + } } }, mounted: async function() {