From 7379a9eed064a5bd5a1f257cf5c40c3abd55d290 Mon Sep 17 00:00:00 2001 From: Sipachev Igor Date: Wed, 18 Jan 2023 12:50:51 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D0=BA=D0=B0=D1=87=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20output?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/elements/processes/index.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/components/elements/processes/index.tsx b/components/elements/processes/index.tsx index 4837c14..c457b3c 100644 --- a/components/elements/processes/index.tsx +++ b/components/elements/processes/index.tsx @@ -9,6 +9,7 @@ import CheckCircleOutline from "@mui/icons-material/CheckCircleOutline" import ErrorOutline from "@mui/icons-material/ErrorOutline" import ReplayOutlined from "@mui/icons-material/ReplayOutlined" import RunCircleOutlined from "@mui/icons-material/RunCircleOutlined" +import FactCheckOutlined from "@mui/icons-material/FactCheckOutlined" import {IconButton, LinearProgress, TableContainer, Table, TableBody, TableCell, TableHead, TableRow, TablePagination} from "@mui/material" import ConfirmDialog from "../confirm-dialog"; @@ -36,6 +37,7 @@ export interface ProcessInterface { arguments: Record, exception: ProcessExceptionInterface | null, progress: ProcessProgressInterface | null, + outputId: string | null, createdAt: string, updatedAt: string | null, startedAt: string | null, @@ -81,8 +83,8 @@ export default function Processes() { setCount(Number(response.headers.get('X-Pagination-Count'))) refreshLock = false } - let output = async (process: string) => { - let response = await fetch(`http://fmw.sipachev.sv/system-monitoring/processes/${process}/output`, + let output = async (process: ProcessInterface) => { + let response = await fetch(`http://fmw.sipachev.sv/system-monitoring/processes/${process.id}/output`, { method: 'GET', headers: { @@ -90,7 +92,12 @@ export default function Processes() { 'X-Pagination-Count': '0', }, }); - const processes: ProcessInterface[] = await response.json() + const output: string = await response.text() + 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(() => { @@ -195,7 +202,7 @@ export default function Processes() { {Status.Error === status(process) && } - {Status.Success === status(process) && output(process.id)} title={`Success`} aria-label="Success"> + {Status.Success === status(process) && } {Status.Running === status(process) && @@ -215,6 +222,9 @@ export default function Processes() { {canKill(process) && } + {process?.outputId && output(process)} aria-label="Output"> + + } {new Date(process.createdAt).toLocaleDateString()}