Compare commits

..

No commits in common. '7379a9eed064a5bd5a1f257cf5c40c3abd55d290' and 'a52b9a24cf8effe1ba42288dd8ede35aa21cc0d8' have entirely different histories.

  1. 40
      components/elements/processes/index.tsx

@ -1,15 +1,14 @@
import styles from './styles.module.css' import styles from './styles.module.css'
import {useEffect, useState} from "react" import {useEffect, useState} from "react"
import DeleteForeverOutlined from "@mui/icons-material/DeleteForeverOutlined" import DeleteForever from "@mui/icons-material/DeleteForever"
import StopCircleOutlined from "@mui/icons-material/StopCircleOutlined" import StopCircle from "@mui/icons-material/StopCircle"
import PauseCircleOutline from "@mui/icons-material/PauseCircleOutline" import PauseCircleOutline from "@mui/icons-material/PauseCircleOutline"
import PlayCircleOutline from "@mui/icons-material/PlayCircleOutline" import PlayCircleOutline from "@mui/icons-material/PlayCircleOutline"
import HourglassEmptyOutlined from "@mui/icons-material/HourglassEmptyOutlined" import HourglassEmpty from "@mui/icons-material/HourglassEmpty"
import CheckCircleOutline from "@mui/icons-material/CheckCircleOutline" import CheckCircleOutline from "@mui/icons-material/CheckCircleOutline"
import ErrorOutline from "@mui/icons-material/ErrorOutline" import ErrorOutline from "@mui/icons-material/ErrorOutline"
import ReplayOutlined from "@mui/icons-material/ReplayOutlined" import Replay from "@mui/icons-material/Replay"
import RunCircleOutlined from "@mui/icons-material/RunCircleOutlined" import RunCircle from "@mui/icons-material/RunCircle"
import FactCheckOutlined from "@mui/icons-material/FactCheckOutlined"
import {IconButton, LinearProgress, TableContainer, Table, TableBody, TableCell, TableHead, TableRow, TablePagination} from "@mui/material" import {IconButton, LinearProgress, TableContainer, Table, TableBody, TableCell, TableHead, TableRow, TablePagination} from "@mui/material"
import ConfirmDialog from "../confirm-dialog"; import ConfirmDialog from "../confirm-dialog";
@ -37,7 +36,6 @@ export interface ProcessInterface {
arguments: Record<string, any>, arguments: Record<string, any>,
exception: ProcessExceptionInterface | null, exception: ProcessExceptionInterface | null,
progress: ProcessProgressInterface | null, progress: ProcessProgressInterface | null,
outputId: string | null,
createdAt: string, createdAt: string,
updatedAt: string | null, updatedAt: string | null,
startedAt: string | null, startedAt: string | null,
@ -83,8 +81,8 @@ export default function Processes() {
setCount(Number(response.headers.get('X-Pagination-Count'))) setCount(Number(response.headers.get('X-Pagination-Count')))
refreshLock = false refreshLock = false
} }
let output = async (process: ProcessInterface) => { let output = async (process: string) => {
let response = await fetch(`http://fmw.sipachev.sv/system-monitoring/processes/${process.id}/output`, let response = await fetch(`http://fmw.sipachev.sv/system-monitoring/processes/${process}/output`,
{ {
method: 'GET', method: 'GET',
headers: { headers: {
@ -92,12 +90,7 @@ export default function Processes() {
'X-Pagination-Count': '0', 'X-Pagination-Count': '0',
}, },
}); });
const output: string = await response.text() const processes: ProcessInterface[] = await response.json()
let a = document.createElement("a");
let file = new Blob([output], {type: 'plain/text'});
a.href = URL.createObjectURL(file);
a.download = `${process.id}.txt`;
a.click();
} }
useEffect(() => { useEffect(() => {
@ -195,35 +188,32 @@ export default function Processes() {
<PauseCircleOutline/> <PauseCircleOutline/>
</IconButton>} </IconButton>}
{canStop(process) && <IconButton title={`Stop`} aria-label="Stop"> {canStop(process) && <IconButton title={`Stop`} aria-label="Stop">
<StopCircleOutlined/> <StopCircle/>
</IconButton>} </IconButton>}
</TableCell> </TableCell>
<TableCell> <TableCell>
{Status.Error === status(process) && <IconButton title={`Error`} aria-label="Error"> {Status.Error === status(process) && <IconButton title={`Error`} aria-label="Error">
<ErrorOutline/> <ErrorOutline/>
</IconButton>} </IconButton>}
{Status.Success === status(process) && <IconButton title={`Success`} aria-label="Success"> {Status.Success === status(process) && <IconButton onClick={() => output(process.id)} title={`Success`} aria-label="Success">
<CheckCircleOutline/> <CheckCircleOutline/>
</IconButton>} </IconButton>}
{Status.Running === status(process) && <IconButton title={`Running`} aria-label="Running"> {Status.Running === status(process) && <IconButton title={`Running`} aria-label="Running">
<RunCircleOutlined/> <RunCircle/>
</IconButton>} </IconButton>}
{Status.Cancelled === status(process) && <IconButton title={`Cancelled`} aria-label="Cancelled"> {Status.Cancelled === status(process) && <IconButton title={`Cancelled`} aria-label="Cancelled">
<StopCircleOutlined/> <StopCircle/>
</IconButton>} </IconButton>}
{Status.Wait === status(process) && <IconButton title={`Wait`} aria-label="Wait"> {Status.Wait === status(process) && <IconButton title={`Wait`} aria-label="Wait">
<HourglassEmptyOutlined/> <HourglassEmpty/>
</IconButton>} </IconButton>}
</TableCell> </TableCell>
<TableCell> <TableCell>
{canRepeat(process) && <IconButton onClick={() => openRepeatDialog(process)} title={`Repeat`} aria-label="Repeat"> {canRepeat(process) && <IconButton onClick={() => openRepeatDialog(process)} title={`Repeat`} aria-label="Repeat">
<ReplayOutlined/> <Replay/>
</IconButton>} </IconButton>}
{canKill(process) && <IconButton title={`Kill`} aria-label="Kill"> {canKill(process) && <IconButton title={`Kill`} aria-label="Kill">
<DeleteForeverOutlined/> <DeleteForever/>
</IconButton>}
{process?.outputId && <IconButton title={`Output`} onClick={() => output(process)} aria-label="Output">
<FactCheckOutlined/>
</IconButton>} </IconButton>}
</TableCell> </TableCell>
<TableCell title={new Date(process.createdAt).toLocaleString()}> <TableCell title={new Date(process.createdAt).toLocaleString()}>

Loading…
Cancel
Save