16672: Adds font size control to the log viewer.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 18 Mar 2022 21:31:42 +0000 (18:31 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 25 Mar 2022 20:59:23 +0000 (17:59 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

src/components/code-snippet/code-snippet.tsx
src/components/icon/icon.tsx
src/views/process-panel/process-log-card.tsx
src/views/process-panel/process-log-code-snippet.tsx

index d0cf6ab34358c0a3079558cebcb4145cf228dec5..6dc124010d97407bf44091464dcc07f16795281c 100644 (file)
@@ -25,17 +25,18 @@ export interface CodeSnippetDataProps {
     className?: string;
     apiResponse?: boolean;
     containerClassName?: string;
+    fontSize?: number;
 }
 
 type CodeSnippetProps = CodeSnippetDataProps & WithStyles<CssRules>;
 
 export const CodeSnippet = withStyles(styles)(
-    ({ classes, lines, className, containerClassName, apiResponse }: CodeSnippetProps) =>
+    ({ classes, lines, className, containerClassName, apiResponse, fontSize }: CodeSnippetProps) =>
         <Typography
             component="div"
             className={classNames(classes.root, containerClassName, className)}>
                 { lines.map((line: string, index: number) => {
-                    return <Typography key={index} className={apiResponse ? classes.space : className} component="pre">{line}</Typography>;
+                    return <Typography key={index} style={{ fontSize: fontSize }} className={apiResponse ? classes.space : className} component="pre">{line}</Typography>;
                 }) }
         </Typography>
     );
\ No newline at end of file
index 7fb74e81163cd3fc9b91eb7db117504ee69192fc..557e22e77c959e08107ca10b11e174e13a967c30 100644 (file)
@@ -66,6 +66,8 @@ import LinkOutlined from '@material-ui/icons/LinkOutlined';
 import RemoveRedEye from '@material-ui/icons/RemoveRedEye';
 import Computer from '@material-ui/icons/Computer';
 import WrapText from '@material-ui/icons/WrapText';
+import TextIncrease from '@material-ui/icons/ZoomIn';
+import TextDecrease from '@material-ui/icons/ZoomOut';
 
 // Import FontAwesome icons
 import { library } from '@fortawesome/fontawesome-svg-core';
@@ -175,3 +177,5 @@ export const CanWriteIcon: IconType = (props) => <Edit {...props} />;
 export const CanManageIcon: IconType = (props) => <Computer {...props} />;
 export const AddUserIcon: IconType = (props) => <PersonAdd {...props} />;
 export const WordWrapIcon: IconType = (props) => <WrapText {...props} />;
+export const TextIncreaseIcon: IconType = (props) => <TextIncrease {...props} />;
+export const TextDecreaseIcon: IconType = (props) => <TextDecrease {...props} />;
index bbb4ff9dc62e126ba04d83aebaa566f733b094fc..56ac4d92738110dd49325a2b6ed92b4f8fb5efff 100644 (file)
@@ -21,6 +21,8 @@ import {
     CollectionIcon,
     LogIcon,
     MaximizeIcon,
+    TextDecreaseIcon,
+    TextIncreaseIcon,
     WordWrapIcon
 } from 'components/icon/icon';
 import { Process } from 'store/processes/process';
@@ -87,6 +89,10 @@ export const ProcessLogsCard = withStyles(styles)(
     ({ classes, process, filters, selectedFilter, lines, onLogFilterChange, navigateToLog,
         doHidePanel, doMaximizePanel, panelMaximized, panelName }: ProcessLogsCardProps) => {
         const [wordWrapToggle, setWordWrapToggle] = useState<boolean>(true);
+        const [fontSize, setFontSize] = useState<number>(3);
+        const fontBaseSize = 10;
+        const fontStepSize = 1;
+
         return <Grid item className={classes.root} xs={12}>
             <Card className={classes.card}>
                 <CardHeader className={classes.header}
@@ -96,6 +102,20 @@ export const ProcessLogsCard = withStyles(styles)(
                             <ProcessLogForm selectedFilter={selectedFilter}
                                 filters={filters} onChange={onLogFilterChange} />
                         </Grid>
+                        <Grid item>
+                            <Tooltip title="Decrease font size" disableFocusListener>
+                                <IconButton onClick={() => fontSize > 1 && setFontSize(fontSize-1)}>
+                                    <TextDecreaseIcon />
+                                </IconButton>
+                            </Tooltip>
+                        </Grid>
+                        <Grid item>
+                            <Tooltip title="Increase font size" disableFocusListener>
+                                <IconButton onClick={() => fontSize < 5 && setFontSize(fontSize+1)}>
+                                    <TextIncreaseIcon />
+                                </IconButton>
+                            </Tooltip>
+                        </Grid>
                         <Grid item>
                             <Tooltip title="Toggle word wrapping" disableFocusListener>
                                 <IconButton onClick={() => setWordWrapToggle(!wordWrapToggle)}>
@@ -133,7 +153,7 @@ export const ProcessLogsCard = withStyles(styles)(
                             spacing={24}
                             direction='column'>
                             <Grid className={classes.logViewer} item xs>
-                                <ProcessLogCodeSnippet wordWrap={wordWrapToggle} lines={lines} />
+                                <ProcessLogCodeSnippet fontSize={fontBaseSize+(fontStepSize*fontSize)} wordWrap={wordWrapToggle} lines={lines} />
                             </Grid>
                         </Grid>
                         : <DefaultView
index eb3ede6f5f2ee75aa0c01f5e4a46dc340a598023..1ea839122125c6ba8b270a7448776e9519120b9e 100644 (file)
@@ -38,13 +38,14 @@ const theme = createMuiTheme({
 
 interface ProcessLogCodeSnippetProps {
     lines: string[];
+    fontSize: number;
     wordWrap?: boolean;
 }
 
 export const ProcessLogCodeSnippet = withStyles(styles)(
     (props: ProcessLogCodeSnippetProps & WithStyles<CssRules>) =>
         <MuiThemeProvider theme={theme}>
-            <CodeSnippet lines={props.lines}
+            <CodeSnippet lines={props.lines} fontSize={props.fontSize}
                 className={props.wordWrap ? props.classes.wordWrap : undefined}
                 containerClassName={props.classes.codeSnippetContainer} />
         </MuiThemeProvider>);
\ No newline at end of file