webapp.scripts.components.entities.entities.util.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of centraldogma-server Show documentation
Show all versions of centraldogma-server Show documentation
Highly-available version-controlled service configuration repository based on Git, ZooKeeper and HTTP/2 (centraldogma-server)
'use strict';
angular.module('CentralDogmaAdmin')
.factory('EntitiesUtil',
function (StringUtil) {
return {
toKeySet: function (map) {
if (angular.isUndefined(map) || map === null) {
return [];
}
return Object.keys(map);
},
toUniqueSet: function (sourceSet, filterSet) {
if (angular.isUndefined(sourceSet) || sourceSet === null) {
return [];
}
if (angular.isUndefined(filterSet) || filterSet === null || filterSet.length === 0) {
return sourceSet;
}
return sourceSet.filter(function (value) {
return filterSet.indexOf(value) === -1; // not exist
});
},
toDateTimeStr: function (timestamp) {
return moment(timestamp).fromNow();
},
toReplaceJsonPatch: function (path, value) {
return [{
op: 'replace',
path: path,
value: value
}]
},
sanitizeEmail: function (email) {
if (StringUtil.endsWith(email, '@localhost.localdomain')) {
return email.split('@')[0];
}
return email;
}
};
});