import { User } from "~/models/user";
import { AxiosInstance } from "axios";
--import { ApiActions, ProgressFn } from "~/services/api/api-actions";
++import { ApiActions } from "~/services/api/api-actions";
import * as uuid from "uuid/v4";
export const API_TOKEN_KEY = 'apiToken';
const lastName = localStorage.getItem(USER_LAST_NAME_KEY);
const uuid = localStorage.getItem(USER_UUID_KEY);
const ownerUuid = localStorage.getItem(USER_OWNER_UUID_KEY);
- const isAdmin = Boolean(localStorage.getItem(USER_IS_ADMIN));
+ const isAdmin = this.getIsAdmin();
++ console.log(isAdmin);
- return email && firstName && lastName && uuid && ownerUuid && isAdmin
+ return email && firstName && lastName && uuid && ownerUuid
? { email, firstName, lastName, uuid, ownerUuid, isAdmin }
: undefined;
}
virtualMachines: ListResults<any>;
logins: VirtualMachinesLoginsResource[];
links: ListResults<any>;
- isAdmin: string;
++ isAdmin: boolean;
}
interface VirtualMachinesPanelActionProps {
</Tooltip>
</a>
</div>
-- <Table>
-- <TableHead>
-- <TableRow>
-- <TableCell>Host name</TableCell>
-- <TableCell>Login name</TableCell>
-- <TableCell>Command line</TableCell>
-- <TableCell>Web shell</TableCell>
-- </TableRow>
-- </TableHead>
-- <TableBody>
-- {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>
-- <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>
-- </TableCell>
-- </TableRow>
-- )}
-- </TableBody>
-- </Table>
++ {console.log(props.isAdmin)}
++ {props.isAdmin ? adminVirtualMachinesTable(props) : userVirtualMachinesTable(props)}
</CardContent>
</Card>
</Grid>;
++const userVirtualMachinesTable = (props: VirtualMachineProps) =>
++ <Table>
++ <TableHead>
++ <TableRow>
++ <TableCell>Host name</TableCell>
++ <TableCell>Login name</TableCell>
++ <TableCell>Command line</TableCell>
++ <TableCell>Web shell</TableCell>
++ </TableRow>
++ </TableHead>
++ <TableBody>
++ {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>
++ <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>
++ </TableCell>
++ </TableRow>
++ )}
++ </TableBody>
++ </Table>;
++
++const adminVirtualMachinesTable = (props: VirtualMachineProps) =>
++ <Table>
++ <TableHead>
++ <TableRow>
++ <TableCell>Uuid</TableCell>
++ <TableCell>Host name</TableCell>
++ <TableCell>Logins</TableCell>
++ <TableCell/>
++ </TableRow>
++ </TableHead>
++ <TableBody>
++ {props.virtualMachines.items.map((it, index) =>
++ <TableRow key={index}>
++ <TableCell>{it.uuid}</TableCell>
++ <TableCell>shell</TableCell>
++ <TableCell>ssh {getUsername(props.links, it)}@shell.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>
++ </TableCell>
++ </TableRow>
++ )}
++ </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;