mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-15 00:26:23 +00:00
Update terminal-panel.tsx
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
import type React from "react"
|
import type React from "react"
|
||||||
import { useEffect, useRef, useState } from "react"
|
import { useEffect, useRef, useState } from "react"
|
||||||
import { API_PORT } from "../lib/api-config"
|
import { API_PORT } from "../lib/api-config"
|
||||||
|
import { fetchApi } from "@/lib/api-config" // Cambiando import para usar fetchApi directamente
|
||||||
import {
|
import {
|
||||||
Activity,
|
Activity,
|
||||||
Trash2,
|
Trash2,
|
||||||
@@ -226,29 +227,12 @@ export const TerminalPanel: React.FC<TerminalPanelProps> = ({ websocketUrl, onCl
|
|||||||
setIsSearching(true)
|
setIsSearching(true)
|
||||||
|
|
||||||
const searchEndpoint = `/api/terminal/search-command?q=${encodeURIComponent(query)}`
|
const searchEndpoint = `/api/terminal/search-command?q=${encodeURIComponent(query)}`
|
||||||
const apiUrl = getApiUrl(searchEndpoint)
|
|
||||||
const token = typeof window !== "undefined" ? localStorage.getItem("proxmenux-auth-token") : null
|
|
||||||
|
|
||||||
const headers: Record<string, string> = {
|
const data = await fetchApi<{ success: boolean; examples: any[] }>(searchEndpoint, {
|
||||||
Accept: "application/json",
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token) {
|
|
||||||
headers["Authorization"] = `Bearer ${token}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(apiUrl, {
|
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers,
|
|
||||||
signal: AbortSignal.timeout(10000),
|
signal: AbortSignal.timeout(10000),
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP error! status: ${response.status}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await response.json()
|
|
||||||
|
|
||||||
if (!data.success || !data.examples || data.examples.length === 0) {
|
if (!data.success || !data.examples || data.examples.length === 0) {
|
||||||
throw new Error("No examples found")
|
throw new Error("No examples found")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user