mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-02 23:23:45 +01:00
63 lines
1.4 KiB
JavaScript
63 lines
1.4 KiB
JavaScript
(function() {
|
|
|
|
'use strict';
|
|
|
|
angular
|
|
.module('harbor.project')
|
|
.directive('addProject', addProject);
|
|
|
|
AddProjectController.$inject = ['AddProjectService', '$scope'];
|
|
|
|
function AddProjectController(AddProjectService, $scope) {
|
|
var vm = this;
|
|
vm.projectName = "";
|
|
vm.isPublic = false;
|
|
|
|
vm.addProject = addProject;
|
|
vm.cancel = cancel;
|
|
|
|
function addProject() {
|
|
|
|
if(vm.projectName == "") {
|
|
alert("Please input the project name.");
|
|
return;
|
|
}
|
|
|
|
AddProjectService(vm.projectName, vm.isPublic)
|
|
.success(addProjectSuccess)
|
|
.error(addProjectFailed);
|
|
}
|
|
|
|
function addProjectSuccess(data, status) {
|
|
vm.isOpen = false;
|
|
vm.projectName = "";
|
|
vm.isPublic = false;
|
|
$scope.$emit('addedSuccess', true);
|
|
}
|
|
|
|
function addProjectFailed(data, status) {
|
|
console.log('Failed to add project:' + status);
|
|
}
|
|
|
|
function cancel(){
|
|
vm.isOpen = false;
|
|
vm.projectName = "";
|
|
vm.isPublic = false;
|
|
}
|
|
}
|
|
|
|
function addProject() {
|
|
var directive = {
|
|
'restrict': 'E',
|
|
'templateUrl': '/static/ng/resources/js/components/project/add-project.directive.html',
|
|
'controller': AddProjectController,
|
|
'scope' : {
|
|
'isOpen': '='
|
|
},
|
|
'controllerAs': 'vm',
|
|
'bindToController': true
|
|
};
|
|
return directive;
|
|
}
|
|
|
|
})(); |