Merge pull request #335 from xiahaoshawn/new-ui-with-sync-image

integrated top ten repositories and user logs to dashboard
This commit is contained in:
kun wang 2016-06-15 17:56:34 +08:00 committed by GitHub
commit 985522e55c
17 changed files with 194 additions and 164 deletions

View File

@ -15,7 +15,7 @@
.success(statProjectSuccess)
.error(statProjectFailed);
function statProjectSuccess(data, status) {
function statProjectSuccess(data) {
vm.statProjects = data;
}

View File

@ -0,0 +1,16 @@
<h4 class="page-header title-color underlined">// 'top_10_repositories' | tr //</h4>
<div class="col-xs-4 col-md-12 up-table-pane">
<table class="table">
<thead>
<th>// 'repository_name' | tr //</th><th>// 'count' | tr //</th><th>// 'creator' | tr //</th>
</thead>
<tbody>
<tr>
<td colspan="5" height="120px" class="empty-hint" ng-if="vm.top10Repositories.length === 0"><h3 class="text-muted">// 'no_top_repositories' | tr //</h3></td>
</tr>
<tr ng-if="vm.top10Repositories.length > 0" ng-repeat="t in vm.top10Repositories">
<td>//t.name//</td><td>//t.count//</td><td>//t.creator//</td>
</tr>
</tbody>
</table>
</div>

View File

@ -0,0 +1,41 @@
(function() {
'use strict';
angular
.module('harbor.top.repository')
.directive('topRepository', topRepository);
TopRepositoryController.$inject = ['ListTopRepositoryService'];
function TopRepositoryController(ListTopRepositoryService) {
var vm = this;
ListTopRepositoryService(10)
.success(listTopRepositorySuccess)
.error(listTopRepositoryFailed);
function listTopRepositorySuccess(data) {
vm.top10Repositories = data || []
console.log(vm.top10Repositories.length);
}
function listTopRepositoryFailed(data, status) {
console.log('Failed list integrated logs:' + status);
}
}
function topRepository() {
var directive = {
'restrict': 'E',
'templateUrl': '/static/ng/resources/js/components/top-repository/top-repository.directive.html',
'controller': TopRepositoryController,
'scope' : true,
'controllerAs': 'vm',
'bindToController': true
};
return directive;
}
})();

View File

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

View File

@ -0,0 +1,16 @@
<h4 class="page-header title-color underlined">// 'logs' | tr //</h4>
<div style="padding: 15px;">
<table class="table">
<thead>
<th>// 'task_name' | tr //</th><th>// 'details' | tr //</th><th>// 'user' | tr //</th><th>// 'creation_time' | tr //</th>
</thead>
<tbody>
<tr>
<td colspan="5" height="120px" class="empty-hint" ng-if="vm.integratedLogs.length === 0"><h3 class="text-muted">// 'no_user_logs' | tr //</h3></td>
</tr>
<tr ng-if="vm.integratedLogs.length > 0" ng-repeat="t in vm.integratedLogs">
<td>//t.Operation//</td><td>//t.RepoName//</td><td>//t.Username//</td><td>//t.OpTime | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
</tr>
</tbody>
</table>
</div>

View File

@ -0,0 +1,40 @@
(function() {
'use strict';
angular
.module('harbor.user.log')
.directive('userLog', userLog);
UserLogController.$inject = ['ListIntegratedLogService'];
function UserLogController(ListIntegratedLogService) {
var vm = this;
ListIntegratedLogService()
.success(listIntegratedLogSuccess)
.error(listIntegratedLogFailed);
function listIntegratedLogSuccess(data) {
vm.integratedLogs = data || []
}
function listIntegratedLogFailed(data, status) {
console.log('Failed list integrated logs:' + status);
}
}
function userLog() {
var directive = {
'restrict': 'E',
'templateUrl': '/static/ng/resources/js/components/user-log/user-log.directive.html',
'controller': UserLogController,
'scope' : true,
'controllerAs': 'vm',
'bindToController': true
};
return directive;
}
})();

View File

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

View File

@ -26,6 +26,8 @@
'harbor.services.replication.job',
'harbor.services.destination',
'harbor.summary',
'harbor.user.log',
'harbor.top.repository',
'harbor.optional.menu',
'harbor.modal.dialog',
'harbor.sign.in',

View File

@ -6,33 +6,8 @@
.module('harbor.layout.dashboard')
.controller('DashboardController', DashboardController);
DashboardController.$inject = ['ListTop10RepositoryService', 'ListIntegratedLogService'];
function DashboardController() {
function DashboardController(ListTop10RepositoryService, ListIntegratedLogService) {
var vm = this;
ListTop10RepositoryService()
.then(listTop10RepositorySuccess, listTop10RepositoryFailed);
ListIntegratedLogService()
.then(listIntegratedLogSuccess, listIntegratedLogFailed);
function listTop10RepositorySuccess(data) {
vm.top10Repositories = data;
}
function listTop10RepositoryFailed(data) {
console.log('Failed list top 10 repositories:' + data);
}
function listIntegratedLogSuccess(data) {
vm.integratedLogs = data;
}
function listIntegratedLogFailed(data) {
console.log('Failed list integrated logs:' + data);
}
}
})();

