From 2f59120e48655d0d7e9a800b430a128d7fcb7097 Mon Sep 17 00:00:00 2001 From: kunw Date: Thu, 12 May 2016 18:30:01 +0800 Subject: [PATCH] updates of dashboard and admin-options for UI. --- controllers/ng/adminoption.go | 9 +++ controllers/ng/index.go | 4 +- controllers/ng/password.go | 4 ++ ngrouter.go | 5 ++ static/ng/resources/css/dashboard.css | 1 - .../optional-menu.directive.html | 2 +- .../optional-menu/optional-menu.directive.js | 16 ++++- .../components/sign-in/sign-in.directive.html | 2 +- .../components/sign-in/sign-in.directive.js | 11 +++- .../user/change-password.controller.js | 15 ----- .../components/user/delete-user.controller.js | 15 ----- .../user/forgot-password.controller.js | 16 ----- .../components/user/list-user.directive.html | 1 - .../js/components/user/list-user.directive.js | 28 -------- .../js/components/user/sign-in.controller.js | 15 ----- .../js/components/user/sign-up.controller.js | 15 ----- .../user/toggle-admin.directive.html | 2 + .../components/user/toggle-admin.directive.js | 57 ++++++++++++++++ static/ng/resources/js/harbor.config.js | 11 +++- static/ng/resources/js/harbor.module.js | 3 + .../admin-option/admin-option.config.js | 26 ++++++++ .../admin-option/admin-option.controller.js | 23 +++++++ .../admin-option/admin-option.module.js | 8 +++ .../layout/dashboard/dashboard.controller.js | 49 ++++++++++++++ .../js/layout/dashboard/dashboard.module.js | 12 ++++ .../js/layout/details/details.config.js | 13 +--- .../system-management.controller.html | 66 +++++++++++++++++++ .../system-management.controller.js | 39 +++++++++++ .../system-management.module.js | 8 +++ .../js/layout/user/user.controller.html | 34 +++++++++- .../js/layout/user/user.controller.js | 47 ++++++++++++- .../resources/js/layout/user/user.module.js | 5 +- .../log/services.list-integrated-log.js | 62 +++++++++++++++++ .../services/project/services.stat-project.js | 40 +++++++++++ .../services.list-top10-repository.js | 58 ++++++++++++++++ .../js/services/user/services.delete-user.js | 5 +- .../js/services/user/services.list-user.js | 11 +++- .../js/services/user/services.log-out.js | 19 ++++++ .../js/services/user/services.toggle-admin.js | 22 +++++++ .../js/session/session.current-user.js | 19 ++++-- ui/ngrouter.go | 3 +- views/ng/admin-options.htm | 20 ++++++ views/ng/dashboard.htm | 61 +++++++---------- views/ng/sections/header-include.htm | 19 +++++- 44 files changed, 724 insertions(+), 177 deletions(-) create mode 100644 controllers/ng/adminoption.go delete mode 100644 static/ng/resources/js/components/user/change-password.controller.js delete mode 100644 static/ng/resources/js/components/user/delete-user.controller.js delete mode 100644 static/ng/resources/js/components/user/forgot-password.controller.js delete mode 100644 static/ng/resources/js/components/user/list-user.directive.html delete mode 100644 static/ng/resources/js/components/user/list-user.directive.js delete mode 100644 static/ng/resources/js/components/user/sign-in.controller.js delete mode 100644 static/ng/resources/js/components/user/sign-up.controller.js create mode 100644 static/ng/resources/js/components/user/toggle-admin.directive.html create mode 100644 static/ng/resources/js/components/user/toggle-admin.directive.js create mode 100644 static/ng/resources/js/layout/admin-option/admin-option.config.js create mode 100644 static/ng/resources/js/layout/admin-option/admin-option.controller.js create mode 100644 static/ng/resources/js/layout/admin-option/admin-option.module.js create mode 100644 static/ng/resources/js/layout/dashboard/dashboard.controller.js create mode 100644 static/ng/resources/js/layout/dashboard/dashboard.module.js create mode 100644 static/ng/resources/js/layout/system-management/system-management.controller.html create mode 100644 static/ng/resources/js/layout/system-management/system-management.controller.js create mode 100644 static/ng/resources/js/layout/system-management/system-management.module.js create mode 100644 static/ng/resources/js/services/log/services.list-integrated-log.js create mode 100644 static/ng/resources/js/services/project/services.stat-project.js create mode 100644 static/ng/resources/js/services/repository/services.list-top10-repository.js create mode 100644 static/ng/resources/js/services/user/services.log-out.js create mode 100644 static/ng/resources/js/services/user/services.toggle-admin.js create mode 100644 views/ng/admin-options.htm diff --git a/controllers/ng/adminoption.go b/controllers/ng/adminoption.go new file mode 100644 index 000000000..c0a56bb2d --- /dev/null +++ b/controllers/ng/adminoption.go @@ -0,0 +1,9 @@ +package ng + +type AdminOptionController struct { + BaseController +} + +func (aoc *AdminOptionController) Get() { + aoc.Forward("Admin Options", "admin-options.htm") +} diff --git a/controllers/ng/index.go b/controllers/ng/index.go index df27b91a2..0c34fe58b 100644 --- a/controllers/ng/index.go +++ b/controllers/ng/index.go @@ -4,6 +4,6 @@ type IndexController struct { BaseController } -func (c *IndexController) Get() { - c.Forward("Index", "index.htm") +func (ic *IndexController) Get() { + ic.Forward("Index", "index.htm") } diff --git a/controllers/ng/password.go b/controllers/ng/password.go index a360254bd..9b16bba93 100644 --- a/controllers/ng/password.go +++ b/controllers/ng/password.go @@ -22,6 +22,10 @@ func (cc *CommonController) Render() error { return nil } +func (cc *CommonController) LogOut() { + cc.DestroySession() +} + type messageDetail struct { Hint string URL string diff --git a/ngrouter.go b/ngrouter.go index 45ac58f69..61cbaf74e 100644 --- a/ngrouter.go +++ b/ngrouter.go @@ -14,6 +14,11 @@ func initNgRouters() { beego.Router("/ng/repository", &ng.RepositoryController{}) beego.Router("/ng/sign_up", &ng.SignUpController{}) beego.Router("/ng/account_setting", &ng.AccountSettingController{}) + beego.Router("/ng/admin_option", &ng.AdminOptionController{}) beego.Router("/ng/forgot_password", &ng.ForgotPasswordController{}) beego.Router("/ng/reset_password", &ng.ResetPasswordController{}) + + beego.Router("/ng/reset", &ng.CommonController{}, "post:ResetPassword") + beego.Router("/ng/sendEmail", &ng.CommonController{}, "get:SendEmail") + } diff --git a/static/ng/resources/css/dashboard.css b/static/ng/resources/css/dashboard.css index eb101cd96..a11a6cfc1 100644 --- a/static/ng/resources/css/dashboard.css +++ b/static/ng/resources/css/dashboard.css @@ -12,7 +12,6 @@ } .single { - margin-left: -15px; margin-right: 0; } diff --git a/static/ng/resources/js/components/optional-menu/optional-menu.directive.html b/static/ng/resources/js/components/optional-menu/optional-menu.directive.html index 9834c629b..48c1fc596 100644 --- a/static/ng/resources/js/components/optional-menu/optional-menu.directive.html +++ b/static/ng/resources/js/components/optional-menu/optional-menu.directive.html @@ -22,6 +22,6 @@
  • -
  • Log Out
  • +
  • Log Out
  • \ No newline at end of file diff --git a/static/ng/resources/js/components/optional-menu/optional-menu.directive.js b/static/ng/resources/js/components/optional-menu/optional-menu.directive.js index 8d4c01c06..3a787eb94 100644 --- a/static/ng/resources/js/components/optional-menu/optional-menu.directive.js +++ b/static/ng/resources/js/components/optional-menu/optional-menu.directive.js @@ -6,10 +6,22 @@ .module('harbor.optional.menu') .directive('optionalMenu', optionalMenu); - OptionalMenuController.$inject = ['$scope']; + OptionalMenuController.$inject = ['$scope', '$window', 'LogOutService']; - function OptionalMenuController($scope, $timeout) { + function OptionalMenuController($scope, $window, LogOutService) { var vm = this; + vm.logOut = logOut; + function logOut() { + LogOutService() + .success(logOutSuccess) + .error(logOutFailed); + } + function logOutSuccess(data, status) { + $window.location.href= '/ng'; + } + function logOutFailed(data, status) { + console.log('Failed to log out:' + data); + } } function optionalMenu() { diff --git a/static/ng/resources/js/components/sign-in/sign-in.directive.html b/static/ng/resources/js/components/sign-in/sign-in.directive.html index d3b9ece89..ccab43c07 100644 --- a/static/ng/resources/js/components/sign-in/sign-in.directive.html +++ b/static/ng/resources/js/components/sign-in/sign-in.directive.html @@ -20,7 +20,7 @@
    diff --git a/static/ng/resources/js/components/sign-in/sign-in.directive.js b/static/ng/resources/js/components/sign-in/sign-in.directive.js index 0ea51c99b..712879e9a 100644 --- a/static/ng/resources/js/components/sign-in/sign-in.directive.js +++ b/static/ng/resources/js/components/sign-in/sign-in.directive.js @@ -12,7 +12,9 @@ vm.principal = ""; vm.password = ""; vm.doSignIn = doSignIn; - + vm.doSignUp = doSignUp; + vm.doForgotPassword = doForgotPassword; + function doSignIn() { if(vm.principal != "" && vm.password != "") { SignInService(vm.principal, vm.password) @@ -32,6 +34,13 @@ console.log(status); } + function doSignUp() { + $window.location.href = '/ng/sign_up'; + } + + function doForgotPassword() { + $window.location.href = '/ng/forgot_password'; + } } function signIn() { diff --git a/static/ng/resources/js/components/user/change-password.controller.js b/static/ng/resources/js/components/user/change-password.controller.js deleted file mode 100644 index 4f97f4b8d..000000000 --- a/static/ng/resources/js/components/user/change-password.controller.js +++ /dev/null @@ -1,15 +0,0 @@ -(function() { - - 'use strict'; - - angular - .module('harbor.user'); - .controller('ChangePasswordController', ChangePasswordController); - - ChangePassswordController.$inject = ['ChangePasswordService']; - - function ChangePasswordController(ChangePasswordService) { - - } - -})(); \ No newline at end of file diff --git a/static/ng/resources/js/components/user/delete-user.controller.js b/static/ng/resources/js/components/user/delete-user.controller.js deleted file mode 100644 index 95c07f763..000000000 --- a/static/ng/resources/js/components/user/delete-user.controller.js +++ /dev/null @@ -1,15 +0,0 @@ -(function() { - - 'use strict'; - - angular - .module('harbor.user'); - .controller('DeleteUserController', DeleteUserController); - - DeleteUserController.$inject = ['DeleteUserService']; - - function DeleteUserController(DeleteUserService) { - - } - -})(); \ No newline at end of file diff --git a/static/ng/resources/js/components/user/forgot-password.controller.js b/static/ng/resources/js/components/user/forgot-password.controller.js deleted file mode 100644 index ac01e841d..000000000 --- a/static/ng/resources/js/components/user/forgot-password.controller.js +++ /dev/null @@ -1,16 +0,0 @@ -(function() { - - 'use strict'; - - angular - .module('harbor.user'); - .controller('ForgotPasswordController', ForgotPasswordController); - - - ForgotPasswordController.$inject = ['ForgotPasswordService']; - - function ForgotPasswordController(ForgotPasswordService) { - - } - -})(); \ No newline at end of file diff --git a/static/ng/resources/js/components/user/list-user.directive.html b/static/ng/resources/js/components/user/list-user.directive.html deleted file mode 100644 index 70bcff3a4..000000000 --- a/static/ng/resources/js/components/user/list-user.directive.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/static/ng/resources/js/components/user/list-user.directive.js b/static/ng/resources/js/components/user/list-user.directive.js deleted file mode 100644 index 1cff1551d..000000000 --- a/static/ng/resources/js/components/user/list-user.directive.js +++ /dev/null @@ -1,28 +0,0 @@ -(function() { - - 'use strict'; - - angular - .module('harbor.user') - .directive('listUser', listUser); - - ListUserController.$inject = ['ListUserService']; - - function ListUserController(ListUserService) { - - } - - function listUser() { - var directive = { - restrict: 'E', - templateUrl: '/static/ng/resources/js/components/user/list-user.directive.html', - replace: true, - controller: ListUserController, - controllerAs: 'vm', - bindToController: true - } - - return directive; - } - -})(); \ No newline at end of file diff --git a/static/ng/resources/js/components/user/sign-in.controller.js b/static/ng/resources/js/components/user/sign-in.controller.js deleted file mode 100644 index 25b13d423..000000000 --- a/static/ng/resources/js/components/user/sign-in.controller.js +++ /dev/null @@ -1,15 +0,0 @@ -(function() { - - 'use strict'; - - angular - .module('harbor.user'); - .controller('SignInController', SignInController); - - SignInController.$inject = ['SignInService']; - - function SignInController(SignInService) { - - } - -})(); \ No newline at end of file diff --git a/static/ng/resources/js/components/user/sign-up.controller.js b/static/ng/resources/js/components/user/sign-up.controller.js deleted file mode 100644 index 5c8c21b1e..000000000 --- a/static/ng/resources/js/components/user/sign-up.controller.js +++ /dev/null @@ -1,15 +0,0 @@ -(function() { - - 'use strict'; - - angular - .module('harbor.user'); - .controller('SignUpController', SignUpController); - - SignUpController.$inject = ['SignUpService']; - - function SignUpController(SignUpService) { - - } - -})(); \ No newline at end of file diff --git a/static/ng/resources/js/components/user/toggle-admin.directive.html b/static/ng/resources/js/components/user/toggle-admin.directive.html new file mode 100644 index 000000000..01787ed6d --- /dev/null +++ b/static/ng/resources/js/components/user/toggle-admin.directive.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/static/ng/resources/js/components/user/toggle-admin.directive.js b/static/ng/resources/js/components/user/toggle-admin.directive.js new file mode 100644 index 000000000..d0eb96a1a --- /dev/null +++ b/static/ng/resources/js/components/user/toggle-admin.directive.js @@ -0,0 +1,57 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.user') + .directive('toggleAdmin', toggleAdmin); + + ToggleAdminController.$inject = ['$scope', 'ToggleAdminService']; + + function ToggleAdminController($scope, ToggleAdminService) { + var vm = this; + + vm.isAdmin = (vm.hasAdminRole == 1) ? true : false; + vm.toggle = toggle; + + function toggle() { + ToggleAdminService(vm.userId) + .success(toggleAdminSuccess) + .error(toggleAdminFailed); + } + + function toggleAdminSuccess(data, status) { + if(vm.isAdmin) { + vm.isAdmin = false; + }else{ + vm.isAdmin = true; + } + console.log('Toggled userId:' + vm.userId + ' to admin:' + vm.isAdmin); + } + + function toggleAdminFailed(data, status) { + console.log('Failed toggle admin:' + data); + } + } + + function toggleAdmin() { + var directive = { + 'restrict': 'E', + 'templateUrl': '/static/ng/resources/js/components/user/toggle-admin.directive.html', + 'scope': { + 'hasAdminRole': '=', + 'userId': '@' + }, + 'link': link, + 'controller': ToggleAdminController, + 'controllerAs': 'vm', + 'bindToController': true + }; + return directive; + + function link(scope, element, attrs, ctrl) { + + } + } + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/harbor.config.js b/static/ng/resources/js/harbor.config.js index 72f53f427..2ec3ccd62 100644 --- a/static/ng/resources/js/harbor.config.js +++ b/static/ng/resources/js/harbor.config.js @@ -8,6 +8,15 @@ }) .config(function($httpProvider) { $httpProvider.defaults.headers.common = {'Accept': 'application/json, text/javascript, */*; q=0.01'}; - }); + }) + .filter('dateL', localizeDate); + + function localizeDate() { + return filter; + + function filter(input, pattern) { + return moment(new Date(input || '')).format(pattern); + } + } })(); \ 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 c7ad7b33c..8cf6fe009 100644 --- a/static/ng/resources/js/harbor.module.js +++ b/static/ng/resources/js/harbor.module.js @@ -12,11 +12,14 @@ 'harbor.layout.forgot.password', 'harbor.layout.reset.password', 'harbor.layout.index', + 'harbor.layout.dashboard', 'harbor.layout.project', 'harbor.layout.repository', 'harbor.layout.project.member', 'harbor.layout.user', + 'harbor.layout.system.management', 'harbor.layout.log', + 'harbor.layout.admin.option', 'harbor.services.project', 'harbor.services.user', 'harbor.services.repository', diff --git a/static/ng/resources/js/layout/admin-option/admin-option.config.js b/static/ng/resources/js/layout/admin-option/admin-option.config.js new file mode 100644 index 000000000..8ace33f55 --- /dev/null +++ b/static/ng/resources/js/layout/admin-option/admin-option.config.js @@ -0,0 +1,26 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.layout.admin.option') + .config(routeConfig); + + function routeConfig($routeProvider) { + $routeProvider + .when('/all_user', { + 'templateUrl': '/static/ng/resources/js/layout/user/user.controller.html', + 'controller': 'UserController', + 'controllerAs': 'vm' + }) + .when('/system_management', { + 'templateUrl': '/static/ng/resources/js/layout/system-management/system-management.controller.html', + 'controller': 'SystemManagementController', + 'controllerAs': 'vm' + }) + .otherwise({ + 'redirectTo': '/' + }); + } + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/layout/admin-option/admin-option.controller.js b/static/ng/resources/js/layout/admin-option/admin-option.controller.js new file mode 100644 index 000000000..39eb1ba72 --- /dev/null +++ b/static/ng/resources/js/layout/admin-option/admin-option.controller.js @@ -0,0 +1,23 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.layout.admin.option') + .controller('AdminOptionController', AdminOptionController); + + function AdminOptionController() { + var vm = this; + vm.toggle = false; + vm.toggleAdminOption = toggleAdminOption; + + function toggleAdminOption() { + if(vm.toggle) { + vm.toggle = false; + }else{ + vm.toggle = true; + } + } + } + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/layout/admin-option/admin-option.module.js b/static/ng/resources/js/layout/admin-option/admin-option.module.js new file mode 100644 index 000000000..c0b5aa48a --- /dev/null +++ b/static/ng/resources/js/layout/admin-option/admin-option.module.js @@ -0,0 +1,8 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.layout.admin.option', []); + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/layout/dashboard/dashboard.controller.js b/static/ng/resources/js/layout/dashboard/dashboard.controller.js new file mode 100644 index 000000000..140e220eb --- /dev/null +++ b/static/ng/resources/js/layout/dashboard/dashboard.controller.js @@ -0,0 +1,49 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.layout.dashboard') + .controller('DashboardController', DashboardController); + + DashboardController.$inject = ['StatProjectService', 'ListTop10RepositoryService', 'ListIntegratedLogService']; + + function DashboardController(StatProjectService, 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; + } + + 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); + } + + } + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/layout/dashboard/dashboard.module.js b/static/ng/resources/js/layout/dashboard/dashboard.module.js new file mode 100644 index 000000000..f061febd3 --- /dev/null +++ b/static/ng/resources/js/layout/dashboard/dashboard.module.js @@ -0,0 +1,12 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.layout.dashboard', [ + 'harbor.services.project', + 'harbor.services.repository', + 'harbor.services.log' + ]); + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/layout/details/details.config.js b/static/ng/resources/js/layout/details/details.config.js index d5aeee5ee..cd2b36cd2 100644 --- a/static/ng/resources/js/layout/details/details.config.js +++ b/static/ng/resources/js/layout/details/details.config.js @@ -5,8 +5,8 @@ angular .module('harbor.details') .config(routeConfig) - .filter('name', nameFilter) - .filter('dateL', localizeDate); + .filter('name', nameFilter); + function routeConfig($routeProvider) { $routeProvider @@ -48,13 +48,6 @@ return input; } } - - function localizeDate() { - return filter; - - function filter(input, pattern) { - return moment(new Date(input || '')).format(pattern); - } - } + })(); \ No newline at end of file diff --git a/static/ng/resources/js/layout/system-management/system-management.controller.html b/static/ng/resources/js/layout/system-management/system-management.controller.html new file mode 100644 index 000000000..00feb9e72 --- /dev/null +++ b/static/ng/resources/js/layout/system-management/system-management.controller.html @@ -0,0 +1,66 @@ +
    +
    +
    +
    System Settings
    +
    +
    +
    + +
    + +
    + Host name is required. +
    +
    +
    +
    + +
    + +
    + Url protocol is required. +
    +
    +
    +
    + +
    + +
    + Email server is required. +
    +
    +
    +
    + +
    + +
    + LDAP URL is required. +
    +
    +
    +
    +
    +
    +
    Registration
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/static/ng/resources/js/layout/system-management/system-management.controller.js b/static/ng/resources/js/layout/system-management/system-management.controller.js new file mode 100644 index 000000000..719f0ab0d --- /dev/null +++ b/static/ng/resources/js/layout/system-management/system-management.controller.js @@ -0,0 +1,39 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.layout.system.management') + .controller('SystemManagementController', SystemManagementController); + + function SystemManagementController() { + var vm = this; + vm.registrationOptions = [ + { + 'name': 'on', + 'value': true + }, + { + 'name': 'off', + 'value': false + } + ]; + vm.currentRegistration = { + 'name': 'on', + 'value': true + }; + + vm.changeSettings = changeSettings; + + vm.selectRegistration = selectRegistration; + + function selectRegistration() { + + } + + function changeSettings(system) { + console.log(system); + } + } + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/layout/system-management/system-management.module.js b/static/ng/resources/js/layout/system-management/system-management.module.js new file mode 100644 index 000000000..0fb06b3d5 --- /dev/null +++ b/static/ng/resources/js/layout/system-management/system-management.module.js @@ -0,0 +1,8 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.layout.system.management', []); + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/layout/user/user.controller.html b/static/ng/resources/js/layout/user/user.controller.html index 70bcff3a4..1f18c1695 100644 --- a/static/ng/resources/js/layout/user/user.controller.html +++ b/static/ng/resources/js/layout/user/user.controller.html @@ -1 +1,33 @@ - \ No newline at end of file +
    +
    +
    + + + + +
    +
    +
    + + + + + + + + + + + + + +
    UsernameRoleEmailRegistration TimeOperation
    //u.username//N/A//u.email////u.creation_time | dateL : 'YYYY-MM-DD HH:mm:ss'// +    +    +
    +
    +
    +
    +
    //vm.users ? vm.users.length : 0// items
    +
    + diff --git a/static/ng/resources/js/layout/user/user.controller.js b/static/ng/resources/js/layout/user/user.controller.js index eda931ee6..c14ba227f 100644 --- a/static/ng/resources/js/layout/user/user.controller.js +++ b/static/ng/resources/js/layout/user/user.controller.js @@ -6,7 +6,52 @@ .module('harbor.layout.user') .controller('UserController', UserController); - function UserController() { + UserController.$inject = ['ListUserService', 'DeleteUserService']; + + function UserController(ListUserService, DeleteUserService) { + var vm = this; + + vm.username = ''; + vm.searchUser = searchUser; + vm.deleteUser = deleteUser; + vm.retrieve = retrieve; + + vm.retrieve(); + + function searchUser() { + vm.retrieve(); + } + + function deleteUser(userId) { + DeleteUserService(userId) + .success(deleteUserSuccess) + .error(deleteUserFailed); + } + + function retrieve() { + ListUserService(vm.username) + .success(listUserSuccess) + .error(listUserFailed); + } + + function deleteUserSuccess(data, status) { + console.log('Successful delete user.'); + vm.retrieve(); + } + + function deleteUserFailed(data, status) { + console.log('Failed delete user.'); + } + + function listUserSuccess(data, status) { + vm.users = data; + } + + function listUserFailed(data, status) { + console.log('Failed list user:' + data); + } + + } diff --git a/static/ng/resources/js/layout/user/user.module.js b/static/ng/resources/js/layout/user/user.module.js index a84323ca4..4bfe54e56 100644 --- a/static/ng/resources/js/layout/user/user.module.js +++ b/static/ng/resources/js/layout/user/user.module.js @@ -3,5 +3,8 @@ 'use strict'; angular - .module('harbor.layout.user', []); + .module('harbor.layout.user', [ + 'harbor.services.user' + ]); + })(); \ No newline at end of file diff --git a/static/ng/resources/js/services/log/services.list-integrated-log.js b/static/ng/resources/js/services/log/services.list-integrated-log.js new file mode 100644 index 000000000..c8119128d --- /dev/null +++ b/static/ng/resources/js/services/log/services.list-integrated-log.js @@ -0,0 +1,62 @@ +(function() { + + 'use strict'; + + 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; + } + + return listIntegratedLog; + + function listIntegratedLog() { + return async(); + } + + } + + + + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/services/project/services.stat-project.js b/static/ng/resources/js/services/project/services.stat-project.js new file mode 100644 index 000000000..52fac9876 --- /dev/null +++ b/static/ng/resources/js/services/project/services.stat-project.js @@ -0,0 +1,40 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.services.project') + .factory('StatProjectService', StatProjectService); + + StatProjectService.$inject = ['$http', '$q', '$timeout']; + + function StatProjectService($http, $q, $timeout) { + + 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; + } + + return statProject; + + function statProject() { + return async(); + } + + } + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/services/repository/services.list-top10-repository.js b/static/ng/resources/js/services/repository/services.list-top10-repository.js new file mode 100644 index 000000000..693809332 --- /dev/null +++ b/static/ng/resources/js/services/repository/services.list-top10-repository.js @@ -0,0 +1,58 @@ +(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(); + } + + } + + + + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/services/user/services.delete-user.js b/static/ng/resources/js/services/user/services.delete-user.js index 43f271bce..c2139f5c8 100644 --- a/static/ng/resources/js/services/user/services.delete-user.js +++ b/static/ng/resources/js/services/user/services.delete-user.js @@ -12,8 +12,9 @@ return DeleteUser; - function DeleteUser(user) { - + function DeleteUser(userId) { + return $http + .delete('/api/users/' + userId); } } diff --git a/static/ng/resources/js/services/user/services.list-user.js b/static/ng/resources/js/services/user/services.list-user.js index 92e154cd2..b906a206b 100644 --- a/static/ng/resources/js/services/user/services.list-user.js +++ b/static/ng/resources/js/services/user/services.list-user.js @@ -10,10 +10,15 @@ function ListUserService($http, $log) { - return ListUser; + return listUser; - function ListUser(queryParams) { - $log.info(queryParams); + function listUser(username) { + return $http + .get('/api/users', { + 'params' : { + 'username': username + } + }); } } })(); \ No newline at end of file diff --git a/static/ng/resources/js/services/user/services.log-out.js b/static/ng/resources/js/services/user/services.log-out.js new file mode 100644 index 000000000..0f639851a --- /dev/null +++ b/static/ng/resources/js/services/user/services.log-out.js @@ -0,0 +1,19 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.services.user') + .factory('LogOutService', LogOutService); + + LogOutService.$inject = ['$http']; + + function LogOutService($http) { + return logOut; + function logOut() { + return $http + .get('/ng/log_out'); + } + } + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/services/user/services.toggle-admin.js b/static/ng/resources/js/services/user/services.toggle-admin.js new file mode 100644 index 000000000..cb90d5af5 --- /dev/null +++ b/static/ng/resources/js/services/user/services.toggle-admin.js @@ -0,0 +1,22 @@ +(function() { + + 'use strict'; + + angular + .module('harbor.services.user') + .factory('ToggleAdminService', ToggleAdminService); + + ToggleAdminService.$inject = ['$http']; + + function ToggleAdminService($http) { + + return toggleAdmin; + + function toggleAdmin(userId) { + return $http + .put('/api/users/' + userId); + } + + } + +})(); \ No newline at end of file diff --git a/static/ng/resources/js/session/session.current-user.js b/static/ng/resources/js/session/session.current-user.js index 03ec40244..6eacb39a8 100644 --- a/static/ng/resources/js/session/session.current-user.js +++ b/static/ng/resources/js/session/session.current-user.js @@ -4,11 +4,11 @@ angular .module('harbor.session') - .controller('CurrentUserController', CurrentUserController) - - CurrentUserController.$inject = ['CurrentUserService', 'currentUser', '$scope', '$timeout']; + .controller('CurrentUserController', CurrentUserController); + + CurrentUserController.$inject = ['CurrentUserService', 'currentUser', '$scope', '$timeout', '$window']; - function CurrentUserController(CurrentUserService, currentUser, $scope, $timeout) { + function CurrentUserController(CurrentUserService, currentUser, $scope, $timeout, $window) { var vm = this; @@ -25,8 +25,15 @@ } function getCurrentUserFailed(e){ - console.log('Have not logged in yet.'); + var url = location.pathname; + var exclusions = ['/ng', '/ng/forgot_password', '/ng/sign_up', '/ng/reset_password']; + for(var i = 0; i < exclusions.length; i++) { + if(exclusions[i]===url) { + return; + } + } + $window.location.href = '/ng'; } } - + })(); \ No newline at end of file diff --git a/ui/ngrouter.go b/ui/ngrouter.go index 4e72fe19c..d03c1a100 100644 --- a/ui/ngrouter.go +++ b/ui/ngrouter.go @@ -13,9 +13,10 @@ func initNgRouters() { beego.Router("/ng/repository", &ng.RepositoryController{}) beego.Router("/ng/sign_up", &ng.SignUpController{}) beego.Router("/ng/account_setting", &ng.AccountSettingController{}) + beego.Router("/ng/admin_option", &ng.AdminOptionController{}) beego.Router("/ng/forgot_password", &ng.ForgotPasswordController{}) beego.Router("/ng/reset_password", &ng.ResetPasswordController{}) - + beego.Router("/ng/log_out", &ng.CommonController{}, "get:LogOut") beego.Router("/ng/reset", &ng.CommonController{}, "post:ResetPassword") beego.Router("/ng/sendEmail", &ng.CommonController{}, "get:SendEmail") diff --git a/views/ng/admin-options.htm b/views/ng/admin-options.htm new file mode 100644 index 000000000..6937a34aa --- /dev/null +++ b/views/ng/admin-options.htm @@ -0,0 +1,20 @@ +
    +
    +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/views/ng/dashboard.htm b/views/ng/dashboard.htm index 71fdcecf0..cc043cb96 100644 --- a/views/ng/dashboard.htm +++ b/views/ng/dashboard.htm @@ -1,4 +1,4 @@ -
    +
    @@ -6,34 +6,28 @@
    -
    Projects:
    40
    -
    Public Projects:
    30
    -
    Total Projects:
    60
    -
    Repositories:
    20
    -
    Public Repositories:
    18
    -
    Total Repositories:
    32
    +
    Projects:
    //vm.statProjects['projects']//
    +
    Public Projects:
    //vm.statProjects['public_projects']//
    +
    Total Projects:
    //vm.statProjects['total_projects']//
    +
    Repositories:
    //vm.statProjects['repositories']//
    +
    Public Repositories:
    //vm.statProjects['public_repositories']//
    +
    Total Repositories:
    //vm.statProjects['total_repositories']//
    - +
    - + - - - - - - - - - + + +
    UsernameRepository NameOperationTimestampRepository NameSizeCreator
    Haoxmyrepo/UbuntuCreate2016-03-22 12:35:00
    Haoxmyrepo/MySQLPush2016-03-22 12:35:00
    Danielmyproject/GolangCreate2016-03-12 12:35:00
    //t.repo_name////t.image_size//MB//t.creator//
    @@ -45,25 +39,18 @@
    - -

    - Project Harbor is to build an enterprise-class, - reliable registry server. Enterprises can set - up a private registry server in their own environment - to improve productivity as well as security. - Project Harbor can be used in both development - and production environment. -

    -
      -
    • Security: Keep their intellectual properties ...
    • -
    • Efficiency: A private registry server is set up ...
    • -
    • Access Control: RBAC (Role Based Access ...
    • -
    • Audit: All access to the registry are logged ...
    • -
    • GUI: User friendly single-pane-of-glass ...
    • -
    - + + + + + + + + + + + +
    Task NameDetailsUserTime
    //t.task_name////t.details////t.user////t.creation_time//
    diff --git a/views/ng/sections/header-include.htm b/views/ng/sections/header-include.htm index 4e4ad7a16..2846e8919 100644 --- a/views/ng/sections/header-include.htm +++ b/views/ng/sections/header-include.htm @@ -63,6 +63,9 @@ + + + @@ -79,9 +82,16 @@ + + + + + + + @@ -89,6 +99,7 @@ + @@ -98,13 +109,17 @@ - + + + + + @@ -115,6 +130,7 @@ + @@ -160,6 +176,7 @@ +