2018-02-01 12:27:52 +00:00
|
|
|
angular.module('portainer.docker')
|
2017-01-31 23:26:29 +00:00
|
|
|
.factory('LabelHelper', [function LabelHelperFactory() {
|
|
|
|
'use strict';
|
|
|
|
return {
|
|
|
|
fromLabelHashToKeyValue: function(labels) {
|
|
|
|
if (labels) {
|
|
|
|
return Object.keys(labels).map(function(key) {
|
|
|
|
return {key: key, value: labels[key], originalKey: key, originalValue: labels[key], added: true};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
},
|
|
|
|
fromKeyValueToLabelHash: function(labelKV) {
|
|
|
|
var labels = {};
|
|
|
|
if (labelKV) {
|
|
|
|
labelKV.forEach(function(label) {
|
2019-04-18 21:18:40 +00:00
|
|
|
if (label.key) {
|
|
|
|
labels[label.key] = label.value;
|
|
|
|
}
|
2017-01-31 23:26:29 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
return labels;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}]);
|