From 6c1fee736bb3b4afcea1cc6ecd37e59292336efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 8 Jan 2016 17:58:46 +0100 Subject: [PATCH] feat(sidemenu): improved user dropdown and sidemenu, will be improved further, #3687 --- public/app/core/controllers/sidemenu_ctrl.js | 34 ++++--- public/app/partials/sidemenu.html | 100 +++++-------------- public/less/sidemenu.less | 28 +----- 3 files changed, 46 insertions(+), 116 deletions(-) diff --git a/public/app/core/controllers/sidemenu_ctrl.js b/public/app/core/controllers/sidemenu_ctrl.js index 7534f2a59e5..671e89f7851 100644 --- a/public/app/core/controllers/sidemenu_ctrl.js +++ b/public/app/core/controllers/sidemenu_ctrl.js @@ -24,26 +24,32 @@ function (angular, _, $, coreModule, config) { }); }; - $scope.loadOrgs = function() { - $scope.orgMenu = []; + $scope.openUserDropdown = function() { + $scope.orgMenu = [ + {section: 'You', cssClass: 'dropdown-menu-title'}, + {text: 'Profile', url: $scope.getUrl('/profile')}, + ]; if (contextSrv.hasRole('Admin')) { + $scope.orgMenu.push({section: contextSrv.user.orgName, cssClass: 'dropdown-menu-title'}); $scope.orgMenu.push({ - text: "Organization settings", - href: $scope.getUrl("/org"), + text: "Settings", + url: $scope.getUrl("/org"), }); $scope.orgMenu.push({ text: "Users", - href: $scope.getUrl("/org/users"), + url: $scope.getUrl("/org/users"), }); $scope.orgMenu.push({ text: "API Keys", - href: $scope.getUrl("/org/apikeys"), + url: $scope.getUrl("/org/apikeys"), }); } - if ($scope.orgMenu.length > 0) { - $scope.orgMenu.push({ cssClass: 'divider' }); + $scope.orgMenu.push({cssClass: "divider"}); + + if (config.allowOrgCreate) { + $scope.orgMenu.push({text: "New organization", icon: "fa fa-fw fa-plus", url: $scope.getUrl('/org/new')}); } backendSrv.get('/api/user/orgs').then(function(orgs) { @@ -61,12 +67,12 @@ function (angular, _, $, coreModule, config) { }); }); - if (config.allowOrgCreate) { - $scope.orgMenu.push({ - text: "New Organization", - icon: "fa fa-fw fa-plus", - href: $scope.getUrl('/org/new') - }); + $scope.orgMenu.push({cssClass: "divider"}); + if (contextSrv.isGrafanaAdmin) { + $scope.orgMenu.push({text: "Server admin", url: $scope.getUrl("/admin/settings")}); + } + if (contextSrv.isSignedIn) { + $scope.orgMenu.push({text: "Sign out", url: $scope.getUrl("/logout"), target: "_self"}); } }); }; diff --git a/public/app/partials/sidemenu.html b/public/app/partials/sidemenu.html index 2279629ff3c..21ee3af6a1b 100644 --- a/public/app/partials/sidemenu.html +++ b/public/app/partials/sidemenu.html @@ -8,27 +8,21 @@ - +
  • + + + Sign in + +
  • +
  • @@ -51,75 +52,20 @@
  • - + {{item.text}} - -
  • - - - - - diff --git a/public/less/sidemenu.less b/public/less/sidemenu.less index 420749067f1..ac3470c65ea 100644 --- a/public/less/sidemenu.less +++ b/public/less/sidemenu.less @@ -33,7 +33,6 @@ } .sidemenu { - font-size: 16px; font-weight: @baseFontWeight; list-style: none; margin: 0; @@ -48,32 +47,11 @@ top: 2px; font-size: 90%; } - - &.sidemenu-small { - font-size: 14px; - - .icon-circle { - border-radius: 50%; - background: @iconContainerBackground; - box-shadow: @iconContainerShadow; - border: @iconContainerBorder; - width: 28px; - height: 28px; - i { - top: 1px; - left: 4px; - font-size: 110%; - } - } - - .sidemenu-item { - // color: @textColor; - line-height: 28px; - padding-left: 25px; - } - } } +.sidemenu-main-link { + font-size: 16px; +} .sidemenu-item-text { width: 110px;