+
+export const ProcessStartDate = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const process = getProcess(props.uuid)(state.resources);
+ return { date: (process && process.container) ? process.container.startedAt : '' };
+ })((props: { date: string }) => renderDate(props.date));
+
+export const renderRunTime = (time: number) =>
+ <Typography noWrap style={{ minWidth: '45px' }}>
+ {formatTime(time, true)}
+ </Typography>;
+
+interface ContainerRunTimeProps {
+ process: Process;
+}
+
+interface ContainerRunTimeState {
+ runtime: number;
+}
+
+export const ContainerRunTime = connect((state: RootState, props: { uuid: string }) => {
+ return { process: getProcess(props.uuid)(state.resources) };
+})(class extends React.Component<ContainerRunTimeProps, ContainerRunTimeState> {
+ private timer: any;
+
+ constructor(props: ContainerRunTimeProps) {
+ super(props);
+ this.state = { runtime: this.getRuntime() };
+ }
+
+ getRuntime() {
+ return this.props.process ? getProcessRuntime(this.props.process) : 0;
+ }
+
+ updateRuntime() {
+ this.setState({ runtime: this.getRuntime() });
+ }
+
+ componentDidMount() {
+ this.timer = setInterval(this.updateRuntime.bind(this), 5000);
+ }
+
+ componentWillUnmount() {
+ clearInterval(this.timer);
+ }
+
+ render() {
+ return renderRunTime(this.state.runtime);
+ }
+});