Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users TS #391

Merged
merged 8 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

### Pending Release

### v4.21.0 - 2024-10-17

- :bug: Fix Iconset Filter in UI
- :tada: Add `data_alt` field to show a different icon in CloudTAK than the Iconset Default
- :bug: Automatically resize to a width of 32px on all spritesheets
- :bug: Fix a bug where CoT messages that didn 't need to be updated in a Data Sync were injected into the channel

### v4.20.0 - 2024-10-17

- :tada: `UI` Add ability to renew lease & show if lease is expired
Expand Down
5 changes: 4 additions & 1 deletion api/lib/sprites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export default async function(icons: Array<Static<typeof IconResponse>>, config:
const src = [];
for (const icon of icons) {
const contents = await Sharp(Buffer.from(config.useDataAlt && icon.data_alt ? icon.data_alt : icon.data, 'base64'))
.resize(32)
.resize(32, 32, {
fit: 'contain',
background: {r: 0, g: 0, b: 0, alpha: 0}
})
.png()
.toBuffer();

Expand Down
5 changes: 4 additions & 1 deletion api/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export const ProfileResponse = Type.Object({
tak_callsign: Type.String(),
tak_group: Type.Enum(TAKGroup),
tak_role: Type.Enum(TAKRole),
tak_loc: Type.Any(),
tak_loc: Type.Union([Type.Object({
type: Type.Literal('Point'),
coordinates: Type.Array(Type.Number())
}), Type.Null()]),
display_stale: Type.String(),
display_text: Type.String(),
display_distance: Type.String(),
Expand Down
2,161 changes: 652 additions & 1,509 deletions api/package-lock.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions api/routes/connection-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ export default async function router(schema: Schema, config: Config) {
if (data.connection !== req.params.connectionid) {
throw new Err(400, null, 'Layer cannot reference a Data Sync that is not part of the current connection');
}

try {
// Handle Potential Renames
await DataMission.sync(config, data);
} catch (err) {
// Eventually do something
console.error(err);
}
}

if (req.body.styles) {
Expand Down
26 changes: 26 additions & 0 deletions api/routes/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ export default async function router(schema: Schema, config: Config) {
}
});

await schema.patch('/user/:username', {
name: 'Update User',
group: 'User',
description: 'Update a User',
params: Type.Object({
username: Type.String(),
}),
body: Type.Object({
system_admin: Type.Optional(Type.Boolean())
}),
res: ProfileResponse
}, async (req, res) => {
try {
await Auth.as_user(config, req, { admin: true });

const user = await config.models.Profile.commit(req.params.username, req.body);

res.json({
...user,
agency_admin: user.agency_admin || []
});
} catch (err) {
Err.respond(err, res);
}
});

await schema.get('/user/:username', {
name: 'Get User',
group: 'User',
Expand Down
1,187 changes: 587 additions & 600 deletions api/web/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dropzone": "^6.0.0-beta.2",
"floating-vue": "^2.0.0-beta.17",
"jsonata": "^2.0.4",
"maplibre-gl": "^4.0.0",
"maplibre-gl": "^5.0.0-pre.3",
"moment": "^2.29.3",
"p12-pem": "^1.0.5",
"phone": "^3.1.42",
Expand Down
15 changes: 14 additions & 1 deletion api/web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,20 @@ export default defineComponent({
});
</script>

<style>
<style lang='scss'>
$cloudtak-yellow: #FFB703;
$cloudtak-orange: #FF9820;
$cloudtak-navy: #023047;
$cloudtak-blue: #07556D;

.cloudtak-gradient {
background: radial-gradient(at left top, $cloudtak-blue, $cloudtak-navy);
}

.btn-primary {
background-color: #07556D !important;
}

.hover-button-hidden {
visibility: hidden;
}
Expand Down
12 changes: 9 additions & 3 deletions api/web/src/components/Admin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,15 @@
</div>
</div>
<div class='col-12 col-md-9 position-relative'>
<router-view
:data='data'
/>
<Suspense>
<router-view
:data='data'
/>

<template #fallback>
<TablerLoading />
</template>
</Suspense>
</div>
</div>
</div>
Expand Down
72 changes: 36 additions & 36 deletions api/web/src/components/Admin/AdminUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IconCircleArrowLeft
class='cursor-pointer'
:size='32'
:stroke='1'
stroke='1'
@click='$router.push("/admin/user")'
/>

Expand All @@ -14,20 +14,22 @@
/>

<div class='ms-auto btn-list'>
<IconRefresh
v-tooltip='"Refresh"'
:size='32'
:stroke='1'
class='cursor-pointer'
@click='fetchUser'
/>
<TablerIconButton
title='Refresh'
@click='fetchUserLoading'
>
<IconRefresh
:size='32'
stroke='1'
/>
</TablerIconButton>
</div>
</div>
<div class='card-body'>
<TablerLoading v-if='loading' />
<template v-else>
<div class='datagrid'>
<template v-for='ele in Object.keys(user)'>
<template v-for='ele in getKeys(user)'>
<div
v-if='user[ele]'
class='datagrid-item'
Expand Down Expand Up @@ -63,39 +65,37 @@
</div>
</template>

<script>
import { std, stdurl } from '/src/std.ts';
<script setup lang='ts'>
import { std, stdurl } from '../../std.ts';
import type { User } from '../../types.ts';
import {
TablerLoading
TablerLoading,
TablerIconButton
} from '@tak-ps/vue-tabler';
import {
IconRefresh,
IconCircleArrowLeft,
} from '@tabler/icons-vue'

export default {
name: 'UserAdmin',
components: {
IconRefresh,
IconCircleArrowLeft,
TablerLoading,
},
data: function() {
return {
loading: true,
user: {}
}
},
mounted: async function() {
await this.fetchUser();
},
methods: {
fetchUser: async function() {
this.loading = true;
const url = stdurl(`/api/user/${this.$route.params.user}`);
this.user = await std(url);
this.loading = false;
}
}
import { ref } from 'vue';
import { useRoute } from 'vue-router'

const route = useRoute()

async function fetchUser(): Promise<User> {
const url = stdurl(`/api/user/${route.params.user}`);
return await std(url) as User;
}

const loading = ref(false);
const user = ref<User>(await fetchUser());

const getKeys = <T extends object>(obj: T) => Object.keys(obj) as Array<keyof T>

async function fetchUserLoading(): Promise<void> {
loading.value = true;
const url = stdurl(`/api/user/${route.params.user}`);
user.value = await std(url) as User;
loading.value = false;
}
</script>
Loading
Loading