Merge pull request #197 from kitematic/fix-downloading

Fix downloading
This commit is contained in:
Jeffrey Morgan 2015-02-23 14:15:18 -05:00
commit 68338dd414
3 changed files with 21 additions and 10 deletions

View File

@ -31,7 +31,7 @@ var ContainerListItem = React.createClass({
});
ContainerStore.remove(this.props.container.Name, () => {
var containers = ContainerStore.sorted();
if (containers.length === 1) {
if (containers.length === 0) {
$(document.body).find('.new-container-item').parent().fadeIn();
}
});

View File

@ -218,7 +218,6 @@ var ContainerStore = assign(Object.create(EventEmitter.prototype), {
callback();
}
var placeholderData = JSON.parse(localStorage.getItem('store.placeholders'));
console.log(placeholderData);
if (placeholderData) {
_placeholders = _.omit(placeholderData, _.keys(_containers));
localStorage.setItem('store.placeholders', JSON.stringify(_placeholders));
@ -287,16 +286,20 @@ var ContainerStore = assign(Object.create(EventEmitter.prototype), {
_muted[containerName] = true;
_progress[containerName] = 0;
this._pullImage(repository, tag, () => {
metrics.track('Container Finished Creating');
_blocked[containerName] = false;
if (!_placeholders[containerName]) {
return;
}
delete _placeholders[containerName];
localStorage.setItem('store.placeholders', JSON.stringify(_placeholders));
_blocked[containerName] = false;
this._createContainer(containerName, {Image: imageName}, () => {
metrics.track('Container Finished Creating');
delete _progress[containerName];
_muted[containerName] = false;
this.emit(this.CLIENT_CONTAINER_EVENT, containerName);
});
}, progress => {
_blocked[containerName] = false;
_progress[containerName] = progress;
this.emit(this.SERVER_PROGRESS_EVENT, containerName);
}, () => {
@ -342,6 +345,9 @@ var ContainerStore = assign(Object.create(EventEmitter.prototype), {
remove: function (name, callback) {
if (_placeholders[name]) {
delete _placeholders[name];
localStorage.setItem('store.placeholders', JSON.stringify(_placeholders));
this.emit(this.CLIENT_CONTAINER_EVENT, name, 'destroy');
callback();
return;
}
var container = docker.client().getContainer(name);
@ -380,7 +386,7 @@ var ContainerStore = assign(Object.create(EventEmitter.prototype), {
}
},
containers: function() {
return _.extend(_containers, _placeholders);
return _.extend(_.clone(_containers), _placeholders);
},
container: function (name) {
return this.containers()[name];

View File

@ -41,17 +41,20 @@ var Containers = React.createClass({
ContainerStore.removeListener(ContainerStore.SERVER_CONTAINER_EVENT, this.update);
ContainerStore.removeListener(ContainerStore.CLIENT_CONTAINER_EVENT, this.updateFromClient);
},
onDestroy: function () {
if (this.state.sorted.length) {
this.transitionTo('containerHome', {name: this.state.sorted[0].Name});
} else {
this.transitionTo('containers');
}
},
update: function (name, status) {
this.setState({
containers: ContainerStore.containers(),
sorted: ContainerStore.sorted()
});
if (status === 'destroy') {
if (this.state.sorted.length) {
this.transitionTo('containerHome', {name: this.state.sorted[0].Name});
} else {
this.transitionTo('containers');
}
this.onDestroy();
}
},
updateFromClient: function (name, status) {
@ -61,6 +64,8 @@ var Containers = React.createClass({
});
if (status === 'create') {
this.transitionTo('containerHome', {name: name});
} else if (status === 'destroy') {
this.onDestroy();
}
},
handleScroll: function (e) {