diff --git a/controllers/ng/signin.go b/controllers/ng/signin.go index 1d7fb85..7e83aa2 100644 --- a/controllers/ng/signin.go +++ b/controllers/ng/signin.go @@ -8,10 +8,12 @@ import ( "github.com/vmware/harbor/utils/log" ) +// SignInController handles requests to /ng/sign_in type SignInController struct { BaseController } +//Get renders sign_in page func (sic *SignInController) Get() { sessionUserID := sic.GetSession("userId") var hasLoggedIn bool diff --git a/static/ng/resources/js/components/project-member/project-member.config.js b/static/ng/resources/js/components/project-member/project-member.config.js index 937dbcc..8a12037 100644 --- a/static/ng/resources/js/components/project-member/project-member.config.js +++ b/static/ng/resources/js/components/project-member/project-member.config.js @@ -9,6 +9,7 @@ function roles() { return [ + {'id': '0', 'name': 'NA', 'roleName': 'NA'}, {'id': '1', 'name': 'Project Admin', 'roleName': 'projectAdmin'}, {'id': '2', 'name': 'Developer', 'roleName': 'developer'}, {'id': '3', 'name': 'Guest', 'roleName': 'guest'} @@ -25,7 +26,7 @@ for(var i = 0; i < r.length; i++) { var role = r[i]; if(query.key === 'roleName' && role.roleName === query.value - || query.key === 'roleId' && role.id === query.value) { + || query.key === 'roleId' && role.id === String(query.value)) { return role; } } diff --git a/static/ng/resources/js/components/summary/summary.directive.html b/static/ng/resources/js/components/summary/summary.directive.html new file mode 100644 index 0000000..188f46a --- /dev/null +++ b/static/ng/resources/js/components/summary/summary.directive.html @@ -0,0 +1,4 @@ + +
+
// key | tr //:
//value//
+
diff --git a/static/ng/resources/js/components/summary/summary.directive.js b/static/ng/resources/js/components/summary/summary.directive.js new file mode 100644 index 0000000..880f9d2 --- /dev/null +++ b/static/ng/resources/js/components/summary/summary.directive.js @@ -0,0 +1,40 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.summary') + .directive('projectSummary', projectSummary); + + ProjectSummaryController.$inject = ['StatProjectService']; + + function ProjectSummaryController(StatProjectService) { + var vm = this; + + StatProjectService() + .success(statProjectSuccess) + .error(statProjectFailed); + + function statProjectSuccess(data, status) { + vm.statProjects = data; + } + + function statProjectFailed(status) { + console.log('Failed stat project:' + status); + } + } + + function projectSummary() { + var directive = { + 'restrict': 'E', + 'templateUrl': '/static/ng/resources/js/components/summary/summary.directive.html', + 'controller': ProjectSummaryController, + 'scope' : true, + 'controllerAs': 'vm', + 'bindToController': true + }; + + return directive; + } + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/components/summary/summary.module.js b/static/ng/resources/js/components/summary/summary.module.js new file mode 100644 index 0000000..29340b0 --- /dev/null +++ b/static/ng/resources/js/components/summary/summary.module.js @@ -0,0 +1,10 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.summary', [ + 'harbor.services.project' + ]); + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/harbor.module.js b/static/ng/resources/js/harbor.module.js index df243cb..389a69f 100644 --- a/static/ng/resources/js/harbor.module.js +++ b/static/ng/resources/js/harbor.module.js @@ -25,6 +25,7 @@ 'harbor.services.replication.policy', 'harbor.services.replication.job', 'harbor.services.destination', + 'harbor.summary', 'harbor.optional.menu', 'harbor.modal.dialog', 'harbor.sign.in', diff --git a/static/ng/resources/js/layout/dashboard/dashboard.controller.js b/static/ng/resources/js/layout/dashboard/dashboard.controller.js index 140e220..bd2f8b6 100644 --- a/static/ng/resources/js/layout/dashboard/dashboard.controller.js +++ b/static/ng/resources/js/layout/dashboard/dashboard.controller.js @@ -6,28 +6,17 @@ .module('harbor.layout.dashboard') .controller('DashboardController', DashboardController); - DashboardController.$inject = ['StatProjectService', 'ListTop10RepositoryService', 'ListIntegratedLogService']; + DashboardController.$inject = ['ListTop10RepositoryService', 'ListIntegratedLogService']; - function DashboardController(StatProjectService, ListTop10RepositoryService, ListIntegratedLogService) { + function DashboardController(ListTop10RepositoryService, ListIntegratedLogService) { var vm = this; - - StatProjectService() - .then(statProjectSuccess, statProjectFailed); - + ListTop10RepositoryService() .then(listTop10RepositorySuccess, listTop10RepositoryFailed); ListIntegratedLogService() .then(listIntegratedLogSuccess, listIntegratedLogFailed); - - function statProjectSuccess(data) { - vm.statProjects = data; - } - - function statProjectFailed(data) { - console.log('Failed stat project:' + data); - } - + function listTop10RepositorySuccess(data) { vm.top10Repositories = data; } diff --git a/static/ng/resources/js/layout/dashboard/dashboard.module.js b/static/ng/resources/js/layout/dashboard/dashboard.module.js index f061feb..cc45227 100644 --- a/static/ng/resources/js/layout/dashboard/dashboard.module.js +++ b/static/ng/resources/js/layout/dashboard/dashboard.module.js @@ -4,7 +4,6 @@ angular .module('harbor.layout.dashboard', [ - 'harbor.services.project', 'harbor.services.repository', 'harbor.services.log' ]); diff --git a/static/ng/resources/js/layout/project/project.controller.js b/static/ng/resources/js/layout/project/project.controller.js index 9b14b15..095b6eb 100644 --- a/static/ng/resources/js/layout/project/project.controller.js +++ b/static/ng/resources/js/layout/project/project.controller.js @@ -6,9 +6,9 @@ .module('harbor.layout.project') .controller('ProjectController', ProjectController); - ProjectController.$inject = ['$scope', 'ListProjectService', '$timeout', 'currentUser']; + ProjectController.$inject = ['$scope', 'ListProjectService', '$timeout', 'currentUser', 'getRole']; - function ProjectController($scope, ListProjectService, $timeout, currentUser) { + function ProjectController($scope, ListProjectService, $timeout, currentUser, getRole) { var vm = this; vm.isOpen = false; @@ -22,6 +22,7 @@ vm.togglePublicity = togglePublicity; vm.user = currentUser.get(); vm.retrieve(); + vm.getProjectRole = getProjectRole; function retrieve() { @@ -34,6 +35,11 @@ vm.projects = data || []; } + function getProjectRole(roleId) { + var role = getRole({'key': 'roleId', 'value': roleId}); + return role.name; + } + function listProjectFailed(e) { console.log('Failed to list Project:' + e); } diff --git a/static/ng/resources/js/layout/project/project.module.js b/static/ng/resources/js/layout/project/project.module.js index ae2d88a..9133726 100644 --- a/static/ng/resources/js/layout/project/project.module.js +++ b/static/ng/resources/js/layout/project/project.module.js @@ -4,6 +4,7 @@ angular .module('harbor.layout.project', [ + 'harbor.project.member', 'harbor.services.project', 'harbor.services.user' ]); diff --git a/static/ng/resources/js/services/i18n/locale_messages_en-US.js b/static/ng/resources/js/services/i18n/locale_messages_en-US.js index b3f8b43..4298817 100644 --- a/static/ng/resources/js/services/i18n/locale_messages_en-US.js +++ b/static/ng/resources/js/services/i18n/locale_messages_en-US.js @@ -45,15 +45,18 @@ var locale_messages = { 'comments': 'Comments', 'comment_is_too_long': 'Comment is too long. (maximum 20 characters)', 'forgot_password_description': 'Please input the Email used when you signed up, a reset password Email will be sent to you.', - 'email_does_not_exist': 'Email does not exist', 'reset_password': 'Reset Password', 'summary': 'Summary', 'projects': 'Projects', 'public_projects': 'Public Projects', 'public': 'Public', - 'total_projects': 'Total Projects', 'public_repositories': 'Public Repositories', - 'total_repositories': 'Total Repositories', + 'my_project_count': 'Projects', + 'my_repo_count': 'Repositories', + 'public_project_count': 'Public Projects', + 'public_repo_count': 'Public Repositories', + 'total_project_count': 'Total Projects', + 'total_repo_count': 'Total Repositories', 'top_10_repositories': 'Top 10 Repositories', 'repository_name': 'Repository Name', 'size': 'Size', diff --git a/static/ng/resources/js/services/i18n/locale_messages_zh-CN.js b/static/ng/resources/js/services/i18n/locale_messages_zh-CN.js index ca0d326..babfb8b 100644 --- a/static/ng/resources/js/services/i18n/locale_messages_zh-CN.js +++ b/static/ng/resources/js/services/i18n/locale_messages_zh-CN.js @@ -45,15 +45,18 @@ var locale_messages = { 'comments': '备注', 'comment_is_too_long' : '备注长度超出限制。(最长为20个字符)', 'forgot_password_description': '重置邮件将发送到此邮箱。', - 'email_does_not_exist': '邮箱不存在。', 'reset_password': '重置密码', 'summary': '摘要', 'projects': '项目', 'public_projects': '公开项目', 'public': '公开', - 'total_projects': '全部项目', 'public_repositories': '公开镜像仓库', - 'total_repositories': '全部镜像仓库', + 'my_project_count': '项目', + 'my_repo_count': '镜像仓库', + 'public_project_count': '公开项目', + 'public_repo_count': '公开镜像仓库', + 'total_project_count': '全部项目', + 'total_repo_count': '全部镜像仓库', 'top_10_repositories': 'Top 10 镜像仓库', 'repository_name': '镜像仓库名', 'size': '规格', diff --git a/static/ng/resources/js/services/project/services.stat-project.js b/static/ng/resources/js/services/project/services.stat-project.js index 52fac98..fd398bc 100644 --- a/static/ng/resources/js/services/project/services.stat-project.js +++ b/static/ng/resources/js/services/project/services.stat-project.js @@ -6,35 +6,18 @@ .module('harbor.services.project') .factory('StatProjectService', StatProjectService); - StatProjectService.$inject = ['$http', '$q', '$timeout']; + StatProjectService.$inject = ['$http', '$log']; - function StatProjectService($http, $q, $timeout) { + function StatProjectService($http, $log) { + + return StatProject; - var mockData = { - 'projects': 30, - 'public_projects': 50, - 'total_projects': 120, - 'repositories': 50, - 'public_repositories': 40, - 'total_repositories': 110 - }; - - function async() { - var deferred = $q.defer(); - - $timeout(function() { - deferred.resolve(mockData); - }, 500); - - return deferred.promise; + function StatProject() { + $log.info('statistics projects and repositories'); + return $http + .get('/api/statistics'); } - - return statProject; - - function statProject() { - return async(); - } - + } })(); \ No newline at end of file diff --git a/views/ng/dashboard.htm b/views/ng/dashboard.htm index 9b1a872..5616ea4 100644 --- a/views/ng/dashboard.htm +++ b/views/ng/dashboard.htm @@ -4,15 +4,7 @@
- -
-
// 'projects' | tr //:
//vm.statProjects['projects']//
-
// 'public_projects' | tr //:
//vm.statProjects['public_projects']//
-
// 'total_projects' | tr //:
//vm.statProjects['total_projects']//
-
// 'repositories' | tr //:
//vm.statProjects['repositories']//
-
// 'public_repositories' | tr //:
//vm.statProjects['public_repositories']//
-
// 'total_repositories' | tr //:
//vm.statProjects['total_repositories']//
-
+
diff --git a/views/ng/project.htm b/views/ng/project.htm index 5e07143..4d6b82f 100644 --- a/views/ng/project.htm +++ b/views/ng/project.htm @@ -35,8 +35,8 @@ //p.Name// - N/A - N/A + //p.repo_count// + //vm.getProjectRole(p.role_id)// //p.CreationTime | dateL : 'YYYY-MM-DD HH:mm:ss'// diff --git a/views/ng/sections/header-include.htm b/views/ng/sections/header-include.htm index 83706aa..c1087a5 100644 --- a/views/ng/sections/header-include.htm +++ b/views/ng/sections/header-include.htm @@ -198,6 +198,7 @@ + @@ -211,3 +212,5 @@ + +