fixed redirecting to project with public or private of UI.

This commit is contained in:
kunw 2016-05-17 11:40:36 +08:00
parent a69f5725a6
commit 4d7bc7a7e6
5 changed files with 45 additions and 17 deletions

View File

@ -6,17 +6,19 @@
.module('harbor.details')
.directive('retrieveProjects', retrieveProjects);
RetrieveProjectsController.$inject = ['$scope', 'nameFilter', '$filter', 'CurrentProjectMemberService', 'ListProjectService', '$routeParams', '$location'];
RetrieveProjectsController.$inject = ['$scope', 'nameFilter', '$filter', 'CurrentProjectMemberService', 'ListProjectService', '$routeParams', '$route', '$location'];
function RetrieveProjectsController($scope, nameFilter, $filter, CurrentProjectMemberService, ListProjectService, $routeParams, $location) {
function RetrieveProjectsController($scope, nameFilter, $filter, CurrentProjectMemberService, ListProjectService, $routeParams, $route, $location) {
var vm = this;
vm.projectName = '';
vm.isPublic = 0;
vm.publicity = false;
if($route.current.params.is_public) {
vm.isPublic = $route.current.params.is_public === 'true' ? 1 : 0;
vm.publicity = (vm.isPublic === 1) ? true : false;
}
vm.retrieve = retrieve;
vm.retrieve();
vm.checkProjectMember = checkProjectMember;
@ -31,8 +33,9 @@
vm.selectItem = selectItem;
$scope.$watch('vm.publicity', function(current, origin) {
vm.isPublic = current ? 1 : 0;
vm.projectType = (vm.isPublic == 1) ? 'public_projects' : 'my_projects';
vm.publicity = current ? 1 : 0;
vm.isPublic = vm.publicity ? 1 : 0;
vm.projectType = (vm.isPublic === 1) ? 'public_projects' : 'my_projects';
vm.retrieve();
});
@ -44,12 +47,15 @@
function getProjectSuccess(data, status) {
vm.projects = data;
if(vm.projects == null) {
if(!angular.isDefined(vm.projects)) {
vm.isPublic = 1;
vm.publicity = 1;
console.log('vm.projects is null, load public projects.');
vm.projectType = 'public_projects';
console.log('vm.projects is undefined, load public projects.');
}
vm.selectedProject = vm.projects[0];
vm.selectedProject = vm.projects[0];
if($routeParams.project_id){
angular.forEach(vm.projects, function(value, index) {
@ -109,7 +115,6 @@
'publicity': '=',
'isProjectMember': '='
},
link: link,
replace: true,
controller: RetrieveProjectsController,
bindToController: true,
@ -118,9 +123,6 @@
return directive;
function link(scope, element, attrs, ctrl) {
}
}
})();

View File

@ -12,7 +12,7 @@
</div>
</div>
<div class="form-group">
<input type="checkbox" ng-model="vm.isPublic">&nbsp;// 'public_projects' | tr //
<input type="checkbox" ng-model="vm.isPublic">&nbsp;// 'public' | tr //
</div>
</form>
</div>

View File

@ -200,6 +200,10 @@ var global_messages = {
'zh-CN': '项目'
},
'public_projects': {
'en-US': 'Public Projects',
'zh-CN': '公开项目'
},
'public': {
'en-US': 'Public',
'zh-CN': '公开'
},

View File

@ -0,0 +1,22 @@
(function() {
'use strict';
angular
.module('harbor.services.project')
.factory('GetProjectById', GetProjectById);
GetProjectById.$inject = ['$http'];
function GetProjectById($http) {
return getProject;
function getProject(id) {
return $http
.get('/api/projects/' + id);
}
}
})();

View File

@ -30,7 +30,7 @@
</thead>
<tbody>
<tr ng-repeat="p in vm.projects">
<td><a href="/ng/repository#/repositories?project_id=//p.ProjectId//">//p.Name//</a></td>
<td><a href="/ng/repository#/repositories?project_id=//p.ProjectId//&is_public=//p.Public//">//p.Name//</a></td>
<td>N/A</td>
<td>N/A</td>
<td>//p.CreationTime | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>