virtual-machines-admin-panel
authorPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Fri, 30 Nov 2018 16:16:41 +0000 (17:16 +0100)
committerPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Fri, 30 Nov 2018 16:16:41 +0000 (17:16 +0100)
Feature #14498

Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>

src/models/virtual-machines.ts
src/store/virtual-machines/virtual-machines-actions.ts
src/views/virtual-machine-panel/virtual-machine-panel.tsx

index acc084a3ea0b37601faa777cbe758d49cbbc80c3..85d0a565c07bf18ab34b67386008357be07d3a91 100644 (file)
@@ -12,9 +12,9 @@ export interface VirtualMachinesLoginsItems {
     hostname: string;
     username: string;
     public_key: string;
-    user_uuid: string;
-    virtual_machine_uuid: string;
-    authorized_key_uuid: string;
+    userUuid: string;
+    virtualMachineUuid: string;
+    authorizedKeyUuid: string;
 }
 
 export interface VirtualMachineLogins {
index bb942bb6dcf03a43810c3a84fb413a3a4e5f671e..d87433f99f04a2b55bb6ad7040e4276ae6b4e82e 100644 (file)
@@ -57,8 +57,8 @@ export const loadVirtualMachinesData = () =>
         });
         dispatch(virtualMachinesActions.SET_VIRTUAL_MACHINES(virtualMachines));
         dispatch(virtualMachinesActions.SET_LINKS(links));
-        const logins = await services.virtualMachineService.logins(virtualMachinesUuids[0]);
-        dispatch(virtualMachinesActions.SET_LOGINS(logins));
+        const getAllLogins = await services.virtualMachineService.getAllLogins();
+        dispatch(virtualMachinesActions.SET_LOGINS(getAllLogins));
     };
 
 export const saveRequestedDate = () =>
index 6c8955448c64d3a9c1b699d5c04f53a0289af70b..de5e33a059c7e9152dfa9a4b064b66d3eca68e50 100644 (file)
@@ -113,7 +113,7 @@ export const VirtualMachinePanel = compose(
                 const { virtualMachines, links, isAdmin } = this.props;
                 return (
                     <Grid container spacing={16}>
-                        {virtualMachines.itemsAvailable === 0 && <CardContentWithNoVirtualMachines {...this.props} />}
+                        {!isAdmin && virtualMachines.itemsAvailable > 0 && <CardContentWithNoVirtualMachines {...this.props} />}
                         {virtualMachines.itemsAvailable > 0 && links.itemsAvailable > 0 && <CardContentWithVirtualMachines {...this.props} />}
                         {!isAdmin && <CardSSHSection {...this.props} />}
                     </Grid>
@@ -148,16 +148,8 @@ const CardContentWithVirtualMachines = (props: VirtualMachineProps) =>
     <Grid item xs={12}>
         <Card>
             <CardContent>
-                {props.isAdmin ?
-                    <span>
-                        <div className={props.classes.rightAlign}>
-                            <Button variant="contained" color="primary" className={props.classes.button} onClick={props.saveRequestedDate}>
-                                <AddIcon /> NEW VIRTUAL MACHINE
-                            </Button>
-                        </div>
-                        {adminVirtualMachinesTable(props)}
-                    </span> :
-                    <span>
+                {props.isAdmin ? <span>{adminVirtualMachinesTable(props)}</span>
+                    : <span>
                         <div className={props.classes.rightAlign}>
                             <Button variant="contained" color="primary" className={props.classes.button} onClick={props.saveRequestedDate}>
                                 SEND REQUEST FOR SHELL ACCESS
@@ -195,11 +187,11 @@ const userVirtualMachinesTable = (props: VirtualMachineProps) =>
             {props.virtualMachines.items.map((it, index) =>
                 <TableRow key={index}>
                     <TableCell>{it.hostname}</TableCell>
-                    <TableCell>{getUsername(props.links, it)}</TableCell>
-                    <TableCell>ssh {getUsername(props.links, it)}@shell.arvados</TableCell>
+                    <TableCell>{getUsername(props.links)}</TableCell>
+                    <TableCell>ssh {getUsername(props.links)}@{it.hostname}.arvados</TableCell>
                     <TableCell>
-                        <a href={`https://workbench.c97qk.arvadosapi.com${it.href}/webshell/${getUsername(props.links, it)}`} target="_blank" className={props.classes.link}>
-                            Log in as {getUsername(props.links, it)}
+                        <a href={`https://workbench.c97qk.arvadosapi.com${it.href}/webshell/${getUsername(props.links)}`} target="_blank" className={props.classes.link}>
+                            Log in as {getUsername(props.links)}
                         </a>
                     </TableCell>
                 </TableRow>
@@ -221,7 +213,7 @@ const adminVirtualMachinesTable = (props: VirtualMachineProps) =>
             {props.logins.items.length > 0 && props.virtualMachines.items.map((it, index) =>
                 <TableRow key={index}>
                     <TableCell>{it.uuid}</TableCell>
-                    <TableCell>{props.logins.items[0].hostname}</TableCell>
+                    <TableCell>{it.hostname}</TableCell>
                     <TableCell>["{props.logins.items[0].username}"]</TableCell>
                     <TableCell className={props.classes.moreOptions}>
                         <Tooltip title="More options" disableFocusListener>
@@ -235,9 +227,8 @@ const adminVirtualMachinesTable = (props: VirtualMachineProps) =>
         </TableBody>
     </Table>;
 
-const getUsername = (links: ListResults<any>, virtualMachine: VirtualMachinesResource) => {
-    const link = links.items.find((item: any) => item.headUuid === virtualMachine.uuid);
-    return link.properties.username || undefined;
+const getUsername = (links: ListResults<any>) => {
+    return links.items[0].properties.username;
 };
 
 const CardSSHSection = (props: VirtualMachineProps) =>