Skip to content

Commit

Permalink
Update Lints
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Aug 26, 2024
1 parent 8b784f2 commit 5b6cb1f
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 87 deletions.
72 changes: 40 additions & 32 deletions api/routes/video-lease.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Type } from '@sinclair/typebox'
import { Static, Type } from '@sinclair/typebox'
import moment from 'moment';
import Schema from '@openaddresses/batch-schema';
import Err from '@openaddresses/batch-error';
Expand All @@ -11,6 +11,30 @@ import { StandardResponse, VideoLeaseResponse } from '../lib/types.js';
import ECSVideoControl from '../lib/control/video-service.js';
import * as Default from '../lib/limits.js';


export const Protocols = Type.Object({
rtmp: Type.Optional(Type.Object({
name: Type.String(),
url: Type.String()
})),
rtsp: Type.Optional(Type.Object({
name: Type.String(),
url: Type.String()
})),
webrtc: Type.Optional(Type.Object({
name: Type.String(),
url: Type.String()
})),
hls: Type.Optional(Type.Object({
name: Type.String(),
url: Type.String()
})),
srt: Type.Optional(Type.Object({
name: Type.String(),
url: Type.String()
}))
})

export default async function router(schema: Schema, config: Config) {
const videoControl = new ECSVideoControl(config);

Expand Down Expand Up @@ -59,42 +83,26 @@ export default async function router(schema: Schema, config: Config) {
}),
res: Type.Object({
lease: VideoLeaseResponse,
protocols: Type.Object({
rtmp: Type.Optional(Type.Object({
name: Type.String(),
url: Type.String()
})),
rtsp: Type.Optional(Type.Object({
name: Type.String(),
url: Type.String()
})),
webrtc: Type.Optional(Type.Object({
name: Type.String(),
url: Type.String()
})),
hls: Type.Optional(Type.Object({
name: Type.String(),
url: Type.String()
})),
srt: Type.Optional(Type.Object({
name: Type.String(),
url: Type.String()
}))
})
protocols: Protocols
})
}, async (req, res) => {
try {
const user = await Auth.as_user(config, req);

const lease = await config.models.VideoLease.from(req.params.lease);
let lease;
if (user.access === AuthUserAccess.ADMIN) {
lease = await config.models.VideoLease.from(req.params.lease);
} else {
lease = await config.models.VideoLease.from(req.params.lease);

if (lease.username !== user.email) {
throw new Err(400, null, 'You can only delete a lease you created');
}
}

const protocols: Static<typeof Protocols> = {};
const c = await videoControl.configuration();
if (!c.configured) return res.json({ lease });

const protocols: {
rtsp?: { name: string; url: string }
rtmp?: { name: string; url: string }
} = {};
if (!c.configured) return res.json({ lease, protocols });

if (c.config.rtsp) {
// Format: rtsp://localhost:8554/mystream
Expand Down Expand Up @@ -219,7 +227,7 @@ export default async function router(schema: Schema, config: Config) {
if (lease.username === user.email) {
lease = await config.models.VideoLease.commit(req.params.lease, req.body);
} else {
throw new Err(400, null, 'You can only delete a least you created');
throw new Err(400, null, 'You can only delete a lease you created');
}
}

Expand Down Expand Up @@ -249,7 +257,7 @@ export default async function router(schema: Schema, config: Config) {
if (lease.username === user.email) {
await videoControl.delete(req.params.lease);
} else {
throw new Err(400, null, 'You can only delete a least you created');
throw new Err(400, null, 'You can only delete a lease you created');
}
}

Expand Down
93 changes: 49 additions & 44 deletions api/test/fixtures/get_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,115 +399,115 @@
"query": true,
"res": true
},
"POST /import": {
"GET /iconset": {
"body": false,
"query": true,
"res": true
},
"POST /iconset": {
"body": true,
"query": false,
"res": true
},
"PUT /import/:import": {
"body": false,
"PATCH /iconset/:iconset": {
"body": true,
"query": false,
"res": true
},
"PUT /import": {
"GET /iconset/:iconset": {
"body": false,
"query": false,
"query": true,
"res": true
},
"GET /import/:import": {
"DELETE /iconset/:iconset": {
"body": false,
"query": false,
"res": true
},
"PATCH /import/:import": {
"POST /iconset/:iconset/icon": {
"body": true,
"query": false,
"res": true
},
"DELETE /import/:import": {
"body": false,
"query": false,
"res": true
},
"GET /import": {
"GET /icon": {
"body": false,
"query": true,
"res": true
},
"POST /import/:import/batch": {
"GET /iconset/:iconset/icon/:icon": {
"body": false,
"query": false,
"res": true
},
"GET /import/:import/batch": {
"body": false,
"PATCH /iconset/:iconset/icon/:icon": {
"body": true,
"query": false,
"res": true
},
"GET /iconset": {
"DELETE /iconset/:iconset/icon/:icon": {
"body": false,
"query": true,
"res": true
},
"POST /iconset": {
"body": true,
"query": false,
"res": true
},
"PATCH /iconset/:iconset": {
"body": true,
"query": false,
"res": true
"GET /iconset/:iconset/icon/:icon/raw": {
"body": false,
"query": true,
"res": false
},
"GET /iconset/:iconset": {
"GET /icon/sprite:size?.json": {
"body": false,
"query": true,
"res": true
"res": false
},
"DELETE /iconset/:iconset": {
"GET /icon/sprite:size?.png": {
"body": false,
"query": true,
"res": false
},
"POST /import": {
"body": true,
"query": false,
"res": true
},
"POST /iconset/:iconset/icon": {
"body": true,
"PUT /import/:import": {
"body": false,
"query": false,
"res": true
},
"GET /icon": {
"PUT /import": {
"body": false,
"query": true,
"query": false,
"res": true
},
"GET /iconset/:iconset/icon/:icon": {
"GET /import/:import": {
"body": false,
"query": false,
"res": true
},
"PATCH /iconset/:iconset/icon/:icon": {
"PATCH /import/:import": {
"body": true,
"query": false,
"res": true
},
"DELETE /iconset/:iconset/icon/:icon": {
"DELETE /import/:import": {
"body": false,
"query": false,
"res": true
},
"GET /iconset/:iconset/icon/:icon/raw": {
"GET /import": {
"body": false,
"query": true,
"res": false
"res": true
},
"GET /icon/sprite:size?.json": {
"POST /import/:import/batch": {
"body": false,
"query": true,
"res": false
"query": false,
"res": true
},
"GET /icon/sprite:size?.png": {
"GET /import/:import/batch": {
"body": false,
"query": true,
"res": false
"query": false,
"res": true
},
"GET /layer": {
"body": false,
Expand Down Expand Up @@ -934,6 +934,11 @@
"query": true,
"res": true
},
"GET /video/lease/:lease": {
"body": false,
"query": false,
"res": true
},
"POST /video/lease": {
"body": true,
"query": false,
Expand Down
10 changes: 8 additions & 2 deletions api/web/src/components/CloudTAK/Menu/Import.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@
desc='Running Import'
/>
<template v-if='batch.logs.length'>
<label for='logs' class='subheader'>Import Logs</label>
<pre id='logs' v-text='batch.logs.map((log) => { return log.message }).join("\n")'></pre>
<label
for='logs'
class='subheader'
>Import Logs</label>
<pre
id='logs'
v-text='batch.logs.map((log) => { return log.message }).join("\n")'
/>
</template>
</template>
<template v-else-if='imported.status === "Fail"'>
Expand Down
2 changes: 1 addition & 1 deletion api/web/src/components/CloudTAK/Menu/Videos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<div
v-for='l in leases.items'
:key='l.id'
@click='lease = l'
class='col-12 py-2 px-3 d-flex align-items-center hover-dark cursor-pointer'
@click='lease = l'
>
<div class='row g-0 w-100'>
<div class='d-flex align-items-center w-100'>
Expand Down
24 changes: 16 additions & 8 deletions api/web/src/components/CloudTAK/Menu/Videos/VideoLeaseModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
</div>
</div>

<TablerLoading v-if='loading'/>
<div v-else class='modal-body row'>
<TablerLoading v-if='loading' />
<div
v-else
class='modal-body row'
>
<div
class='col-12'
>
Expand Down Expand Up @@ -68,23 +71,28 @@
class='col-12'
>
<TablerInput
:disabled='editLease.id'
v-model='editLease.stream_user'
:disabled='editLease.id'
label='Stream Username'
/>

<TablerInput
:disabled='editLease.id'
v-model='editLease.stream_pass'
:disabled='editLease.id'
label='Stream Password'
/>
</div>

<template v-if='Object.keys(protocols).length'>
<div class='subheader pt-4'>Video Streaming Protocols</div>
<div v-for='protocol in protocols' class='pt-2'>
<div v-text='protocol.name'/>
<CopyField :text='protocol.url'/>
<div class='subheader pt-4'>
Video Streaming Protocols
</div>
<div
v-for='protocol in protocols'
class='pt-2'
>
<div v-text='protocol.name' />
<CopyField :text='protocol.url' />
</div>
</template>
</div>
Expand Down

0 comments on commit 5b6cb1f

Please sign in to comment.