diff --git a/static/ng/resources/js/components/summary/summary.config.js b/static/ng/resources/js/components/summary/summary.config.js new file mode 100644 index 000000000..86be426d5 --- /dev/null +++ b/static/ng/resources/js/components/summary/summary.config.js @@ -0,0 +1,37 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.summary') + .constant('projectStatistics', projectStatistics) + .factory('getStatisticsName', getStatisticsName); + + function projectStatistics() { + return [ + {'name': 'projects', 'payloadName': 'my_project_count'}, + {'name': 'repositories', 'payloadName': 'my_repo_count'}, + {'name': 'public_projects', 'payloadName': 'public_project_count'}, + {'name': 'public_repositories', 'payloadName': 'public_repo_count'}, + {'name': 'total_projects', 'payloadName': 'total_project_count'}, + {'name': 'total_repositories', 'payloadName': 'total_repo_count'}, + ]; + } + + getStatisticsName.$inject = ['projectStatistics']; + + function getStatisticsName(projectStatistics) { + var r = projectStatistics(); + return get; + function get(query) { + + for(var i = 0; i < r.length; i++) { + var StatisticsName = r[i]; + if(query.key === 'payloadName' && StatisticsName.payloadName === query.value + || query.key === 'name' && StatisticsName.name === query.value) { + return StatisticsName; + } + } + } + } +})(); \ No newline at end of file diff --git a/static/ng/resources/js/components/summary/summary.directive.html b/static/ng/resources/js/components/summary/summary.directive.html index 7ee01d521..314651419 100644 --- a/static/ng/resources/js/components/summary/summary.directive.html +++ b/static/ng/resources/js/components/summary/summary.directive.html @@ -1,15 +1,4 @@ -
-
// 'projects' | tr //:
//vm.statProjects['my_project_count']//
-
// 'public_projects' | tr //:
//vm.statProjects['public_project_count']//
-
// 'total_projects' | tr //:
//vm.statProjects['total_project_count']//
-
// 'repositories' | tr //:
//vm.statProjects['my_repo_count']//
-
// 'public_repositories' | tr //:
//vm.statProjects['public_repo_count']//
-
// 'total_repositories' | tr //:
//vm.statProjects['total_repo_count']//
+
+
// vm.getSummaryName(key) | tr //:
//value//
-
-
// 'projects' | tr //:
//vm.statProjects['my_project_count']//
-
// 'public_projects' | tr //:
//vm.statProjects['public_project_count']//
-
// 'repositories' | tr //:
//vm.statProjects['my_repo_count']//
-
// 'public_repositories' | tr //:
//vm.statProjects['public_repo_count']//
-
\ No newline at end of file diff --git a/static/ng/resources/js/components/summary/summary.directive.js b/static/ng/resources/js/components/summary/summary.directive.js index 3bc70fb1c..f22053043 100644 --- a/static/ng/resources/js/components/summary/summary.directive.js +++ b/static/ng/resources/js/components/summary/summary.directive.js @@ -6,10 +6,11 @@ .module('harbor.summary') .directive('projectSummary', projectSummary); - ProjectSummaryController.$inject = ['StatProjectService']; + ProjectSummaryController.$inject = ['StatProjectService', 'getStatisticsName']; - function ProjectSummaryController(StatProjectService) { + function ProjectSummaryController(StatProjectService, getStatisticsName) { var vm = this; + vm.getSummaryName = getSummaryName; StatProjectService() .success(statProjectSuccess) @@ -17,16 +18,16 @@ function statProjectSuccess(data, status) { vm.statProjects = data; - if(vm.statProjects.hasOwnProperty("total_project_count")) { - vm.isAdmin = true; - }else { - vm.isAdmin = false; - } } function statProjectFailed(status) { console.log('Failed stat project:' + status); - } + } + + function getSummaryName(payloadName) { + var statisticsName = getStatisticsName({'key': 'payloadName', 'value': payloadName}); + return statisticsName.name; + } } function projectSummary() { diff --git a/static/ng/resources/js/layout/project/project.controller.js b/static/ng/resources/js/layout/project/project.controller.js index 8eca93747..095b6eb62 100644 --- a/static/ng/resources/js/layout/project/project.controller.js +++ b/static/ng/resources/js/layout/project/project.controller.js @@ -22,6 +22,7 @@ vm.togglePublicity = togglePublicity; vm.user = currentUser.get(); vm.retrieve(); + vm.getProjectRole = getProjectRole; function retrieve() { @@ -31,13 +32,12 @@ } function listProjectSuccess(data, status) { - data.forEach(function(data){ - var currentRole = getRole({'key': 'roleId', 'value': data.role_id}); - data.role_name = currentRole.name; - }); - vm.projects = data || []; - + } + + function getProjectRole(roleId) { + var role = getRole({'key': 'roleId', 'value': roleId}); + return role.name; } function listProjectFailed(e) { 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 b3f8b4344..9609fc1ea 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,7 +45,6 @@ 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', 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 ca0d3265b..a319a49b9 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,7 +45,6 @@ var locale_messages = { 'comments': '备注', 'comment_is_too_long' : '备注长度超出限制。(最长为20个字符)', 'forgot_password_description': '重置邮件将发送到此邮箱。', - 'email_does_not_exist': '邮箱不存在。', 'reset_password': '重置密码', 'summary': '摘要', 'projects': '项目', diff --git a/views/ng/project.htm b/views/ng/project.htm index b4eb38f51..4d6b82ffa 100644 --- a/views/ng/project.htm +++ b/views/ng/project.htm @@ -36,7 +36,7 @@ //p.Name// //p.repo_count// - //p.role_name// + //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 4cbb14521..7742a3aa6 100644 --- a/views/ng/sections/header-include.htm +++ b/views/ng/sections/header-include.htm @@ -200,3 +200,4 @@ +