2022-03-06 05:16:31 +01:00
|
|
|
import { rest } from 'msw';
|
2023-10-07 05:20:30 +02:00
|
|
|
// import { API_HOST } from '../src/env';
|
2022-03-06 05:16:31 +01:00
|
|
|
|
|
|
|
export const handlers = [
|
2023-10-07 05:20:30 +02:00
|
|
|
rest.get(`api/config`, (req, res, ctx) => {
|
2022-03-06 05:16:31 +01:00
|
|
|
return res(
|
|
|
|
ctx.status(200),
|
|
|
|
ctx.json({
|
|
|
|
mqtt: {
|
|
|
|
stats_interval: 60,
|
|
|
|
},
|
|
|
|
service: {
|
|
|
|
version: '0.8.3',
|
|
|
|
},
|
|
|
|
cameras: {
|
|
|
|
front: {
|
|
|
|
name: 'front',
|
|
|
|
objects: { track: ['taco', 'cat', 'dog'] },
|
2023-07-01 15:18:33 +02:00
|
|
|
audio: { enabled: false, enabled_in_config: false },
|
2023-05-15 14:36:26 +02:00
|
|
|
record: { enabled: true, enabled_in_config: true },
|
2022-03-06 05:16:31 +01:00
|
|
|
detect: { width: 1280, height: 720 },
|
|
|
|
snapshots: {},
|
2022-11-02 12:36:09 +01:00
|
|
|
restream: { enabled: true, jsmpeg: { height: 720 } },
|
2022-04-15 14:23:02 +02:00
|
|
|
ui: { dashboard: true, order: 0 },
|
2022-03-06 05:16:31 +01:00
|
|
|
},
|
|
|
|
side: {
|
|
|
|
name: 'side',
|
|
|
|
objects: { track: ['taco', 'cat', 'dog'] },
|
2023-07-01 15:18:33 +02:00
|
|
|
audio: { enabled: false, enabled_in_config: false },
|
2023-05-15 14:36:26 +02:00
|
|
|
record: { enabled: false, enabled_in_config: true },
|
2022-03-06 05:16:31 +01:00
|
|
|
detect: { width: 1280, height: 720 },
|
|
|
|
snapshots: {},
|
2022-11-02 12:36:09 +01:00
|
|
|
restream: { enabled: true, jsmpeg: { height: 720 } },
|
2022-04-15 14:23:02 +02:00
|
|
|
ui: { dashboard: true, order: 1 },
|
2022-03-06 05:16:31 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}),
|
2023-10-07 05:20:30 +02:00
|
|
|
rest.get(`api/stats`, (req, res, ctx) => {
|
2022-03-06 05:16:31 +01:00
|
|
|
return res(
|
|
|
|
ctx.status(200),
|
|
|
|
ctx.json({
|
2022-11-13 19:48:14 +01:00
|
|
|
cpu_usages: { 74: {cpu: 6, mem: 6}, 64: { cpu: 5, mem: 5 }, 54: { cpu: 4, mem: 4 }, 71: { cpu: 3, mem: 3}, 60: {cpu: 2, mem: 2}, 72: {cpu: 1, mem: 1} },
|
2022-03-06 05:16:31 +01:00
|
|
|
detection_fps: 0.0,
|
|
|
|
detectors: { coral: { detection_start: 0.0, inference_speed: 8.94, pid: 52 } },
|
2022-11-13 19:48:14 +01:00
|
|
|
front: { camera_fps: 5.0, capture_pid: 64, detection_fps: 0.0, pid: 54, process_fps: 0.0, skipped_fps: 0.0, ffmpeg_pid: 72 },
|
2022-03-06 05:16:31 +01:00
|
|
|
side: {
|
|
|
|
camera_fps: 6.9,
|
|
|
|
capture_pid: 71,
|
|
|
|
detection_fps: 0.0,
|
|
|
|
pid: 60,
|
|
|
|
process_fps: 0.0,
|
|
|
|
skipped_fps: 0.0,
|
2022-11-13 19:48:14 +01:00
|
|
|
ffmpeg_pid: 74,
|
2022-03-06 05:16:31 +01:00
|
|
|
},
|
|
|
|
service: { uptime: 34812, version: '0.8.1-d376f6b' },
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}),
|
2023-10-07 05:20:30 +02:00
|
|
|
rest.get(`api/events`, (req, res, ctx) => {
|
2022-03-06 05:16:31 +01:00
|
|
|
return res(
|
|
|
|
ctx.status(200),
|
|
|
|
ctx.json(
|
|
|
|
new Array(12).fill(null).map((v, i) => ({
|
|
|
|
end_time: 1613257337 + i,
|
|
|
|
has_clip: true,
|
|
|
|
has_snapshot: true,
|
|
|
|
id: i,
|
|
|
|
label: 'person',
|
|
|
|
start_time: 1613257326 + i,
|
|
|
|
top_score: Math.random(),
|
|
|
|
zones: ['front_patio'],
|
|
|
|
thumbnail: '/9j/4aa...',
|
2022-08-25 13:44:34 +02:00
|
|
|
camera: 'camera_name',
|
2022-03-06 05:16:31 +01:00
|
|
|
}))
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}),
|
2023-10-07 05:20:30 +02:00
|
|
|
rest.get(`api/sub_labels`, (req, res, ctx) => {
|
2022-05-29 16:47:43 +02:00
|
|
|
return res(
|
|
|
|
ctx.status(200),
|
|
|
|
ctx.json([
|
|
|
|
'one',
|
|
|
|
'two',
|
|
|
|
])
|
|
|
|
);
|
|
|
|
}),
|
2022-03-06 05:16:31 +01:00
|
|
|
];
|