From 23fe88f60d9b578c892eb5b67b2851ab0f9b2e3b Mon Sep 17 00:00:00 2001 From: ingalls Date: Thu, 12 Dec 2024 11:31:13 -0700 Subject: [PATCH 1/8] Add Video Server Management --- .gitignore | 2 + api/web/src/components/Admin.vue | 40 +-- api/web/src/components/Admin/AdminVideos.vue | 257 +++++------------- .../Admin/Videos/AdminVideoService.vue | 68 +++++ .../AdminVideoTask.vue} | 0 .../Admin/Videos/AdminVideoTasks.vue | 235 ++++++++++++++++ .../Admin/{ => Videos}/VideoConfig.vue | 0 .../Admin/{ => Videos}/VideoConfigPath.vue | 0 api/web/src/main.js | 25 +- 9 files changed, 401 insertions(+), 226 deletions(-) create mode 100644 api/web/src/components/Admin/Videos/AdminVideoService.vue rename api/web/src/components/Admin/{AdminVideo.vue => Videos/AdminVideoTask.vue} (100%) create mode 100644 api/web/src/components/Admin/Videos/AdminVideoTasks.vue rename api/web/src/components/Admin/{ => Videos}/VideoConfig.vue (100%) rename api/web/src/components/Admin/{ => Videos}/VideoConfigPath.vue (100%) diff --git a/.gitignore b/.gitignore index 4c239258d..60e847496 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ + # Custom *.p12 *.cert @@ -5,6 +6,7 @@ *.crt *.dump .env-* +.docker-* api/assets/* # Logs diff --git a/api/web/src/components/Admin.vue b/api/web/src/components/Admin.vue index c5ad9fb95..d11a1d579 100644 --- a/api/web/src/components/Admin.vue +++ b/api/web/src/components/Admin.vue @@ -6,11 +6,11 @@
- + - diff --git a/api/web/src/components/Admin/AdminVideos.vue b/api/web/src/components/Admin/AdminVideos.vue index 29441fda1..3ae370c3d 100644 --- a/api/web/src/components/Admin/AdminVideos.vue +++ b/api/web/src/components/Admin/AdminVideos.vue @@ -1,200 +1,79 @@ - diff --git a/api/web/src/components/Admin/Videos/AdminVideoService.vue b/api/web/src/components/Admin/Videos/AdminVideoService.vue new file mode 100644 index 000000000..549cc03a6 --- /dev/null +++ b/api/web/src/components/Admin/Videos/AdminVideoService.vue @@ -0,0 +1,68 @@ + + + diff --git a/api/web/src/components/Admin/AdminVideo.vue b/api/web/src/components/Admin/Videos/AdminVideoTask.vue similarity index 100% rename from api/web/src/components/Admin/AdminVideo.vue rename to api/web/src/components/Admin/Videos/AdminVideoTask.vue diff --git a/api/web/src/components/Admin/Videos/AdminVideoTasks.vue b/api/web/src/components/Admin/Videos/AdminVideoTasks.vue new file mode 100644 index 000000000..f6af6e83a --- /dev/null +++ b/api/web/src/components/Admin/Videos/AdminVideoTasks.vue @@ -0,0 +1,235 @@ + + + diff --git a/api/web/src/components/Admin/VideoConfig.vue b/api/web/src/components/Admin/Videos/VideoConfig.vue similarity index 100% rename from api/web/src/components/Admin/VideoConfig.vue rename to api/web/src/components/Admin/Videos/VideoConfig.vue diff --git a/api/web/src/components/Admin/VideoConfigPath.vue b/api/web/src/components/Admin/Videos/VideoConfigPath.vue similarity index 100% rename from api/web/src/components/Admin/VideoConfigPath.vue rename to api/web/src/components/Admin/Videos/VideoConfigPath.vue diff --git a/api/web/src/main.js b/api/web/src/main.js index 721b16b74..a29e8791a 100644 --- a/api/web/src/main.js +++ b/api/web/src/main.js @@ -291,11 +291,26 @@ const router = new VueRouter.createRouter({ },{ path: 'video', name: 'admin-videos', - component: () => import('./components/Admin/AdminVideos.vue') - },{ - path: 'video/:video', - name: 'admin-video', - component: () => import('./components/Admin/AdminVideo.vue') + component: () => import('./components/Admin/AdminVideos.vue'), + children: [{ + path: '', + name: 'admin-video-default', + redirect: () => { + return { name: 'admin-video-service' }; + } + },{ + path: 'service', + name: 'admin-video-service', + component: () => import('./components/Admin/Videos/AdminVideoService.vue') + },{ + path: 'tasks', + name: 'admin-video-tasks', + component: () => import('./components/Admin/Videos/AdminVideoTasks.vue') + },{ + path: 'tasks/:task', + name: 'admin-video', + component: () => import('./components/Admin/Videos/AdminVideoTask.vue') + }] },{ path: 'overlay', name: 'admin-overlays', From 54e227baa69bbf2f961080652d0271ce93cd460a Mon Sep 17 00:00:00 2001 From: ingalls Date: Thu, 12 Dec 2024 14:09:58 -0700 Subject: [PATCH 2/8] First pass at Admin Lease Management --- api/routes/video-lease.ts | 48 ++- api/web/src/components/Admin.vue | 26 +- api/web/src/components/Admin/AdminVideos.vue | 3 +- .../Admin/Videos/AdminVideoLeases.vue | 163 ++++++++++ .../Admin/Videos/AdminVideoService.vue | 14 +- .../Admin/Videos/AdminVideoTasks.vue | 292 ++++++------------ .../components/CloudTAK/util/Breadcrumb.vue | 5 +- api/web/src/main.js | 4 + 8 files changed, 324 insertions(+), 231 deletions(-) create mode 100644 api/web/src/components/Admin/Videos/AdminVideoLeases.vue diff --git a/api/routes/video-lease.ts b/api/routes/video-lease.ts index f065c37c7..3777c176d 100644 --- a/api/routes/video-lease.ts +++ b/api/routes/video-lease.ts @@ -19,6 +19,10 @@ export default async function router(schema: Schema, config: Config) { group: 'VideoLease', description: 'List all video leases', query: Type.Object({ + impersonate: Type.Optional(Type.Union([ + Type.Boolean({ description: 'List all of the given resource, regardless of ACL' }), + Type.String({ description: 'Filter the given resource by a given username' }), + ])), limit: Default.Limit, page: Default.Page, order: Default.Order, @@ -32,21 +36,39 @@ export default async function router(schema: Schema, config: Config) { }) }, async (req, res) => { try { - const user = await Auth.as_user(config, req); + if (req.query.impersonate) { + await Auth.as_user(config, req, { admin: true }); - const list = await config.models.VideoLease.list({ - limit: req.query.limit, - page: req.query.page, - order: req.query.order, - sort: req.query.sort, - where: sql` - name ~* ${req.query.filter} - AND username = ${user.email} - AND ephemeral = ${req.query.ephemeral} - ` - }); + const impersonate: string | null = req.query.impersonate === true ? null : req.query.impersonate; + + console.error(impersonate); - res.json(list); + res.json(await config.models.VideoLease.list({ + limit: req.query.limit, + page: req.query.page, + order: req.query.order, + sort: req.query.sort, + where: sql` + name ~* ${req.query.filter} + AND ephemeral = ${req.query.ephemeral} + AND (${impersonate}::TEXT IS NULL OR username = ${impersonate}::TEXT) + ` + })); + } else { + const user = await Auth.as_user(config, req); + + res.json(await config.models.VideoLease.list({ + limit: req.query.limit, + page: req.query.page, + order: req.query.order, + sort: req.query.sort, + where: sql` + name ~* ${req.query.filter} + AND username = ${user.email} + AND ephemeral = ${req.query.ephemeral} + ` + })); + } } catch (err) { Err.respond(err, res); } diff --git a/api/web/src/components/Admin.vue b/api/web/src/components/Admin.vue index d11a1d579..2f7d8ae99 100644 --- a/api/web/src/components/Admin.vue +++ b/api/web/src/components/Admin.vue @@ -33,7 +33,7 @@ > TAK Server Connection CloudTAK Settings ETL Containers Global Overlays Registered Tasks Connections Layers Data Syncs Users Video Services Export Layer Templates
- + diff --git a/api/web/src/components/Admin/Videos/AdminVideoService.vue b/api/web/src/components/Admin/Videos/AdminVideoService.vue index 549cc03a6..ee574a161 100644 --- a/api/web/src/components/Admin/Videos/AdminVideoService.vue +++ b/api/web/src/components/Admin/Videos/AdminVideoService.vue @@ -1,18 +1,26 @@ - diff --git a/api/web/src/components/Admin/Videos/AdminVideoTasks.vue b/api/web/src/components/Admin/Videos/AdminVideoTasks.vue index 34e1f769d..b5e16a8ff 100644 --- a/api/web/src/components/Admin/Videos/AdminVideoTasks.vue +++ b/api/web/src/components/Admin/Videos/AdminVideoTasks.vue @@ -9,12 +9,22 @@ v-if='list.versions.length' title='Create Server' @click='createServer' - > + > + + + > + +
@@ -47,7 +57,7 @@ v-for='server in list.items' :key='server.id' class='cursor-pointer' - @click='$router.push(`/admin/video/${server.id}`)' + @click='router.push(`/admin/video/tasks/${server.id}`)' > From d0104ef1f3655b306ceb410c5ad3066a7b5aa120 Mon Sep 17 00:00:00 2001 From: ingalls Date: Fri, 13 Dec 2024 08:30:12 -0700 Subject: [PATCH 8/8] More TS Improvements --- .../src/components/Admin/Videos/AdminVideoTask.vue | 13 ++++++++----- .../src/components/Admin/Videos/AdminVideoTasks.vue | 4 ++-- api/web/src/types.ts | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/api/web/src/components/Admin/Videos/AdminVideoTask.vue b/api/web/src/components/Admin/Videos/AdminVideoTask.vue index 3d8c56c3e..c57235088 100644 --- a/api/web/src/components/Admin/Videos/AdminVideoTask.vue +++ b/api/web/src/components/Admin/Videos/AdminVideoTask.vue @@ -8,7 +8,7 @@ @click='$router.push("/admin/video")' />

-