2022-03-06 05:16:31 +01:00
|
|
|
import { rest } from 'msw';
|
|
|
|
import { API_HOST } from '../src/env';
|
|
|
|
|
|
|
|
export const handlers = [
|
2022-05-20 16:27:21 +02:00
|
|
|
rest.get(`${API_HOST}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'] },
|
|
|
|
record: { enabled: true },
|
|
|
|
detect: { width: 1280, height: 720 },
|
|
|
|
snapshots: {},
|
|
|
|
live: { 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'] },
|
|
|
|
record: { enabled: false },
|
|
|
|
detect: { width: 1280, height: 720 },
|
|
|
|
snapshots: {},
|
|
|
|
live: { height: 720 },
|
2022-04-15 14:23:02 +02:00
|
|
|
ui: { dashboard: true, order: 1 },
|
2022-03-06 05:16:31 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}),
|
2022-05-20 16:27:21 +02:00
|
|
|
rest.get(`${API_HOST}api/stats`, (req, res, ctx) => {
|
2022-03-06 05:16:31 +01:00
|
|
|
return res(
|
|
|
|
ctx.status(200),
|
|
|
|
ctx.json({
|
|
|
|
detection_fps: 0.0,
|
|
|
|
detectors: { coral: { detection_start: 0.0, inference_speed: 8.94, pid: 52 } },
|
|
|
|
front: { camera_fps: 5.0, capture_pid: 64, detection_fps: 0.0, pid: 54, process_fps: 0.0, skipped_fps: 0.0 },
|
|
|
|
side: {
|
|
|
|
camera_fps: 6.9,
|
|
|
|
capture_pid: 71,
|
|
|
|
detection_fps: 0.0,
|
|
|
|
pid: 60,
|
|
|
|
process_fps: 0.0,
|
|
|
|
skipped_fps: 0.0,
|
|
|
|
},
|
|
|
|
service: { uptime: 34812, version: '0.8.1-d376f6b' },
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}),
|
2022-05-20 16:27:21 +02:00
|
|
|
rest.get(`${API_HOST}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...',
|
|
|
|
}))
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
];
|