add about menu item to show version info.

This commit is contained in:
kunw 2016-09-06 15:33:50 +08:00
parent bc52b212cf
commit bd54cb528f
8 changed files with 67 additions and 9 deletions

View File

@ -113,6 +113,8 @@ func (b *BaseController) Prepare() {
b.SelfRegistration = true b.SelfRegistration = true
} }
b.Data["SelfRegistration"] = b.SelfRegistration b.Data["SelfRegistration"] = b.SelfRegistration
b.Data["Version"] = os.Getenv("VERSION")
} }
// Forward to setup layout and template for content for a page. // Forward to setup layout and template for content for a page.

View File

@ -20,9 +20,9 @@
.module('harbor.optional.menu') .module('harbor.optional.menu')
.directive('optionalMenu', optionalMenu); .directive('optionalMenu', optionalMenu);
OptionalMenuController.$inject = ['$window', 'I18nService', 'LogOutService', 'currentUser', '$timeout']; OptionalMenuController.$inject = ['$scope', '$window', 'I18nService', 'LogOutService', 'currentUser', '$timeout', 'trFilter', '$filter'];
function OptionalMenuController($window, I18nService, LogOutService, currentUser, $timeout) { function OptionalMenuController($scope, $window, I18nService, LogOutService, currentUser, $timeoutm, trFilter, $filter) {
var vm = this; var vm = this;
vm.currentLanguage = I18nService().getCurrentLanguage(); vm.currentLanguage = I18nService().getCurrentLanguage();
@ -36,6 +36,7 @@
vm.user = currentUser.get(); vm.user = currentUser.get();
vm.setLanguage = setLanguage; vm.setLanguage = setLanguage;
vm.logOut = logOut; vm.logOut = logOut;
vm.about = about;
function setLanguage(language) { function setLanguage(language) {
I18nService().setCurrentLanguage(language); I18nService().setCurrentLanguage(language);
@ -54,13 +55,25 @@
function logOutFailed(data, status) { function logOutFailed(data, status) {
console.log('Failed to log out:' + data); console.log('Failed to log out:' + data);
} }
function about() {
$scope.$emit('modalTitle', $filter('tr')('about_harbor'));
$scope.$emit('modalMessage', $filter('tr')('current_version', [vm.version]));
var raiseInfo = {
'confirmOnly': true,
'contentType': 'text/html',
'action': function() {}
};
$scope.$emit('raiseInfo', raiseInfo);
}
} }
function optionalMenu() { function optionalMenu() {
var directive = { var directive = {
'restrict': 'E', 'restrict': 'E',
'templateUrl': '/optional_menu?timestamp=' + new Date().getTime(), 'templateUrl': '/optional_menu?timestamp=' + new Date().getTime(),
'scope': true, 'scope': {
'version': '@'
},
'controller': OptionalMenuController, 'controller': OptionalMenuController,
'controllerAs': 'vm', 'controllerAs': 'vm',
'bindToController': true 'bindToController': true

View File

@ -76,6 +76,7 @@
function togglePublicity(e) { function togglePublicity(e) {
vm.publicity = e.publicity; vm.publicity = e.publicity;
vm.target = 'repositories';
} }
} }

View File

@ -42,6 +42,40 @@
vm.searchInput = getParameterByName('q', $window.location.search); vm.searchInput = getParameterByName('q', $window.location.search);
console.log('vm.searchInput at header:' + vm.searchInput); console.log('vm.searchInput at header:' + vm.searchInput);
} }
$scope.$on('modalTitle', function(e, val) {
vm.modalTitle = val;
});
$scope.$on('modalMessage', function(e, val) {
vm.modalMessage = val;
});
$scope.$on('raiseInfo', function(e, val) {
if(val) {
vm.action = function() {
val.action();
$scope.$broadcast('showDialog', false);
};
vm.contentType = val.contentType;
vm.confirmOnly = val.confirmOnly;
$scope.$broadcast('showDialog', true);
}
});
$scope.$on('raiseInfo', function(e, val) {
if(val) {
vm.action = function() {
val.action();
$scope.$broadcast('showDialog', false);
};
vm.contentType = val.contentType;
vm.confirmOnly = val.confirmOnly;
$scope.$broadcast('showDialog', true);
}
});
} }
})(); })();

View File

