From 8127ec60857755f5b4a264bda4856697c80e2e99 Mon Sep 17 00:00:00 2001 From: ingalls Date: Wed, 18 Dec 2024 11:28:23 -0700 Subject: [PATCH 1/2] Video Lease Channels --- api/routes/video-lease.ts | 10 +++++- .../Admin/Videos/AdminVideoLeases.vue | 2 +- .../src/components/CloudTAK/Menu/Videos.vue | 34 +++++++++++++++---- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/api/routes/video-lease.ts b/api/routes/video-lease.ts index 56f46ecfe..67dd4c054 100644 --- a/api/routes/video-lease.ts +++ b/api/routes/video-lease.ts @@ -10,6 +10,7 @@ import { randomUUID } from 'node:crypto'; import { StandardResponse, VideoLeaseResponse } from '../lib/types.js'; import ECSVideoControl, { Protocols } from '../lib/control/video-service.js'; import * as Default from '../lib/limits.js'; +import TAKAPI, { APIAuthCertificate } from '../lib/tak-api.js'; export default async function router(schema: Schema, config: Config) { const videoControl = new ECSVideoControl(config); @@ -55,6 +56,13 @@ export default async function router(schema: Schema, config: Config) { } else { const user = await Auth.as_user(config, req); + const profile = await config.models.Profile.from(user.email); + const api = await TAKAPI.init(new URL(String(config.server.api)), new APIAuthCertificate(profile.auth.cert, profile.auth.key)); + + const groups = (await api.Group.list({ useCache: true })).data.map((group) => { + return group.name; + }); + res.json(await config.models.VideoLease.list({ limit: req.query.limit, page: req.query.page, @@ -62,7 +70,7 @@ export default async function router(schema: Schema, config: Config) { sort: req.query.sort, where: sql` name ~* ${req.query.filter} - AND username = ${user.email} + AND (username = ${user.email} OR channel IN ${groups}) AND ephemeral = ${req.query.ephemeral} ` })); diff --git a/api/web/src/components/Admin/Videos/AdminVideoLeases.vue b/api/web/src/components/Admin/Videos/AdminVideoLeases.vue index 52a1cc31d..efbe1b817 100644 --- a/api/web/src/components/Admin/Videos/AdminVideoLeases.vue +++ b/api/web/src/components/Admin/Videos/AdminVideoLeases.vue @@ -142,7 +142,7 @@ const list = ref({ items: [] }); -watch(paging, async () => { +watch(paging.value, async () => { await fetchList(); }); diff --git a/api/web/src/components/CloudTAK/Menu/Videos.vue b/api/web/src/components/CloudTAK/Menu/Videos.vue index f7c244735..d7082e4bd 100644 --- a/api/web/src/components/CloudTAK/Menu/Videos.vue +++ b/api/web/src/components/CloudTAK/Menu/Videos.vue @@ -86,6 +86,10 @@ label='Video Connections' :create='false' /> +