2016-04-22 18:49:52 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.project.member')
|
|
|
|
.constant('roles', roles)
|
2016-04-26 12:23:34 +02:00
|
|
|
.factory('getRole', getRole);
|
2016-04-22 18:49:52 +02:00
|
|
|
|
|
|
|
function roles() {
|
|
|
|
return [
|
2016-07-05 07:03:18 +02:00
|
|
|
{'id': '1', 'name': 'project_admin', 'roleName': 'projectAdmin'},
|
|
|
|
{'id': '2', 'name': 'developer', 'roleName': 'developer'},
|
|
|
|
{'id': '3', 'name': 'guest', 'roleName': 'guest'}
|
2016-04-22 18:49:52 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-07-05 07:03:18 +02:00
|
|
|
getRole.$inject = ['roles', '$filter', 'trFilter'];
|
2016-04-22 18:49:52 +02:00
|
|
|
|
2016-07-05 07:03:18 +02:00
|
|
|
function getRole(roles, $filter, trFilter) {
|
2016-04-22 18:49:52 +02:00
|
|
|
var r = roles();
|
2016-04-26 12:23:34 +02:00
|
|
|
return get;
|
|
|
|
function get(query) {
|
2016-04-22 18:49:52 +02:00
|
|
|
|
|
|
|
for(var i = 0; i < r.length; i++) {
|
|
|
|
var role = r[i];
|
2016-05-23 12:29:17 +02:00
|
|
|
if(query.key === 'roleName' && role.roleName === query.value
|
2016-06-02 09:44:53 +02:00
|
|
|
|| query.key === 'roleId' && role.id === String(query.value)) {
|
2016-04-26 12:23:34 +02:00
|
|
|
return role;
|
2016-04-22 18:49:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})();
|