Remove unused DDNS functionality from DashboardComponent
This commit is contained in:
@@ -7,20 +7,17 @@ import { Alert, AlertDescription } from './ui/alert';
|
|||||||
import { Badge } from './ui/badge';
|
import { Badge } from './ui/badge';
|
||||||
import {
|
import {
|
||||||
LayoutDashboard, Cloud, CheckCircle, XCircle, AlertCircle, Loader2,
|
LayoutDashboard, Cloud, CheckCircle, XCircle, AlertCircle, Loader2,
|
||||||
RefreshCw, BookOpen, Globe, Router, Server, RotateCw, Key,
|
BookOpen, Globe, Router, Server, RotateCw, Key,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { useCloudflare } from '../hooks/useCloudflare';
|
import { useCloudflare } from '../hooks/useCloudflare';
|
||||||
import { useDdns } from '../hooks/useDdns';
|
|
||||||
import { useCentralStatus } from '../hooks/useCentralStatus';
|
import { useCentralStatus } from '../hooks/useCentralStatus';
|
||||||
import { useVpn } from '../hooks/useVpn';
|
import { useVpn } from '../hooks/useVpn';
|
||||||
import { secretsApi, dnsSettingsApi, nftablesConfigApi } from '../services/api';
|
import { secretsApi, dnsSettingsApi, nftablesConfigApi } from '../services/api';
|
||||||
import { usePageHelp } from '../hooks/usePageHelp';
|
import { usePageHelp } from '../hooks/usePageHelp';
|
||||||
import type { DdnsRecordStatus } from '../services/api/networking';
|
|
||||||
|
|
||||||
export function DashboardComponent() {
|
export function DashboardComponent() {
|
||||||
const { data: centralStatus, isLoading: statusLoading, restart: restartDaemon, isRestarting } = useCentralStatus();
|
const { data: centralStatus, isLoading: statusLoading, restart: restartDaemon, isRestarting } = useCentralStatus();
|
||||||
const { verification, isLoading: cfLoading } = useCloudflare();
|
const { verification, isLoading: cfLoading } = useCloudflare();
|
||||||
const { status: ddnsStatus, isLoadingStatus: ddnsLoading, trigger: triggerDdns, isTriggering } = useDdns();
|
|
||||||
const { config: vpnConfig } = useVpn();
|
const { config: vpnConfig } = useVpn();
|
||||||
const { data: dnsSettings } = useQuery({ queryKey: ['dns', 'settings'], queryFn: () => dnsSettingsApi.get() });
|
const { data: dnsSettings } = useQuery({ queryKey: ['dns', 'settings'], queryFn: () => dnsSettingsApi.get() });
|
||||||
const { data: nftConfig } = useQuery({ queryKey: ['nftables', 'config'], queryFn: () => nftablesConfigApi.get() });
|
const { data: nftConfig } = useQuery({ queryKey: ['nftables', 'config'], queryFn: () => nftablesConfigApi.get() });
|
||||||
@@ -50,8 +47,7 @@ export function DashboardComponent() {
|
|||||||
// Warning conditions
|
// Warning conditions
|
||||||
const cfTokenMissing = !cfLoading && !verification?.tokenConfigured;
|
const cfTokenMissing = !cfLoading && !verification?.tokenConfigured;
|
||||||
const cfTokenInvalid = !cfLoading && verification?.tokenConfigured && !verification?.tokenValid;
|
const cfTokenInvalid = !cfLoading && verification?.tokenConfigured && !verification?.tokenValid;
|
||||||
const ddnsFailed = ddnsStatus?.enabled && ddnsStatus?.lastError;
|
const hasWarnings = cfTokenMissing || cfTokenInvalid;
|
||||||
const hasWarnings = cfTokenMissing || cfTokenInvalid || ddnsFailed;
|
|
||||||
|
|
||||||
usePageHelp({
|
usePageHelp({
|
||||||
title: 'What is the Dashboard?',
|
title: 'What is the Dashboard?',
|
||||||
@@ -99,12 +95,6 @@ export function DashboardComponent() {
|
|||||||
<AlertDescription>Cloudflare API token is invalid. Check your token in Cloudflare settings.</AlertDescription>
|
<AlertDescription>Cloudflare API token is invalid. Check your token in Cloudflare settings.</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
{ddnsFailed && (
|
|
||||||
<Alert variant="error">
|
|
||||||
<AlertCircle className="h-4 w-4" />
|
|
||||||
<AlertDescription>DDNS sync error: {ddnsStatus.lastError}</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -222,90 +212,7 @@ export function DashboardComponent() {
|
|||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
{/* 2. Dynamic DNS */}
|
{/* 2. Daemon Status */}
|
||||||
<Card className="p-4 border-l-4 border-l-green-500">
|
|
||||||
<div className="flex items-center justify-between mb-3">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Globe className="h-5 w-5 text-green-500" />
|
|
||||||
<div className="font-medium">Dynamic DNS</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
{ddnsLoading ? (
|
|
||||||
<Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />
|
|
||||||
) : ddnsStatus?.enabled ? (
|
|
||||||
<Badge variant="success" className="gap-1">
|
|
||||||
<CheckCircle className="h-3 w-3" />
|
|
||||||
Active
|
|
||||||
</Badge>
|
|
||||||
) : (
|
|
||||||
<Badge variant="secondary">Disabled</Badge>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{ddnsStatus?.enabled ? (
|
|
||||||
<div className="space-y-3 ml-7">
|
|
||||||
<div className="grid grid-cols-2 gap-4 text-sm">
|
|
||||||
<div>
|
|
||||||
<span className="text-muted-foreground">Public IP</span>
|
|
||||||
<div className="font-mono font-medium mt-0.5">{ddnsStatus.currentIP || '--'}</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<span className="text-muted-foreground">Last checked</span>
|
|
||||||
<div className="font-mono mt-0.5">
|
|
||||||
{ddnsStatus.lastChecked ? new Date(ddnsStatus.lastChecked).toLocaleTimeString() : '--'}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Record list (read-only — derived from public domains) */}
|
|
||||||
{ddnsStatus.records?.length ? (
|
|
||||||
<div className="space-y-1">
|
|
||||||
{ddnsStatus.records.map((rs: DdnsRecordStatus) => (
|
|
||||||
<div key={rs.name} className="flex items-center gap-2 text-xs">
|
|
||||||
{rs.ok ? (
|
|
||||||
<CheckCircle className="h-3.5 w-3.5 text-green-500 shrink-0" />
|
|
||||||
) : (
|
|
||||||
<XCircle className="h-3.5 w-3.5 text-red-500 shrink-0" />
|
|
||||||
)}
|
|
||||||
<span className="font-mono bg-muted px-2 py-0.5 rounded">{rs.name}</span>
|
|
||||||
{rs.ok && rs.ip && (
|
|
||||||
<span className="text-muted-foreground font-mono">{rs.ip}</span>
|
|
||||||
)}
|
|
||||||
{!rs.ok && rs.error && (
|
|
||||||
<span className="text-red-500 truncate" title={rs.error}>{rs.error}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
<p className="text-xs text-muted-foreground mt-1">
|
|
||||||
Records are derived from public domains. Toggle Public on the Domains page to manage.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
No public domains registered. Set a domain to Public on the Domains page to enable DDNS.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => triggerDdns()}
|
|
||||||
disabled={isTriggering}
|
|
||||||
className="gap-1"
|
|
||||||
>
|
|
||||||
{isTriggering ? <Loader2 className="h-3 w-3 animate-spin" /> : <RefreshCw className="h-3 w-3" />}
|
|
||||||
Check Now
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<p className="text-sm text-muted-foreground ml-7">
|
|
||||||
DDNS is not enabled. Enable it in the global config to keep public domain DNS records in sync with your public IP.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
{/* 3. Daemon Status */}
|
|
||||||
<Card className="p-4 border-l-4 border-l-purple-500">
|
<Card className="p-4 border-l-4 border-l-purple-500">
|
||||||
<div className="flex items-center justify-between mb-3">
|
<div className="flex items-center justify-between mb-3">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@@ -368,7 +275,7 @@ export function DashboardComponent() {
|
|||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
{/* 4. Gateway Router */}
|
{/* 3. Gateway Router */}
|
||||||
<Card className="p-4 border-l-4 border-l-amber-500 bg-gradient-to-r from-amber-50/50 to-orange-50/50 dark:from-amber-950/10 dark:to-orange-950/10">
|
<Card className="p-4 border-l-4 border-l-amber-500 bg-gradient-to-r from-amber-50/50 to-orange-50/50 dark:from-amber-950/10 dark:to-orange-950/10">
|
||||||
<div className="flex items-center gap-2 mb-3">
|
<div className="flex items-center gap-2 mb-3">
|
||||||
<Router className="h-5 w-5 text-amber-500" />
|
<Router className="h-5 w-5 text-amber-500" />
|
||||||
|
|||||||
Reference in New Issue
Block a user