updates for interactions of retrieving project list in repositories.

This commit is contained in:
kunw 2016-09-02 18:16:58 +08:00
parent bc38b8175f
commit e28af6ffce
4 changed files with 39 additions and 36 deletions

View File

@ -27,11 +27,11 @@
vm.projectName = ''; vm.projectName = '';
vm.isOpen = false; vm.isOpen = false;
vm.isProjectMember = false;
vm.target = 'repositories';
if(getParameterByName('is_public', $location.absUrl())) { vm.isPublic = Number(getParameterByName('is_public', $location.absUrl()));
vm.isPublic = getParameterByName('is_public', $location.absUrl()) === 'true' ? 1 : 0;
vm.publicity = (vm.isPublic === 1) ? true : false; vm.publicity = (vm.isPublic === 1) ? true : false;
}
vm.retrieve = retrieve; vm.retrieve = retrieve;
vm.filterInput = ''; vm.filterInput = '';
@ -58,20 +58,20 @@
} }
function getProjectSuccess(data, status) { function getProjectSuccess(data, status) {
vm.projects = data; vm.projects = data || [];
if(vm.projects == null) { if(vm.projects.length == 0){
vm.isPublic = 1; if(vm.isPublic === 0) {
$window.location.href = '/project';
}else{
vm.publicity = true; vm.publicity = true;
vm.projectType = 'public_projects'; vm.projectType = 'public_projects';
console.log('vm.projects is null, load public projects.'); vm.target = 'repositories';
return; }
} }
if(angular.isArray(vm.projects) && vm.projects.length > 0) { if(angular.isArray(vm.projects) && vm.projects.length > 0) {
vm.selectedProject = vm.projects[0]; vm.selectedProject = vm.projects[0];
}else{
$window.location.href = '/project';
} }
if(getParameterByName('project_id', $location.absUrl())){ if(getParameterByName('project_id', $location.absUrl())){
@ -83,8 +83,8 @@
} }
$location.search('project_id', vm.selectedProject.project_id); $location.search('project_id', vm.selectedProject.project_id);
vm.checkProjectMember(vm.selectedProject.project_id); vm.checkProjectMember(vm.selectedProject.project_id);
vm.resultCount = vm.projects.length; vm.resultCount = vm.projects.length;
$scope.$watch('vm.filterInput', function(current, origin) { $scope.$watch('vm.filterInput', function(current, origin) {
@ -102,10 +102,11 @@
function selectItem(item) { function selectItem(item) {
vm.selectedProject = item; vm.selectedProject = item;
$location.search('project_id', vm.selectedProject.project_id); $location.search('project_id', vm.selectedProject.project_id);
vm.checkProjectMember(vm.selectedProject.project_id);
} }
$scope.$on('$locationChangeSuccess', function(e) { $scope.$on('$locationChangeSuccess', function(e) {
var projectId = getParameterByName('project_id', $location.absUrl()); vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.isOpen = false; vm.isOpen = false;
}); });
@ -132,6 +133,7 @@
restrict: 'E', restrict: 'E',
templateUrl: '/static/resources/js/components/details/retrieve-projects.directive.html', templateUrl: '/static/resources/js/components/details/retrieve-projects.directive.html',
scope: { scope: {
'target': '=',
'isOpen': '=', 'isOpen': '=',
'selectedProject': '=', 'selectedProject': '=',
'publicity': '=', 'publicity': '=',

View File

@ -66,10 +66,6 @@
$scope.$on('$locationChangeSuccess', function() { $scope.$on('$locationChangeSuccess', function() {
if(vm.publicity) {
vm.target = 'repositories';
}
vm.projectId = getParameterByName('project_id', $location.absUrl()); vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.queryParams = { vm.queryParams = {
'beginTimestamp' : vm.beginTimestamp, 'beginTimestamp' : vm.beginTimestamp,

View File

@ -25,6 +25,7 @@
function NavigationDetailsController($window, $location, $scope, getParameterByName) { function NavigationDetailsController($window, $location, $scope, getParameterByName) {
var vm = this; var vm = this;
vm.projectId = getParameterByName('project_id', $location.absUrl()); vm.projectId = getParameterByName('project_id', $location.absUrl());
$scope.$on('$locationChangeSuccess', function() { $scope.$on('$locationChangeSuccess', function() {
@ -53,9 +54,6 @@
function link(scope, element, attrs, ctrl) { function link(scope, element, attrs, ctrl) {
var visited = ctrl.path.substring(1); var visited = ctrl.path.substring(1);
if(visited.indexOf('?') >= 0) {
visited = ctrl.url.substring(1, ctrl.url.indexOf('?'));
}
if(visited) { if(visited) {
element.find('a[tag="' + visited + '"]').addClass('active'); element.find('a[tag="' + visited + '"]').addClass('active');
@ -63,7 +61,14 @@
element.find('a:first').addClass('active'); element.find('a:first').addClass('active');
} }
ctrl.target = visited; scope.$watch('vm.target', function(current) {
if(current) {
ctrl.target = current;
element.find('a').removeClass('active');
element.find('a[tag="' + ctrl.target + '"]').addClass('active');
}
});
element.find('a').on('click', click); element.find('a').on('click', click);
function click(event) { function click(event) {

View File

@ -30,7 +30,7 @@
<navigation-details target="vm.target" ng-show="vm.isProjectMember"></navigation-details> <navigation-details target="vm.target" ng-show="vm.isProjectMember"></navigation-details>
</span> </span>
</div> </div>
<retrieve-projects is-open="vm.isOpen" selected-project="vm.selectedProject" is-project-member="vm.isProjectMember" publicity="vm.publicity"></retrieve-projects> <retrieve-projects target="vm.target" is-open="vm.isOpen" selected-project="vm.selectedProject" is-project-member="vm.isProjectMember" publicity="vm.publicity"></retrieve-projects>
<!-- Tab panes --> <!-- Tab panes -->
<div class="tab-content" ng-click="vm.closeRetrievePane()"> <div class="tab-content" ng-click="vm.closeRetrievePane()">
<input type="hidden" id="HarborRegUrl" value="{{.HarborRegUrl}}"> <input type="hidden" id="HarborRegUrl" value="{{.HarborRegUrl}}">