|
|
|
@ -1,15 +1,16 @@ |
|
|
|
|
import styles from './styles.module.css' |
|
|
|
|
import {useEffect, useState} from "react"; |
|
|
|
|
import DeleteForever from "@mui/icons-material/DeleteForever"; |
|
|
|
|
import StopCircle from "@mui/icons-material/StopCircle"; |
|
|
|
|
import PauseCircleOutline from "@mui/icons-material/PauseCircleOutline"; |
|
|
|
|
import PlayCircleOutline from "@mui/icons-material/PlayCircleOutline"; |
|
|
|
|
import HourglassEmpty from "@mui/icons-material/HourglassEmpty"; |
|
|
|
|
import CheckCircleOutline from "@mui/icons-material/CheckCircleOutline"; |
|
|
|
|
import ErrorOutline from "@mui/icons-material/ErrorOutline"; |
|
|
|
|
import Replay from "@mui/icons-material/Replay"; |
|
|
|
|
import RunCircle from "@mui/icons-material/RunCircle"; |
|
|
|
|
import {IconButton, LinearProgress, TableContainer, Table, TableBody, TableCell, TableHead, TableRow, TablePagination} from "@mui/material"; |
|
|
|
|
import {useEffect, useState} from "react" |
|
|
|
|
import DeleteForever from "@mui/icons-material/DeleteForever" |
|
|
|
|
import StopCircle from "@mui/icons-material/StopCircle" |
|
|
|
|
import PauseCircleOutline from "@mui/icons-material/PauseCircleOutline" |
|
|
|
|
import PlayCircleOutline from "@mui/icons-material/PlayCircleOutline" |
|
|
|
|
import HourglassEmpty from "@mui/icons-material/HourglassEmpty" |
|
|
|
|
import CheckCircleOutline from "@mui/icons-material/CheckCircleOutline" |
|
|
|
|
import ErrorOutline from "@mui/icons-material/ErrorOutline" |
|
|
|
|
import Replay from "@mui/icons-material/Replay" |
|
|
|
|
import RunCircle from "@mui/icons-material/RunCircle" |
|
|
|
|
import {IconButton, LinearProgress, TableContainer, Table, TableBody, TableCell, TableHead, TableRow, TablePagination} from "@mui/material" |
|
|
|
|
import { v4 } from "uuid" |
|
|
|
|
|
|
|
|
|
export interface ProcessExceptionInterface { |
|
|
|
|
message: string, |
|
|
|
@ -55,8 +56,14 @@ export default function Processes() { |
|
|
|
|
const [processes, setProcesses] = useState<ProcessInterface[]>([]); |
|
|
|
|
const [page, setPage] = useState<number>(0); |
|
|
|
|
const [count, setCount] = useState<number>(0); |
|
|
|
|
let requestId = v4() |
|
|
|
|
|
|
|
|
|
let refreshLock = false |
|
|
|
|
let refreshProcesses = async () => { |
|
|
|
|
if (refreshLock) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
refreshLock = true |
|
|
|
|
let response = await fetch('http://fmw.sipachev.sv/system-monitoring/processes?' + new URLSearchParams({ |
|
|
|
|
page: page + 1, |
|
|
|
|
limit: 20, |
|
|
|
@ -71,12 +78,13 @@ export default function Processes() { |
|
|
|
|
const processes: ProcessInterface[] = await response.json() |
|
|
|
|
setProcesses(processes) |
|
|
|
|
setCount(Number(response.headers.get('X-Pagination-Count'))) |
|
|
|
|
setTimeout(() => refreshProcesses, 1000) |
|
|
|
|
refreshLock = false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
refreshProcesses() |
|
|
|
|
}, [page]) |
|
|
|
|
const timer = setInterval(() => refreshProcesses(), 1000) |
|
|
|
|
return () => clearInterval(timer); |
|
|
|
|
}, [page]); |
|
|
|
|
|
|
|
|
|
let isFinished = (process: ProcessInterface) => process.cancelledAt || process.completedAt |
|
|
|
|
let canPlay = (process: ProcessInterface) => !isFinished(process) && process.progress && process.pausedAt |
|
|
|
@ -106,6 +114,10 @@ export default function Processes() { |
|
|
|
|
setPage(page); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const repeat = (event: any) => { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
<TableContainer> |
|
|
|
@ -158,7 +170,7 @@ export default function Processes() { |
|
|
|
|
</IconButton>} |
|
|
|
|
</TableCell> |
|
|
|
|
<TableCell> |
|
|
|
|
{canRepeat(process) && <IconButton title={`Repeat`} aria-label="Repeat"> |
|
|
|
|
{canRepeat(process) && <IconButton onClick={repeat} title={`Repeat`} aria-label="Repeat"> |
|
|
|
|
<Replay/> |
|
|
|
|
</IconButton>} |
|
|
|
|
{canKill(process) && <IconButton title={`Kill`} aria-label="Kill"> |
|
|
|
|