Skip to content

Commit

Permalink
Setup Group Bits
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Feb 8, 2024
1 parent 2867fcb commit 0317b12
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions api/lib/api/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export default class {
});
}

async update(query: {
async update(body: Group[], query: {
clientUid?: string;
}, body: object[]) {
}): Promise<void> {
const url = new URL(`/Marti/api/groups/active`, this.api.url);
for (const q in query) url.searchParams.append(q, query[q]);

return await this.api.fetch(url, {
await this.api.fetch(url, {
method: 'PUT',
body
});
Expand Down
15 changes: 10 additions & 5 deletions api/lib/data-mission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ export default class DataMission {

const api = await TAKAPI.init(new URL(String(config.server.api)), new APIAuthCertificate(connection.auth.cert, connection.auth.key));

// All groups should be active for data-sync api to work properly
const groups = await api.Group.list({ useCache: 'true' });
if (groups.data.some((g) => { return !g.active })) {
const updatedGroups = await api.Group.update(groups.data.map((group) => {
group.active = true;
return group;
}), {})
}

try {
const missions = await api.Mission.get(data.name, {});
//TODO Update Groups: Not supported by TAK Server at this time
Expand All @@ -27,11 +36,7 @@ export default class DataMission {
if (!data.mission_sync) return;

if (!data.mission_groups.length) {
data.mission_groups = (await api.Group.list({
useCache: 'true'
})).data.map((group) =>{
return group.name;
});
data.mission_groups = groups.data.map((group) => { return group.name });
}

const missions = await api.Mission.create(data.name, {
Expand Down
2 changes: 1 addition & 1 deletion api/routes/marti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default async function router(schema: any, config: Config) {
const query = {};
for (const q in req.query) query[q] = String(req.query[q]);

const groups = await api.Group.update(query, req.body);
const groups = await api.Group.update(req.body, {});

return res.json(groups);
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion api/schema/profile_overlays/id.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "number",
"description": "",
"$comment": "int8"
"$comment": "int4"
}
2 changes: 1 addition & 1 deletion api/schema/profile_overlays/mode.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "string",
"description": "",
"$comment": "text"
"$comment": "varchar"
}
2 changes: 1 addition & 1 deletion api/schema/profile_overlays/name.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "string",
"description": "",
"$comment": "text"
"$comment": "varchar"
}
2 changes: 1 addition & 1 deletion api/schema/profile_overlays/opacity.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "number",
"description": "",
"$comment": "float8"
"$comment": "int4"
}
2 changes: 1 addition & 1 deletion api/schema/profile_overlays/type.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "string",
"description": "",
"$comment": "text"
"$comment": "varchar"
}
2 changes: 1 addition & 1 deletion api/schema/profile_overlays/url.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "string",
"description": "",
"$comment": "text"
"$comment": "varchar"
}
7 changes: 2 additions & 5 deletions api/schema/profile_overlays/username.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"type": [
"string",
"null"
],
"type": "string",
"description": "",
"$comment": "text"
"$comment": "varchar"
}

0 comments on commit 0317b12

Please sign in to comment.