From bbbd3320ef543b727fcfd682420ed27742964e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 25 Feb 2015 16:01:37 +0100 Subject: [PATCH] Created seperate admin sidenav #1506 --- src/app/controllers/sidemenuCtrl.js | 112 ++++++++++++------ src/app/features/admin/partials/orgs.html | 15 +++ src/app/features/admin/partials/settings.html | 9 +- src/app/features/admin/partials/users.html | 5 +- src/app/features/org/partials/orgDetails.html | 4 +- src/app/partials/sidemenu.html | 38 ++---- src/app/routes/backend/all.js | 3 + src/css/less/sidemenu.less | 31 +++++ 8 files changed, 145 insertions(+), 72 deletions(-) create mode 100644 src/app/features/admin/partials/orgs.html diff --git a/src/app/controllers/sidemenuCtrl.js b/src/app/controllers/sidemenuCtrl.js index 5e80e819ac1..14b1c44494d 100644 --- a/src/app/controllers/sidemenuCtrl.js +++ b/src/app/controllers/sidemenuCtrl.js @@ -15,55 +15,101 @@ function (angular, _, $, config) { return config.appSubUrl + url; }; - $scope.mainLinks = []; - $scope.mainLinks.push({ - text: "Dashboards", - icon: "fa fa-fw fa-th-large", - href: $scope.getUrl("/"), - }); - - if (contextSrv.hasRole('Admin')) { + $scope.setupMainNav = function() { $scope.mainLinks.push({ - text: "Data Sources", - icon: "fa fa-fw fa-database", - href: $scope.getUrl("/datasources"), - }); - } - - $scope.bottomLinks = []; - if (contextSrv.user.isSignedIn) { - $scope.bottomLinks.push({ - text: contextSrv.user.name, - imgSrc: contextSrv.user.gravatarUrl, - href: $scope.getUrl("/profile"), - }); - - $scope.bottomLinks.push({ - text: contextSrv.user.orgName, - href: $scope.getUrl("/org"), - icon: "fa fa-fw fa-users", + text: "Dashboards", + icon: "fa fa-fw fa-th-large", + href: $scope.getUrl("/"), }); if (contextSrv.hasRole('Admin')) { - $scope.bottomLinks.push({ - text: "System admin", - icon: "fa fa-fw fa-cog", - href: $scope.getUrl("/admin/settings"), + $scope.mainLinks.push({ + text: "Data Sources", + icon: "fa fa-fw fa-database", + href: $scope.getUrl("/datasources"), }); } + if (contextSrv.user.isSignedIn) { + $scope.bottomLinks.push({ + text: contextSrv.user.name, + imgSrc: contextSrv.user.gravatarUrl, + href: $scope.getUrl("/profile"), + }); + + $scope.bottomLinks.push({ + text: contextSrv.user.orgName, + href: $scope.getUrl("/org"), + icon: "fa fa-fw fa-users", + }); + + if (contextSrv.hasRole('Admin')) { + $scope.bottomLinks.push({ + text: "Grafana admin", + icon: "fa fa-fw fa-cog", + href: $scope.getUrl("/admin/settings"), + }); + } + + $scope.bottomLinks.push({ + text: "Sign out", + icon: "fa fa-fw fa-sign-out", + href: $scope.getUrl("/logout"), + }); + } + }; + + $scope.setupAdminNav = function() { + $scope.systemSection = true; + $scope.grafanaVersion = config.buildInfo.version; + + $scope.mainLinks.push({ + text: "System info", + icon: "fa fa-fw fa-info", + href: $scope.getUrl("/admin/settings"), + }); + + $scope.mainLinks.push({ + text: "Global Users", + icon: "fa fa-fw fa-user", + href: $scope.getUrl("/admin/users"), + }); + + $scope.mainLinks.push({ + text: "Global Orgs", + icon: "fa fa-fw fa-users", + href: $scope.getUrl("/admin/orgs"), + }); + + $scope.bottomLinks.push({ + text: "Exit admin", + icon: "fa fa-fw fa-backward", + href: $scope.getUrl("/"), + }); + $scope.bottomLinks.push({ text: "Sign out", icon: "fa fa-fw fa-sign-out", href: $scope.getUrl("/logout"), }); - } + }; - $scope.updateState = function() { + $scope.updateMenu = function() { + $scope.systemSection = false; + $scope.mainLinks = []; + $scope.bottomLinks = []; + + var currentPath = $location.path(); + if (currentPath.indexOf('/admin') === 0) { + $scope.setupAdminNav(); + } else { + $scope.setupMainNav(); + } }; $scope.init = function() { - $scope.updateState(); + $scope.updateMenu(); + $scope.$on('$routeChangeSuccess', $scope.updateMenu); }; }); diff --git a/src/app/features/admin/partials/orgs.html b/src/app/features/admin/partials/orgs.html new file mode 100644 index 00000000000..1bb8996a825 --- /dev/null +++ b/src/app/features/admin/partials/orgs.html @@ -0,0 +1,15 @@ + + + + +
+
+

