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.projectName = '';
vm.isOpen = false; vm.isOpen = false;
vm.isProjectMember = false; vm.isProjectMember = false;
vm.target = 'repositories'; vm.target = $location.path().substr(1) || 'repositories';
vm.isPublic = Number(getParameterByName('is_public', $location.absUrl())); vm.isPublic = Number(getParameterByName('is_public', $location.absUrl()));
vm.publicity = (vm.isPublic === 1) ? true : false;
vm.retrieve = retrieve; vm.retrieve = retrieve;
vm.filterInput = ''; vm.filterInput = '';
vm.selectItem = selectItem; vm.selectItem = selectItem;
vm.checkProjectMember = checkProjectMember; 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() { function retrieve() {
ListProjectService(vm.projectName, vm.isPublic) ListProjectService(vm.projectName, vm.isPublic)
.success(getProjectSuccess) .success(getProjectSuccess)
.error(getProjectFailed); .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) { function getProjectSuccess(data, status) {
vm.projects = data || []; vm.projects = data || [];
if(vm.projects.length == 0){ if(vm.projects.length == 0 && vm.isPublic === 0){
if(vm.isPublic === 0) {
$window.location.href = '/project'; $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())){ if(getParameterByName('project_id', $location.absUrl())){
angular.forEach(vm.projects, function(value, index) { for(var i in vm.projects) {
if(value['project_id'] === Number(getParameterByName('project_id', $location.absUrl()))) { var project = vm.projects[i];
vm.selectedProject = value; if(project['project_id'] == getParameterByName('project_id', $location.absUrl())) {
vm.selectedProject = project;
break;
}
} }
});
} }
$location.search('project_id', vm.selectedProject.project_id); $location.search('project_id', vm.selectedProject.project_id);
@ -125,6 +116,7 @@
function getCurrentProjectMemberFailed(data, status) { function getCurrentProjectMemberFailed(data, status) {
vm.isProjectMember = false; vm.isProjectMember = false;
console.log('Current user has no member for the project:' + status + ', location.url:' + $location.url()); console.log('Current user has no member for the project:' + status + ', location.url:' + $location.url());
vm.target = 'repositories';
} }
} }
@ -137,7 +129,7 @@
'target': '=', 'target': '=',
'isOpen': '=', 'isOpen': '=',
'selectedProject': '=', 'selectedProject': '=',
'publicity': '=', 'isPublic': '=',
'isProjectMember': '=' 'isProjectMember': '='
}, },
link: link, link: link,

View File

