2017-01-31 23:26:29 +00:00
|
|
|
function ContainerViewModel(data) {
|
|
|
|
this.Id = data.Id;
|
|
|
|
this.Status = data.Status;
|
|
|
|
this.State = data.State;
|
|
|
|
this.Names = data.Names;
|
|
|
|
// Unavailable in Docker < 1.10
|
|
|
|
if (data.NetworkSettings && !_.isEmpty(data.NetworkSettings.Networks)) {
|
|
|
|
this.IP = data.NetworkSettings.Networks[Object.keys(data.NetworkSettings.Networks)[0]].IPAddress;
|
|
|
|
}
|
|
|
|
this.Image = data.Image;
|
|
|
|
this.Command = data.Command;
|
|
|
|
this.Checked = false;
|
2017-03-12 16:24:15 +00:00
|
|
|
this.Labels = data.Labels;
|
2017-01-31 23:26:29 +00:00
|
|
|
this.Ports = [];
|
2017-03-12 16:24:15 +00:00
|
|
|
this.Mounts = data.Mounts;
|
2017-01-31 23:26:29 +00:00
|
|
|
for (var i = 0; i < data.Ports.length; ++i) {
|
|
|
|
var p = data.Ports[i];
|
|
|
|
if (p.PublicPort) {
|
|
|
|
this.Ports.push({ host: p.IP, private: p.PrivatePort, public: p.PublicPort });
|
|
|
|
}
|
|
|
|
}
|
2017-03-12 16:24:15 +00:00
|
|
|
if (data.Portainer) {
|
|
|
|
this.Metadata = {};
|
|
|
|
if (data.Portainer.ResourceControl) {
|
|
|
|
this.Metadata.ResourceControl = {
|
|
|
|
OwnerId: data.Portainer.ResourceControl.OwnerId
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2017-01-31 23:26:29 +00:00
|
|
|
}
|