2017-02-10 01:11:36 +00:00
|
|
|
function TemplateViewModel(data) {
|
2017-11-07 07:18:23 +00:00
|
|
|
this.Type = data.type;
|
2018-02-28 07:59:31 +00:00
|
|
|
this.Name = data.name;
|
2018-05-02 18:41:46 +00:00
|
|
|
this.Hostname = data.hostname;
|
2017-02-10 01:11:36 +00:00
|
|
|
this.Title = data.title;
|
|
|
|
this.Description = data.description;
|
2017-05-18 21:00:08 +00:00
|
|
|
this.Note = data.note;
|
|
|
|
this.Categories = data.categories ? data.categories : [];
|
2017-06-17 14:50:35 +00:00
|
|
|
this.Platform = data.platform ? data.platform : 'undefined';
|
2017-02-10 01:11:36 +00:00
|
|
|
this.Logo = data.logo;
|
|
|
|
this.Image = data.image;
|
|
|
|
this.Registry = data.registry ? data.registry : '';
|
2017-02-10 05:11:00 +00:00
|
|
|
this.Command = data.command ? data.command : '';
|
2017-02-10 20:32:34 +00:00
|
|
|
this.Network = data.network ? data.network : '';
|
2017-02-10 01:11:36 +00:00
|
|
|
this.Env = data.env ? data.env : [];
|
2017-03-10 14:43:57 +00:00
|
|
|
this.Privileged = data.privileged ? data.privileged : false;
|
2017-05-18 20:49:55 +00:00
|
|
|
this.Interactive = data.interactive ? data.interactive : false;
|
2017-05-27 08:11:42 +00:00
|
|
|
this.RestartPolicy = data.restart_policy ? data.restart_policy : 'always';
|
2018-01-06 17:24:51 +00:00
|
|
|
this.Labels = data.labels ? data.labels : [];
|
2017-05-27 08:11:42 +00:00
|
|
|
this.Volumes = [];
|
2018-01-06 17:24:51 +00:00
|
|
|
|
2017-02-13 05:16:14 +00:00
|
|
|
if (data.volumes) {
|
|
|
|
this.Volumes = data.volumes.map(function (v) {
|
2017-08-28 18:57:41 +00:00
|
|
|
// @DEPRECATED: New volume definition introduced
|
|
|
|
// via https://github.com/portainer/portainer/pull/1154
|
2017-08-28 18:53:36 +00:00
|
|
|
var volume = {
|
|
|
|
readOnly: v.readonly || false,
|
|
|
|
containerPath: v.container || v,
|
2017-02-13 05:16:14 +00:00
|
|
|
type: 'auto'
|
|
|
|
};
|
2017-08-28 18:53:36 +00:00
|
|
|
|
|
|
|
if (v.bind) {
|
|
|
|
volume.name = v.bind;
|
|
|
|
volume.type = 'bind';
|
|
|
|
}
|
|
|
|
|
|
|
|
return volume;
|
2017-02-13 05:16:14 +00:00
|
|
|
});
|
|
|
|
}
|
2017-02-10 01:11:36 +00:00
|
|
|
this.Ports = [];
|
|
|
|
if (data.ports) {
|
|
|
|
this.Ports = data.ports.map(function (p) {
|
|
|
|
var portAndProtocol = _.split(p, '/');
|
|
|
|
return {
|
|
|
|
containerPort: portAndProtocol[0],
|
|
|
|
protocol: portAndProtocol[1]
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
2018-02-28 07:59:31 +00:00
|
|
|
this.Hosts = data.hosts ? data.hosts : [];
|
2017-02-10 01:11:36 +00:00
|
|
|
}
|