Fill an admin link's URL from a server's own known ports
Both places you add an admin link - a server's own Admin Links section and the Operations > Admin Links summary page - now offer a "fill from a known port" dropdown once a server is picked, listing its agent-reported and manually-noted ports (the same data the Ports page/card shows). Picking one fills in the URL as http(s)://<hostname-or-IP>:<port>, guessing https for a handful of common admin-panel ports, and fills the label too if it's still empty. The URL field stays fully editable either way. Shared the address/label logic in a small adminLinkUrl.ts helper used by both pages. No server-side changes needed - built entirely on the existing per-server ports and detail endpoints. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ff1c6550c
commit
21054aaa8c
3 files changed
+135
-1
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import type { PortEntry } from "../api/client";
|
||||
|
||||
// Common admin-panel ports that are HTTPS-only (often with a self-signed cert) even though nothing
|
||||
// on the wire says so — a small, honest guess, not a detection. Anything else defaults to http://,
|
||||
// and the URL field stays a normal editable text input either way.
|
||||
const HTTPS_PORTS = new Set([443, 5001, 8006, 8007, 8443, 9090, 9443, 10000]);
|
||||
|
||||
/** What to show for one port in a "fill from a known port" picker. */
|
||||
export function portOptionLabel(entry: PortEntry): string {
|
||||
const bits = [`${entry.port}/${entry.protocol}`];
|
||||
if (entry.agent?.process) bits.push(entry.agent.process);
|
||||
if (entry.label) bits.push(entry.label);
|
||||
return bits.join(" — ");
|
||||
}
|
||||
|
||||
/** A best-effort URL for a server's port, or null if no address is known for it yet. */
|
||||
export function guessAdminUrl(address: string | null, entry: PortEntry): string | null {
|
||||
if (!address) return null;
|
||||
return `${HTTPS_PORTS.has(entry.port) ? "https" : "http"}://${address}:${entry.port}`;
|
||||
}
|
||||
Reference in new issue
Block a user