X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/38d27e9783f7f760cee84cc225e86144069848c4..85836abe716b2403f3b7fe75c551e4ace3995157:/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 10be5d63..091a8198 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'; @@ -12,9 +12,13 @@ import { saveRequestedDate, loadVirtualMachinesUserData } from 'store/virtual-ma import { RootState } from 'store/store'; import { ListResults } from 'services/common-service/common-service'; 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"; -type CssRules = 'button' | 'codeSnippet' | 'link' | 'linkIcon' | 'rightAlign' | 'cardWithoutMachines' | 'icon'; +type CssRules = 'button' | 'codeSnippet' | 'link' | 'linkIcon' | 'rightAlign' | 'cardWithoutMachines' | 'icon' | 'chipsRoot'; + +const EXTRA_TOKEN = "exraToken"; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ button: { @@ -52,7 +56,10 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ icon: { textAlign: "right", marginTop: theme.spacing.unit - } + }, + chipsRoot: { + margin: `0px -${theme.spacing.unit / 2}px`, + }, }); const mapStateToProps = (state: RootState) => { @@ -61,7 +68,10 @@ const mapStateToProps = (state: RootState) => { userUuid: state.auth.user!.uuid, helpText: state.auth.config.clusterConfig.Workbench.SSHHelpPageHTML, hostSuffix: state.auth.config.clusterConfig.Workbench.SSHHelpHostSuffix || "", - webShell: state.auth.config.clusterConfig.Services.Workbench1.ExternalURL, + token: state.auth.extraApiToken || state.auth.apiToken || '', + tokenLocation: state.auth.extraApiToken ? EXTRA_TOKEN : (state.auth.apiTokenLocation || ''), + webshellUrl: state.auth.config.clusterConfig.Services.WebShell.ExternalURL, + idleTimeout: parse(state.auth.config.clusterConfig.Workbench.IdleTimeout, 's') || 0, ...state.virtualMachines }; }; @@ -78,7 +88,10 @@ interface VirtualMachinesPanelDataProps { links: ListResults; helpText: string; hostSuffix: string; - webShell: string; + token: string; + tokenLocation: string; + webshellUrl: string; + idleTimeout: number; } interface VirtualMachinesPanelActionProps { @@ -164,27 +177,43 @@ const virtualMachinesTable = (props: VirtualMachineProps) => Host name Login name + Groups Command line - {props.webShell !== "" && Web shell} + Web shell {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)}`; + } return {it.hostname} {username} + + + { + (lk.properties.groups || []).map((group, i) => ( + + + + )) + } + + {command} - {props.webShell !== "" && - + + Log in as {username} - } + ; } return null;