Browse Source

Merge branch 'pro' of github.com:torkelo/grafana-private into pro

Conflicts:
	src/test/test-main.js
Torkel Ödegaard 11 years ago
parent
commit
9b2476451e

+ 1 - 1
src/app/controllers/p_grafanaCtrl.js

@@ -14,7 +14,7 @@ function (angular, config, _, $, store) {
 
 
     $scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion;
     $scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion;
     $scope.consoleEnabled = store.getBool('grafanaConsole');
     $scope.consoleEnabled = store.getBool('grafanaConsole');
-    $scope.showProSideMenu = store.getBool('grafanaProSideMenu');
+    //$scope.showProSideMenu = store.getBool('grafanaProSideMenu');
 
 
     $rootScope.profilingEnabled = store.getBool('profilingEnabled');
     $rootScope.profilingEnabled = store.getBool('profilingEnabled');
     $rootScope.performance = { loadStart: new Date().getTime() };
     $rootScope.performance = { loadStart: new Date().getTime() };

+ 1 - 1
src/app/panels/overview/module.js

@@ -2,7 +2,7 @@ define([
   'angular',
   'angular',
   'app',
   'app',
   'lodash',
   'lodash',
-  '../graph/timeSeries',
+  'components/timeSeries',
   'services/panelSrv',
   'services/panelSrv',
 ],
 ],
 function (angular, app, _, timeSeries) {
 function (angular, app, _, timeSeries) {

+ 6 - 0
src/app/partials/pro/login.html

@@ -42,6 +42,12 @@
 				<strong>Login failed:</strong> {{loginError}}
 				<strong>Login failed:</strong> {{loginError}}
 			</div>
 			</div>
 		</form>
 		</form>
+
+		<div class="register-box text-center">
+			<h3>If you do not already have an account<h3>
+			</a> <a href="/register" class="btn btn-info btn-large">Sign up now!</a>
+		</div>
+
 	</div>
 	</div>
 
 
 
 

+ 51 - 0
src/app/partials/pro/register.html

@@ -0,0 +1,51 @@
+
+<div class="container">
+
+	<div class="login-box">
+
+		<div class="login-box-logo">
+			<img src="/img/logo_transparent_200x75.png">
+		</div>
+
+		<div class="text-center" style="margin-bottom: 50px">
+ 			<h3>Account registration</32>
+		</div>
+
+		<form name="loginForm" class="form-horizontal">
+			<div class="row-fluid">
+				<div class="span8">
+					<div class="control-group">
+						<label class="control-label" for="inputEmail">Email</label>
+						<div class="controls">
+							<input type="text" required ng-model="loginModel.email" id="inputEmail" placeholder="Email">
+						</div>
+					</div>
+					<div class="control-group">
+						<label class="control-label" for="inputPassword">Password</label>
+						<div class="controls">
+							<input type="password" required ng-model="loginModel.password" id="inputPassword" placeholder="Password">
+						</div>
+					</div>
+					<div class="control-group">
+						<label class="control-label" for="inputPassword2">Confirm password</label>
+						<div class="controls">
+							<input type="password" required ng-model="loginModel.password2" id="password2" placeholder="Confirm password">
+						</div>
+					</div>
+				</div>
+				<div class="span4">
+					<button type="submit" ng-click="register()" class="btn btn-success btn-large">
+						<i class="icon-lock"></i>
+						Sign up
+					</button>
+				</div>
+			</div>
+			<div class="alert alert-error" ng-show="loginError">
+				<button type="button" class="close" data-dismiss="alert">&times;</button>
+				<strong>Login failed:</strong> {{loginError}}
+			</div>
+		</form>
+	</div>
+
+
+</div>

+ 1 - 0
src/app/routes/p_dashboard.js

@@ -38,6 +38,7 @@ function (angular) {
         $scope.emitAppEvent('setup-dashboard', dashboard);
         $scope.emitAppEvent('setup-dashboard', dashboard);
       }).then(null, function(error) {
       }).then(null, function(error) {
         alertSrv.set('Error', error, 'error');
         alertSrv.set('Error', error, 'error');
+        $scope.emitAppEvent('setup-dashboard', {});
       });
       });
 
 
   });
   });

+ 34 - 0
src/app/routes/p_login.js

@@ -11,9 +11,43 @@ function (angular) {
       .when('/login', {
       .when('/login', {
         templateUrl: 'app/partials/pro/login.html',
         templateUrl: 'app/partials/pro/login.html',
         controller : 'LoginCtrl',
         controller : 'LoginCtrl',
+      })
+      .when('/register', {
+        templateUrl: 'app/partials/pro/register.html',
+        controller : 'RegisterCtrl',
       });
       });
   });
   });
 
 
+  module.controller('RegisterCtrl', function($scope, $http, $location, $routeParams) {
+    $scope.loginModel = {};
+
+    $scope.init = function() {
+      if ($routeParams.logout) {
+        $scope.logout();
+      }
+    };
+
+    $scope.register = function() {
+      delete $scope.registerError;
+
+      if (!$scope.loginForm.$valid) { return; }
+      if ($scope.loginModel.password !== $scope.loginModel.password2) {
+        $scope.registerError = "Passwords do not match";
+        return;
+      }
+
+      $http.post('/api/register/user', $scope.loginModel).then(function() {
+        $location.path('/login');
+      }, function(err) {
+        $scope.registerError = "Unexpected error: " + err;
+      });
+    };
+
+    $scope.init();
+
+  });
+
+
   module.controller('LoginCtrl', function($scope, $http, $location, $routeParams, alertSrv) {
   module.controller('LoginCtrl', function($scope, $http, $location, $routeParams, alertSrv) {
     $scope.loginModel = {};
     $scope.loginModel = {};
 
 

+ 7 - 2
src/app/services/grafana/grafanaDatasource.js

@@ -42,9 +42,14 @@ function (angular) {
     };
     };
 
 
     GrafanaDatasource.prototype.saveDashboard = function(dashboard) {
     GrafanaDatasource.prototype.saveDashboard = function(dashboard) {
+      // remove id if title has changed
+      if (dashboard.title !== dashboard.originalTitle) {
+        dashboard.id = null;
+      }
+
       return $http.post('/api/dashboard/', { dashboard: dashboard })
       return $http.post('/api/dashboard/', { dashboard: dashboard })
-        .then(function() {
-          return { title: dashboard.title, url: '/dashboard/db/' + dashboard.title };
+        .then(function(result) {
+          return { title: dashboard.title, url: '/dashboard/db/' + result.data.slug };
         }, function(data) {
         }, function(data) {
           throw "Failed to search: " + data;
           throw "Failed to search: " + data;
         });
         });

+ 2 - 1
src/test/test-main.js

@@ -115,6 +115,7 @@ require([
   angular.module('grafana.filters', []);
   angular.module('grafana.filters', []);
 
 
   require([
   require([
+    'specs/overview-ctrl-specs',
     'specs/lexer-specs',
     'specs/lexer-specs',
     'specs/parser-specs',
     'specs/parser-specs',
     'specs/gfunc-specs',
     'specs/gfunc-specs',
@@ -133,7 +134,7 @@ require([
     'specs/templateValuesSrv-specs',
     'specs/templateValuesSrv-specs',
     'specs/kbn-format-specs',
     'specs/kbn-format-specs',
     'specs/dashboardSrv-specs',
     'specs/dashboardSrv-specs',
-    'specs/dashboardViewStateSrv-specs'
+    'specs/dashboardViewStateSrv-specs',
   ], function () {
   ], function () {
     window.__karma__.start();
     window.__karma__.start();
   });
   });