From e5dec021fe35cd9582a158be4cd7052abfd3cfb6 Mon Sep 17 00:00:00 2001 From: kunw Date: Tue, 13 Sep 2016 17:02:31 +0800 Subject: [PATCH] add links to popular repo items and recent logs. --- .../details/retrieve-projects.directive.js | 4 ++- .../js/components/log/list-log.directive.js | 15 ++--------- .../top-repository.directive.html | 3 ++- .../top-repository.directive.js | 26 +++++++++++++++++-- .../user-log/user-log.directive.html | 5 +++- .../components/user-log/user-log.directive.js | 13 +++++++--- 6 files changed, 45 insertions(+), 21 deletions(-) diff --git a/static/resources/js/components/details/retrieve-projects.directive.js b/static/resources/js/components/details/retrieve-projects.directive.js index 4b36c63..be739b0 100644 --- a/static/resources/js/components/details/retrieve-projects.directive.js +++ b/static/resources/js/components/details/retrieve-projects.directive.js @@ -28,7 +28,9 @@ 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; diff --git a/static/resources/js/components/log/list-log.directive.js b/static/resources/js/components/log/list-log.directive.js index 2faac6a..84c1231 100644 --- a/static/resources/js/components/log/list-log.directive.js +++ b/static/resources/js/components/log/list-log.directive.js @@ -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){ diff --git a/static/resources/js/components/top-repository/top-repository.directive.html b/static/resources/js/components/top-repository/top-repository.directive.html index a44c1dc..3dc0129 100644 --- a/static/resources/js/components/top-repository/top-repository.directive.html +++ b/static/resources/js/components/top-repository/top-repository.directive.html @@ -29,7 +29,8 @@

// 'no_top_repositories' | tr //

- //t.name////t.count// + //t.name// + //t.count// diff --git a/static/resources/js/components/top-repository/top-repository.directive.js b/static/resources/js/components/top-repository/top-repository.directive.js index 800f7e7..a385c88 100644 --- a/static/resources/js/components/top-repository/top-repository.directive.js +++ b/static/resources/js/components/top-repository/top-repository.directive.js @@ -20,14 +20,16 @@ .module('harbor.top.repository') .directive('topRepository', topRepository); - TopRepositoryController.$inject = ['$scope', 'ListTopRepositoryService', '$filter', 'trFilter']; + TopRepositoryController.$inject = ['$scope', 'ListTopRepositoryService', 'SearchService', '$filter', 'trFilter', '$window']; - function TopRepositoryController($scope, ListTopRepositoryService, $filter, trFilter) { + function TopRepositoryController($scope, ListTopRepositoryService, SearchService, $filter, trFilter, $window) { var vm = this; ListTopRepositoryService(5) .success(listTopRepositorySuccess) .error(listTopRepositoryFailed); + + vm.gotoRepo = gotoRepo; function listTopRepositorySuccess(data) { vm.top10Repositories = data || []; @@ -39,6 +41,26 @@ $scope.$emit('raiseError', true); 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() { diff --git a/static/resources/js/components/user-log/user-log.directive.html b/static/resources/js/components/user-log/user-log.directive.html index 5500b0f..d3a9a12 100644 --- a/static/resources/js/components/user-log/user-log.directive.html +++ b/static/resources/js/components/user-log/user-log.directive.html @@ -30,7 +30,10 @@

// 'no_user_logs' | tr //

- //t.operation////t.repo_name////t.username////t.op_time | dateL : 'YYYY-MM-DD HH:mm:ss'// + //t.operation// + //t.repo_name// + //t.username// + //t.op_time | dateL : 'YYYY-MM-DD HH:mm:ss'// diff --git a/static/resources/js/components/user-log/user-log.directive.js b/static/resources/js/components/user-log/user-log.directive.js index 8869c78..ceb86a7 100644 --- a/static/resources/js/components/user-log/user-log.directive.js +++ b/static/resources/js/components/user-log/user-log.directive.js @@ -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() {