feat(dashboard): streamline server network tab
Build and publish Docker image / build-and-publish (push) Successful in 12s
Build and publish Docker image / build-and-publish (push) Successful in 12s
This commit is contained in:
1 parent
3523a2e141
commit
473ee8f9e5
1 file changed
+76
-132
+76
-132
@@ -3417,148 +3417,92 @@ const handleWebSocketMessage = useCallback((data) => {
|
|||||||
const serverPorts = selectedServer.ports || [];
|
const serverPorts = selectedServer.ports || [];
|
||||||
const primaryPort = serverPorts[0];
|
const primaryPort = serverPorts[0];
|
||||||
const mappingCount = serverPorts.length + (selectedServer.sftp_port ? 1 : 0);
|
const mappingCount = serverPorts.length + (selectedServer.sftp_port ? 1 : 0);
|
||||||
const flowExampleInternal = primaryPort?.internal || '8080';
|
const primaryExternalPort = primaryPort?.external || selectedServer.sftp_port;
|
||||||
const flowExampleExternal = primaryPort?.external || '31234';
|
|
||||||
const canExposePorts = ['vps', 'game', 'database'].includes(selectedServer.type);
|
const canExposePorts = ['vps', 'game', 'database'].includes(selectedServer.type);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-7xl mx-auto space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-300">
|
<div className="max-w-7xl mx-auto space-y-5 animate-in fade-in duration-200">
|
||||||
<div
|
<section
|
||||||
className="rounded-2xl border transition-all duration-300 bg-brightBlack/20 backdrop-blur-sm w-full overflow-hidden"
|
className="rounded-xl border overflow-hidden"
|
||||||
style={{ borderColor: `${colors.blue}25`, boxShadow: `0 10px 30px -15px rgba(0,0,0,0.5), 0 0 0 1px ${colors.blue}10` }}
|
style={{ borderColor: `${colors.primary}25`, backgroundColor: colors.brightBlack }}
|
||||||
|
aria-labelledby="network-overview-title"
|
||||||
>
|
>
|
||||||
<button
|
<div className="grid grid-cols-1 lg:grid-cols-[minmax(0,1fr)_auto]">
|
||||||
type="button"
|
<div className="p-5 sm:p-6 min-w-0">
|
||||||
onClick={() => setShowPortMappingGuide((open) => !open)}
|
<div className="flex items-start gap-3">
|
||||||
className="w-full flex items-center justify-between gap-4 p-5 sm:p-6 text-left transition-colors hover:bg-white/[0.02]"
|
<div className="p-2.5 rounded-lg border shrink-0" style={{ backgroundColor: `${colors.primary}12`, borderColor: `${colors.primary}25` }}>
|
||||||
>
|
<NetworkIcon className="w-5 h-5" style={{ color: colors.primary }} />
|
||||||
<div className="flex items-center gap-4 min-w-0">
|
</div>
|
||||||
<div
|
<div className="min-w-0">
|
||||||
className="p-3 rounded-xl border shrink-0"
|
<h3 id="network-overview-title" className="text-base font-bold" style={{ color: colors.brightWhite }}>Network access</h3>
|
||||||
style={{ backgroundColor: `${colors.blue}15`, borderColor: `${colors.blue}30` }}
|
<p className="text-xs opacity-50 mt-1">Use the public address and port to reach this server.</p>
|
||||||
>
|
</div>
|
||||||
<Info className="w-5 h-5" style={{ color: colors.blue }} />
|
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0">
|
<div className="mt-5 flex flex-col sm:flex-row sm:items-center gap-3">
|
||||||
<h3 className="text-base sm:text-lg font-bold tracking-tight" style={{ color: colors.brightWhite }}>
|
<div className="min-w-0">
|
||||||
How Port Mapping Works
|
<p className="text-[10px] font-bold uppercase tracking-wider opacity-40 mb-1">Primary address</p>
|
||||||
</h3>
|
{primaryExternalPort ? (
|
||||||
<p className="text-xs opacity-50 mt-0.5 truncate sm:whitespace-normal">
|
<code className="block text-lg sm:text-xl font-bold font-mono text-primary break-all">{serverIp}:{primaryExternalPort}</code>
|
||||||
{showPortMappingGuide ? 'Tap to collapse' : 'Port mapping, how to connect, and tips'}
|
) : (
|
||||||
</p>
|
<p className="text-sm opacity-50">No public port assigned yet</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{primaryExternalPort && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
navigator.clipboard.writeText(`${serverIp}:${primaryExternalPort}`);
|
||||||
|
setAlertModal({ open: true, title: 'Success', message: 'Address copied to clipboard', type: 'success' });
|
||||||
|
}}
|
||||||
|
className="inline-flex items-center justify-center gap-2 rounded-lg border px-3 py-2 text-xs font-semibold transition-colors hover:bg-white/[0.05] focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary"
|
||||||
|
style={{ borderColor: `${colors.primary}35`, color: colors.primary }}
|
||||||
|
>
|
||||||
|
<Copy className="w-4 h-4" /> Copy address
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ChevronDown
|
<div className="flex lg:flex-col justify-between lg:justify-center gap-5 border-t lg:border-t-0 lg:border-l px-5 py-4 sm:px-6" style={{ borderColor: `${colors.white}10` }}>
|
||||||
className={`w-5 h-5 shrink-0 opacity-50 transition-transform duration-300 ${showPortMappingGuide ? 'rotate-180' : ''}`}
|
<div>
|
||||||
style={{ color: colors.blue }}
|
<p className="text-xl font-bold tabular-nums" style={{ color: colors.brightWhite }}>{mappingCount}</p>
|
||||||
/>
|
<p className="text-[10px] opacity-45">{mappingCount === 1 ? 'active mapping' : 'active mappings'}</p>
|
||||||
</button>
|
|
||||||
|
|
||||||
{showPortMappingGuide && (
|
|
||||||
<div className="px-5 sm:px-6 pb-6 border-t border-white/5 animate-in slide-in-from-top-2 duration-200">
|
|
||||||
<p className="text-sm leading-relaxed opacity-60 mb-6 mt-5 max-w-3xl">
|
|
||||||
Your server listens on an <span className="text-white font-semibold">internal port</span> inside its container.
|
|
||||||
{branding.name} maps it to a unique <span className="text-white font-semibold">external port</span> on our public IP so people on the internet can reach it — without exposing your server directly.
|
|
||||||
</p>
|
|
||||||
<div className="flex flex-col lg:flex-row items-stretch justify-center gap-3 lg:gap-4">
|
|
||||||
<div className="flex-1 p-5 rounded-2xl border text-center" style={{ backgroundColor: colors.brightBlack, borderColor: colors.brightBlack }}>
|
|
||||||
<p className="text-[10px] font-black uppercase tracking-widest opacity-40 mb-3">Inside your server</p>
|
|
||||||
<code className="text-sm font-bold font-mono" style={{ color: colors.brightWhite }}>:{flowExampleInternal}</code>
|
|
||||||
<p className="text-[10px] opacity-40 mt-3 leading-relaxed">What your app or game listens on</p>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center justify-center py-1 lg:py-0">
|
|
||||||
<ArrowRight className="w-5 h-5 text-primary rotate-90 lg:rotate-0 shrink-0 opacity-60" />
|
|
||||||
</div>
|
|
||||||
<div className="flex-1 p-5 rounded-2xl border text-center" style={{ backgroundColor: `${colors.primary}10`, borderColor: `${colors.primary}25` }}>
|
|
||||||
<p className="text-[10px] font-black uppercase tracking-widest text-primary mb-3">{branding.name} gateway</p>
|
|
||||||
<NetworkIcon className="w-6 h-6 mx-auto text-primary mb-1" />
|
|
||||||
<p className="text-[10px] opacity-50 mt-2 leading-relaxed">Secure NodePort + firewall</p>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center justify-center py-1 lg:py-0">
|
|
||||||
<ArrowRight className="w-5 h-5 text-primary rotate-90 lg:rotate-0 shrink-0 opacity-60" />
|
|
||||||
</div>
|
|
||||||
<div className="flex-1 p-5 rounded-2xl border text-center" style={{ backgroundColor: `${colors.green}08`, borderColor: `${colors.green}20` }}>
|
|
||||||
<p className="text-[10px] font-black uppercase tracking-widest mb-3" style={{ color: colors.brightGreen }}>Public address</p>
|
|
||||||
<code className="text-sm font-bold font-mono text-primary">{serverIp}:{flowExampleExternal}</code>
|
|
||||||
<p className="text-[10px] opacity-40 mt-3 leading-relaxed">What you give to users & clients</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6 mt-8 pt-8 border-t border-white/5">
|
<p className="text-sm font-semibold capitalize" style={{ color: colors.brightWhite }}>{selectedServer.status || 'Unknown'}</p>
|
||||||
<div>
|
<p className="text-[10px] opacity-45">Server status</p>
|
||||||
<div className="flex items-center gap-3 mb-4">
|
</div>
|
||||||
<div className="p-2 rounded-lg border shrink-0" style={{ backgroundColor: `${colors.blue}15`, borderColor: `${colors.blue}30` }}>
|
</div>
|
||||||
<ExternalLink className="w-4 h-4" style={{ color: colors.blue }} />
|
</div>
|
||||||
</div>
|
<div className="border-t px-5 sm:px-6 py-3 flex flex-wrap items-center justify-between gap-3" style={{ borderColor: `${colors.white}08`, backgroundColor: 'rgba(0,0,0,0.12)' }}>
|
||||||
<h4 className="text-sm font-bold tracking-tight" style={{ color: colors.brightWhite }}>How to Connect</h4>
|
<p className="text-xs opacity-55">Internal ports stay inside the server; external ports accept connections from the internet.</p>
|
||||||
</div>
|
<button
|
||||||
<p className="text-xs leading-relaxed opacity-50 mb-4">{getNetworkConnectionHint(selectedServer)}</p>
|
type="button"
|
||||||
<div className="p-5 rounded-2xl border space-y-4" style={{ backgroundColor: `${colors.primary}05`, borderColor: `${colors.primary}15` }}>
|
onClick={() => setShowPortMappingGuide((open) => !open)}
|
||||||
{[
|
aria-expanded={showPortMappingGuide}
|
||||||
{ step: '01', title: 'Copy your address', body: 'Pick a port from the table below and copy its public IP:port address.' },
|
className="inline-flex items-center gap-2 text-xs font-semibold transition-colors hover:text-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary rounded"
|
||||||
{ step: '02', title: 'Open your client', body: selectedServer.type === 'game' ? 'Launch your game and open Multiplayer → Direct Connect.' : 'Open SSH, RDP, a browser, or your database tool.' },
|
style={{ color: colors.primary }}
|
||||||
{ step: '03', title: 'Connect', body: `Paste the full address, e.g. ${serverIp}:${flowExampleExternal}` },
|
>
|
||||||
].map((item) => (
|
{showPortMappingGuide ? 'Hide connection guide' : 'How connections work'}
|
||||||
<div key={item.step} className="flex items-start gap-4">
|
<ChevronDown className={`w-4 h-4 transition-transform ${showPortMappingGuide ? 'rotate-180' : ''}`} />
|
||||||
<div className="w-8 h-8 rounded-xl flex items-center justify-center shrink-0 border" style={{ backgroundColor: `${colors.primary}15`, borderColor: `${colors.primary}30` }}>
|
</button>
|
||||||
<span className="text-xs font-black text-primary">{item.step}</span>
|
</div>
|
||||||
</div>
|
{showPortMappingGuide && (
|
||||||
<div>
|
<div className="border-t px-5 sm:px-6 py-4 grid grid-cols-1 sm:grid-cols-3 gap-4" style={{ borderColor: `${colors.white}08` }}>
|
||||||
<p className="text-sm font-bold mb-0.5" style={{ color: colors.brightWhite }}>{item.title}</p>
|
<div>
|
||||||
<p className="text-xs leading-relaxed opacity-60">{item.body}</p>
|
<p className="text-xs font-semibold" style={{ color: colors.brightWhite }}>1. Choose a mapping</p>
|
||||||
</div>
|
<p className="text-xs opacity-50 mt-1">Use the external address shown in the list below.</p>
|
||||||
</div>
|
</div>
|
||||||
))}
|
<div>
|
||||||
</div>
|
<p className="text-xs font-semibold" style={{ color: colors.brightWhite }}>2. Open your client</p>
|
||||||
</div>
|
<p className="text-xs opacity-50 mt-1">{selectedServer.type === 'game' ? 'Use your game’s direct-connect screen.' : 'Use the matching app, browser, or terminal.'}</p>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center gap-3 mb-4">
|
<p className="text-xs font-semibold" style={{ color: colors.brightWhite }}>3. Connect</p>
|
||||||
<div className="p-2 rounded-lg border shrink-0" style={{ backgroundColor: `${colors.green}15`, borderColor: `${colors.green}30` }}>
|
<p className="text-xs opacity-50 mt-1">{getNetworkConnectionHint(selectedServer)}</p>
|
||||||
<Shield className="w-4 h-4" style={{ color: colors.brightGreen }} />
|
|
||||||
</div>
|
|
||||||
<h4 className="text-sm font-bold tracking-tight" style={{ color: colors.brightWhite }}>Good to Know</h4>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-3">
|
|
||||||
{[
|
|
||||||
{
|
|
||||||
icon: Globe,
|
|
||||||
iconColor: colors.blue,
|
|
||||||
title: 'External ports are assigned for you',
|
|
||||||
body: 'For security, public ports are unique and randomly chosen. Your internal port stays whatever your service expects.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: Shield,
|
|
||||||
iconColor: colors.brightGreen,
|
|
||||||
title: 'Firewall opens automatically',
|
|
||||||
body: `When you expose a port, ${branding.name} opens it on the edge firewall in real time — no manual rules needed.`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: Lock,
|
|
||||||
iconColor: colors.yellow,
|
|
||||||
title: 'System ports cannot be removed',
|
|
||||||
body: 'Default service ports (game, SSH, SFTP) are managed by the platform and marked as System in the table.',
|
|
||||||
},
|
|
||||||
].map((item, idx) => {
|
|
||||||
const TipIcon = item.icon;
|
|
||||||
return (
|
|
||||||
<div key={idx} className="flex items-start gap-4 p-4 rounded-xl border transition-all duration-200 hover:bg-white/[0.02]" style={{ backgroundColor: colors.brightBlack, borderColor: colors.brightBlack }}>
|
|
||||||
<div className="p-2 rounded-lg shrink-0" style={{ backgroundColor: `${item.iconColor}15` }}>
|
|
||||||
<TipIcon className="w-4 h-4" style={{ color: item.iconColor }} />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<p className="text-xs font-bold mb-1" style={{ color: colors.brightWhite }}>{item.title}</p>
|
|
||||||
<p className="text-[10px] leading-relaxed opacity-45">{item.body}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</section>
|
||||||
|
|
||||||
<SectionCard
|
<SectionCard
|
||||||
title="Port Mappings"
|
title="Port Mappings"
|
||||||
@@ -3572,7 +3516,7 @@ const handleWebSocketMessage = useCallback((data) => {
|
|||||||
|
|
||||||
<div className="rounded-2xl border overflow-hidden mb-6" style={{ backgroundColor: colors.brightBlack, borderColor: colors.brightBlack }}>
|
<div className="rounded-2xl border overflow-hidden mb-6" style={{ backgroundColor: colors.brightBlack, borderColor: colors.brightBlack }}>
|
||||||
<div className="overflow-x-auto">
|
<div className="overflow-x-auto">
|
||||||
<table className="w-full text-left border-collapse">
|
<table className="w-full min-w-[720px] text-left border-collapse">
|
||||||
<thead>
|
<thead>
|
||||||
<tr className="border-b" style={{ borderColor: `${colors.white}08`, backgroundColor: `${colors.white}03` }}>
|
<tr className="border-b" style={{ borderColor: `${colors.white}08`, backgroundColor: `${colors.white}03` }}>
|
||||||
<th className="px-5 py-4 text-[10px] font-black uppercase tracking-widest opacity-40">Service</th>
|
<th className="px-5 py-4 text-[10px] font-black uppercase tracking-widest opacity-40">Service</th>
|
||||||
|
|||||||
Reference in new issue
Block a user