@ -226,6 +226,9 @@ var locale_messages = {
'stopped': 'Stopped', 'stopped': 'Stopped',
'retrying': 'Retrying', 'retrying': 'Retrying',
'error': 'Error', 'error': 'Error',
'about': 'About',
'about_harbor': 'About Harbor',
'current_version': '<label>Version</label>&nbsp;&nbsp;<span>$0</span>',
'failed_to_get_project_member': 'Failed to get current project member.', 'failed_to_get_project_member': 'Failed to get current project member.',
'failed_to_delete_repo': 'Failed to delete repository. ', 'failed_to_delete_repo': 'Failed to delete repository. ',
'failed_to_delete_repo_insuffient_permissions': 'Failed to delete repository, insuffient permissions.', 'failed_to_delete_repo_insuffient_permissions': 'Failed to delete repository, insuffient permissions.',

View File

@ -226,6 +226,9 @@ var locale_messages = {
'stopped': '已终止', 'stopped': '已终止',
'retrying': '重试中', 'retrying': '重试中',
'error': '错误', 'error': '错误',
'about': '关于',
'about_harbor': '关于 Harbor',
'current_version': '<label>当前版本</label>&nbsp;&nbsp;<span>$0</span>',
'failed_to_get_project_member': '无法获取当前项目成员。', 'failed_to_get_project_member': '无法获取当前项目成员。',
'failed_to_delete_repo': '无法删除镜像仓库。', 'failed_to_delete_repo': '无法删除镜像仓库。',
'failed_to_delete_repo_insuffient_permissions': '无法删除镜像仓库,权限不足。', 'failed_to_delete_repo_insuffient_permissions': '无法删除镜像仓库,权限不足。',

View File

@ -19,23 +19,24 @@
</a> </a>
<ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu"> <ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
{{ if eq .AddNew true }} {{ if eq .AddNew true }}
<li><a href="/add_new"><span class="glyphicon glyphicon-plus"></span> // 'add_new_title' | tr //</a></li> <li><a href="/add_new"><span class="glyphicon glyphicon-plus"></span>&nbsp;&nbsp;// 'add_new_title' | tr //</a></li>
{{ end }} {{ end }}
<li><a href="/account_setting"><span class="glyphicon glyphicon-pencil"></span> // 'account_setting' | tr //</a></li> <li><a href="/account_setting"><span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;// 'account_setting' | tr //</a></li>
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a tabindex="-1" href="#"><span class="glyphicon glyphicon-globe"></span> //vm.languageName//</a> <a tabindex="-1" href="#"><span class="glyphicon glyphicon-globe"></span>&nbsp;&nbsp;//vm.languageName//</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li ng-repeat="(key, value) in vm.supportLanguages"><a href="javascript:void(0);" ng-click="vm.setLanguage(key)">// value //</a></li> <li ng-repeat="(key, value) in vm.supportLanguages"><a href="javascript:void(0);" ng-click="vm.setLanguage(key)">// value //</a></li>
</ul> </ul>
</li> </li>
<li><a href="javascript:void(0)" ng-click="vm.about()"><span class="glyphicon glyphicon-info-sign"></span>&nbsp;&nbsp;// 'about' | tr //</a></li>
<li class="divider"></li> <li class="divider"></li>
<li><a href="javascript:void(0)" ng-click="vm.logOut()"><span class="glyphicon glyphicon-log-out"></span> // 'log_out' | tr //</a></li> <li><a href="javascript:void(0)" ng-click="vm.logOut()"><span class="glyphicon glyphicon-log-out"></span>&nbsp;&nbsp;// 'log_out' | tr //</a></li>
</ul> </ul>
</div> </div>
{{ else }} {{ else }}
<div class="dropdown"> <div class="dropdown">
<a role="button" data-toggle="dropdown" class="btn btn-link" data-target="#" href=""> <a role="button" data-toggle="dropdown" class="btn btn-link" data-target="#" href="">
<span class="glyphicon glyphicon-globe"></span> //vm.languageName// <span class="glyphicon glyphicon-globe"></span>&nbsp;&nbsp;//vm.languageName//
</a> </a>
<ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu"> <ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
<li ng-repeat="(key, value) in vm.supportLanguages"><a href="javascript:void(0);" ng-click="vm.setLanguage(key)">// value //</a></li> <li ng-repeat="(key, value) in vm.supportLanguages"><a href="javascript:void(0);" ng-click="vm.setLanguage(key)">// value //</a></li>

View File

@ -13,6 +13,7 @@
limitations under the License. limitations under the License.
--> -->
<nav class="navbar navbar-default navbar-custom" ng-controller="HeaderController as vm"> <nav class="navbar navbar-default navbar-custom" ng-controller="HeaderController as vm">
<modal-dialog modal-title="// vm.modalTitle //" modal-message="// vm.modalMessage //" confirm-only="vm.confirmOnly" action="vm.action()" content-type="// vm.contentType //"></modal-dialog>
<div class="container container-custom"> <div class="container container-custom">
<!-- Brand and toggle get grouped for better mobile display --> <!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header"> <div class="navbar-header">
@ -24,7 +25,7 @@
</div> </div>
<!-- Collect the nav links, forms, and other content for toggling --> <!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-harbor-navbar-collapse-1"> <div class="collapse navbar-collapse" id="bs-harbor-navbar-collapse-1">
<optional-menu login-status="//vm.loginStatus//"></optional-menu> <optional-menu version="{{.Version}}" login-status="//vm.loginStatus//"></optional-menu>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li> <li>
<navigation-header></navigation-header> <navigation-header></navigation-header>