Update terminal panel

This commit is contained in:
MacRimi
2026-03-15 16:27:37 +01:00
parent 65add36b2f
commit 0d6d570ae8
4 changed files with 56 additions and 48 deletions

View File

@@ -2,7 +2,7 @@
import type React from "react"
import { useEffect, useRef, useState } from "react"
import { API_PORT, fetchApi, getWebSocketUrl as getWebSocketUrlFromConfig, getApiUrl as getApiUrlFromConfig } from "@/lib/api-config"
import { API_PORT, fetchApi } from "@/lib/api-config" // Unificando importaciones de api-config en una sola línea con alias @/
import {
Activity,
Trash2,
@@ -46,13 +46,31 @@ interface TerminalInstance {
pingInterval?: ReturnType<typeof setInterval> | null // Heartbeat interval to keep connection alive
}
// Use centralized functions from api-config.ts for SSL/proxy support
function getWebSocketUrl(): string {
return getWebSocketUrlFromConfig("/ws/terminal")
if (typeof window === "undefined") {
return "ws://localhost:8008/ws/terminal"
}
const { protocol, hostname, port } = window.location
const isStandardPort = port === "" || port === "80" || port === "443"
const wsProtocol = protocol === "https:" ? "wss:" : "ws:"
if (isStandardPort) {
return `${wsProtocol}//${hostname}/ws/terminal`
} else {
return `${wsProtocol}//${hostname}:${API_PORT}/ws/terminal`
}
}
function getApiUrl(endpoint?: string): string {
return getApiUrlFromConfig(endpoint || "")
if (typeof window === "undefined") {
return "http://localhost:8008"
}
const { protocol, hostname } = window.location
const apiProtocol = protocol === "https:" ? "https:" : "http:"
return `${apiProtocol}//${hostname}:${API_PORT}${endpoint || ""}`
}
const proxmoxCommands = [