X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5c8a5dd07252ed2ac431c53fccc9e2fb649c3014..5c7b87f62d045b50e177f788ecdb907ab5402ad7:/src/views/process-panel/process-log-card.tsx diff --git a/src/views/process-panel/process-log-card.tsx b/src/views/process-panel/process-log-card.tsx index b87bb6e475..4fd8f2343d 100644 --- a/src/views/process-panel/process-log-card.tsx +++ b/src/views/process-panel/process-log-card.tsx @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import React from 'react'; +import React, { useState } from 'react'; import { StyleRulesCallback, WithStyles, @@ -15,14 +15,21 @@ import { Grid, Typography, } from '@material-ui/core'; +import { useAsyncInterval } from 'common/use-async-interval'; import { ArvadosTheme } from 'common/custom-theme'; import { CloseIcon, CollectionIcon, + CopyIcon, LogIcon, - MaximizeIcon + MaximizeIcon, + UnMaximizeIcon, + TextDecreaseIcon, + TextIncreaseIcon, + WordWrapOffIcon, + WordWrapOnIcon, } from 'components/icon/icon'; -import { Process } from 'store/processes/process'; +import { Process, isProcessRunning } from 'store/processes/process'; import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view'; import { FilterOption, @@ -31,25 +38,40 @@ import { import { ProcessLogCodeSnippet } from 'views/process-panel/process-log-code-snippet'; import { DefaultView } from 'components/default-view/default-view'; import { CodeSnippetDataProps } from 'components/code-snippet/code-snippet'; +import CopyToClipboard from 'react-copy-to-clipboard'; -type CssRules = 'card' | 'content' | 'title' | 'iconHeader'; +type CssRules = 'card' | 'content' | 'title' | 'iconHeader' | 'header' | 'root' | 'logViewer' | 'logViewerContainer'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { height: '100%' }, + header: { + paddingTop: theme.spacing.unit, + paddingBottom: theme.spacing.unit, + }, content: { - '&:last-child': { - paddingBottom: theme.spacing.unit * 2, - } + padding: theme.spacing.unit * 0, + height: '100%', + }, + logViewer: { + height: '100%', + overflowY: 'scroll', // Required for MacOS's Safari -- See #19687 + }, + logViewerContainer: { + height: '100%', }, title: { overflow: 'hidden', - paddingTop: theme.spacing.unit * 0.5 + paddingTop: theme.spacing.unit * 0.5, + color: theme.customs.colors.greyD }, iconHeader: { fontSize: '1.875rem', - color: theme.customs.colors.green700 + color: theme.customs.colors.greyL + }, + root: { + height: '100%', }, }); @@ -62,6 +84,8 @@ export interface ProcessLogsCardDataProps { export interface ProcessLogsCardActionProps { onLogFilterChange: (filter: FilterOption) => void; navigateToLog: (uuid: string) => void; + onCopy: (text: string) => void; + pollProcessLogs: (processUuid: string) => Promise; } type ProcessLogsCardProps = ProcessLogsCardDataProps @@ -71,17 +95,57 @@ type ProcessLogsCardProps = ProcessLogsCardDataProps & MPVPanelProps; export const ProcessLogsCard = withStyles(styles)( - ({ classes, process, filters, selectedFilter, lines, onLogFilterChange, navigateToLog, - doHidePanel, doMaximizePanel, panelMaximized, panelName }: ProcessLogsCardProps) => - + ({ classes, process, filters, selectedFilter, lines, + onLogFilterChange, navigateToLog, onCopy, pollProcessLogs, + doHidePanel, doMaximizePanel, doUnMaximizePanel, panelMaximized, panelName }: ProcessLogsCardProps) => { + const [wordWrap, setWordWrap] = useState(true); + const [fontSize, setFontSize] = useState(3); + const fontBaseSize = 10; + const fontStepSize = 1; + + useAsyncInterval(() => ( + pollProcessLogs(process.containerRequest.uuid) + ), isProcessRunning(process) ? 2000 : null); + + return - } action={ + + + fontSize > 1 && setFontSize(fontSize-1)}> + + + + + + + fontSize < 5 && setFontSize(fontSize+1)}> + + + + + + + + onCopy("Log copied to clipboard")}> + + + + + + + + setWordWrap(!wordWrap)}> + {wordWrap ? : } + + + navigateToLog(process.containerRequest.logUuid!)}> @@ -89,15 +153,18 @@ export const ProcessLogsCard = withStyles(styles)( + { doUnMaximizePanel && panelMaximized && + + + } { doMaximizePanel && !panelMaximized && } - { doHidePanel && - - - - } + { doHidePanel && + + + } } title={ @@ -107,11 +174,12 @@ export const ProcessLogsCard = withStyles(styles)( {lines.length > 0 ? < Grid + className={classes.logViewerContainer} container spacing={24} direction='column'> - - + + : -); - +});