refactored on route config for details page.

This commit is contained in:
kunw 2016-06-01 14:01:35 +08:00
parent 98243901d7
commit f6430c98ce
7 changed files with 62 additions and 42 deletions

View File

@ -6,9 +6,9 @@
.module('harbor.details')
.directive('retrieveProjects', retrieveProjects);
RetrieveProjectsController.$inject = ['$scope', 'nameFilter', '$filter', 'CurrentProjectMemberService', 'ListProjectService', '$location', 'getParameterByName', '$window'];
RetrieveProjectsController.$inject = ['$scope', 'nameFilter', '$filter', 'ListProjectService', '$location', 'getParameterByName', '$window'];
function RetrieveProjectsController($scope, nameFilter, $filter, CurrentProjectMemberService, ListProjectService, $location, getParameterByName, $window) {
function RetrieveProjectsController($scope, nameFilter, $filter, ListProjectService, $location, getParameterByName, $window) {
var vm = this;
vm.projectName = '';
@ -20,8 +20,7 @@
}
vm.retrieve = retrieve;
vm.checkProjectMember = checkProjectMember;
$scope.$watch('vm.selectedProject', function(current, origin) {
if(current) {
vm.selectedId = current.ProjectId;
@ -63,7 +62,7 @@
}
});
}
vm.checkProjectMember(vm.selectedProject.ProjectId);
$location.search('project_id', vm.selectedProject.ProjectId);
vm.resultCount = vm.projects.length;
@ -75,31 +74,16 @@
function getProjectFailed(response) {
console.log('Failed to list projects:' + response);
}
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('Failed get current project member:' + status);
vm.isProjectMember = false;
}
function selectItem(item) {
vm.selectedId = item.ProjectId;
vm.selectedProject = item;
vm.checkProjectMember(vm.selectedProject.ProjectId);
vm.isOpen = false;
$location.search('project_id', vm.selectedProject.ProjectId);
$window.location.reload();
}
$scope.$on('$locationChangeSuccess', function(e) {
var projectId = getParameterByName('project_id', $location.absUrl());
vm.isOpen = false;
});
}

View File

@ -31,6 +31,18 @@
'username' : vm.username
};
retrieve(vm.queryParams);
$scope.$on('$locationChangeSuccess', function() {
vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.queryParams = {
'beginTimestamp' : vm.beginTimestamp,
'endTimestamp' : vm.endTimestamp,
'keywords' : vm.keywords,
'projectId': vm.projectId,
'username' : vm.username
};
retrieve(vm.queryParams);
});
function search(e) {
if(e.op[0] === 'all') {

View File

@ -15,11 +15,16 @@
vm.search = search;
vm.addProjectMember = addProjectMember;
vm.retrieve = retrieve;
vm.username = '';
vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.username = "";
vm.retrieve();
$scope.$on('$locationChangeSuccess', function() {
vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.retrieve();
});
function search(e) {
vm.projectId = e.projectId;
vm.username = e.username;

View File

@ -23,9 +23,16 @@
}
vm.retrieve = retrieve;
vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.tagCount = {};
vm.retrieve();
vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.retrieve();
$scope.$on('$locationChangeSuccess', function() {
vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.retrieve();
});
$scope.$watch('vm.repositories', function(current) {
if(current) {

View File

@ -6,17 +6,30 @@
.module('harbor.layout.navigation')
.directive('navigationDetails', navigationDetails);
NavigationDetailsController.$inject = ['$window', '$location', '$scope', '$route'];
NavigationDetailsController.$inject = ['$window', '$location', '$scope', 'getParameterByName', 'CurrentProjectMemberService'];
function NavigationDetailsController($window, $location, $scope, $route) {
function NavigationDetailsController($window, $location, $scope, getParameterByName, CurrentProjectMemberService) {
var vm = this;
$scope.$watch('vm.selectedProject', function(current, origin) {
if(current) {
vm.projectId = current.ProjectId;
}
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();
}
@ -26,7 +39,6 @@
templateUrl: '/ng/navigation_detail',
link: link,
scope: {
'selectedProject': '=',
'target': '='
},
replace: true,
@ -38,7 +50,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

@ -1,4 +1,4 @@
<ul class="switch-pane-tabs pull-right" {{ if eq .IsAdmin 1 }} style="width: 360px" {{ end }} role="tablist">
<ul class="switch-pane-tabs pull-right" {{ if eq .IsAdmin 1 }} style="width: 365px" {{ end }} role="tablist">
<li><a tag="repositories" href="#/repositories?project_id=//vm.projectId//">// 'repositories' | tr //</a><span class="gutter">|</span></li>
{{ if eq .IsAdmin 1 }}
<li><a tag="replication" href="#/replication?project_id=//vm.projectId//">Replication</a><span class="gutter">|</span></li>

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 selected-project="vm.selectedProject" target="vm.target" ng-show="vm.isProjectMember"></navigation-details>
<navigation-details target="vm.target"></navigation-details>
</span>
</div>
<retrieve-projects is-open="vm.isOpen" selected-project="vm.selectedProject" is-project-member="vm.isProjectMember" publicity="vm.publicity"></retrieve-projects>