Improve radio restart buttons

This commit is contained in:
Jack Kingsman
2026-01-17 21:41:37 -08:00
parent 40d2e2781b
commit 74f2e8556d
6 changed files with 71 additions and 64 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -13,8 +13,8 @@
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="manifest" href="/site.webmanifest" />
<script type="module" crossorigin src="/assets/index-DvZkZ2Ie.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-D2NVJvYv.css">
<script type="module" crossorigin src="/assets/index-Z2aWr4hK.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BpFnqQF8.css">
</head>
<body>
<div id="root"></div>

View File

@@ -12,7 +12,6 @@ import { Input } from './ui/input';
import { Label } from './ui/label';
import { Button } from './ui/button';
import { Separator } from './ui/separator';
import { Alert, AlertDescription } from './ui/alert';
import { toast } from './ui/sonner';
import { api } from '../api';
import { formatTime } from '../utils/messageParser';
@@ -191,11 +190,16 @@ export function SettingsModal({
},
};
await onSave(update);
toast.success('Radio config saved');
toast.success('Radio config saved, rebooting...');
setLoading(false);
setRebooting(true);
await onReboot();
onClose();
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to save');
} finally {
setLoading(false);
} finally {
setRebooting(false);
}
};
@@ -242,11 +246,16 @@ export function SettingsModal({
try {
await onSetPrivateKey(privateKey.trim());
setPrivateKey('');
toast.success('Private key set');
toast.success('Private key set, rebooting...');
setLoading(false);
setRebooting(true);
await onReboot();
onClose();
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to set private key');
} finally {
setLoading(false);
} finally {
setRebooting(false);
}
};
@@ -463,8 +472,12 @@ export function SettingsModal({
{error && <div className="text-sm text-destructive">{error}</div>}
<Button onClick={handleSaveRadioConfig} disabled={loading} className="w-full">
{loading ? 'Saving...' : 'Save Radio Config'}
<Button
onClick={handleSaveRadioConfig}
disabled={loading || rebooting}
className="w-full"
>
{loading || rebooting ? 'Saving & Rebooting...' : 'Save Radio Config & Reboot'}
</Button>
</TabsContent>
@@ -503,30 +516,13 @@ export function SettingsModal({
/>
<Button
onClick={handleSetPrivateKey}
disabled={loading || !privateKey.trim()}
disabled={loading || rebooting || !privateKey.trim()}
className="w-full"
>
Set Private Key
{loading || rebooting ? 'Setting & Rebooting...' : 'Set Private Key & Reboot'}
</Button>
</div>
<Separator />
<Alert variant="warning">
<AlertDescription>
Changes to name or private key require a radio reboot to take effect.
</AlertDescription>
</Alert>
<Button
variant="outline"
onClick={handleReboot}
disabled={rebooting || loading}
className="w-full border-yellow-500/50 text-yellow-200 hover:bg-yellow-500/10"
>
{rebooting ? 'Rebooting...' : 'Reboot Radio'}
</Button>
{error && <div className="text-sm text-destructive">{error}</div>}
</TabsContent>
@@ -570,6 +566,17 @@ export function SettingsModal({
{loading ? 'Saving...' : 'Save Settings'}
</Button>
<Separator />
<Button
variant="outline"
onClick={handleReboot}
disabled={rebooting || loading}
className="w-full border-red-500/50 text-red-400 hover:bg-red-500/10"
>
{rebooting ? 'Rebooting...' : 'Reboot Radio'}
</Button>
{error && <div className="text-sm text-destructive">{error}</div>}
</TabsContent>