Commit a2c06ce7 authored by Jochen Kressin's avatar Jochen Kressin
Browse files

adapted UI elements to kui, removed debug statements

parent 5b867a73
......@@ -81,7 +81,6 @@ module.exports = function (pluginRoot, server, kbnServer, APP_ROOT, API_ROOT) {
if (error instanceof AuthenticationError) {
return reply(Boom.unauthorized(error.message));
} else {
console.log(error);
return reply(Boom.badImplementation());
}
}
......
......@@ -102,7 +102,6 @@ export default class SearchGuardBackend {
// get users preferred tenant
var prefs = request.state.searchguard_preferences;
var preferredTenant = prefs[username];
console.log("Tenenat for user "+ username + " is " + preferredTenant);
// user has a preferred tenant, check if it is accessible
if (preferredTenant && tenants[preferredTenant]) {
......
......@@ -11,12 +11,12 @@
<form class="login-form" ng-submit="ui.submit()" method="post">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-user"></i></div>
<input type="text" class="form-control" id="username" name="username" placeholder="Username"
<input type="text" class="form-control kuiTextInput" id="username" name="username" placeholder="Username"
ng-model="ui.credentials.username" required/>
</div>
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-lock"></i></div>
<input type="password" class="form-control" id="password" name="password" placeholder="Password"
<input type="password" class="form-control kuiTextInput" id="password" name="password" placeholder="Password"
ng-model="ui.credentials.password" required/>
</div>
<button type="submit" class="btn btn-default btn-login" style="{{ui.buttonstyle}}">Log in</button>
......
......@@ -15,8 +15,9 @@
*/
import chrome from 'ui/chrome';
import {parse} from 'url';
export default function LoginController($scope, $http, $window) {
export default function LoginController(kbnUrl, $scope, $http, $window) {
const ROOT = chrome.getBasePath();
const APP_ROOT = `${ROOT}/searchguard`;
......@@ -42,6 +43,17 @@ export default function LoginController($scope, $http, $window) {
this.brandimage = BRANDIMAGE;
}
const {query, hash} = parse($window.location.href, true);
let nextUrl;
if (query.next) {
nextUrl = query.next + (hash || '')
} else {
nextUrl = "/";
}
this.logintitle = hash;
this.submit = () => {
$http.post(`${API_ROOT}/login`, this.credentials)
.then(
......@@ -53,7 +65,7 @@ export default function LoginController($scope, $http, $window) {
// matter, in the latter case we always have a tenant as fallback if
// user has no tenants configured and PRIVATE is disabled
if (!chrome.getInjected("multitenancy.enabled") || chrome.getInjected("multitenancy.tenants.enable_global")) {
$window.location.href = `${ROOT}/`;
$window.location.href = `/`;
} else {
// GLOBAL is disabled, check if we have at least one tenant to choose from
var allTenants = response.data.tenants;
......@@ -65,7 +77,7 @@ export default function LoginController($scope, $http, $window) {
if (allTenants == null || allTenants.length == 0 || _.isEmpty(allTenants)) {
this.errorMessage = 'No tenant available for this user, please contact your system administrator.';
} else {
$window.location.href = `${ROOT}/`;
$window.location.href = `/`;
}
}
......@@ -74,7 +86,7 @@ export default function LoginController($scope, $http, $window) {
if (error.status && error.status === 401) {
this.errorMessage = 'Invalid username or password, please try again';
} else {
this.errorMessage = 'An error occurred while checking your credentials, make sure your have a running Elasticsearch cluster secured by Search Guard running.';
this.errorMessage = 'An error occurred while checking your credentials, make sure your have an Elasticsearch cluster secured by Search Guard running.';
}
}
);
......
<div class="searchguard app-container ng-scope">
<kbn-top-nav name="searchguard" config="topNavMenu">
<div class="kuiLocalNav">
<div class="kuiLocalNavRow"></div>
<div class="kuiLocalNavRow kuiLocalNavRow--secondary">
<div data-transclude-slot="bottomRow" class="kuiLocalTabs">
<span class="kuiLocalTab">
Tenants
</span>
</div>
<div class="kuiLocalNav">
<div class="kuiLocalNavRow">
</div>
<div class="kuiLocalNavRow kuiLocalNavRow--secondary">
<div data-transclude-slot="bottomRow" class="kuiLocalTabs">
<span class="kuiLocalTab">
Select Tenant
</span>
</div>
</div>
</kbn-top-nav>
</div>
<div class="container">
<div class="row">
<div class="col-xs-12">
<h3 class="text-center">Available tenants</h3>
<p class="error-message" ng-if="ctrl.errorMessage">{{ ctrl.errorMessage }}</p>
<h4 class="text-center" ng-bind="ctrl.tenantLabel" style="margin-bottom:30px;"></h4>
<div class="page-header">
<h2 class="text-center">Available tenants</h2>
<h4 class="text-center" ng-bind="ctrl.tenantLabel"></h4>
<p class="error-message" ng-if="ctrl.errorMessage" ng-bind="ctrl.errorMessage"></p>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-10 col-xs-offset-1">
<table class="table">
<div class="col-xs-12">
<table class="kuiTable">
<thead>
<tr>
<th>Name</th>
<th>Permissions</th>
<th style="text-align: right">Action</th>
<th class="kuiTableHeaderCell">Name</th>
<th class="kuiTableHeaderCell">Permissions</th>
<th class="kuiTableHeaderCell actions">Action</th>
</tr>
</thead>
<tbody>
<tr ng-class="{'selected': ctrl.currentTenant == ''}" ng-show="ctrl.globalEnabled">
<td>
<tr class="kuiTableRow" ng-class="{'selected': ctrl.currentTenant == ''}" ng-show="ctrl.globalEnabled">
<td class="kuiTableRowCell">
{{ctrl.GLOBAL_USER_LABEL}}
</td>
<td>
<td class="kuiTableRowCell">
<div>read/write</div>
</td>
<td class="actions" style="text-align: right">
<button class="btn-primary" ng-disabled="ctrl.currentTenant == ''"
<td class="actions kuiTableRowCell">
<button class="kuiButton kuiButton--primary" ng-disabled="ctrl.currentTenant == ''"
ng-show="ctrl.currentTenant != ctrl.GLOBAL_USER_VALUE"
ng-click="ctrl.selectTenant(ctrl.GLOBAL_USER_LABEL, ctrl.GLOBAL_USER_VALUE)">Select
</button>
</td>
</tr>
<tr ng-class="{'selected': ctrl.currentTenant == ctrl.PRIVATE_USER_VALUE}" ng-show="ctrl.privateEnabled">
<td>
<tr class="kuiTableRow" ng-class="{'selected': ctrl.currentTenant == ctrl.PRIVATE_USER_VALUE}" ng-show="ctrl.privateEnabled">
<td class="kuiTableRowCell">
{{ctrl.PRIVATE_USER_LABEL}}
</td>
<td>
<td class="kuiTableRowCell">
<div>read/write</div>
</td>
<td class="actions" style="text-align: right">
<button class="btn-primary" ng-disabled="ctrl.currentTenant == ctrl.PRIVATE_USER_VALUE"
<td class="actions kuiTableRowCell">
<button class="kuiButton kuiButton--primary" ng-disabled="ctrl.currentTenant == ctrl.PRIVATE_USER_VALUE"
ng-click="ctrl.selectTenant(ctrl.PRIVATE_USER_LABEL, ctrl.PRIVATE_USER_VALUE)">Select
</button>
</td>
</tr>
<tr ng-repeat="tenantkey in ctrl.tenantkeys" ng-class="{'selected': tenantkey == ctrl.currentTenant}">
<td>
<tr class="kuiTableRow" ng-repeat="tenantkey in ctrl.tenantkeys" ng-class="{'selected': tenantkey == ctrl.currentTenant}">
<td class="kuiTableRowCell">
{{tenantkey}}
</td>
<td>
<div ng-if="ctrl.allTenants[tenantkey] == 'rw'">read/write</div>
<div ng-if="ctrl.allTenants[tenantkey] == 'ro'">read only</div>
<td class="kuiTableRowCell">
<div ng-if="ctrl.tenants[tenantkey]">read/write</div>
<div ng-if="!ctrl.tenants[tenantkey]">read only</div>
</td>
<td class="actions" style="text-align: right">
<button class="btn-primary" ng-disabled="ctrl.currentTenant == tenantkey"
<td class="actions kuiTableRowCell">
<button class="kuiButton kuiButton--primary" ng-disabled="ctrl.currentTenant == tenantkey"
ng-click="ctrl.selectTenant(tenantkey, tenantkey)">Select
</button>
</td>
......
@import "~ui/styles/variables/colors.less";
@import "~ui/styles/variables/bootstrap-mods.less";
.actions {
text-align: right;
}
.selected {
background-color: #eee;
......
Supports Markdown
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