var _ = require('underscore'); var $ = require('jquery'); var React = require('react/addons'); var Radial = require('./Radial.react'); var ContainerProgress = require('./ContainerProgress.react'); var ContainerHomePreview = require('./ContainerHomePreview.react'); var ContainerHomeLogs = require('./ContainerHomeLogs.react'); var ContainerHomeFolders = require('./ContainerHomeFolders.react'); var shell = require('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 () { $('.left .wrapper').height(window.innerHeight - 240); $('.right .wrapper').height(window.innerHeight / 2 - 100); }, handleErrorClick: function () { shell.openExternal('https://github.com/kitematic/kitematic/issues/new'); }, render: function () { if (!this.props.container) { return; } let body; if (this.props.container.Error) { body = (

An error occurred:

{this.props.container.Error.message}

If you feel that this error is invalid, please file a ticket on our GitHub repo.

); } 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 { if (this.props.defaultPort) { body = (
); } else { var right; if (_.keys(this.props.ports) > 0) { right = (
); } else { right = (
); } body = (
{right}
); } } return body; } }); module.exports = ContainerHome;