mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-02 13:15:17 +09:00
Shared ProtectionPanel (status, schedule, history) rendered for WordPress (Backups tab + Settings) and Services (Settings → Backups), plus a calendar view, detail/restore drawers, and storage-cost columns/settings/KPIs on the global Backups page. - components/backups: ProtectionPanel, ProtectionStatusCard, ScheduleCard, BackupHistoryList, BackupCalendar, BackupDetailDrawer, RestoreDrawer, format helpers - api/backupProtection: generic policy/runs methods over targetType - WordPressDetail + service-detail SettingsTab render the shared panel - Backups page: cost rates settings, Site/Cost columns, cost KPI cards Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
49 lines
1.7 KiB
JavaScript
49 lines
1.7 KiB
JavaScript
// Backup "Protection" policy + runs API.
|
|
//
|
|
// Generic over the target so the shared ProtectionPanel can drive both
|
|
// WordPress sites and applications with one set of methods. The backend mounts
|
|
// the same endpoint shapes under /wordpress/sites/:id and /apps/:id.
|
|
|
|
function policyBase(targetType, targetId) {
|
|
return targetType === 'wordpress_site'
|
|
? `/wordpress/sites/${targetId}/backup-policy`
|
|
: `/apps/${targetId}/backup-policy`;
|
|
}
|
|
|
|
function runsBase(targetType, targetId) {
|
|
return targetType === 'wordpress_site'
|
|
? `/wordpress/sites/${targetId}/backups`
|
|
: `/apps/${targetId}/backups`;
|
|
}
|
|
|
|
export async function getBackupPolicy(targetType, targetId) {
|
|
return this.request(policyBase(targetType, targetId));
|
|
}
|
|
|
|
export async function updateBackupPolicy(targetType, targetId, policy) {
|
|
return this.request(policyBase(targetType, targetId), { method: 'PUT', body: policy });
|
|
}
|
|
|
|
export async function triggerBackup(targetType, targetId) {
|
|
return this.request(runsBase(targetType, targetId), { method: 'POST' });
|
|
}
|
|
|
|
export async function getBackupRuns(targetType, targetId) {
|
|
return this.request(runsBase(targetType, targetId));
|
|
}
|
|
|
|
export async function restoreBackupRun(targetType, targetId, runId, options) {
|
|
return this.request(`${runsBase(targetType, targetId)}/${runId}/restore`, {
|
|
method: 'POST',
|
|
body: options || {},
|
|
});
|
|
}
|
|
|
|
export async function verifyBackupRun(targetType, targetId, runId) {
|
|
return this.request(`${runsBase(targetType, targetId)}/${runId}/verify`, { method: 'POST' });
|
|
}
|
|
|
|
export async function deleteBackupRun(targetType, targetId, runId) {
|
|
return this.request(`${runsBase(targetType, targetId)}/${runId}`, { method: 'DELETE' });
|
|
}
|