View File

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

View File

@ -60,11 +60,14 @@ var locale_messages = {
'top_10_repositories': 'Top 10 Repositories',
'repository_name': 'Repository Name',
'size': 'Size',
'count': 'Count',
'creator': 'Creator',
'no_top_repositories': 'No data, start with Harbor now!',
'logs': 'Logs',
'task_name': 'Task Name',
'details': 'Details',
'user': 'User',
'no_user_logs': 'No data, start with Harbor now!',
'users': 'Users',
'my_projects': 'My Projects',
'project_name': 'Project Name',

View File

@ -60,11 +60,14 @@ var locale_messages = {
'top_10_repositories': 'Top 10 镜像仓库',
'repository_name': '镜像仓库名',
'size': '规格',
'count': '次数',
'creator': '创建者',
'no_top_repositories': '没有数据开始使用Harbor',
'logs': '日志',
'task_name': '任务名称',
'details': '详细信息',
'user': '用户',
'no_user_logs': '没有数据开始使用Harbor',
'users': '用户',
'my_projects': '我的项目',
'project_name': '项目名称',

View File

@ -1,62 +1,26 @@
(function() {
'use strict';
angular
angular
.module('harbor.services.log')
.factory('ListIntegratedLogService', ListIntegratedLogService);
ListIntegratedLogService.$inject = ['$http', '$q', '$timeout'];
function ListIntegratedLogService($http, $q, $timeout) {
var mockData = [
{
'task_name': 'create',
'details': 'created myproject/ubuntu',
'user': 'kunw',
'creation_time': '2016-05-10 17:53:25'
},
{
'task_name': 'push',
'details': 'pushed myproject/mysql',
'user': 'kunw',
'creation_time': '2016-05-10 16:25:15'
},
{
'task_name': 'pull',
'details': 'pulled myrepo/nginx',
'user': 'user1',
'creation_time': '2016-05-11 10:42:43'
},
{
'task_name': 'delete',
'details': 'deleted myrepo/golang',
'user': 'user1',
'creation_time': '2016-05-11 12:21:35'
}
];
function async() {
var deferred = $q.defer();
$timeout(function() {
deferred.resolve(mockData);
}, 500);
return deferred.promise;
}
ListIntegratedLogService.$inject = ['$http', '$log'];
function ListIntegratedLogService($http, $log) {
return listIntegratedLog;
function listIntegratedLog() {
return async();
function listIntegratedLog(lines) {
$log.info('Get recent logs of the projects which the user is a member of:');
return $http
.get('/api/logs', {
'params' : {
'lines': lines,
}
});
}
}
})();

View File

@ -0,0 +1,26 @@
(function() {
'use strict';
angular
.module('harbor.services.repository')
.factory('ListTopRepositoryService', ListTopRepositoryService);
ListTopRepositoryService.$inject = ['$http', '$log'];
function ListTopRepositoryService($http, $log) {
return listTopRepository;
function listTopRepository(count) {
$log.info('Get public repositories which are accessed most:');
return $http
.get('/api/repositories/top', {
'params' : {
'count': count,
}
});
}
}
})();

View File

@ -1,58 +0,0 @@
(function() {
'use strict';
angular
.module('harbor.services.repository')
.factory('ListTop10RepositoryService', ListTop10RepositoryService);
ListTop10RepositoryService.$inject = ['$http', '$q', '$timeout'];
function ListTop10RepositoryService($http, $q, $timeout) {
var mockData = [
{
'repo_name': 'myproject/ubuntu',
'image_size': '89',
'creator': 'kunw'
},
{
'repo_name': 'myproject/nginx',
'image_size': '67',
'creator': 'kunw'
},
{
'repo_name': 'myrepo/mysql',
'image_size': '122',
'creator': 'user1'
},
{
'repo_name': 'target/golang',
'image_size': '587',
'creator': 'tester'
}
];
function async() {
var deferred = $q.defer();
$timeout(function() {
deferred.resolve(mockData);
}, 500);
return deferred.promise;
}
return listTop10Repository;
function listTop10Repository() {
return async();
}
}
})();

View File

@ -10,19 +10,7 @@
</div>
<div class="col-xs-8 col-md-8">
<div class="up-section">
<h4 class="page-header title-color underlined">// 'top_10_repositories' | tr //</h4>
<div class="col-xs-4 col-md-12 up-table-pane">
<table class="table">
<thead>
<th>// 'repository_name' | tr //</th><th>// 'size' | tr //</th><th>// 'creator' | tr //</th>
</thead>
<tbody>
<tr ng-repeat="t in vm.top10Repositories">
<td>//t.repo_name//</td><td>//t.image_size//MB</td><td>//t.creator//</td>
</tr>
</tbody>
</table>
</div>
<top-Repository></top-Repository>
</div>
</div>
</div>
@ -31,18 +19,7 @@
<div class="row row-custom">
<div class="col-xs-12 col-md-12">
<div class="down-section">
<h4 class="page-header title-color underlined">// 'logs' | tr //</h4>
<div style="padding: 15px;">
<table class="table">
<thead>
<th>// 'task_name' | tr //</th><th>// 'details' | tr //</th><th>// 'user' | tr //</th><th>// 'creation_time' | tr //</th>
</thead>
<tbody>
<tr ng-repeat="t in vm.integratedLogs">
<td>//t.task_name//</td><td>//t.details//</td><td>//t.user//</td><td>//t.creation_time//</td>
</tr>
</tbody>
</table>
<user-Log></user-Log>
</div>
</div>
</div>

View File

@ -122,7 +122,7 @@
<script src="/static/ng/resources/js/services/repository/services.list-tag.js"></script>
<script src="/static/ng/resources/js/services/repository/services.list-manifest.js"></script>
<script src="/static/ng/resources/js/services/repository/services.delete-repository.js"></script>
<script src="/static/ng/resources/js/services/repository/services.list-top10-repository.js"></script>
<script src="/static/ng/resources/js/services/repository/services.list-top-repository.js"></script>
<script src="/static/ng/resources/js/services/project-member/services.project-member.module.js"></script>
<script src="/static/ng/resources/js/services/project-member/services.current-project-member.js"></script>
@ -219,3 +219,9 @@
<script src="/static/ng/resources/js/components/summary/summary.module.js"></script>
<script src="/static/ng/resources/js/components/summary/summary.directive.js"></script>
<script src="/static/ng/resources/js/components/user-log/user-log.module.js"></script>
<script src="/static/ng/resources/js/components/user-log/user-log.directive.js"></script>
<script src="/static/ng/resources/js/components/top-repository/top-repository.module.js"></script>
<script src="/static/ng/resources/js/components/top-repository/top-repository.directive.js"></script>