Spaces:
Paused
Paused
File size: 9,500 Bytes
8d1819a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
<html>
<head>
<title>Restore Backup</title>
<script type="module">
import { store } from "/components/settings/backup/backup-store.js";
</script>
</head>
<body>
<div x-data>
<template x-if="$store.backupStore">
<div x-init="$store.backupStore.initRestore()" x-destroy="$store.backupStore.onClose()">
<!-- File Upload Section -->
<div class="upload-section">
<label for="backup-file" class="upload-label">
Select Backup File (.zip)
</label>
<input type="file" id="backup-file" accept=".zip"
@change="$store.backupStore.handleFileUpload($event)">
</div>
<!-- Warning Message (only show when backup file is loaded) -->
<div x-show="$store.backupStore.backupMetadata" class="restore-warning">
<span class="warning-icon">⚠️</span>
<span class="warning-text">After restoring a backup you will have to restart Agent-Zero to fully load the backed-up configuration (button in the left pane).</span>
<span class="warning-icon">⚠️</span>
</div>
<!-- File Conflict Policy (Dropdown) -->
<div x-show="$store.backupStore.backupMetadata" class="overwrite-policy">
<label class="policy-label">
<span class="policy-label-text">File Conflict Policy:</span>
<select x-model="$store.backupStore.overwritePolicy" class="policy-dropdown">
<option value="overwrite">Overwrite existing files</option>
<option value="skip">Skip existing files</option>
<option value="backup">Backup existing files (.backup.timestamp)</option>
</select>
</label>
</div>
<!-- Clean Before Restore Option -->
<div x-show="$store.backupStore.backupMetadata" class="clean-before-restore">
<label class="checkbox-label">
<input type="checkbox" x-model="$store.backupStore.cleanBeforeRestore">
<span class="checkbox-text">Clean before restore (delete existing files matching original backup patterns)</span>
</label>
<div class="clean-description">
When enabled, all existing files matching the original backup patterns will be deleted before restoring files from the archive. This ensures a completely clean restore state.
</div>
</div>
<!-- Loading indicator -->
<div x-show="$store.backupStore.loading" class="restore-loading">
<span x-text="$store.backupStore.loadingMessage || 'Processing...'"></span>
</div>
<!-- Error display -->
<div x-show="$store.backupStore.error" class="restore-error">
<span x-text="$store.backupStore.error"></span>
</div>
<!-- Success display -->
<div x-show="$store.backupStore.restoreResult" class="restore-result">
<h4>Restore Complete</h4>
<div class="result-stats">
<div x-show="$store.backupStore.restoreResult?.deleted_files?.length > 0">Deleted: <span x-text="$store.backupStore.restoreResult?.deleted_files?.length || 0"></span></div>
<div>Restored: <span x-text="$store.backupStore.restoreResult?.restored_files?.length || 0"></span></div>
<div>Skipped: <span x-text="$store.backupStore.restoreResult?.skipped_files?.length || 0"></span></div>
<div>Errors: <span x-text="$store.backupStore.restoreResult?.errors?.length || 0"></span></div>
</div>
</div>
<!-- Header with buttons (following MCP servers pattern) -->
<h3 x-show="$store.backupStore.backupMetadata">Restore Configuration JSON
<button class="btn slim" style="margin-left: 0.5em;"
@click="$store.backupStore.formatJson()">Format</button>
<button class="btn slim" style="margin-left: 0.5em;"
@click="$store.backupStore.resetToOriginalMetadata()">Reset</button>
<button class="btn slim" style="margin-left: 0.5em;"
@click="$store.backupStore.dryRun()" :disabled="$store.backupStore.loading">Dry Run</button>
<button class="btn slim primary" style="margin-left: 0.5em;"
@click="$store.backupStore.performRestore()" :disabled="$store.backupStore.loading">Restore Files</button>
</h3>
<!-- JSON Editor (upper part) -->
<div x-show="$store.backupStore.backupMetadata" id="restore-metadata-editor"></div>
<!-- File Operations Display (lower part) -->
<h3 x-show="$store.backupStore.backupMetadata" id="restore-operations">File Operations</h3>
<!-- File listing textarea -->
<div x-show="$store.backupStore.backupMetadata" class="file-operations-container">
<textarea id="restore-file-list"
x-model="$store.backupStore.fileOperationsLog"
readonly
placeholder="File operations will be displayed here..."></textarea>
</div>
</div>
</template>
</div>
<style>
.upload-section {
margin-bottom: 1.5rem;
padding: 1rem;
border: 2px dashed var(--color-border);
border-radius: 4px;
text-align: center;
}
.upload-label {
display: block;
margin-bottom: 0.5rem;
font-weight: 600;
}
.restore-loading {
width: 100%;
text-align: center;
margin-top: 2rem;
margin-bottom: 2rem;
color: var(--color-secondary);
}
#restore-metadata-editor {
width: 100%;
height: 25em;
}
.file-operations-container {
margin-top: 0.5em;
margin-bottom: 1em;
}
#restore-file-list {
width: 100%;
height: 15em;
font-family: monospace;
font-size: 0.85em;
background: var(--color-input);
color: var(--color-text);
border: 1px solid var(--color-border);
border-radius: 4px;
padding: 0.5em;
resize: vertical;
}
.overwrite-policy {
margin: 1rem 0;
}
.policy-label {
display: flex;
align-items: center;
gap: 0.5rem;
margin: 0.5rem 0;
}
.clean-before-restore {
margin: 1rem 0;
padding: 0.75rem;
background: var(--color-input);
border: 1px solid var(--color-border);
border-radius: 4px;
}
.checkbox-label {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.5rem;
cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
width: 1rem;
height: 1rem;
}
.checkbox-text {
font-weight: 600;
color: var(--color-text);
}
.clean-description {
font-size: 0.85rem;
color: var(--color-secondary);
line-height: 1.4;
margin-left: 1.5rem;
}
.policy-label-text {
font-weight: 600;
white-space: nowrap;
}
.policy-dropdown {
flex: 1;
padding: 0.5rem;
border: 1px solid var(--color-border);
border-radius: 4px;
background: var(--color-input);
color: var(--color-text);
font-size: 0.9rem;
}
.restore-error {
color: var(--color-error);
margin: 0.5rem 0;
padding: 0.5rem;
background: var(--color-input);
border: 1px solid var(--color-error);
border-radius: 4px;
}
.restore-result {
margin: 1rem 0;
padding: 1rem;
background: var(--color-secondary);
border-radius: 4px;
}
.result-stats {
display: flex;
gap: 1rem;
margin-top: 0.5rem;
}
.restore-warning {
display: flex;
align-items: center;
justify-content: center;
margin: 1rem 0;
padding: 1rem;
background: var(--color-background);
border: 2px solid #f1c40f;
border-radius: 4px;
color: var(--color-text);
}
.warning-icon {
font-size: 1.2em;
margin: 0 1rem;
color: #f39c12;
}
.warning-text {
text-align: center;
font-weight: 500;
flex: 1;
}
</style>
</body>
</html>
|