mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-01 06:33:41 +01:00
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
(function() {
|
|
|
|
'use strict';
|
|
|
|
angular
|
|
.module('harbor.project.member')
|
|
.directive('addProjectMember', addProjectMember);
|
|
|
|
AddProjectMemberController.$inject = ['$scope', 'roles', 'AddProjectMemberService'];
|
|
|
|
function AddProjectMemberController($scope, roles, AddProjectMemberService) {
|
|
var vm = this;
|
|
vm.username = "";
|
|
vm.roles = roles();
|
|
vm.optRole = 1;
|
|
vm.save = save;
|
|
vm.cancel = cancel;
|
|
|
|
function save() {
|
|
AddProjectMemberService(vm.projectId, vm.optRole, vm.username)
|
|
.success(addProjectMemberComplete)
|
|
.error(addProjectMemberFailed);
|
|
vm.username = "";
|
|
vm.optRole = 1;
|
|
vm.reload();
|
|
}
|
|
|
|
function cancel() {
|
|
vm.isOpen = false;
|
|
vm.username = "";
|
|
vm.optRole = 1;
|
|
}
|
|
|
|
function addProjectMemberComplete(data, status, header) {
|
|
console.log('addProjectMemberComplete: status:' + status + ', data:' + data);
|
|
}
|
|
|
|
function addProjectMemberFailed(data, status, headers) {
|
|
console.log('addProjectMemberFailed: status:' + status + ', data:' + data);
|
|
}
|
|
|
|
}
|
|
|
|
function addProjectMember() {
|
|
var directive = {
|
|
'restrict': 'E',
|
|
'templateUrl': '/static/ng/resources/js/components/project-member/add-project-member.directive.html',
|
|
'scope': {
|
|
'projectId': '@',
|
|
'isOpen': '=',
|
|
'reload': '&'
|
|
},
|
|
'controller': AddProjectMemberController,
|
|
'controllerAs': 'vm',
|
|
'bindToController': true
|
|
}
|
|
return directive;
|
|
}
|
|
|
|
})(); |