Commit 477f66f5 by Torkel Ödegaard

dashobard load/save work, and began register view

parent 359bca06
......@@ -42,6 +42,12 @@
<strong>Login failed:</strong> {{loginError}}
</div>
</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 class="container">
<div class="login-box">
<div class="login-box-logo">
<img src="/img/logo_transparent_200x75.png">
<h3>Grafana 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="login()" 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>
......@@ -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,
......
......@@ -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 = {};
......
......@@ -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;
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment