feat: TurboSu initial release - racing telemetry dashboard
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
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 importDashboard(data) { return this.post('/dashboards/import', data); },
|
||||
|
||||
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 importScene(data) { return this.post('/scenes/import', data); },
|
||||
|
||||
async startTelemetry() { return this.post('/telemetry/start'); },
|
||||
async stopTelemetry() { return this.post('/telemetry/stop'); },
|
||||
async getLatestTelemetry() { return this.get('/telemetry/latest'); },
|
||||
|
||||
async installGamePlugin(data) { return this.post('/games/install', data); },
|
||||
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;
|
||||
Reference in New Issue
Block a user