Merge pull request #798 from wknet123/dev

Refinements on toggling project publicity and rollback changes on popular repos
This commit is contained in:
Daniel Jiang 2016-09-19 16:28:03 +08:00 committed by GitHub
commit 981a13d751
13 changed files with 138 additions and 147 deletions

View File

@ -28,58 +28,49 @@
vm.projectName = '';
vm.isOpen = false;
vm.isProjectMember = false;
vm.target = 'repositories';
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) {
$window.location.href = '/project';
}else{
vm.publicity = true;
vm.projectType = 'public_projects';
vm.target = 'repositories';
}
if(vm.projects.length == 0 && vm.isPublic === 0){
$window.location.href = '/project';
}
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;
break;
}
});
}
}
$location.search('project_id', vm.selectedProject.project_id);
@ -125,6 +116,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';
}
}
@ -137,7 +129,7 @@
'target': '=',
'isOpen': '=',
'selectedProject': '=',
'publicity': '=',
'isPublic': '=',
'isProjectMember': '='
},
link: link,

View File

@ -35,7 +35,8 @@
vm.beginTimestamp = 0;
vm.endTimestamp = 0;
vm.keywords = '';
vm.username = '';
vm.username = $location.hash() || '';
vm.op = [];
vm.opOthers = true;
@ -118,18 +119,6 @@
console.log('Total Count in logs:' + vm.totalCount + ', page:' + vm.page);
// vm.queryParams = {
// 'beginTimestamp' : 0,
// 'endTimestamp' : 0,
// 'keywords' : '',
// 'projectId': vm.projectId,
// 'username' : ''
// };
// vm.op = ['all'];
// vm.fromDate = '';
// vm.toDate = '';
// vm.others = '';
// vm.opOthers = true;
vm.isOpen = false;
}
function listLogFailed(response){
@ -159,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

@ -94,8 +94,7 @@
function getProjectMemberFailed(response) {
console.log('Failed to get project members:' + response);
vm.projectMembers = [];
vm.target = 'repositories';
vm.projectMembers = [];
$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

@ -31,7 +31,7 @@
vm.filterInput = '';
vm.toggleInProgress = [];
var hashValue = $location.hash();
if(hashValue) {
var slashIndex = hashValue.indexOf('/');
@ -54,10 +54,10 @@
if(val) {
vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.filterInput = '';
vm.retrieve();
vm.retrieve();
}
});
$scope.$watch('vm.repositories', function(current) {
if(current) {
@ -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,8 @@
<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%">//t.name//</td><td width="40%">//t.count//</td>
<td width="60%">//t.name//</td>
<td width="40%">//t.count//</td>
</tr>
</tbody>
</table>

View File

@ -28,7 +28,7 @@
ListTopRepositoryService(5)
.success(listTopRepositorySuccess)
.error(listTopRepositoryFailed);
function listTopRepositorySuccess(data) {
vm.top10Repositories = data || [];
}
@ -39,6 +39,7 @@
$scope.$emit('raiseError', true);
console.log('Failed to get top repo:' + 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,7 +31,11 @@
<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%">//t.repo_name//</td><td width="25%">//t.username//</td><td width="25%">//t.op_time | dateL : 'YYYY-MM-DD HH:mm:ss'//</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>
</table>

View File

@ -20,15 +20,17 @@
.module('harbor.user.log')
.directive('userLog', userLog);
UserLogController.$inject = ['$scope', 'ListIntegratedLogService', '$filter', 'trFilter'];
UserLogController.$inject = ['$scope', 'ListIntegratedLogService', '$filter', 'trFilter', '$window'];
function UserLogController($scope, ListIntegratedLogService, $filter, trFilter) {
function UserLogController($scope, ListIntegratedLogService, $filter, trFilter, $window) {
var vm = this;
ListIntegratedLogService()
.success(listIntegratedLogSuccess)
.error(listIntegratedLogFailed);
vm.gotoLog = gotoLog;
function listIntegratedLogSuccess(data) {
vm.integratedLogs = data || [];
}
@ -39,6 +41,11 @@
$scope.$emit('raiseError', true);
console.log('Failed to get user logs:' + data);
}
function gotoLog(projectId, username) {
$window.location.href = '/repository#/logs?project_id=' + projectId + '#' + encodeURIComponent(username);
}
}
function userLog() {

View File

@ -20,17 +20,17 @@
.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;
vm.sectionDefaultHeight = {'min-height': '579px'};
vm.sectionHeight = {'min-height': '579px'};
//Message dialog handler for details.
$scope.$on('modalTitle', function(e, val) {
@ -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,18 +20,20 @@
.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;
vm.sectionHeight = {'min-height': '579px'};
vm.retrieve = retrieve;
vm.showAddProject = showAddProject;
vm.searchProject = searchProject;
@ -44,6 +46,7 @@
vm.confirmToDelete = confirmToDelete;
vm.deleteProject = deleteProject;
//Error message dialog handler for project.
$scope.$on('modalTitle', function(e, val) {
@ -89,7 +92,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 +130,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,13 +19,13 @@
<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 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>
</h4>
<div class="search-pane">
<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-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">
<div class="input-group">
<input type="text" class="form-control" placeholder="" ng-model="vm.projectName" size="30" ng-keydown="vm.searchProjectByKeyPress($event)">
@ -33,50 +33,48 @@
<button class="btn btn-primary" type="button" ng-click="vm.searchProject()"><span class="glyphicon glyphicon-search"></span></button>
</span>
</div>
<button ng-if="vm.isOpen" class="btn btn-default" disabled="disabled" type="button"><span class="glyphicon glyphicon-plus"></span> // 'new_project' | tr //</button>
<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>
<button ng-if="vm.isOpen" class="btn btn-default" disabled="disabled" type="button"><span class="glyphicon glyphicon-plus"></span> // 'new_project' | tr //</button>
<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">
<div class="table-head-container">
<table class="table table-pane table-header">
<thead>
<th width="20%">// 'project_name' | tr //</th>
<th width="15%">// 'repositories' | tr //</th>
<th width="15%" ng-if="!vm.publicity">// 'role' | tr //</th>
<th width="20%">// 'creation_time' | tr //</th>
<th width="15%">// 'publicity' | tr //</th>
<th width="10%">// 'operation' | tr //</th>
</thead>
</table>
</div>
<div class="table-body-container">
<table class="table table-pane">
<tbody>
<tr>
<td colspan="5" height="320px" class="empty-hint" ng-if="vm.projects.length === 0"><h4 class="text-muted">// 'no_projects_add_new_project' | tr //</h4></td>
</tr>
<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="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%">
&nbsp;&nbsp;<a href="javascript:void(0)" ng-click="vm.confirmToDelete(p.project_id, p.name)"><span class="glyphicon glyphicon-trash"></span></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<add-project ng-show="vm.isOpen" is-open="vm.isOpen"></add-project>
<div class="each-tab-pane">
<div class="sub-pane">
<div class="table-head-container">
<table class="table table-pane table-header">
<thead>
<th width="20%">// 'project_name' | tr //</th>
<th width="15%">// 'repositories' | tr //</th>
<th width="15%" ng-if="!vm.publicity">// 'role' | tr //</th>
<th width="20%">// 'creation_time' | tr //</th>
<th width="15%">// 'publicity' | tr //</th>
<th width="10%">// 'operation' | tr //</th>
</thead>
</table>
</div>
<div class="table-body-container">
<table class="table table-pane">
<tbody>
<tr>
<td colspan="5" height="320px" class="empty-hint" ng-if="vm.projects.length === 0"><h4 class="text-muted">// 'no_projects_add_new_project' | tr //</h4></td>
</tr>
<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.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%">
&nbsp;&nbsp;<a href="javascript:void(0)" ng-click="vm.confirmToDelete(p.project_id, p.name)"><span class="glyphicon glyphicon-trash"></span></a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<paginator ng-if="vm.totalCount > 0" total-count="//vm.totalCount//" page-size="//vm.pageSize//" page="vm.page" display-count="5"></paginator>
</div>
<paginator ng-if="vm.totalCount > 0" total-count="//vm.totalCount//" page-size="//vm.pageSize//" page="vm.page" display-count="5"></paginator>
</div>
</div>
</div>
</div>
</div>

View File

@ -16,29 +16,28 @@
<modal-dialog action="vm.action()" content-type="//vm.contentType//" modal-title="//vm.modalTitle//" modal-message="//vm.modalMessage//" confirm-only="vm.confirmOnly"></modal-dialog>
<div class="container container-custom">
<div class="row extend-height">
<div class="col-xs-12 col-md-12 extend-height">
<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 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 === 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-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>
<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>
<!-- Tab panes -->
<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>
<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"></list-project-member>
<list-log ng-if="vm.target === 'logs'" section-height="vm.sectionHeight" target="vm.target"></list-log>
</div>
</div>
</div>