refinements on toggling project publicity and rollback changes on popular repos.

This commit is contained in:
kunw 2016-09-14 00:40:42 +08:00
parent 575b2b90da
commit dd2960270c
12 changed files with 122 additions and 156 deletions

View File

@ -28,60 +28,50 @@
vm.projectName = '';
vm.isOpen = false;
vm.isProjectMember = false;
vm.target = $location.path().substr(1) || 'repositories';
vm.isPublic = Number(getParameterByName('is_public', $location.absUrl()));
vm.publicity = (vm.isPublic === 1) ? true : false;
vm.retrieve = retrieve;
vm.filterInput = '';
vm.selectItem = selectItem;
vm.checkProjectMember = checkProjectMember;
$scope.$watch('vm.selectedProject', function(current, origin) {
if(current) {
vm.selectedId = current.project_id;
}
});
$scope.$watch('vm.publicity', function(current, origin) {
vm.publicity = current ? true : false;
vm.isPublic = vm.publicity ? 1 : 0;
vm.projectType = (vm.isPublic === 1) ? 'public_projects' : 'my_projects';
vm.retrieve();
});
function retrieve() {
ListProjectService(vm.projectName, vm.isPublic)
.success(getProjectSuccess)
.error(getProjectFailed);
}
vm.retrieve();
$scope.$watch('vm.isPublic', function(current) {
vm.projectType = vm.isPublic === 0 ? 'my_project_count' : 'public_project_count';
});
$scope.$watch('vm.selectedProject', function(current) {
if(current) {
vm.selectedId = current.project_id;
}
});
function getProjectSuccess(data, status) {
vm.projects = data || [];
if(vm.projects.length == 0){
if(vm.isPublic === 0) {
if(vm.projects.length == 0 && vm.isPublic === 0){
$window.location.href = '/project';
}else{
vm.publicity = true;
vm.projectType = 'public_projects';
vm.target = 'repositories';
}
}
if(angular.isArray(vm.projects) && vm.projects.length > 0) {
vm.selectedProject = vm.projects[0];
}
if(getParameterByName('project_id', $location.absUrl())){
angular.forEach(vm.projects, function(value, index) {
if(value['project_id'] === Number(getParameterByName('project_id', $location.absUrl()))) {
vm.selectedProject = value;
for(var i in vm.projects) {
var project = vm.projects[i];
if(project['project_id'] == getParameterByName('project_id', $location.absUrl())) {
vm.selectedProject = project;
console.log('matched project_id:' + angular.toJson(vm.selectedProject));
break;
}
}
});
}
$location.search('project_id', vm.selectedProject.project_id);
@ -127,6 +117,7 @@
function getCurrentProjectMemberFailed(data, status) {
vm.isProjectMember = false;
console.log('Current user has no member for the project:' + status + ', location.url:' + $location.url());
vm.target = 'repositories';
}
}
@ -139,7 +130,7 @@
'target': '=',
'isOpen': '=',
'selectedProject': '=',
'publicity': '=',
'isPublic': '=',
'isProjectMember': '='
},
link: link,

View File

@ -148,9 +148,7 @@
'restrict': 'E',
'templateUrl': '/static/resources/js/components/log/list-log.directive.html',
'scope': {
'sectionHeight': '=',
'target': '=',
'publicity': '='
'sectionHeight': '='
},
'link': link,
'controller': ListLogController,

View File

@ -95,7 +95,6 @@
function getProjectMemberFailed(response) {
console.log('Failed to get project members:' + response);
vm.projectMembers = [];
vm.target = 'repositories';
$location.url('repositories').search('project_id', vm.projectId);
}
@ -106,8 +105,7 @@
'restrict': 'E',
'templateUrl': '/static/resources/js/components/project-member/list-project-member.directive.html',
'scope': {
'sectionHeight': '=',
'target': '='
'sectionHeight': '='
},
'link': link,
'controller': ListProjectMemberController,

View File

@ -93,6 +93,7 @@
vm.deleteImage = deleteImage;
function retrieve(){
console.log('retrieve repositories, project_id:' + vm.projectId);
ListRepositoryService(vm.projectId, vm.filterInput, vm.page, vm.pageSize)
.then(getRepositoryComplete, getRepositoryFailed);
}

View File

@ -30,7 +30,6 @@
$scope.$watch('vm.repoName', function(current, origin) {
if(current) {
console.log('vm.repoName in tags:' + current);
vm.retrieve();
}
});

View File

@ -29,7 +29,7 @@
<td colspan="5" height="120px" class="empty-hint" ng-if="vm.top10Repositories.length === 0"><h4 class="text-muted">// 'no_top_repositories' | tr //</h4></td>
</tr>
<tr ng-if="vm.top10Repositories.length > 0" ng-repeat="t in vm.top10Repositories">
<td width="60%"><a href="javascript:void(0);" ng-click="vm.gotoRepo(t.name)">//t.name//</a></td>
<td width="60%">//t.name//</td>
<td width="40%">//t.count//</td>
</tr>
</tbody>

View File

@ -20,17 +20,15 @@
.module('harbor.top.repository')
.directive('topRepository', topRepository);
TopRepositoryController.$inject = ['$scope', 'ListTopRepositoryService', 'SearchService', '$filter', 'trFilter', '$window'];
TopRepositoryController.$inject = ['$scope', 'ListTopRepositoryService', '$filter', 'trFilter'];
function TopRepositoryController($scope, ListTopRepositoryService, SearchService, $filter, trFilter, $window) {
function TopRepositoryController($scope, ListTopRepositoryService, $filter, trFilter) {
var vm = this;
ListTopRepositoryService(5)
.success(listTopRepositorySuccess)
.error(listTopRepositoryFailed);
vm.gotoRepo = gotoRepo;
function listTopRepositorySuccess(data) {
vm.top10Repositories = data || [];
}
@ -42,25 +40,6 @@
console.log('Failed to get top repo:' + data);
}
function gotoRepo(repoName) {
SearchService(repoName)
.success(searchSuccess)
.error(searchFailed);
}
function searchSuccess(data, status) {
var repoInfo = data['repository'];
if(repoInfo && repoInfo.length > 0) {
var projectId = repoInfo[0]['project_id'];
var publicity = repoInfo[0]['project_public'];
var repoName = repoInfo[0]['repository_name'];
$window.location.href = '/repository#/repositories?project_id=' + projectId + '&is_public=' + publicity +'#' + repoName;
}
}
function searchFailed(data) {
console.log('Failed to get repo info:' + data);
}
}
function topRepository() {

View File

@ -16,10 +16,11 @@
<div class="table-head-container">
<table class="table table-pane table-header">
<thead>
<th width="25%">// 'operation' | tr //</th>
<th width="25%">// 'details' | tr //</th>
<th width="25%">// 'user' | tr //</th>
<th width="25%">// 'creation_time' | tr //</th>
<th width="18%">// 'username' | tr //</th>
<th width="28%">// 'repository_name' | tr //</th>
<th width="15%">// 'tag' | tr //</th>
<th width="14%">// 'operation' | tr //</th>
<th width="25%">// 'timestamp' | tr //</th>
</thead>
</table>
</div>
@ -30,9 +31,10 @@
<td colspan="5" height="120px" class="empty-hint" ng-if="vm.integratedLogs.length === 0"><h4 class="text-muted">// 'no_user_logs' | tr //</h4></td>
</tr>
<tr ng-if="vm.integratedLogs.length > 0" ng-repeat="t in vm.integratedLogs">
<td width="25%">//t.operation//</td>
<td width="25%"><a href="javascript:void(0);" ng-click="vm.gotoLog(t.project_id, t.username)">//t.repo_name//</a></td>
<td width="25%">//t.username//</td>
<td width="18%">//t.username//</td>
<td width="28%"><a href="javascript:void(0);" ng-click="vm.gotoLog(t.project_id, t.username)">//t.repo_name//</a></td>
<td width="15%">//t.repo_tag//</td>
<td width="14%">//t.operation//</td>
<td width="25%">//t.op_time | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
</tr>
</tbody>

View File

@ -20,12 +20,12 @@
.module('harbor.details')
.controller('DetailsController', DetailsController);
DetailsController.$inject = ['$scope', '$timeout'];
DetailsController.$inject = ['$scope', '$timeout', '$window'];
function DetailsController($scope, $timeout) {
function DetailsController($scope, $timeout, $window) {
var vm = this;
vm.publicity = false;
vm.isPublic = 0;
vm.isProjectMember = false;
vm.togglePublicity = togglePublicity;
@ -75,8 +75,9 @@
});
function togglePublicity(e) {
vm.publicity = e.publicity;
vm.target = 'repositories';
vm.isPublic = e.isPublic;
$window.location='/project?is_public=' + vm.isPublic;
return;
}
}

View File

@ -20,14 +20,14 @@
.module('harbor.layout.project')
.controller('ProjectController', ProjectController);
ProjectController.$inject = ['$scope', 'ListProjectService', 'DeleteProjectService', '$timeout', 'currentUser', 'getRole', '$filter', 'trFilter'];
ProjectController.$inject = ['$scope', 'ListProjectService', 'DeleteProjectService', '$timeout', 'currentUser', 'getRole', '$filter', 'trFilter', 'getParameterByName', '$location'];
function ProjectController($scope, ListProjectService, DeleteProjectService, $timeout, currentUser, getRole, $filter, trFilter) {
function ProjectController($scope, ListProjectService, DeleteProjectService, $timeout, currentUser, getRole, $filter, trFilter, getParameterByName, $location) {
var vm = this;
vm.isOpen = false;
vm.projectName = '';
vm.publicity = 0;
vm.isPublic = Number(getParameterByName('is_public', $location.absUrl())) || 0;
vm.page = 1;
vm.pageSize = 15;
@ -45,6 +45,7 @@
vm.deleteProject = deleteProject;
//Error message dialog handler for project.
$scope.$on('modalTitle', function(e, val) {
vm.modalTitle = val;
@ -89,7 +90,7 @@
});
function retrieve() {
ListProjectService(vm.projectName, vm.publicity, vm.page, vm.pageSize)
ListProjectService(vm.projectName, vm.isPublic, vm.page, vm.pageSize)
.then(listProjectSuccess)
.catch(listProjectFailed);
}
@ -127,15 +128,14 @@
}
function showAddButton() {
return (vm.publicity === 0);
return (vm.isPublic === 0);
}
function togglePublicity(e) {
vm.publicity = e.publicity;
vm.isPublic = e.isPublic;
vm.isOpen = false;
vm.page = 1;
vm.retrieve();
console.log('vm.publicity:' + vm.publicity);
}
function searchProjectByKeyPress($event) {

View File

@ -19,11 +19,11 @@
<div class="col-xs-12 col-md-12 extend-height">
<div class="section">
<h4 class="page-header">
<span ng-show="!vm.publicity">// 'my_projects' | tr //</span>
<a ng-show="vm.publicity" href="#" ng-click="vm.togglePublicity({publicity: 0})">// 'my_projects' | tr //</a>
<span ng-if="vm.isPublic === 0">// 'my_projects' | tr //</span>
<a ng-if="vm.isPublic === 1" href="javascript:void(0);" ng-click="vm.togglePublicity({isPublic: 0})">// 'my_projects' | tr //</a>
<span class="gutter">|</span>
<span ng-show="vm.publicity">// 'public_projects' | tr //</span>
<a ng-show="!vm.publicity" href="#" class="title-color" ng-click="vm.togglePublicity({publicity: 1})">// 'public_projects' | tr //</a>
<span ng-if="vm.isPublic === 1">// 'public_projects' | tr //</span>
<a ng-if="vm.isPublic === 0" href="javascript:void(0);" class="title-color" ng-click="vm.togglePublicity({isPublic: 1})">// 'public_projects' | tr //</a>
</h4>
<div class="search-pane">
<div class="form-inline">
@ -37,7 +37,6 @@
<button ng-if="!vm.isOpen" class="btn btn-success" type="button" ng-show="vm.showAddButton()" ng-click="vm.showAddProject()"><span class="glyphicon glyphicon-plus"></span> // 'new_project' | tr //</button>
</div>
</div>
<add-project ng-show="vm.isOpen" is-open="vm.isOpen"></add-project>
<div class="each-tab-pane">
<div class="sub-pane">
@ -62,7 +61,7 @@
<tr ng-if="vm.projects.length > 0" ng-repeat="p in vm.projects">
<td width="20%"><a href="/repository#/repositories?project_id=//p.project_id//&is_public=//p.public//">//p.name//</a></td>
<td width="15%">//p.repo_count//</td>
<td width="15%" ng-if="!vm.publicity">//vm.getProjectRole(p.current_user_role_id) | tr//</td>
<td width="15%" ng-if="vm.isPublic === 0">//vm.getProjectRole(p.current_user_role_id) | tr//</td>
<td width="20%">//p.creation_time | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
<td width="15%"><publicity-button is-public="p.public" project-id="p.project_id"></publicity-button></td>
<td width="10%">
@ -78,5 +77,4 @@
</div>
</div>
</div>
</div>
</div>

View File

@ -19,26 +19,25 @@
<div class="col-xs-12 col-md-12 extend-height">
<div class="section" ng-style="vm.sectionHeight">
<h4 class="page-header">
<span ng-show="!vm.publicity">// 'my_projects' | tr //</span>
<a ng-show="vm.publicity" href="#/repositories?project_id=//vm.selectedProject.project_id//" class="title-color" ng-click="vm.togglePublicity({publicity: false})">// 'my_projects' | tr //</a>
<span ng-if="vm.isPublic === 0">// 'my_projects' | tr //</span>
<a ng-if="vm.isPublic === 1" href="javascript:void(0);" class="title-color" ng-click="vm.togglePublicity({isPublic: 0})">// 'my_projects' | tr //</a>
<span class="gutter">|</span>
<span ng-show="vm.publicity">// 'public_projects' | tr //</span>
<a ng-show="!vm.publicity" href="#/repositories?project_id=//vm.selectedProject.project_id//" class="title-color" ng-click="vm.togglePublicity({publicity: true})">// 'public_projects' | tr //</a></h4>
<span ng-if="vm.isPublic === 1">// 'public_projects' | tr //</span>
<a ng-if="vm.isPublic === 0" href="javascript:void(0);" class="title-color" ng-click="vm.togglePublicity({isPublic: 1})">// 'public_projects' | tr //</a></h4>
<div class="switch-pane">
<switch-pane-projects is-open="vm.isOpen" selected-project="vm.selectedProject"></switch-pane-projects>
<span>
<navigation-details target="vm.target" ng-show="vm.isProjectMember"></navigation-details>
</span>
</div>
<retrieve-projects target="vm.target" 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" is-public="vm.isPublic"></retrieve-projects>
<!-- Tab panes -->
<div class="tab-content" ng-click="vm.closeRetrievePane()">
<input type="hidden" id="HarborRegUrl" value="{{.HarborRegUrl}}">
<list-repository ng-if="vm.target === 'repositories'" section-height="vm.sectionHeight"></list-repository>
<list-replication ng-if="vm.target === 'replication'" section-height="vm.sectionHeight"></list-replication>
<list-project-member ng-if="vm.target === 'users'" section-height="vm.sectionHeight" target="vm.target"></list-project-member>
<list-log ng-if="vm.target === 'logs'" section-height="vm.sectionHeight" target="vm.target" publicity="vm.publicity"></list-log>
</div>
<list-project-member ng-if="vm.target === 'users'" section-height="vm.sectionHeight"></list-project-member>
<list-log ng-if="vm.target === 'logs'" section-height="vm.sectionHeight" target="vm.target"></list-log>
</div>
</div>
</div>