Commit 8ed92124 by Torkel Ödegaard

Redesigned and polished login view, still needs work on validation

parent 5760fa10
...@@ -45,12 +45,6 @@ function (angular, config, _, $, store) { ...@@ -45,12 +45,6 @@ function (angular, config, _, $, store) {
$scope.grafana.sidemenu = false; $scope.grafana.sidemenu = false;
$scope.grafana.user = {}; $scope.grafana.user = {};
}); });
$scope.onAppEvent('logged-in', function(evt, user) {
$scope.grafana.sidemenu = store.getBool('grafana.sidemenu', true);
$scope.grafana.user = user;
store.set('grafana.sidemenu', $scope.grafana.sidemenu);
});
}; };
$scope.initDashboard = function(dashboardData, viewScope) { $scope.initDashboard = function(dashboardData, viewScope) {
......
...@@ -8,8 +8,15 @@ function (angular, config) { ...@@ -8,8 +8,15 @@ function (angular, config) {
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
module.controller('LoginCtrl', function($scope, backendSrv, $location, $routeParams, alertSrv) { module.controller('LoginCtrl', function($scope, backendSrv, $location, $routeParams, alertSrv) {
$scope.loginModel = {}; $scope.loginModel = {
user: '',
password: ''
};
$scope.newUser = {};
$scope.grafana.sidemenu = false; $scope.grafana.sidemenu = false;
$scope.mode = 'login';
// build info view model // build info view model
$scope.buildInfo = { $scope.buildInfo = {
...@@ -18,12 +25,35 @@ function (angular, config) { ...@@ -18,12 +25,35 @@ function (angular, config) {
buildstamp: new Date(config.buildInfo.buildstamp * 1000) buildstamp: new Date(config.buildInfo.buildstamp * 1000)
}; };
$scope.submit = function() {
if ($scope.mode === 'login') {
$scope.login();
} else {
$scope.signUp();
}
};
$scope.init = function() { $scope.init = function() {
if ($routeParams.logout) { if ($routeParams.logout) {
$scope.logout(); $scope.logout();
} }
}; };
$scope.signUp = function() {
if ($scope.mode === 'login') {
$scope.mode = 'signup';
return;
}
if (!$scope.loginForm.$valid) {
return;
}
backendSrv.put('/api/user/signup', $scope.newUser).then(function() {
window.location.href = config.appSubUrl + '/';
});
};
$scope.logout = function() { $scope.logout = function() {
backendSrv.post('/logout').then(function() { backendSrv.post('/logout').then(function() {
alertSrv.set('Logged out!', '', 'success', 3000); alertSrv.set('Logged out!', '', 'success', 3000);
...@@ -33,14 +63,17 @@ function (angular, config) { ...@@ -33,14 +63,17 @@ function (angular, config) {
}; };
$scope.login = function() { $scope.login = function() {
if ($scope.mode === 'signup') {
$scope.mode = 'login';
return;
}
delete $scope.loginError; delete $scope.loginError;
if (!$scope.loginForm.$valid) { if (!$scope.loginForm.$valid) {
return; return;
} }
backendSrv.post('/login', $scope.loginModel).then(function(results) { backendSrv.post('/login', $scope.loginModel).then(function() {
$scope.appEvent('logged-in', results.user);
window.location.href = config.appSubUrl + '/'; window.location.href = config.appSubUrl + '/';
}); });
}; };
......
<div class="container"> <div class="container">
<div class="login-box"> <div class="login-box">
...@@ -8,68 +7,104 @@ ...@@ -8,68 +7,104 @@
</div> </div>
<div class="login-inner-box"> <div class="login-inner-box">
<h1 ng-if="mode === 'login'">Login</h1>
<h1 ng-if="mode === 'signup'">Sign up</h1>
<form name="loginForm"> <form name="loginForm" class="login-form">
<div class="tight-form"> <div class="tight-form" ng-if="mode === 'login'">
<ul class="tight-form-list"> <ul class="tight-form-list">
<li class="tight-form-item" style="width: 80px"> <li class="tight-form-item" style="width: 80px">
User User
</li> </li>
<li> <li>
<input type="text" class="input-large tight-form-input" ng-model='login.email' placeholder="email or username"></input> <input type="text" class="tight-form-input last" ng-model='loginModel.user' placeholder="email or username" style="width: 246px">
</li> </li>
</ul> </ul>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<div class="tight-form"> <div class="tight-form" ng-if="mode === 'login'">
<ul class="tight-form-list"> <ul class="tight-form-list">
<li class="tight-form-item" style="width: 80px"> <li class="tight-form-item" style="width: 80px">
Password Password
</li> </li>
<li> <li>
<input type="password" class="input-large tight-form-input" required ng-model="loginModel.password" id="inputPassword"> <input type="password" class="tight-form-input last" required ng-model="loginModel.password" id="inputPassword" style="width: 246px">
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="tight-form" ng-if="mode === 'signup'">
<ul class="tight-form-list">
<li class="tight-form-item" style="width: 80px">
Email
</li> </li>
<li class="tight-form-item"> <li>
<a href="asd">Forgotten password?</a> <input type="email" class="tight-form-input last" required ng-model='newUser.email' placeholder="email" style="width: 246px">
</li> </li>
</ul> </ul>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<div class="tight-form" ng-if="mode === 'signup'">
<ul class="tight-form-list">
<li class="tight-form-item" style="width: 80px">
Name
</li>
<li>
<input type="text" class="tight-form-input last" ng-model='newUser.name' placeholder="your full name (optional)" style="width: 246px">
</li>
</ul>
<div class="clearfix"></div>
</div> </div>
<button type="submit" ng-click="login()" class="btn btn-success" style="margin-bottom: 20px"> <div class="tight-form" ng-if="mode === 'signup'">
Sign in <ul class="tight-form-list">
</button> <li class="tight-form-item" style="width: 80px">
</form> Password
</li>
<li>
<input type="password" class="tight-form-input last" required ng-model='newUser.password' placeholder="" style="width: 246px">
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="alert alert-error" ng-show="loginError"> <div class="tight-form">
<button type="button" class="close" data-dismiss="alert">&times;</button> <ul class="tight-form-list">
<strong>Login failed:</strong> {{loginError}} <li class="tight-form-item login-signup-button" ng-class="{'login-signup-button-disable': mode === 'signup'}">
<a ng-click="login()">Log in</a>
</li>
<li class="tight-form-item login-signup-button last" ng-class="{'login-signup-button-disable': mode === 'login'}">
<a ng-click="signUp()">Sign up</a>
</li>
</ul>
<div class="clearfix"></div>
</div> </div>
<button type="submit" ng-click="submit();" class="hidden"></button>
</form>
<div class="clearfix"></div>
<div class="login-oauth text-center"> <div class="login-oauth text-center">
<a class="btn btn-primary" href="login/google" target="_self"> <a class="btn btn-google" href="login/google" target="_self">
Sign in with Google <i class="fa fa-google"></i>
with Google
</a> </a>
<a class="btn btn-primary" href="login/github" target="_self"> <a class="btn btn-github" href="login/github" target="_self">
Sign in with Github <i class="fa fa-github"></i>
with Github
</a> </a>
</div> </div>
<div class="register-box text-center">
<a href="signup" class="btn btn-info">Sign up now!</a>
</div>
</div> </div>
<div class="clearfix"></div> <div class="row" style="margin-top: 100px">
</div>
<div class="row" style="margin-top: 100px">
<div class="version-footer text-center small"> <div class="version-footer text-center small">
Grafana version: {{buildInfo.version}}, commit: {{buildInfo.commit}}, Grafana version: {{buildInfo.version}}, commit: {{buildInfo.commit}},
build date: {{buildInfo.buildstamp | date: 'yyyy-MM-dd HH:mm:ss' }} build date: {{buildInfo.buildstamp | date: 'yyyy-MM-dd HH:mm:ss' }}
</div> </div>
</div> </div>
</div> </div>
......
...@@ -70,16 +70,55 @@ ...@@ -70,16 +70,55 @@
} }
.login-inner-box { .login-inner-box {
background: @grafanaPanelBackground;
h1 {
font-size: 1.15em;
background: @grafanaTargetBackground;
text-align: center;
padding: 2px;
}
}
.login-signup-button {
width: 45%;
text-align: center;
a {
font-weight: bold;
}
&.login-signup-button-disable {
a {
color: darken(@linkColor, 35%);
}
}
}
.login-oauth {
margin-top: 30px;
padding: 10px;
background: @grafanaTargetBackground;
.btn-google {
background: #dd4b39;
color: white;
}
.btn-github {
background: #555;
color: white;
}
}
.login-form {
width: 50%; width: 50%;
float: left; float: left;
margin-left: 25%; margin-left: 25%;
margin-right: 25%; margin-right: 25%;
padding-top: 30px;
} }
.login-box { .login-box {
width: 700px; width: 700px;
margin: 100px auto 0 auto; margin: 100px auto 0 auto;
} }
.login-box-logo { .login-box-logo {
text-align: center; text-align: center;
......
...@@ -125,8 +125,12 @@ input[type=text].tight-form-clear-input { ...@@ -125,8 +125,12 @@ input[type=text].tight-form-clear-input {
border-right: 1px solid @grafanaTargetSegmentBorder; border-right: 1px solid @grafanaTargetSegmentBorder;
} }
//[type=text].grafana-target-segment-input, [type=number].grafana-target-segment-input { [type=text],
[type=text].tight-form-input, [type=number].tight-form-input { [type=email],
[type=number],
[type=password] {
&.tight-form-input {
border: none; border: none;
border-right: 1px solid @grafanaTargetSegmentBorder; border-right: 1px solid @grafanaTargetSegmentBorder;
margin: 0px; margin: 0px;
...@@ -135,6 +139,7 @@ input[type=text].tight-form-clear-input { ...@@ -135,6 +139,7 @@ input[type=text].tight-form-clear-input {
&.last { &.last {
border-right: none; border-right: none;
} }
}
} }
//input[type=checkbox].grafana-target-option-checkbox { //input[type=checkbox].grafana-target-option-checkbox {
......
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