+ Organizations +

+ + View not implemented yet... +
+
diff --git a/src/app/features/admin/partials/settings.html b/src/app/features/admin/partials/settings.html index aef8b095aaa..d242a9a2776 100644 --- a/src/app/features/admin/partials/settings.html +++ b/src/app/features/admin/partials/settings.html @@ -1,15 +1,10 @@ - - +

- System settings + System information

diff --git a/src/app/features/admin/partials/users.html b/src/app/features/admin/partials/users.html index 1f8778c148d..bdcfccf615d 100644 --- a/src/app/features/admin/partials/users.html +++ b/src/app/features/admin/partials/users.html @@ -1,7 +1,6 @@ - + diff --git a/src/app/features/org/partials/orgDetails.html b/src/app/features/org/partials/orgDetails.html index 59df2042aab..d2e0645f45f 100644 --- a/src/app/features/org/partials/orgDetails.html +++ b/src/app/features/org/partials/orgDetails.html @@ -10,7 +10,7 @@

Organization Details

-
+
    @@ -32,7 +32,7 @@ API Keys -
    +
    • diff --git a/src/app/partials/sidemenu.html b/src/app/partials/sidemenu.html index c51497a2161..29ea75d7357 100644 --- a/src/app/partials/sidemenu.html +++ b/src/app/partials/sidemenu.html @@ -9,6 +9,16 @@
    • +
    • +
      + +
      +
      Grafana Admin
      + +
      +
      +
    • +
    • @@ -18,13 +28,7 @@
    diff --git a/src/app/routes/backend/all.js b/src/app/routes/backend/all.js index 06044c5bfec..06d817bd7f8 100644 --- a/src/app/routes/backend/all.js +++ b/src/app/routes/backend/all.js @@ -82,6 +82,9 @@ define([ templateUrl: 'app/features/admin/partials/edit_user.html', controller : 'AdminEditUserCtrl', }) + .when('/admin/orgs', { + templateUrl: 'app/features/admin/partials/orgs.html', + }) .when('/login', { templateUrl: 'app/partials/login.html', controller : 'LoginCtrl', diff --git a/src/css/less/sidemenu.less b/src/css/less/sidemenu.less index e73e52233c1..e374073d52c 100644 --- a/src/css/less/sidemenu.less +++ b/src/css/less/sidemenu.less @@ -138,4 +138,35 @@ } } +.sidemenu-system-section { + background-color: @blueDark; + color: @white; + padding: 3px 0; + margin-left: 10px; + margin-right: 10px; + border-radius: 2px; + .sidemenu-system-section-inner { + border: 2px solid black; + border-left: none; + border-right: none; + padding: 4px; + overflow: hidden; + } + + .fa { + float: left; + font-size: 120%; + line-height: 41px; + padding: 0 15px; + } +} +.sidemenu-section-tagline { + font-style: italic; + font-size: 75%; + line-height: 10px; +} + +.sidemenu-section-text-wrapper { + padding-top: 4px; +}