Refactor video streaming feature and update dependencies

- Replaced npm ci with npm install in docker-compose for better package management.
- Introduced remote component loading for the VideoStreamingPage with error handling.
- Updated the title in index.html to "Experiments Dashboard" for clarity.
- Added new video remote service configuration in docker-compose for improved integration.
- Removed deprecated files and components related to the video streaming feature to streamline the codebase.
- Updated package.json and package-lock.json to include @originjs/vite-plugin-federation for module federation support.
This commit is contained in:
salirezav
2025-10-30 15:36:19 -04:00
parent a88301cb97
commit 36b9ca6525
102 changed files with 4656 additions and 13376 deletions

View File

@@ -0,0 +1,28 @@
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
const BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000'
async function request<T>(path: string, method: HttpMethod = 'GET', body?: unknown): Promise<T> {
const res = await fetch(`${BASE_URL}${path}`, {
method,
headers: {
'Content-Type': 'application/json'
},
body: body ? JSON.stringify(body) : undefined,
})
if (!res.ok) {
const text = await res.text().catch(() => '')
throw new Error(text || `Request failed: ${res.status}`)
}
return (await res.json()) as T
}
export const apiClient = {
get: <T>(path: string) => request<T>(path, 'GET'),
post: <T>(path: string, body?: unknown) => request<T>(path, 'POST', body),
put: <T>(path: string, body?: unknown) => request<T>(path, 'PUT', body),
patch: <T>(path: string, body?: unknown) => request<T>(path, 'PATCH', body),
delete: <T>(path: string) => request<T>(path, 'DELETE'),
}

View File

@@ -0,0 +1,4 @@
export { apiClient } from './client'

View File

@@ -0,0 +1,30 @@
import { apiClient } from './client'
import type { VideoListParams, VideoListResponse } from '../types/video'
const BASE = (import.meta as any).env?.VITE_VISION_API_URL || '/api'
export const videoApi = {
async list(params: VideoListParams = {}): Promise<VideoListResponse> {
const search = new URLSearchParams()
Object.entries(params).forEach(([k, v]) => {
if (v !== undefined && v !== null) search.append(k, String(v))
})
const qs = search.toString()
return apiClient.get(`${BASE}/videos/${qs ? `?${qs}` : ''}`)
},
streamingUrl(fileId: string): string {
return `${BASE}/videos/${fileId}/stream`
},
thumbnailUrl(fileId: string, params: { timestamp?: number; width?: number; height?: number } = {}): string {
const search = new URLSearchParams()
Object.entries(params).forEach(([k, v]) => {
if (v !== undefined && v !== null) search.append(k, String(v))
})
const qs = search.toString()
return `${BASE}/videos/${fileId}/thumbnail${qs ? `?${qs}` : ''}`
}
}