mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-16 00:56:26 +00:00
Update AppImage
This commit is contained in:
@@ -58,9 +58,9 @@ export function HybridScriptMonitor({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!sessionId) return
|
if (!sessionId) return
|
||||||
|
|
||||||
const pollScript = async () => {
|
const pollStatus = async () => {
|
||||||
try {
|
try {
|
||||||
console.log("[v0] Polling script status and logs for session:", sessionId)
|
console.log("[v0] Polling script status for session:", sessionId)
|
||||||
|
|
||||||
// Get status
|
// Get status
|
||||||
const statusData = await fetchApi(`/api/scripts/status/${sessionId}`)
|
const statusData = await fetchApi(`/api/scripts/status/${sessionId}`)
|
||||||
@@ -79,15 +79,26 @@ export function HybridScriptMonitor({
|
|||||||
}
|
}
|
||||||
onComplete?.(false)
|
onComplete?.(false)
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[v0] Error polling status:", error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get logs
|
// Set up EventSource for log streaming
|
||||||
const logsData = await fetchApi(`/api/scripts/logs/${sessionId}`)
|
const apiUrl =
|
||||||
console.log("[v0] Logs data:", logsData)
|
(typeof window !== "undefined" && window.location.port === "80") || window.location.port === "443"
|
||||||
|
? `/api/scripts/logs/${sessionId}`
|
||||||
|
: `http://${window.location.hostname}:8008/api/scripts/logs/${sessionId}`
|
||||||
|
|
||||||
if (logsData.logs && Array.isArray(logsData.logs)) {
|
console.log("[v0] Connecting to log stream:", apiUrl)
|
||||||
const parsedLogs: LogEntry[] = []
|
|
||||||
|
const eventSource = new EventSource(apiUrl)
|
||||||
|
|
||||||
|
eventSource.onmessage = (event) => {
|
||||||
|
try {
|
||||||
|
const logLine = event.data
|
||||||
|
console.log("[v0] Received log:", logLine)
|
||||||
|
|
||||||
for (const logLine of logsData.logs) {
|
|
||||||
// Check for web interaction
|
// Check for web interaction
|
||||||
if (logLine.includes("WEB_INTERACTION:")) {
|
if (logLine.includes("WEB_INTERACTION:")) {
|
||||||
const parts = logLine.split("WEB_INTERACTION:")[1].split(":")
|
const parts = logLine.split("WEB_INTERACTION:")[1].split(":")
|
||||||
@@ -112,7 +123,9 @@ export function HybridScriptMonitor({
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Regular log entry
|
// Regular log entry
|
||||||
parsedLogs.push({
|
setLogs((prev) => [
|
||||||
|
...prev,
|
||||||
|
{
|
||||||
timestamp: new Date().toLocaleTimeString(),
|
timestamp: new Date().toLocaleTimeString(),
|
||||||
message: logLine,
|
message: logLine,
|
||||||
type: logLine.toLowerCase().includes("error")
|
type: logLine.toLowerCase().includes("error")
|
||||||
@@ -122,32 +135,34 @@ export function HybridScriptMonitor({
|
|||||||
: logLine.toLowerCase().includes("success")
|
: logLine.toLowerCase().includes("success")
|
||||||
? "success"
|
? "success"
|
||||||
: "info",
|
: "info",
|
||||||
})
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[v0] Error parsing log:", error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setLogs(parsedLogs)
|
eventSource.onerror = (error) => {
|
||||||
}
|
console.error("[v0] EventSource error:", error)
|
||||||
} catch (error) {
|
eventSource.close()
|
||||||
console.error("[v0] Error polling script:", error)
|
|
||||||
setLogs((prev) => [
|
setLogs((prev) => [
|
||||||
...prev,
|
...prev,
|
||||||
{
|
{
|
||||||
timestamp: new Date().toLocaleTimeString(),
|
timestamp: new Date().toLocaleTimeString(),
|
||||||
message: `Error: ${error}`,
|
message: "Lost connection to log stream",
|
||||||
type: "error",
|
type: "error",
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Initial poll
|
// Poll status every 2 seconds
|
||||||
pollScript()
|
pollStatus()
|
||||||
|
pollingIntervalRef.current = setInterval(pollStatus, 2000)
|
||||||
// Set up polling interval
|
|
||||||
pollingIntervalRef.current = setInterval(pollScript, 2000)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
console.log("[v0] Cleaning up EventSource and polling")
|
||||||
|
eventSource.close()
|
||||||
if (pollingIntervalRef.current) {
|
if (pollingIntervalRef.current) {
|
||||||
clearInterval(pollingIntervalRef.current)
|
clearInterval(pollingIntervalRef.current)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
import jwt
|
import jwt
|
||||||
import psutil
|
import psutil
|
||||||
from flask import Flask, jsonify, request, send_file, send_from_directory
|
from flask import Flask, jsonify, request, send_file, send_from_directory, Response
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
|
|
||||||
# Ensure local imports work even if working directory changes
|
# Ensure local imports work even if working directory changes
|
||||||
|
|||||||
Reference in New Issue
Block a user