merge updates of new-version-of-ui

This commit is contained in:
kunw 2016-06-07 14:24:01 +08:00
commit cbb6491970
16 changed files with 99 additions and 62 deletions

View File

@ -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

View File

@ -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;
}
}

View File

@ -0,0 +1,4 @@
<h4 class="page-header title-color underlined">// 'summary' | tr //</h4>
<dl class="page-content dl-horizontal" ng-repeat="(key, value) in vm.statProjects">
<dt>// key | tr //:</dt><dd>//value//</dd>
</dl>

View File

@ -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;
}
})();

View File

@ -0,0 +1,10 @@
(function() {
'use strict';
angular
.module('harbor.summary', [
'harbor.services.project'
]);
})();

View File

@ -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',

View File

@ -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;
}

View File

@ -4,7 +4,6 @@
angular
.module('harbor.layout.dashboard', [
'harbor.services.project',
'harbor.services.repository',
'harbor.services.log'
]);

View File

@ -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);
}

View File

@ -4,6 +4,7 @@
angular
.module('harbor.layout.project', [
'harbor.project.member',
'harbor.services.project',
'harbor.services.user'
]);

View File

@ -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',

View File

@ -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': '规格',

View File

@ -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();
}
}
})();

View File

@ -4,15 +4,7 @@
<div class="col-xs-4 col-md-4">
<div class="row">
<div class="up-section">
<h4 class="page-header title-color underlined">// 'summary' | tr //</h4>
<dl class="page-content dl-horizontal">
<dt>// 'projects' | tr //:</dt><dd>//vm.statProjects['projects']//</dd>
<dt>// 'public_projects' | tr //:</dt><dd>//vm.statProjects['public_projects']//</dd>
<dt>// 'total_projects' | tr //:</dt><dd>//vm.statProjects['total_projects']//</dd>
<dt>// 'repositories' | tr //:</dt><dd>//vm.statProjects['repositories']//</dd>
<dt>// 'public_repositories' | tr //:</dt><dd>//vm.statProjects['public_repositories']//</dd>
<dt>// 'total_repositories' | tr //:</dt><dd>//vm.statProjects['total_repositories']//</dd>
</dl>
<project-Summary></project-Summary>
</div>
</div>
</div>

View File

@ -35,8 +35,8 @@
</tr>
<tr ng-if="vm.projects.length > 0" ng-repeat="p in vm.projects">
<td><a href="/ng/repository#/repositories?project_id=//p.ProjectId//&is_public=//p.Public//">//p.Name//</a></td>
<td>N/A</td>
<td>N/A</td>
<td>//p.repo_count//</td>
<td>//vm.getProjectRole(p.role_id)//</td>
<td>//p.CreationTime | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
<td><publicity-button is-public="p.Public" owned="p.OwnerId == vm.user.UserId" project-id="p.ProjectId"></publicity-button></td>
</tr>

View File

@ -198,6 +198,7 @@
<script src="/static/ng/resources/js/components/log/list-log.directive.js"></script>
<script src="/static/ng/resources/js/components/log/advanced-search.directive.js"></script>
<script src="/static/ng/resources/js/components/replication/replication.module.js"></script>
<script src="/static/ng/resources/js/components/replication/list-replication.directive.js"></script>
<script src="/static/ng/resources/js/components/replication/create-policy.directive.js"></script>
@ -211,3 +212,5 @@
<script src="/static/ng/resources/js/components/system-management/configuration.directive.js"></script>
<script src="/static/ng/resources/js/components/summary/summary.module.js"></script>
<script src="/static/ng/resources/js/components/summary/summary.directive.js"></script>