update for checking project-member and sign-in field update options.

This commit is contained in:
kunw 2016-06-01 14:50:34 +08:00
parent 3c530f63f0
commit c8d0d06464
4 changed files with 36 additions and 30 deletions

View File

@ -6,9 +6,9 @@
.module('harbor.details')
.directive('retrieveProjects', retrieveProjects);
RetrieveProjectsController.$inject = ['$scope', 'nameFilter', '$filter', 'ListProjectService', '$location', 'getParameterByName', '$window'];
RetrieveProjectsController.$inject = ['$scope', 'nameFilter', '$filter', 'ListProjectService', '$location', 'getParameterByName', 'CurrentProjectMemberService'];
function RetrieveProjectsController($scope, nameFilter, $filter, ListProjectService, $location, getParameterByName, $window) {
function RetrieveProjectsController($scope, nameFilter, $filter, ListProjectService, $location, getParameterByName, CurrentProjectMemberService) {
var vm = this;
vm.projectName = '';
@ -20,16 +20,16 @@
}
vm.retrieve = retrieve;
vm.filterInput = "";
vm.selectItem = selectItem;
vm.checkProjectMember = checkProjectMember;
$scope.$watch('vm.selectedProject', function(current, origin) {
if(current) {
vm.selectedId = current.ProjectId;
}
});
vm.filterInput = "";
vm.selectItem = selectItem;
$scope.$watch('vm.publicity', function(current, origin) {
vm.publicity = current ? true : false;
vm.isPublic = vm.publicity ? 1 : 0;
@ -64,6 +64,8 @@
}
$location.search('project_id', vm.selectedProject.ProjectId);
vm.checkProjectMember(vm.selectedProject.ProjectId);
vm.resultCount = vm.projects.length;
$scope.$watch('vm.filterInput', function(current, origin) {
@ -82,9 +84,26 @@
$scope.$on('$locationChangeSuccess', function(e) {
var projectId = getParameterByName('project_id', $location.absUrl());
vm.checkProjectMember(projectId);
vm.isOpen = false;
});
function checkProjectMember(projectId) {
CurrentProjectMemberService(projectId)
.success(getCurrentProjectMemberSuccess)
.error(getCurrentProjectMemberFailed);
}
function getCurrentProjectMemberSuccess(data, status) {
console.log('Successful get current project member:' + status);
vm.isProjectMember = true;
}
function getCurrentProjectMemberFailed(data, status) {
console.log('Use has no member for current project:' + status);
vm.isProjectMember = false;
}
}
function retrieveProjects() {
@ -110,10 +129,10 @@
function clickHandler(e) {
$('[data-toggle="popover"]').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).parent().popover('hide');
if (!$(this).is(e.target) &&
$(this).has(e.target).length === 0 &&
$('.popover').has(e.target).length === 0) {
$(this).parent().popover('hide');
}
});
var targetId = $(e.target).attr('id');

View File

@ -6,30 +6,17 @@
.module('harbor.layout.navigation')
.directive('navigationDetails', navigationDetails);
NavigationDetailsController.$inject = ['$window', '$location', '$scope', 'getParameterByName', 'CurrentProjectMemberService'];
NavigationDetailsController.$inject = ['$window', '$location', '$scope', 'getParameterByName'];
function NavigationDetailsController($window, $location, $scope, getParameterByName, CurrentProjectMemberService) {
function NavigationDetailsController($window, $location, $scope, getParameterByName) {
var vm = this;
vm.projectId = getParameterByName('project_id', $location.absUrl());
$scope.$on('$locationChangeSuccess', function() {
vm.projectId = getParameterByName('project_id', $location.absUrl());
CurrentProjectMemberService(vm.projectId)
.success(getCurrentProjectMemberSuccess)
.error(getCurrentProjectMemberFailed);
});
function getCurrentProjectMemberSuccess(data, status) {
console.log('Successful get current project member:' + status);
vm.isProjectMember = true;
}
function getCurrentProjectMemberFailed(data, status) {
console.log('Failed get current project member:' + status);
vm.isProjectMember = false;
}
vm.path = $location.path();
}
@ -50,7 +37,7 @@
return directive;
function link(scope, element, attrs, ctrl) {
var visited = ctrl.path.substring(1);
if(visited.indexOf('?') >= 0) {
visited = ctrl.url.substring(1, ctrl.url.indexOf('?'));

View File

@ -12,7 +12,7 @@
<div class="switch-pane">
<switch-pane-projects is-open="vm.isOpen" selected-project="vm.selectedProject"></switch-pane-projects>
<span>
<navigation-details target="vm.target"></navigation-details>
<navigation-details target="vm.target" ng-show="vm.isProjectMember"></navigation-details>
</span>
</div>
<retrieve-projects is-open="vm.isOpen" selected-project="vm.selectedProject" is-project-member="vm.isProjectMember" publicity="vm.publicity"></retrieve-projects>

View File

@ -9,7 +9,7 @@
<form name="form" class="form-horizontal css-form" ng-submit="form.$valid" novalidate>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input id="username" type="text" class="form-control" placeholder="// 'username_email' | tr //" name="uPrincipal" ng-change="vm.reset()" ng-model="user.principal" required>
<input id="username" type="text" class="form-control" placeholder="// 'username_email' | tr //" name="uPrincipal" ng-change="vm.reset()" ng-model="user.principal" ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }" required>
<div class="error-message">
<div ng-messages="form.uPrincipal.$error" ng-if="form.uPrincipal.$touched || form.$submitted">
<span ng-message="required">// 'username_is_required' | tr //</span>
@ -19,7 +19,7 @@
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input type="password" class="form-control" placeholder="// 'password' | tr //" name="uPassword" ng-change="vm.reset()" ng-model="user.password" required>
<input type="password" class="form-control" placeholder="// 'password' | tr //" name="uPassword" ng-change="vm.reset()" ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }" ng-model="user.password" required>
<div class="error-message">
<div ng-messages="form.uPassword.$error" ng-if="form.uPassword.$touched || form.$submitted">
<span ng-message="required">// 'password_is_required' | tr //</span>