import styles from './styles.module.css' import {useEffect, useState} from "react"; export interface ProcessExceptionInterface { message: string, file: string, line: bigint, code: bigint, trace: any[], } export interface ProcessProgressInterface { total: bigint, progress: bigint, memory: any[], } export interface ProcessInterface { id: string, lock: string|null, containerUuid: string|null, pid: bigint|null, name: string, options: Record, arguments: Record, exception: ProcessExceptionInterface|null, progress: ProcessProgressInterface|null, createdAt: string, updatedAt: string|null, startedAt: string|null, pausedAt: string|null, cancelledAt: string|null completedAt: string|null } export default function Processes() { const [processes, setProcesses] = useState([]); let refreshProcesses = async () => { let response = await fetch('http://fmw.sipachev.sv/system-monitoring/processes', { method: 'GET', headers: { 'Content-Type': 'application/json;charset=utf-8', 'X-Plugin-Token': 'passw0rd' }, }); const processes: ProcessInterface[] = await response.json() setProcesses(processes) setTimeout(() => refreshProcesses, 1000) } useEffect(() => { refreshProcesses() }, []) return (
{processes.map((process: ProcessInterface, index: number) => (
{process.name} 
{!process.progress && 'N/A'} {process.progress && {`${process.progress.progress}`} / {`${process.progress.total}`} - 50% [53Mb] / 20 sec }
{process.completedAt && } {process.pausedAt && } {!process.pausedAt && !process.completedAt && !process.cancelledAt && } {!process.completedAt && !process.cancelledAt && }
))}
) }