Implement backup functionality with UI and backend support
Co-authored-by: Koha9 <36852125+Koha9@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Playlist, ServerType, ApiResponse, PlexServerConnection, PlexConnectionSettings, PlexLibrary, ReplacementRule, PathMappingConfig, PathMappingMode, PathMappingRules, SyncStrategy, ScheduleSettings } from '../types';
|
||||
import { Playlist, ServerType, ApiResponse, PlexServerConnection, PlexConnectionSettings, PlexLibrary, ReplacementRule, PathMappingConfig, PathMappingMode, PathMappingRules, SyncStrategy, ScheduleSettings, BackupSettings } from '../types';
|
||||
|
||||
const API_BASE = import.meta.env.VITE_API_BASE_URL || '';
|
||||
|
||||
@@ -234,4 +234,31 @@ export const apiService = {
|
||||
const response = await fetch(`${API_BASE}/api/sync/status`);
|
||||
return handleResponse(response);
|
||||
},
|
||||
|
||||
async getBackupSettings(): Promise<ApiResponse<BackupSettings>> {
|
||||
const response = await fetch(`${API_BASE}/api/backup/settings`);
|
||||
const result = await handleResponse<any>(response);
|
||||
if (result.status === 'success') {
|
||||
return {
|
||||
status: 'success',
|
||||
data: {
|
||||
enabled: result.data.enabled ?? false,
|
||||
retentionCount: result.data.retention_count ?? 5,
|
||||
},
|
||||
};
|
||||
}
|
||||
return result as ApiResponse<BackupSettings>;
|
||||
},
|
||||
|
||||
async saveBackupSettings(settings: BackupSettings): Promise<ApiResponse<null>> {
|
||||
const response = await fetch(`${API_BASE}/api/backup/settings`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
enabled: settings.enabled,
|
||||
retention_count: settings.retentionCount,
|
||||
}),
|
||||
});
|
||||
return handleResponse(response);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user