mirror of https://github.com/portainer/portainer
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
angular.module('uifordocker.helpers', [])
|
|
.factory('ImageHelper', [function ImageHelperFactory() {
|
|
'use strict';
|
|
return {
|
|
createImageConfig: function(imageName, registry) {
|
|
var imageNameAndTag = imageName.split(':');
|
|
var image = imageNameAndTag[0];
|
|
if (registry) {
|
|
image = registry + '/' + imageNameAndTag[0];
|
|
}
|
|
var imageConfig = {
|
|
repo: image,
|
|
tag: imageNameAndTag[1] ? imageNameAndTag[1] : 'latest'
|
|
};
|
|
return imageConfig;
|
|
}
|
|
};
|
|
}])
|
|
.factory('ContainerHelper', [function ContainerHelperFactory() {
|
|
'use strict';
|
|
return {
|
|
hideContainers: function(containers, containersToHideLabels) {
|
|
return containers.filter(function (container) {
|
|
var filterContainer = false;
|
|
containersToHideLabels.forEach(function(label, index) {
|
|
if (_.has(container.Labels, label.name) &&
|
|
container.Labels[label.name] === label.value) {
|
|
filterContainer = true;
|
|
}
|
|
});
|
|
if (!filterContainer) {
|
|
return container;
|
|
}
|
|
});
|
|
},
|
|
};
|
|
}]);
|