mirror of https://github.com/docker/docs.git
commit
68338dd414
|
@ -31,7 +31,7 @@ var ContainerListItem = React.createClass({
|
||||||
});
|
});
|
||||||
ContainerStore.remove(this.props.container.Name, () => {
|
ContainerStore.remove(this.props.container.Name, () => {
|
||||||
var containers = ContainerStore.sorted();
|
var containers = ContainerStore.sorted();
|
||||||
if (containers.length === 1) {
|
if (containers.length === 0) {
|
||||||
$(document.body).find('.new-container-item').parent().fadeIn();
|
$(document.body).find('.new-container-item').parent().fadeIn();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -218,7 +218,6 @@ var ContainerStore = assign(Object.create(EventEmitter.prototype), {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
var placeholderData = JSON.parse(localStorage.getItem('store.placeholders'));
|
var placeholderData = JSON.parse(localStorage.getItem('store.placeholders'));
|
||||||
console.log(placeholderData);
|
|
||||||
if (placeholderData) {
|
if (placeholderData) {
|
||||||
_placeholders = _.omit(placeholderData, _.keys(_containers));
|
_placeholders = _.omit(placeholderData, _.keys(_containers));
|
||||||
localStorage.setItem('store.placeholders', JSON.stringify(_placeholders));
|
localStorage.setItem('store.placeholders', JSON.stringify(_placeholders));
|
||||||
|
@ -287,16 +286,20 @@ var ContainerStore = assign(Object.create(EventEmitter.prototype), {
|
||||||
_muted[containerName] = true;
|
_muted[containerName] = true;
|
||||||
_progress[containerName] = 0;
|
_progress[containerName] = 0;
|
||||||
this._pullImage(repository, tag, () => {
|
this._pullImage(repository, tag, () => {
|
||||||
metrics.track('Container Finished Creating');
|
_blocked[containerName] = false;
|
||||||
|
if (!_placeholders[containerName]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
delete _placeholders[containerName];
|
delete _placeholders[containerName];
|
||||||
localStorage.setItem('store.placeholders', JSON.stringify(_placeholders));
|
localStorage.setItem('store.placeholders', JSON.stringify(_placeholders));
|
||||||
_blocked[containerName] = false;
|
|
||||||
this._createContainer(containerName, {Image: imageName}, () => {
|
this._createContainer(containerName, {Image: imageName}, () => {
|
||||||
|
metrics.track('Container Finished Creating');
|
||||||
delete _progress[containerName];
|
delete _progress[containerName];
|
||||||
_muted[containerName] = false;
|
_muted[containerName] = false;
|
||||||
this.emit(this.CLIENT_CONTAINER_EVENT, containerName);
|
this.emit(this.CLIENT_CONTAINER_EVENT, containerName);
|
||||||
});
|
});
|
||||||
}, progress => {
|
}, progress => {
|
||||||
|
_blocked[containerName] = false;
|
||||||
_progress[containerName] = progress;
|
_progress[containerName] = progress;
|
||||||
this.emit(this.SERVER_PROGRESS_EVENT, containerName);
|
this.emit(this.SERVER_PROGRESS_EVENT, containerName);
|
||||||
}, () => {
|
}, () => {
|
||||||
|
@ -342,6 +345,9 @@ var ContainerStore = assign(Object.create(EventEmitter.prototype), {
|
||||||
remove: function (name, callback) {
|
remove: function (name, callback) {
|
||||||
if (_placeholders[name]) {
|
if (_placeholders[name]) {
|
||||||
delete _placeholders[name];
|
delete _placeholders[name];
|
||||||
|
localStorage.setItem('store.placeholders', JSON.stringify(_placeholders));
|
||||||
|
this.emit(this.CLIENT_CONTAINER_EVENT, name, 'destroy');
|
||||||
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var container = docker.client().getContainer(name);
|
var container = docker.client().getContainer(name);
|
||||||
|
@ -380,7 +386,7 @@ var ContainerStore = assign(Object.create(EventEmitter.prototype), {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
containers: function() {
|
containers: function() {
|
||||||
return _.extend(_containers, _placeholders);
|
return _.extend(_.clone(_containers), _placeholders);
|
||||||
},
|
},
|
||||||
container: function (name) {
|
container: function (name) {
|
||||||
return this.containers()[name];
|
return this.containers()[name];
|
||||||
|
|
|
@ -41,17 +41,20 @@ var Containers = React.createClass({
|
||||||
ContainerStore.removeListener(ContainerStore.SERVER_CONTAINER_EVENT, this.update);
|
ContainerStore.removeListener(ContainerStore.SERVER_CONTAINER_EVENT, this.update);
|
||||||
ContainerStore.removeListener(ContainerStore.CLIENT_CONTAINER_EVENT, this.updateFromClient);
|
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) {
|
update: function (name, status) {
|
||||||
this.setState({
|
this.setState({
|
||||||
containers: ContainerStore.containers(),
|
containers: ContainerStore.containers(),
|
||||||
sorted: ContainerStore.sorted()
|
sorted: ContainerStore.sorted()
|
||||||
});
|
});
|
||||||
if (status === 'destroy') {
|
if (status === 'destroy') {
|
||||||
if (this.state.sorted.length) {
|
this.onDestroy();
|
||||||
this.transitionTo('containerHome', {name: this.state.sorted[0].Name});
|
|
||||||
} else {
|
|
||||||
this.transitionTo('containers');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateFromClient: function (name, status) {
|
updateFromClient: function (name, status) {
|
||||||
|
@ -61,6 +64,8 @@ var Containers = React.createClass({
|
||||||
});
|
});
|
||||||
if (status === 'create') {
|
if (status === 'create') {
|
||||||
this.transitionTo('containerHome', {name: name});
|
this.transitionTo('containerHome', {name: name});
|
||||||
|
} else if (status === 'destroy') {
|
||||||
|
this.onDestroy();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleScroll: function (e) {
|
handleScroll: function (e) {
|
||||||
|
|
Loading…
Reference in New Issue