X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/80cadd658a7a51917338036a1044c5549f62ba1c..099468843d687fdc8c6fbb0f0e3dc54f59d0de15:/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx diff --git a/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx b/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx index d8725461..56c92805 100644 --- a/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx +++ b/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx @@ -4,7 +4,7 @@ import React from 'react'; import { connect } from 'react-redux'; -import { Grid, Typography, Button, Card, CardContent, TableBody, TableCell, TableHead, TableRow, Table, Tooltip } from '@material-ui/core'; +import { Grid, Typography, Button, Card, CardContent, TableBody, TableCell, TableHead, TableRow, Table, Tooltip, Chip } from '@material-ui/core'; import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles'; import { ArvadosTheme } from 'common/custom-theme'; import { compose, Dispatch } from 'redux'; @@ -15,8 +15,12 @@ import { HelpIcon } from 'components/icon/icon'; import { SESSION_STORAGE } from "services/auth-service/auth-service"; // import * as CopyToClipboard from 'react-copy-to-clipboard'; import parse from "parse-duration"; +import { CopyIcon } from 'components/icon/icon'; +import CopyToClipboard from 'react-copy-to-clipboard'; +import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions'; +import { sanitizeHTML } from 'common/html-sanitize'; -type CssRules = 'button' | 'codeSnippet' | 'link' | 'linkIcon' | 'rightAlign' | 'cardWithoutMachines' | 'icon'; +type CssRules = 'button' | 'codeSnippet' | 'link' | 'linkIcon' | 'rightAlign' | 'cardWithoutMachines' | 'icon' | 'chipsRoot' | 'copyIcon' | 'tableWrapper' | 'webshellButton'; const EXTRA_TOKEN = "exraToken"; @@ -56,7 +60,25 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ icon: { textAlign: "right", marginTop: theme.spacing.unit - } + }, + chipsRoot: { + margin: `0px -${theme.spacing.unit / 2}px`, + }, + copyIcon: { + marginLeft: theme.spacing.unit, + color: theme.palette.grey["500"], + cursor: 'pointer', + display: 'inline', + '& svg': { + fontSize: '1rem' + } + }, + tableWrapper: { + overflowX: 'auto', + }, + webshellButton: { + textTransform: "initial", + }, }); const mapStateToProps = (state: RootState) => { @@ -73,9 +95,16 @@ const mapStateToProps = (state: RootState) => { }; }; -const mapDispatchToProps = (dispatch: Dispatch): Pick => ({ +const mapDispatchToProps = (dispatch: Dispatch): Pick => ({ saveRequestedDate: () => dispatch(saveRequestedDate()), loadVirtualMachinesData: () => dispatch(loadVirtualMachinesUserData()), + onCopy: (message: string) => { + dispatch(snackbarActions.OPEN_SNACKBAR({ + message, + hideDuration: 2000, + kind: SnackbarKind.SUCCESS + })); + }, }); interface VirtualMachinesPanelDataProps { @@ -94,6 +123,7 @@ interface VirtualMachinesPanelDataProps { interface VirtualMachinesPanelActionProps { saveRequestedDate: () => void; loadVirtualMachinesData: () => string; + onCopy: (message: string) => void; } type VirtualMachineProps = VirtualMachinesPanelActionProps & VirtualMachinesPanelDataProps & WithStyles; @@ -109,7 +139,7 @@ export const VirtualMachineUserPanel = compose( render() { const { virtualMachines, links } = this.props; return ( - + {virtualMachines.itemsAvailable === 0 && } {virtualMachines.itemsAvailable > 0 && links.itemsAvailable > 0 && } {} @@ -150,7 +180,9 @@ const CardContentWithVirtualMachines = (props: VirtualMachineProps) => - {virtualMachinesTable(props)} +
+ {virtualMachinesTable(props)} +
@@ -169,11 +201,12 @@ const virtualMachineSendRequest = (props: VirtualMachineProps) => ; const virtualMachinesTable = (props: VirtualMachineProps) => - +
Host name Login name + Groups Command line Web shell @@ -181,23 +214,48 @@ const virtualMachinesTable = (props: VirtualMachineProps) => {props.virtualMachines.items.map(it => props.links.items.map(lk => { - if (lk.tailUuid === props.userUuid) { + if (lk.tailUuid === props.userUuid && lk.headUuid === it.uuid) { const username = lk.properties.username; const command = `ssh ${username}@${it.hostname}${props.hostSuffix}`; let tokenParam = ""; if (props.tokenLocation === SESSION_STORAGE || props.tokenLocation === EXTRA_TOKEN) { tokenParam = `&token=${encodeURIComponent(props.token)}`; } + const loginHref = `/webshell/?host=${encodeURIComponent(props.webshellUrl + '/' + it.hostname)}&timeout=${props.idleTimeout}&login=${encodeURIComponent(username)}${tokenParam}`; return {it.hostname} {username} + + + { + (lk.properties.groups || []).map((group, i) => ( + + + + )) + } + + {command} + + + props.onCopy!("Copied")}> + + + + - - Log in as {username} - + ; } @@ -212,7 +270,7 @@ const CardSSHSection = (props: VirtualMachineProps) => -
+