15672: Adds renderers for create_at and container run time
authorEric Biagiotti <ebiagiotti@veritasgenetics.com>
Tue, 3 Dec 2019 00:38:28 +0000 (19:38 -0500)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 17 Dec 2019 20:44:03 +0000 (17:44 -0300)
Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti@veritasgenetics.com>

src/common/formatters.ts
src/views-components/data-explorer/renderers.tsx
src/views/link-account-panel/link-account-panel-root.tsx

index 819875bec14c6527ce177ee6478ac435a698844d..1386338c900197a2aa2d918f11a02195d6e88729 100644 (file)
@@ -31,10 +31,15 @@ export const formatFileSize = (size?: number) => {
     return "";
 };
 
-export const formatTime = (time: number) => {
+export const formatTime = (time: number, seconds?: boolean) => {
     const minutes = Math.floor(time / (1000 * 60) % 60).toFixed(0);
     const hours = Math.floor(time / (1000 * 60 * 60)).toFixed(0);
 
+    if (seconds) {
+        const seconds = Math.floor(time / (1000) % 60).toFixed(0);
+        return hours + "h " + minutes + "m " + seconds + "s";
+    }
+
     return hours + "h " + minutes + "m";
 };
 
index 47ec76c892b9a25ca68e97f609ba7ce1c5122b22..7680f33895e5675879df68a50eb9990898c550de 100644 (file)
@@ -7,13 +7,13 @@ import { Grid, Typography, withStyles, Tooltip, IconButton, Checkbox } from '@ma
 import { FavoriteStar, PublicFavoriteStar } from '../favorite-star/favorite-star';
 import { ResourceKind, TrashableResource } from '~/models/resource';
 import { ProjectIcon, CollectionIcon, ProcessIcon, DefaultIcon, WorkflowIcon, ShareIcon } from '~/components/icon/icon';
-import { formatDate, formatFileSize } from '~/common/formatters';
+import { formatDate, formatFileSize, formatTime } from '~/common/formatters';
 import { resourceLabel } from '~/common/labels';
 import { connect, DispatchProp } from 'react-redux';
 import { RootState } from '~/store/store';
 import { getResource } from '~/store/resources/resources';
 import { GroupContentsResource } from '~/services/groups-service/groups-service';
-import { getProcess, Process, getProcessStatus, getProcessStatusColor } from '~/store/processes/process';
+import { getProcess, Process, getProcessStatus, getProcessStatusColor, getProcessRuntime } from '~/store/processes/process';
 import { ArvadosTheme } from '~/common/custom-theme';
 import { compose, Dispatch } from 'redux';
 import { WorkflowResource } from '~/models/workflow';
@@ -383,6 +383,12 @@ export const ResourceLastModifiedDate = connect(
         return { date: resource ? resource.modifiedAt : '' };
     })((props: { date: string }) => renderDate(props.date));
 
+export const ResourceCreatedAtDate = connect(
+    (state: RootState, props: { uuid: string }) => {
+        const resource = getResource<GroupContentsResource>(props.uuid)(state.resources);
+        return { date: resource ? resource.createdAt : '' };
+    })((props: { date: string }) => renderDate(props.date));
+
 export const ResourceTrashDate = connect(
     (state: RootState, props: { uuid: string }) => {
         const resource = getResource<TrashableResource>(props.uuid)(state.resources);
@@ -449,3 +455,14 @@ export const ProcessStatus = compose(
             {status}
         </Typography>;
     });
+
+export const renderRunTime = (time: number) =>
+    <Typography noWrap style={{ minWidth: '45px' }}>
+        {formatTime(time, true)}
+    </Typography>;
+
+export const ContainerRunTime = connect(
+    (state: RootState, props: { uuid: string }) => {
+        const process = getProcess(props.uuid)(state.resources);
+        return { time: process ? getProcessRuntime(process) : 0 };
+    })((props: { time: number }) => renderRunTime(props.time));
\ No newline at end of file
index 2438f04e4f2dd1ec74e6cb8435848deae4c6eac2..10de75e800acd26ed2d9bfbd0d485901ba2e98be 100644 (file)
@@ -139,7 +139,7 @@ export const LinkAccountPanelRoot = withStyles(styles)(
                                             <Grid item>
                                                 <Button color="primary" variant="contained" onClick={() => startLinking(LinkAccountType.ADD_LOCAL_TO_REMOTE)}>
                                                     Link an account from {localCluster} to this account
-                                                               </Button>
+                                                                   </Button>
                                             </Grid> </>
                                         : <Grid item>Please visit cluster
                                                        <a href={remoteHostsConfig[loginCluster].workbench2Url + "/link_account"}>{loginCluster}</a>