Add mock mode for web UI development and testing

- Add mock data module with simulated camera search and stream discovery
- Enable mock mode via ?mock=true URL parameter
- Show MOCK MODE indicator when enabled
- Remove statistics cards from discovery screen, keep only progress bar
- Mock mode works independently from Go backend for easier UI testing
This commit is contained in:
eduard256
2025-11-21 22:40:38 +03:00
parent 8036d3e9be
commit 8bf92e6598
5 changed files with 265 additions and 19 deletions
+10 -1
View File
@@ -1,14 +1,23 @@
import { MockCameraSearch } from '../mock/mock-data.js';
export class CameraSearchAPI {
constructor(baseURL = null) {
constructor(baseURL = null, useMock = false) {
// Use relative URLs since API and UI are on the same port
if (!baseURL) {
this.baseURL = '';
} else {
this.baseURL = baseURL;
}
this.useMock = useMock;
this.mockAPI = useMock ? new MockCameraSearch() : null;
}
async search(query, limit = 10) {
// Use mock API if enabled
if (this.useMock) {
return await this.mockAPI.search(query, limit);
}
const response = await fetch(`${this.baseURL}api/v1/cameras/search`, {
method: 'POST',
headers: {