diff --git a/src/app/components/settings.js b/src/app/components/settings.js index 9bef2757d9f..98c57d40084 100644 --- a/src/app/components/settings.js +++ b/src/app/components/settings.js @@ -34,12 +34,7 @@ function (_, crypto) { } }; - // This initializes a new hash on purpose, to avoid adding parameters to - // config.js without providing sane defaults - var settings = {}; - _.each(defaults, function(value, key) { - settings[key] = typeof options[key] !== 'undefined' ? options[key] : defaults[key]; - }); + var settings = _.extend({}, defaults, options); var parseBasicAuth = function(datasource) { var passwordEnd = datasource.url.indexOf('@'); diff --git a/src/app/controllers/grafanaCtrl.js b/src/app/controllers/grafanaCtrl.js index d2047cfef30..8df9b4155d6 100644 --- a/src/app/controllers/grafanaCtrl.js +++ b/src/app/controllers/grafanaCtrl.js @@ -10,17 +10,17 @@ function (angular, config, _, $, store) { var module = angular.module('grafana.controllers'); - module.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, grafanaVersion, $rootScope, $controller) { - $scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion; - $scope.grafana = {}; - - $rootScope.profilingEnabled = store.getBool('profilingEnabled'); - $rootScope.performance = { loadStart: new Date().getTime() }; - $rootScope.appSubUrl = config.appSubUrl; + module.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, grafanaVersion, $rootScope, $controller, userSrv) { $scope.init = function() { + $scope.grafana = {}; + $scope.grafana.version = grafanaVersion; $scope._ = _; + $rootScope.profilingEnabled = store.getBool('profilingEnabled'); + $rootScope.performance = { loadStart: new Date().getTime() }; + $rootScope.appSubUrl = config.appSubUrl; + if ($rootScope.profilingEnabled) { $scope.initProfiling(); } alertSrv.init(); @@ -28,19 +28,9 @@ function (angular, config, _, $, store) { $scope.dashAlerts = alertSrv; $scope.grafana.style = 'dark'; - - if (window.grafanaBackend) { - $scope.initBackendFeatures(); - } - }; - - $scope.initBackendFeatures = function() { + $scope.grafana.user = userSrv.getSignedInUser(); $scope.grafana.sidemenu = store.getBool('grafana.sidemenu'); - if (window.grafanaBootData.user.login) { - $scope.grafana.user = window.grafanaBootData.user; - } - $scope.onAppEvent('logged-out', function() { $scope.grafana.sidemenu = false; $scope.grafana.user = {}; diff --git a/src/app/controllers/loginCtrl.js b/src/app/controllers/loginCtrl.js index c3696d55124..e6b0f99f867 100644 --- a/src/app/controllers/loginCtrl.js +++ b/src/app/controllers/loginCtrl.js @@ -16,6 +16,10 @@ function (angular, config) { }; $scope.grafana.sidemenu = false; + + $scope.googleAuthEnabled = config.googleAuthEnabled; + $scope.githubAuthEnabled = config.githubAuthEnabled; + $scope.loginMode = true; $scope.submitBtnClass = 'btn-inverse'; $scope.submitBtnText = 'Log in'; diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index 3abcf4ec0a3..0b755ccbdb7 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -154,7 +154,8 @@ function (angular, _, config, $) { }; $scope.newDashboard = function() { - $location.url('/dashboard/file/empty.json'); + //$location.path('/dashboard/file/empty.json'); + $location.url('dashboard/new'); }; }); diff --git a/src/app/controllers/sidemenuCtrl.js b/src/app/controllers/sidemenuCtrl.js index 10b73e2458a..28e826646e8 100644 --- a/src/app/controllers/sidemenuCtrl.js +++ b/src/app/controllers/sidemenuCtrl.js @@ -15,39 +15,59 @@ function (angular, _, $, config) { return config.appSubUrl + url; }; - $scope.menu = [ - { - text: "Dashbord", - href: $scope.getUrl("/"), - startsWith: config.appSubUrl + '/dashboard/', - icon: "fa fa-th-large", - links: [ - { text: 'Settings', editview: 'settings', icon: "fa fa-cogs" }, - { text: 'Templating', editview: 'templating', icon: "fa fa-cogs" }, - { text: 'Annotations', editview: 'annotations', icon: "fa fa-bolt" }, - { text: 'Export', href:"", icon: "fa fa-bolt" }, - { text: 'JSON', href:"", icon: "fa fa-bolt" }, - ] - }, - { + $scope.menu = []; + $scope.menu.push({ + text: "Dashbord", + href: $scope.getUrl("/"), + startsWith: config.appSubUrl + '/dashboard/', + icon: "fa fa-th-large", + links: [ + { text: 'Settings', editview: 'settings'}, + { text: 'Templating', editview: 'templating'}, + { text: 'Annotations', editview: 'annotations'}, + { text: 'Export', href:""}, + { text: 'JSON', href:""}, + ] + }); + + if ($scope.grafana.user.accountRole === 'Admin') { + $scope.menu.push({ text: "Account", href: $scope.getUrl("/account"), + requireRole: "Admin", icon: "fa fa-shield", links: [ - { text: 'Info', href: $scope.getUrl("/account"), icon: "fa fa-sitemap" }, - { text: 'Data sources', href: $scope.getUrl("/account/datasources"), icon: "fa fa-sitemap" }, - { text: 'Users', href: $scope.getUrl("/account/users"), icon: "fa fa-users" }, - { text: 'API Keys', href: $scope.getUrl("/account/apikeys"), icon: "fa fa-key" }, + { text: 'Info', href: $scope.getUrl("/account")}, + { text: 'Data sources', href: $scope.getUrl("/account/datasources")}, + { text: 'Users', href: $scope.getUrl("/account/users")}, + { text: 'API Keys', href: $scope.getUrl("/account/apikeys")}, ] - }, - { + }); + } + + if ($scope.grafana.user.isSignedIn) { + $scope.menu.push({ text: "Profile", href: $scope.getUrl("/profile"), icon: "fa fa-user", + requireSignedIn: true, links: [ - { text: 'Info', href: $scope.getUrl("/profile"), icon: "fa fa-sitemap" }, + { text: 'Info', href: $scope.getUrl("/profile"), icon: "fa fa-sitemap" }, { text: 'Password', href:"", icon: "fa fa-lock" }, ] - } - ]; + }); + } + + if ($scope.grafana.user.isGrafanaAdmin) { + $scope.menu.push({ + text: "Admin", href: $scope.getUrl("/admin/users"), + icon: "fa fa-cube", + requireSignedIn: true, + links: [ + { text: 'Settings', href: $scope.getUrl("/admin/settings")}, + { text: 'Users', href: $scope.getUrl("/admin/users"), icon: "fa fa-lock" }, + { text: 'Log', href: "", icon: "fa fa-lock" }, + ] + }); + } $scope.onAppEvent('$routeUpdate', function() { $scope.updateState(); diff --git a/src/app/directives/dashEditLink.js b/src/app/directives/dashEditLink.js index dbafebae35c..b44b048f9d4 100644 --- a/src/app/directives/dashEditLink.js +++ b/src/app/directives/dashEditLink.js @@ -102,6 +102,7 @@ function (angular, $) { } }); + scope.$on("$destroy", hideEditorPane); scope.onAppEvent('hide-dash-editor', hideEditorPane); scope.onAppEvent('show-dash-editor', showEditorPane); } diff --git a/src/app/features/admin/adminSettingsCtrl.js b/src/app/features/admin/adminSettingsCtrl.js new file mode 100644 index 00000000000..736e5ce55d2 --- /dev/null +++ b/src/app/features/admin/adminSettingsCtrl.js @@ -0,0 +1,18 @@ +define([ + 'angular', +], +function (angular) { + 'use strict'; + + var module = angular.module('grafana.controllers'); + + module.controller('AdminSettingsCtrl', function($scope) { + + $scope.init = function() { + + }; + + $scope.init(); + + }); +}); diff --git a/src/app/features/admin/partials/settings.html b/src/app/features/admin/partials/settings.html new file mode 100644 index 00000000000..bea1f5fd4c7 --- /dev/null +++ b/src/app/features/admin/partials/settings.html @@ -0,0 +1,11 @@ +
+ +