63e3c8d607
- Each dashboard is now a self-contained folder: manifest.json + index.html - Auto-scan dashboards/ and data/dashboards/ on startup - Export: .tsd (dashboards), .tss (scenes), .tsp (game plugins) - all zip format - Dashboard index.html is complete standalone page (WS + data binding) - Aspect ratio constraints handled in each dashboard's own JS - Removed template-based dashboard rendering in favor of static serve - Import via file upload endpoints, export via direct file download
64 lines
2.5 KiB
JavaScript
64 lines
2.5 KiB
JavaScript
const API = {
|
|
_base: '/api',
|
|
|
|
async get(path) {
|
|
const res = await fetch(`${this._base}${path}`);
|
|
return res.json();
|
|
},
|
|
|
|
async post(path, data) {
|
|
const res = await fetch(`${this._base}${path}`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(data),
|
|
});
|
|
return res.json();
|
|
},
|
|
|
|
async put(path, data) {
|
|
const res = await fetch(`${this._base}${path}`, {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(data),
|
|
});
|
|
return res.json();
|
|
},
|
|
|
|
async del(path) {
|
|
const res = await fetch(`${this._base}${path}`, { method: 'DELETE' });
|
|
return res.json();
|
|
},
|
|
|
|
async getStatus() { return this.get('/status'); },
|
|
async getConfig() { return this.get('/config'); },
|
|
async updateConfig(data) { return this.put('/config', data); },
|
|
|
|
async getGames() { return this.get('/games'); },
|
|
|
|
async getDashboards(category) { return this.get(`/dashboards?category=${category || 'all'}`); },
|
|
async getCategories() { return this.get('/dashboards/categories'); },
|
|
async getDashboard(id) { return this.get(`/dashboards/${id}`); },
|
|
async getDashboardTemplate(id) { return this.get(`/dashboards/${id}/template`); },
|
|
async createDashboard(data) { return this.post('/dashboards', data); },
|
|
async updateDashboard(id, data) { return this.put(`/dashboards/${id}`, data); },
|
|
async deleteDashboard(id) { return this.del(`/dashboards/${id}`); },
|
|
async exportDashboard(id) { return this.get(`/dashboards/${id}/export`); },
|
|
|
|
async getScenes(gameId) { return this.get(`/scenes?game_id=${gameId || ''}`); },
|
|
async getScene(id) { return this.get(`/scenes/${id}`); },
|
|
async createScene(data) { return this.post('/scenes', data); },
|
|
async updateScene(id, data) { return this.put(`/scenes/${id}`, data); },
|
|
async deleteScene(id) { return this.del(`/scenes/${id}`); },
|
|
async exportScene(id) { return this.get(`/scenes/${id}/export`); },
|
|
|
|
async startTelemetry() { return this.post('/telemetry/start'); },
|
|
async stopTelemetry() { return this.post('/telemetry/stop'); },
|
|
async getLatestTelemetry() { return this.get('/telemetry/latest'); },
|
|
|
|
async removeGamePlugin(id) { return this.del(`/games/${id}`); },
|
|
async exportGamePlugin(id) { return this.get(`/games/${id}/export`); },
|
|
async reloadGamePlugins() { return this.post('/games/reload'); },
|
|
};
|
|
|
|
window.API = API;
|