diff --git a/src/app/partials/pro/login.html b/src/app/partials/pro/login.html index 92f1c4e8923..22340b89ffe 100644 --- a/src/app/partials/pro/login.html +++ b/src/app/partials/pro/login.html @@ -42,6 +42,12 @@ Login failed: {{loginError}} + +
+

If you do not already have an account

+ Sign up now! +

+ diff --git a/src/app/partials/pro/register.html b/src/app/partials/pro/register.html new file mode 100644 index 00000000000..3a3ffe0b456 --- /dev/null +++ b/src/app/partials/pro/register.html @@ -0,0 +1,48 @@ + +
+ +
+ + + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+ + Login failed: {{loginError}} +
+
+
+ + +
diff --git a/src/app/routes/p_dashboard.js b/src/app/routes/p_dashboard.js index ef5da131e2f..8c4b8d438de 100644 --- a/src/app/routes/p_dashboard.js +++ b/src/app/routes/p_dashboard.js @@ -13,7 +13,7 @@ function (angular) { controller : 'DashFromDBProvider', reloadOnSearch: false, }) - .when('/dashboard/:id', { + .when('/dashboard/db/:id', { templateUrl: '/app/partials/dashboard.html', controller : 'DashFromDBProvider', reloadOnSearch: false, diff --git a/src/app/routes/p_login.js b/src/app/routes/p_login.js index 127c4d47f81..e97bba49a0e 100644 --- a/src/app/routes/p_login.js +++ b/src/app/routes/p_login.js @@ -11,9 +11,47 @@ function (angular) { .when('/login', { templateUrl: 'app/partials/pro/login.html', 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; + } + + $http.post('/api/register/user', $scope.loginModel).then(function() { + $scope.emitAppEvent('logged-in'); + $location.path('/'); + }, function(err) { + if (err.status === 401) { + $scope.registerError = "Username or password is incorrect"; + } + else { + $scope.loginError = "Unexpected error"; + } + }); + }; + + $scope.init(); + + }); + + module.controller('LoginCtrl', function($scope, $http, $location, $routeParams, alertSrv) { $scope.loginModel = {}; diff --git a/src/app/services/grafana/grafanaDatasource.js b/src/app/services/grafana/grafanaDatasource.js index 9b83e4f3673..684d0abe25f 100644 --- a/src/app/services/grafana/grafanaDatasource.js +++ b/src/app/services/grafana/grafanaDatasource.js @@ -49,7 +49,7 @@ function (angular) { return $http.post('/api/dashboard/', { dashboard: dashboard }) .then(function(result) { - return { title: dashboard.title, url: '/dashboard/' + result.data.slug }; + return { title: dashboard.title, url: '/dashboard/db/' + result.data.slug }; }, function(data) { throw "Failed to search: " + data; });