Sfoglia il codice sorgente

feat(signup): selecting org after invite now works

Torkel Ödegaard 10 anni fa
parent
commit
13c70ac02c

+ 5 - 2
public/app/controllers/signupCtrl.js

@@ -27,8 +27,11 @@ function (angular, config) {
       }
 
       backendSrv.post('/api/user/signup/step2', $scope.formModel).then(function(rsp) {
-        console.log(rsp);
-        //window.location.href = config.appSubUrl + '/';
+        if (rsp.code === 'redirect-to-select-org') {
+          window.location.href = config.appSubUrl + '/profile/select-org?signup=1';
+        } else {
+          window.location.href = config.appSubUrl + '/';
+        }
       });
     };
 

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

@@ -7,6 +7,7 @@ define([
   './panel/all',
   './profile/profileCtrl',
   './profile/changePasswordCtrl',
+  './profile/selectOrgCtrl',
   './org/all',
   './admin/all',
 ], function () {});

+ 53 - 0
public/app/features/profile/partials/select_org.html

@@ -0,0 +1,53 @@
+<div class="container">
+
+	<div class="signup-page-background">
+	</div>
+
+	<div class="login-box">
+
+		<div class="login-box-logo">
+			<img src="img/logo_transparent_200x75.png">
+		</div>
+
+    <div class="invite-box">
+			<h3>
+				<i class="fa fa-users"></i>&nbsp;
+				Change active organization
+			</h3>
+
+			<div class="modal-tagline">
+				You have been added to another Organization <br>
+				due to an open invitation!
+				<br><br>
+
+				Please select which organization you want to <br>
+				use right now (you can change this later at any time).
+			</div>
+
+			<div style="display: inline-block; width: 400px; margin: 30px 0">
+				<table class="grafana-options-table">
+					<tr ng-repeat="org in orgs">
+						<td class="nobg max-width-btns">
+							<a ng-click="setUsingOrg(org)" class="btn btn-inverse">
+								{{org.name}} ({{org.role}})
+							</a>
+						</td>
+					</tr>
+				</table>
+			</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' }}
+			</div>
+		</div>
+
+	</div>
+
+</div>
+
+

+ 33 - 0
public/app/features/profile/selectOrgCtrl.js

@@ -0,0 +1,33 @@
+define([
+  'angular',
+  'config',
+],
+function (angular, config) {
+  'use strict';
+
+  var module = angular.module('grafana.controllers');
+
+  module.controller('SelectOrgCtrl', function($scope, backendSrv, contextSrv) {
+
+    contextSrv.sidemenu = false;
+
+    $scope.init = function() {
+      $scope.getUserOrgs();
+    };
+
+    $scope.getUserOrgs = function() {
+      backendSrv.get('/api/user/orgs').then(function(orgs) {
+        $scope.orgs = orgs;
+      });
+    };
+
+    $scope.setUsingOrg = function(org) {
+      backendSrv.post('/api/user/using/' + org.orgId).then(function() {
+        window.location.href = config.appSubUrl + '/';
+      });
+    };
+
+    $scope.init();
+
+  });
+});

+ 2 - 2
public/app/partials/login.html

@@ -16,7 +16,7 @@
 				</button>
 			</div>
 
-      <form name="loginForm" class="login-form">
+      <form name="loginForm" class="login-form" style="margin-top: 25px;">
 				<div class="tight-from-container">
 					<div class="tight-form" ng-if="loginMode">
 						<ul class="tight-form-list">
@@ -41,7 +41,7 @@
 						<div class="clearfix"></div>
 					</div>
 
-					<div class="tight-form" ng-if="!loginMode">
+					<div class="tight-form" ng-if="!loginMode" style="margin: 20px 0 57px 0">
 						<ul class="tight-form-list">
 							<li class="tight-form-item" style="width: 79px">
 								<strong>Email</strong>

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

@@ -74,6 +74,10 @@ define([
         templateUrl: 'app/features/profile/partials/password.html',
         controller : 'ChangePasswordCtrl',
       })
+      .when('/profile/select-org', {
+        templateUrl: 'app/features/profile/partials/select_org.html',
+        controller : 'SelectOrgCtrl',
+      })
       .when('/admin/settings', {
         templateUrl: 'app/features/admin/partials/settings.html',
         controller : 'AdminSettingsCtrl',