se agregaron nuevas caracteristicas
This commit is contained in:
@@ -22,6 +22,7 @@ export interface ClientItem {
|
||||
id: number;
|
||||
client_code: string;
|
||||
name: string;
|
||||
alias?: string;
|
||||
hostname?: string;
|
||||
os_info?: string;
|
||||
ip_address?: string;
|
||||
@@ -80,6 +81,15 @@ export interface EventLogItem {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface SystemSettingsResponse {
|
||||
storage_root: string;
|
||||
global_quota_gb: number;
|
||||
default_client_quota_gb: number;
|
||||
default_keep_daily: number;
|
||||
default_keep_weekly: number;
|
||||
default_keep_monthly: number;
|
||||
}
|
||||
|
||||
export const getAuthToken = (): string | null => {
|
||||
return localStorage.getItem('oed_token');
|
||||
};
|
||||
@@ -156,8 +166,21 @@ export const api = {
|
||||
}),
|
||||
revokeClient: (clientId: number) =>
|
||||
request<{ message: string }>(`/clients/${clientId}/revoke`, { method: 'POST' }),
|
||||
generateReRegisterCode: (clientId: number) =>
|
||||
request<{ code: string; expires_at: string; client_id: number }>(`/clients/${clientId}/re-register`, { method: 'POST' }),
|
||||
deleteClient: (clientId: number) =>
|
||||
request<{ message: string }>(`/clients/${clientId}`, { method: 'DELETE' }),
|
||||
updateClient: (clientId: number, data: { alias?: string; storage_quota_bytes?: number }) =>
|
||||
request<ClientItem>(`/clients/${clientId}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(data),
|
||||
}),
|
||||
getSettings: () => request<SystemSettingsResponse>('/settings'),
|
||||
updateSettings: (data: Partial<SystemSettingsResponse>) =>
|
||||
request<SystemSettingsResponse>('/settings', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(data),
|
||||
}),
|
||||
|
||||
// Jobs
|
||||
getJobs: (clientId?: number) =>
|
||||
@@ -189,6 +212,25 @@ export const api = {
|
||||
if (jobId) params.append('job_id', jobId.toString());
|
||||
return request<BackupFileItem[]>(`/backups?${params.toString()}`);
|
||||
},
|
||||
downloadBackup: async (backup: BackupFileItem) => {
|
||||
const token = getAuthToken();
|
||||
const response = await fetch(`${API_BASE}/backups/${backup.id}/download`, {
|
||||
headers: token ? { 'Authorization': `Bearer ${token}` } : {},
|
||||
});
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => ({ detail: 'Network error' }));
|
||||
throw new Error(errorData.detail || `Download failed with status ${response.status}`);
|
||||
}
|
||||
const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = backup.filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
},
|
||||
deleteBackup: (backupId: number) =>
|
||||
request<{ message: string }>(`/backups/${backupId}`, { method: 'DELETE' }),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user