Sfoglia il codice sorgente

began work on reset password view, and angular controller

Torkel Ödegaard 10 anni fa
parent
commit
e40b462040

+ 1 - 0
public/app/controllers/all.js

@@ -6,6 +6,7 @@ define([
   './inspectCtrl',
   './jsonEditorCtrl',
   './loginCtrl',
+  './resetPasswordCtrl',
   './sidemenuCtrl',
   './errorCtrl',
 ], function () {});

+ 28 - 0
public/app/controllers/resetPasswordCtrl.js

@@ -0,0 +1,28 @@
+define([
+  'angular',
+  'app',
+  'lodash'
+],
+function (angular, app, _) {
+  'use strict';
+
+  var module = angular.module('grafana.controllers');
+
+  module.controller('ResetPasswordCtrl', function($scope, contextSrv, backendSrv) {
+
+    contextSrv.sidemenu = false;
+    $scope.sendMode = true;
+    $scope.formModel = {};
+
+    $scope.sendResetEmail = function() {
+      if (!$scope.loginForm.$valid) {
+        return;
+      }
+
+      backendSrv.post('/api/user/password/send-reset-email', $scope.formModel).then(function() {
+      });
+    };
+
+  });
+
+});

+ 9 - 1
public/app/partials/login.html

@@ -91,7 +91,15 @@
 			</div>
 	</div>
 
-	<div class="row" style="margin-top: 100px">
+	<div class="row" style="margin-top: 40px">
+		<div class="text-center">
+			<a href="reset-password/send">
+				Forgot your password?
+			</a>
+		</div>
+	</div>
+
+	<div class="row" style="margin-top: 50px">
 		<div class="version-footer text-center small">
 			Grafana version: {{buildInfo.version}}, commit: {{buildInfo.commit}},
 			build date: {{buildInfo.buildstamp | date: 'yyyy-MM-dd HH:mm:ss' }}

+ 41 - 0
public/app/partials/reset_password.html

@@ -0,0 +1,41 @@
+<div class="container">
+
+	<div class="login-box">
+
+		<div class="login-box-logo">
+			<img src="img/logo_transparent_200x75.png">
+		</div>
+
+		<div class="login-inner-box">
+			<div class="login-tab-header">
+				<button class="btn-login-tab" class="active">
+					Reset password
+				</button>
+			</div>
+
+			<form name="sendResetForm" class="login-form">
+				<div class="tight-form" ng-if="sendMode">
+					<ul class="tight-form-list">
+						<li class="tight-form-item" style="width: 78px">
+							<strong>User</strong>
+						</li>
+						<li>
+							<input type="text" name="username" class="tight-form-input last" required ng-model='formModel.userOrEmail' placeholder="email or username" style="width: 253px">
+						</li>
+					</ul>
+					<div class="clearfix"></div>
+				</div>
+
+				<div class="login-submit-button-row">
+					<button type="submit" class="btn" ng-click="sendResetEmail();" ng-class="{'btn-inverse': !sendResetForm.$valid, 'btn-primary': sendResetForm.$valid}">
+						Send reset instructions
+					</button>
+				</div>
+			</form>
+
+			<div class="clearfix"></div>
+		</div>
+
+	</div>
+</div>
+

+ 4 - 0
public/app/routes/all.js

@@ -97,6 +97,10 @@ define([
         templateUrl: 'app/partials/login.html',
         controller : 'LoginCtrl',
       })
+      .when('/reset-password/send', {
+        templateUrl: 'app/partials/reset_password.html',
+        controller : 'ResetPasswordCtrl',
+      })
       .otherwise({
         templateUrl: 'app/partials/error.html',
         controller: 'ErrorCtrl'

+ 1 - 1
public/css/less/login.less

@@ -74,7 +74,7 @@
     padding: 9px 7px;
     font-size: 14px;
     font-weight: bold;
-    width: 150px;
+    min-width: 150px;
     display: inline-block;
     border: 1px solid lighten(@btnInverseBackground, 10%);
   }