2016-05-01 19:46:50 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.layout.project')
|
|
|
|
.controller('ProjectController', ProjectController);
|
|
|
|
|
2016-05-11 09:57:52 +02:00
|
|
|
ProjectController.$inject = ['$scope', 'ListProjectService'];
|
2016-05-01 19:46:50 +02:00
|
|
|
|
2016-05-11 09:57:52 +02:00
|
|
|
function ProjectController($scope, ListProjectService) {
|
2016-05-02 12:24:58 +02:00
|
|
|
var vm = this;
|
2016-05-03 12:29:58 +02:00
|
|
|
|
2016-05-01 19:46:50 +02:00
|
|
|
vm.isOpen = false;
|
2016-05-03 12:29:58 +02:00
|
|
|
vm.projectName = '';
|
|
|
|
vm.publicity = 0;
|
2016-05-04 12:42:05 +02:00
|
|
|
|
2016-05-03 12:29:58 +02:00
|
|
|
vm.retrieve = retrieve;
|
|
|
|
vm.showAddProject = showAddProject;
|
|
|
|
vm.searchProject = searchProject;
|
2016-05-02 12:24:58 +02:00
|
|
|
vm.showAddButton = showAddButton;
|
|
|
|
vm.togglePublicity = togglePublicity;
|
2016-05-01 19:46:50 +02:00
|
|
|
|
2016-05-11 09:57:52 +02:00
|
|
|
$scope.$on('currentUser', function(e, val) {
|
|
|
|
vm.currentUser = val;
|
|
|
|
});
|
|
|
|
|
2016-05-03 12:29:58 +02:00
|
|
|
vm.retrieve();
|
|
|
|
|
2016-05-10 12:43:52 +02:00
|
|
|
function retrieve() {
|
2016-05-11 09:57:52 +02:00
|
|
|
|
2016-05-10 12:43:52 +02:00
|
|
|
ListProjectService(vm.projectName, vm.publicity)
|
|
|
|
.success(listProjectSuccess)
|
|
|
|
.error(listProjectFailed);
|
2016-05-03 12:29:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function listProjectSuccess(data, status) {
|
|
|
|
vm.projects = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
function listProjectFailed(e) {
|
|
|
|
console.log('Failed to list Project:' + e);
|
|
|
|
}
|
2016-05-10 12:43:52 +02:00
|
|
|
|
2016-05-01 19:46:50 +02:00
|
|
|
$scope.$on('addedSuccess', function(e, val) {
|
2016-05-03 12:29:58 +02:00
|
|
|
vm.retrieve();
|
2016-05-01 19:46:50 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
function showAddProject() {
|
|
|
|
if(vm.isOpen){
|
|
|
|
vm.isOpen = false;
|
|
|
|
}else{
|
|
|
|
vm.isOpen = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function searchProject() {
|
2016-05-03 12:29:58 +02:00
|
|
|
vm.retrieve();
|
2016-05-01 19:46:50 +02:00
|
|
|
}
|
2016-05-02 12:24:58 +02:00
|
|
|
|
|
|
|
function showAddButton() {
|
2016-05-03 12:29:58 +02:00
|
|
|
if(vm.publicity == 0) {
|
2016-05-02 12:24:58 +02:00
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function togglePublicity(e) {
|
2016-05-03 12:29:58 +02:00
|
|
|
vm.publicity = e.publicity;
|
2016-05-14 07:34:54 +02:00
|
|
|
vm.isOpen = false;
|
2016-05-03 12:29:58 +02:00
|
|
|
vm.retrieve();
|
|
|
|
console.log('vm.publicity:' + vm.publicity);
|
2016-05-02 12:24:58 +02:00
|
|
|
}
|
|
|
|
|
2016-05-01 19:46:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
})();
|