@ -35,7 +35,8 @@
vm.beginTimestamp = 0; vm.beginTimestamp = 0;
vm.endTimestamp = 0; vm.endTimestamp = 0;
vm.keywords = ''; vm.keywords = '';
vm.username = '';
vm.username = $location.hash() || '';
vm.op = []; vm.op = [];
vm.opOthers = true; vm.opOthers = true;
@ -118,18 +119,6 @@
console.log('Total Count in logs:' + vm.totalCount + ', page:' + vm.page); 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; vm.isOpen = false;
} }
function listLogFailed(response){ function listLogFailed(response){
@ -159,9 +148,7 @@
'restrict': 'E', 'restrict': 'E',
'templateUrl': '/static/resources/js/components/log/list-log.directive.html', 'templateUrl': '/static/resources/js/components/log/list-log.directive.html',
'scope': { 'scope': {
'sectionHeight': '=', 'sectionHeight': '='
'target': '=',
'publicity': '='
}, },
'link': link, 'link': link,
'controller': ListLogController, 'controller': ListLogController,

View File

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

View File

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

View File

@ -30,7 +30,6 @@
$scope.$watch('vm.repoName', function(current, origin) { $scope.$watch('vm.repoName', function(current, origin) {
if(current) { if(current) {
console.log('vm.repoName in tags:' + current);
vm.retrieve(); 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> <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>
<tr ng-if="vm.top10Repositories.length > 0" ng-repeat="t in vm.top10Repositories"> <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> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -39,6 +39,7 @@
$scope.$emit('raiseError', true); $scope.$emit('raiseError', true);
console.log('Failed to get top repo:' + data); console.log('Failed to get top repo:' + data);
} }
} }
function topRepository() { function topRepository() {

View File

@ -16,10 +16,11 @@
<div class="table-head-container"> <div class="table-head-container">
<table class="table table-pane table-header"> <table class="table table-pane table-header">
<thead> <thead>
<th width="25%">// 'operation' | tr //</th> <th width="18%">// 'username' | tr //</th>
<th width="25%">// 'details' | tr //</th> <th width="28%">// 'repository_name' | tr //</th>
<th width="25%">// 'user' | tr //</th> <th width="15%">// 'tag' | tr //</th>
<th width="25%">// 'creation_time' | tr //</th> <th width="14%">// 'operation' | tr //</th>
<th width="25%">// 'timestamp' | tr //</th>
</thead> </thead>
</table> </table>
</div> </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> <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>
<tr ng-if="vm.integratedLogs.length > 0" ng-repeat="t in vm.integratedLogs"> <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> </tr>
</tbody> </tbody>
</table> </table>

View File

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

View File

@ -20,17 +20,17 @@
.module('harbor.details') .module('harbor.details')
.controller('DetailsController', DetailsController); .controller('DetailsController', DetailsController);
DetailsController.$inject = ['$scope', '$timeout']; DetailsController.$inject = ['$scope', '$timeout', '$window'];
function DetailsController($scope, $timeout) { function DetailsController($scope, $timeout, $window) {
var vm = this; var vm = this;
vm.publicity = false; vm.isPublic = 0;
vm.isProjectMember = false; vm.isProjectMember = false;
vm.togglePublicity = togglePublicity; vm.togglePublicity = togglePublicity;
vm.sectionDefaultHeight = {'min-height': '579px'}; vm.sectionHeight = {'min-height': '579px'};
//Message dialog handler for details. //Message dialog handler for details.
$scope.$on('modalTitle', function(e, val) { $scope.$on('modalTitle', function(e, val) {
@ -75,8 +75,9 @@
}); });
function togglePublicity(e) { function togglePublicity(e) {
vm.publicity = e.publicity; vm.isPublic = e.isPublic;
vm.target = 'repositories'; $window.location='/project?is_public=' + vm.isPublic;
return;
} }
} }

View File

@ -20,18 +20,20 @@
.module('harbor.layout.project') .module('harbor.layout.project')
.controller('ProjectController', ProjectController); .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; var vm = this;
vm.isOpen = false; vm.isOpen = false;
vm.projectName = ''; vm.projectName = '';
vm.publicity = 0; vm.isPublic = Number(getParameterByName('is_public', $location.absUrl())) || 0;
vm.page = 1; vm.page = 1;
vm.pageSize = 15; vm.pageSize = 15;
vm.sectionHeight = {'min-height': '579px'};
vm.retrieve = retrieve; vm.retrieve = retrieve;
vm.showAddProject = showAddProject; vm.showAddProject = showAddProject;
vm.searchProject = searchProject; vm.searchProject = searchProject;
@ -45,6 +47,7 @@
vm.deleteProject = deleteProject; vm.deleteProject = deleteProject;
//Error message dialog handler for project. //Error message dialog handler for project.
$scope.$on('modalTitle', function(e, val) { $scope.$on('modalTitle', function(e, val) {
vm.modalTitle = val; vm.modalTitle = val;
@ -89,7 +92,7 @@
}); });
function retrieve() { function retrieve() {
ListProjectService(vm.projectName, vm.publicity, vm.page, vm.pageSize) ListProjectService(vm.projectName, vm.isPublic, vm.page, vm.pageSize)
.then(listProjectSuccess) .then(listProjectSuccess)
.catch(listProjectFailed); .catch(listProjectFailed);
} }
@ -127,15 +130,14 @@
} }
function showAddButton() { function showAddButton() {
return (vm.publicity === 0); return (vm.isPublic === 0);
} }
function togglePublicity(e) { function togglePublicity(e) {
vm.publicity = e.publicity; vm.isPublic = e.isPublic;
vm.isOpen = false; vm.isOpen = false;
vm.page = 1; vm.page = 1;
vm.retrieve(); vm.retrieve();
console.log('vm.publicity:' + vm.publicity);
} }
function searchProjectByKeyPress($event) { function searchProjectByKeyPress($event) {

View File

@ -19,11 +19,11 @@
<div class="col-xs-12 col-md-12 extend-height"> <div class="col-xs-12 col-md-12 extend-height">
<div class="section"> <div class="section">
<h4 class="page-header"> <h4 class="page-header">
<span ng-show="!vm.publicity">// 'my_projects' | tr //</span> <span ng-if="vm.isPublic === 0">// 'my_projects' | tr //</span>
<a ng-show="vm.publicity" href="#" ng-click="vm.togglePublicity({publicity: 0})">// 'my_projects' | tr //</a> <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 class="gutter">|</span>
<span ng-show="vm.publicity">// 'public_projects' | tr //</span> <span ng-if="vm.isPublic === 1">// 'public_projects' | tr //</span>
<a ng-show="!vm.publicity" href="#" class="title-color" ng-click="vm.togglePublicity({publicity: 1})">// 'public_projects' | tr //</a> <a ng-if="vm.isPublic === 0" href="javascript:void(0);" class="title-color" ng-click="vm.togglePublicity({isPublic: 1})">// 'public_projects' | tr //</a>
</h4> </h4>
<div class="search-pane"> <div class="search-pane">
<div class="form-inline"> <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> <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>
</div> </div>
<add-project ng-show="vm.isOpen" is-open="vm.isOpen"></add-project> <add-project ng-show="vm.isOpen" is-open="vm.isOpen"></add-project>
<div class="each-tab-pane"> <div class="each-tab-pane">
<div class="sub-pane"> <div class="sub-pane">
@ -62,7 +61,7 @@
<tr ng-if="vm.projects.length > 0" ng-repeat="p in vm.projects"> <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="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%">//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="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="15%"><publicity-button is-public="p.public" project-id="p.project_id"></publicity-button></td>
<td width="10%"> <td width="10%">
@ -78,5 +77,4 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>

View File

@ -19,26 +19,25 @@
<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"> <div class="section" ng-style="vm.sectionHeight">
<h4 class="page-header"> <h4 class="page-header">
<span ng-show="!vm.publicity">// 'my_projects' | tr //</span> <span ng-if="vm.isPublic === 0">// '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> <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 class="gutter">|</span>
<span ng-show="vm.publicity">// 'public_projects' | tr //</span> <span ng-if="vm.isPublic === 1">// '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> <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"> <div class="switch-pane">
<switch-pane-projects is-open="vm.isOpen" selected-project="vm.selectedProject"></switch-pane-projects> <switch-pane-projects is-open="vm.isOpen" selected-project="vm.selectedProject"></switch-pane-projects>
<span> <span>
<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 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 --> <!-- 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}}">
<list-repository ng-if="vm.target === 'repositories'" section-height="vm.sectionHeight"></list-repository> <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-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-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" publicity="vm.publicity"></list-log> <list-log ng-if="vm.target === 'logs'" section-height="vm.sectionHeight" target="vm.target"></list-log>
</div>
</div> </div>
</div> </div>
</div> </div>