Skip to content

Commit

Permalink
Merge pull request #27 from exacaster/external_logs_link
Browse files Browse the repository at this point in the history
Add support for external logs link
  • Loading branch information
pdambrauskas authored Feb 11, 2022
2 parents 2bbe429 + c8c5343 commit 4548788
Show file tree
Hide file tree
Showing 16 changed files with 3,247 additions and 3,188 deletions.
1 change: 1 addition & 0 deletions frontend/src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ export type BatchPage = {

export type Configuration = {
sparkHistoryServerUrl?: string;
externalLogsUrlTemplate?: string;
};
45 changes: 45 additions & 0 deletions frontend/src/components/AppActions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {ExternalLinkIcon, CloseIcon, CalendarIcon} from '@chakra-ui/icons';
import {HStack, IconButton, Link as ExLink} from '@chakra-ui/react';
import React from 'react';
import {Application} from '../client/types';
import {useConfiguration} from '../hooks/configuration';
import {formatLink} from '../utils/application';

interface Props {
app: Application;
onDelete?: () => void;
}

const AppActions: React.FC<Props> = ({app, onDelete}) => {
const {data: conf} = useConfiguration();

return (
<HStack>
{!!conf?.sparkHistoryServerUrl && !!app.appId && (
<IconButton
size="sm"
icon={<ExternalLinkIcon />}
title="History"
aria-label="History"
as={ExLink}
target="_blank"
href={`${conf.sparkHistoryServerUrl}/history/${app.appId}/jobs`}
/>
)}
{!!conf?.externalLogsUrlTemplate && !!app.appId && (
<IconButton
size="sm"
icon={<CalendarIcon />}
title="External logs"
aria-label="External logs"
as={ExLink}
target="_blank"
href={formatLink(conf.externalLogsUrlTemplate, app)}
/>
)}
{onDelete && <IconButton size="sm" title="Delete" aria-label="Delete" onClick={() => onDelete()} icon={<CloseIcon />} />}
</HStack>
);
};

export default AppActions;
5 changes: 5 additions & 0 deletions frontend/src/components/AppInfo.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.noWrapTable {
td {
white-space: nowrap;
}
}
81 changes: 81 additions & 0 deletions frontend/src/components/AppInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import {Box, Table, Tbody, Td, Th, Thead, Tr} from '@chakra-ui/react';
import React from 'react';
import {Application} from '../client/types';
import styles from './AppInfo.module.scss';

interface Props {
app: Application;
}

const AppInfo: React.FC<Props> = ({app}) => {
return (
<Box mt="5">
<Table className={styles.noWrapTable} variant="simple" size="sm">
<Thead>
<Tr>
<Th>Property</Th>
<Th>Value</Th>
</Tr>
</Thead>
<Tbody>
<Tr>
<Td>File</Td>
<Td>{app.submitParams.file}</Td>
</Tr>
<Tr>
<Td>Args</Td>
<Td>{app.submitParams.args.join(', ')}</Td>
</Tr>
<Tr>
<Td>Name (--name)</Td>
<Td>{app.submitParams.name}</Td>
</Tr>
<Tr>
<Td>Driver Cores (--driver-cores)</Td>
<Td>{app.submitParams.driverCores}</Td>
</Tr>
<Tr>
<Td>Driver Memory (--driver-memory)</Td>
<Td>{app.submitParams.driverMemory}</Td>
</Tr>
<Tr>
<Td>Number Of Executors (--num-executors)</Td>
<Td>{app.submitParams.numExecutors}</Td>
</Tr>
<Tr>
<Td>Executor Cores (--executor-cores)</Td>
<Td>{app.submitParams.executorCores}</Td>
</Tr>
<Tr>
<Td>Executor Memory (--executor-memory)</Td>
<Td>{app.submitParams.executorMemory}</Td>
</Tr>
<Tr>
<Td>Python files (--py-files)</Td>
<Td>{app.submitParams.pyFiles.join(', ')}</Td>
</Tr>
<Tr>
<Td>Archives (--archives)</Td>
<Td>{app.submitParams.archives.join(', ')}</Td>
</Tr>
<Tr>
<Td>Additional files (--files)</Td>
<Td>{app.submitParams.files.join(', ')}</Td>
</Tr>
<Tr>
<Td>Additional JARs (--jars)</Td>
<Td>{app.submitParams.jars.join(', ')}</Td>
</Tr>
{Object.entries(app.submitParams.conf).map(([name, val]) => (
<Tr key={name}>
<Td>--conf {name}</Td>
<Td>{val}</Td>
</Tr>
))}
</Tbody>
</Table>
</Box>
);
};

export default AppInfo;
5 changes: 5 additions & 0 deletions frontend/src/components/AppLogs.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.logs {
white-space: pre-wrap;
max-width: 100%;
font-size: 12px;
}
26 changes: 26 additions & 0 deletions frontend/src/components/AppLogs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {ExternalLinkIcon} from '@chakra-ui/icons';
import {Code, Link} from '@chakra-ui/react';
import React from 'react';
import {ApplicationLog} from '../client/types';
import styles from './AppLogs.module.scss';

interface Props {
logs: ApplicationLog | undefined;
}
const AppLogs: React.FC<Props> = ({logs}) => {
if (!logs?.log) {
return null;
}

if (logs.log.startsWith('http')) {
return (
<Link href={logs.log} isExternal>
{logs?.log} <ExternalLinkIcon mx="2px" marginBottom="5px" />
</Link>
);
}

return <Code className={styles.logs}>{logs.log}</Code>;
};

export default AppLogs;
5 changes: 5 additions & 0 deletions frontend/src/components/AppSubmit.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.command {
white-space: pre-wrap;
max-width: 100%;
font-size: 12px;
}
37 changes: 37 additions & 0 deletions frontend/src/components/AppSubmit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {Code} from '@chakra-ui/react';
import React from 'react';
import {Application} from '../client/types';
import {getSparkSubmitArg} from '../utils/application';
import styles from './AppSubmit.module.scss';

interface Props {
app: Application;
}

const AppSubmit: React.FC<Props> = ({app}) => {
return (
<Code className={styles.command}>
spark-submit
{getSparkSubmitArg('--name', app.submitParams.name)}
{getSparkSubmitArg('--driver-cores', app.submitParams.driverCores.toString())}
{getSparkSubmitArg('--driver-memory', app.submitParams.driverMemory)}
{getSparkSubmitArg('--num-executors', app.submitParams.numExecutors.toString())}
{getSparkSubmitArg('--executor-cores', app.submitParams.executorCores.toString())}
{getSparkSubmitArg('--executor-memory', app.submitParams.executorMemory)}
{getSparkSubmitArg('--py-files', app.submitParams.pyFiles.join(','))}
{getSparkSubmitArg('--archives', app.submitParams.archives.join(','))}
{getSparkSubmitArg('--files', app.submitParams.files.join(','))}
{getSparkSubmitArg('--jars', app.submitParams.jars.join(','))}
{Object.entries(app.submitParams.conf).map(([name, val]) => (
<span key={name}>
{' '}
--conf {name} {val}
</span>
))}
{' ' + app.submitParams.file}
{' ' + app.submitParams.args.join(' ')}
</Code>
);
};

export default AppSubmit;
27 changes: 27 additions & 0 deletions frontend/src/components/AppTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {Grid, GridItem} from '@chakra-ui/react';
import React from 'react';
import {Application} from '../client/types';
import AppActions from './AppActions';
import AppStatus from './AppStatus';
import PageHeading from './PageHeading';

interface Props {
app: Application;
}

const AppTitle: React.FC<Props> = ({app, children}) => {
return (
<PageHeading>
<Grid templateColumns="repeat(5, 1fr)">
<GridItem colSpan={4}>
{children} <AppStatus status={app.state} />
</GridItem>
<GridItem colSpan={1} justifySelf="end">
<AppActions app={app} />
</GridItem>
</Grid>
</PageHeading>
);
};

export default AppTitle;
13 changes: 0 additions & 13 deletions frontend/src/pages/Batch.module.scss

This file was deleted.

Loading

0 comments on commit 4548788

Please sign in to comment.