feat: reboot button in Settings with password confirmation

- system.reboot RPC endpoint requires password re-verification
- Uses systemd path unit pattern (tor-helper.sh) for privilege escalation
- 2-second delay before reboot to allow RPC response to reach client
- Clean UI: password input modal, loading state, error feedback

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-20 10:48:06 +00:00
parent c82158c7c8
commit b4d204d1d6
4 changed files with 104 additions and 0 deletions

View File

@@ -991,6 +991,51 @@
</div>
</div>
<!-- Reboot Section -->
<div class="path-option-card px-6 py-6 mt-6">
<div class="flex items-center justify-between">
<div>
<h2 class="text-xl font-semibold text-white/90 mb-1">Reboot</h2>
<p class="text-sm text-white/60">Restart the machine. All containers will restart automatically.</p>
</div>
<button
class="glass-button px-6 py-2 text-sm"
:disabled="rebooting"
@click="showRebootConfirm = true"
>
{{ rebooting ? 'Rebooting...' : 'Reboot' }}
</button>
</div>
</div>
<!-- Reboot Confirmation Modal -->
<Teleport to="body">
<div v-if="showRebootConfirm" class="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm" @click.self="showRebootConfirm = false">
<div class="glass-card px-8 py-8 max-w-md mx-4">
<h3 class="text-lg font-semibold text-white/90 mb-3">Reboot Node</h3>
<p class="text-sm text-white/60 mb-4">Enter your password to confirm reboot. The node will be temporarily unavailable.</p>
<input
v-model="rebootPassword"
type="password"
class="w-full px-3 py-2 rounded-lg bg-white/10 text-white border border-white/20 focus:border-orange-500 focus:ring-1 focus:ring-orange-500 mb-4"
placeholder="Password"
@keydown.enter="performReboot"
/>
<p v-if="rebootError" class="text-sm text-red-400 mb-3">{{ rebootError }}</p>
<div class="flex gap-3 justify-end">
<button class="glass-button" @click="showRebootConfirm = false">Cancel</button>
<button
class="glass-button px-6"
:disabled="rebooting || !rebootPassword"
@click="performReboot"
>
{{ rebooting ? 'Rebooting...' : 'Confirm Reboot' }}
</button>
</div>
</div>
</div>
</Teleport>
<!-- Factory Reset Section -->
<div class="path-option-card px-6 py-6 mt-6 border-red-500/30">
<h2 class="text-xl font-semibold text-red-400/90 mb-3">Factory Reset</h2>
@@ -1048,6 +1093,25 @@ const router = useRouter()
const { t, locale } = useI18n()
const store = useAppStore()
// Reboot
const showRebootConfirm = ref(false)
const rebooting = ref(false)
const rebootPassword = ref('')
const rebootError = ref('')
async function performReboot() {
if (!rebootPassword.value) return
rebooting.value = true
rebootError.value = ''
try {
await rpcClient.call({ method: 'system.reboot', params: { password: rebootPassword.value } })
showRebootConfirm.value = false
rebootPassword.value = ''
} catch (e) {
rebootError.value = e instanceof Error ? e.message : 'Reboot failed'
rebooting.value = false
}
}
// Factory Reset
const showFactoryResetConfirm = ref(false)
const factoryResetLoading = ref(false)