import _ from 'underscore'; import $ from 'jquery'; import React from 'react/addons'; import Radial from './Radial.react'; import ContainerProgress from './ContainerProgress.react'; import ContainerHomePreview from './ContainerHomePreview.react'; import ContainerHomeLogs from './ContainerHomeLogs.react'; import ContainerHomeFolders from './ContainerHomeFolders.react'; import shell from 'shell'; var ContainerHome = React.createClass({ contextTypes: { router: React.PropTypes.func }, componentDidMount: function() { this.handleResize(); window.addEventListener('resize', this.handleResize); }, componentWillUnmount: function() { window.removeEventListener('resize', this.handleResize); }, componentDidUpdate: function () { this.handleResize(); }, handleResize: function () { $('.full .wrapper').height(window.innerHeight - 132); $('.left .wrapper').height(window.innerHeight - 132); $('.right .wrapper').height(window.innerHeight / 2 - 55); }, handleErrorClick: function () { shell.openExternal('https://github.com/kitematic/kitematic/issues/new'); }, showWeb: function () { return _.keys(this.props.ports).length > 0; }, showFolders: function () { return this.props.container.Mounts && this.props.container.Mounts.length > 0 && this.props.container.State.Running; }, render: function () { if (!this.props.container) { return; } let body; if (this.props.container.Error) { body = (

We're sorry. There seem to be an error:

{this.props.container.Error}

If this error is invalid, please file a ticket on our Github repo.

File Ticket
); } else if (this.props.container && this.props.container.State.Downloading) { if (this.props.container.Progress) { let values = []; let sum = 0.0; for (let i = 0; i < this.props.container.Progress.amount; i++) { values.push(Math.round(this.props.container.Progress.progress[i].value)); sum += this.props.container.Progress.progress[i].value; } sum = sum / this.props.container.Progress.amount; body = (

Downloading Image

{(Math.round(sum*100)/100).toFixed(2)}%

); } else if (this.props.container.State.Waiting) { body = (

Waiting For Another Download

); } else { body = (

Connecting to Docker Hub

); } } else { var logWidget = ( ); var webWidget; if (this.showWeb()) { webWidget = ( ); } var folderWidget; if (this.showFolders()) { folderWidget = ( ); } if (logWidget && !webWidget && !folderWidget) { body = (
{logWidget}
); } else { body = (
{logWidget}
{webWidget} {folderWidget}
); } } return body; } }); module.exports = ContainerHome;