X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/9a37cc202448e431064b247d36ac0229a6bfa9b2..5b88c131a4bbff645ab7791ce9d6c2e3dcca49a9:/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 5cb4565e..66ea017e 100644 --- a/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx +++ b/src/views/virtual-machine-panel/virtual-machine-user-panel.tsx @@ -2,21 +2,23 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; +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 { DefaultCodeSnippet } from '~/components/default-code-snippet/default-code-snippet'; -import { Link } from 'react-router-dom'; +import { ArvadosTheme } from 'common/custom-theme'; import { compose, Dispatch } from 'redux'; -import { saveRequestedDate, loadVirtualMachinesUserData } from '~/store/virtual-machines/virtual-machines-actions'; -import { RootState } from '~/store/store'; -import { ListResults } from '~/services/common-service/common-service'; -import { HelpIcon } from '~/components/icon/icon'; -import { Routes } from '~/routes/routes'; +import { saveRequestedDate, loadVirtualMachinesUserData } from 'store/virtual-machines/virtual-machines-actions'; +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: { @@ -54,13 +56,22 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ icon: { textAlign: "right", marginTop: theme.spacing.unit - } + }, + chipsRoot: { + margin: `0px -${theme.spacing.unit / 2}px`, + }, }); const mapStateToProps = (state: RootState) => { return { requestedDate: state.virtualMachines.date, userUuid: state.auth.user!.uuid, + helpText: state.auth.config.clusterConfig.Workbench.SSHHelpPageHTML, + hostSuffix: state.auth.config.clusterConfig.Workbench.SSHHelpHostSuffix || "", + 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 }; }; @@ -75,6 +86,12 @@ interface VirtualMachinesPanelDataProps { virtualMachines: ListResults; userUuid: string; links: ListResults; + helpText: string; + hostSuffix: string; + token: string; + tokenLocation: string; + webshellUrl: string; + idleTimeout: number; } interface VirtualMachinesPanelActionProps { @@ -95,7 +112,7 @@ export const VirtualMachineUserPanel = compose( render() { const { virtualMachines, links } = this.props; return ( - + {virtualMachines.itemsAvailable === 0 && } {virtualMachines.itemsAvailable > 0 && links.itemsAvailable > 0 && } {} @@ -110,7 +127,7 @@ const CardContentWithoutVirtualMachines = (props: VirtualMachineProps) => - + You do not have access to any virtual machines. Some Arvados features require using the command line. You may request access to a hosted virtual machine with the command line shell. @@ -130,7 +147,7 @@ const CardContentWithVirtualMachines = (props: VirtualMachineProps) => {virtualMachineSendRequest(props)}
- + @@ -149,56 +166,69 @@ const virtualMachineSendRequest = (props: VirtualMachineProps) => SEND REQUEST FOR SHELL ACCESS {props.requestedDate && - + A request for shell access was sent on {props.requestedDate} } ; const virtualMachinesTable = (props: VirtualMachineProps) => - +
Host name Login name + Groups Command line Web shell - {props.virtualMachines.items.map((it, index) => - - {it.hostname} - {getUsername(props.links, props.userUuid)} - ssh {getUsername(props.links, props.userUuid)}@{it.hostname}.arvados - - - Log in as {getUsername(props.links, props.userUuid)} - - - - )} + {props.virtualMachines.items.map(it => + props.links.items.map(lk => { + 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} + + + + Log in as {username} + + + ; + } + return null; + } + ))}
; -const getUsername = (links: ListResults, userUuid: string) => { - return links.items.map(it => it.tailUuid === userUuid ? it.properties.username : ''); -}; - const CardSSHSection = (props: VirtualMachineProps) => - - In order to access virtual machines using SSH, add an SSH key to your account and add a section like this to your SSH configuration file ( ~/.ssh/config): + +
- ; - -const textSSH = `Host *.arvados - TCPKeepAlive yes - ServerAliveInterval 60 - ProxyCommand ssh -p2222 turnout@switchyard.api.ardev.roche.com -x -a $SSH_PROXY_FLAGS %h`; \ No newline at end of file