Phase 2: services/web-ui/public/js/api.js
This commit is contained in:
parent
3aee8c41f5
commit
3f25ea1124
1 changed files with 99 additions and 0 deletions
|
|
@ -346,3 +346,102 @@ function throttle(func, limit) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// UPLOAD API CALLS
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize a multipart upload
|
||||||
|
*/
|
||||||
|
async function initUpload(data) {
|
||||||
|
return api('/upload/init', { method: 'POST', body: JSON.stringify(data) });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Complete a multipart upload
|
||||||
|
*/
|
||||||
|
async function completeUpload(data) {
|
||||||
|
return api('/upload/complete', { method: 'POST', body: JSON.stringify(data) });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abort an ongoing upload
|
||||||
|
*/
|
||||||
|
async function abortUpload(data) {
|
||||||
|
return api('/upload/abort', { method: 'POST', body: JSON.stringify(data) });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload a file part (FormData, no JSON content-type)
|
||||||
|
*/
|
||||||
|
async function uploadPart(formData) {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/v1/upload/part', { method: 'POST', body: formData });
|
||||||
|
if (!response.ok) throw new Error(`Upload part failed: ${response.status}`);
|
||||||
|
const data = await response.json();
|
||||||
|
return { success: true, data };
|
||||||
|
} catch (error) {
|
||||||
|
return { success: false, error: error.message };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple upload for small files (under 50MB)
|
||||||
|
*/
|
||||||
|
async function simpleUpload(formData) {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/v1/upload/simple', { method: 'POST', body: formData });
|
||||||
|
if (!response.ok) throw new Error(`Upload failed: ${response.status}`);
|
||||||
|
const data = await response.json();
|
||||||
|
return { success: true, data };
|
||||||
|
} catch (error) {
|
||||||
|
return { success: false, error: error.message };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// RECORDER API CALLS
|
||||||
|
// ============================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all recorder instances
|
||||||
|
*/
|
||||||
|
async function getRecorders() {
|
||||||
|
return api('/recorders');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new recorder instance
|
||||||
|
*/
|
||||||
|
async function createRecorder(data) {
|
||||||
|
return api('/recorders', { method: 'POST', body: JSON.stringify(data) });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a recorder by ID
|
||||||
|
*/
|
||||||
|
async function startRecorder(id) {
|
||||||
|
return api(`/recorders/${id}/start`, { method: 'POST' });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop a recorder by ID
|
||||||
|
*/
|
||||||
|
async function stopRecorder(id) {
|
||||||
|
return api(`/recorders/${id}/stop`, { method: 'POST' });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a recorder by ID
|
||||||
|
*/
|
||||||
|
async function deleteRecorder(id) {
|
||||||
|
return api(`/recorders/${id}`, { method: 'DELETE' });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get live status for a recorder
|
||||||
|
*/
|
||||||
|
async function getRecorderStatus(id) {
|
||||||
|
return api(`/recorders/${id}/status`);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue