Commit c70c9884 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

wip(frontend): improved access restrictions forms

Improved to make it less ugly on suggestions by @fv3rdugo

issue #916
parent 56ea08f2
......@@ -331,6 +331,9 @@
console.log($scope.cn);
$http.get('/list_ldap_attributes/'+$scope.cn).then(function(response) {
$scope.ldap_attributes = response.data.attributes;
if ($scope.ldap_attributes && $scope.ldap_attributes.length) {
$scope.change_cn = 0;
}
});
};
$scope.count_ldap_entries = function() {
......
<div class="panel panel-default">
<div class="panel-body">
Type a typical LDAP user name to fetch the attribute list
<input type="text" ng-model="cn" ng-change="list_ldap_attributes()"
ng-init="cn='<%= $ldap_attributes_cn %>';list_ldap_attributes()">
<span ng-hide="ldap_attributes || !cn">
User name <b>{{cn}}</b> not found in LDAP server
</span>
</div>
</div>
<div class="panel panel-default">
<div class="panel panel-default" ng-show="ldap_attributes
|| !cn_change
|| ( ldap_attributes_domain && ldap_attributes_domain.length) ">
<div class="panel-heading">
<div class="row">
......@@ -37,3 +28,19 @@
</div>
</div>
<div ng-hide="change_cn || !ldap_attributes">
Using LDAP attributes from user <i>{{cn}}</i>
<button ng-click="change_cn=1">change</button>
</div>
<div class="panel panel-default"
ng-show="change_cn || !ldap_attributes">
<div class="panel-body">
Type a typical LDAP user name to fetch the attribute list
<input type="text" ng-model="cn" ng-change="list_ldap_attributes()"
ng-init="cn='<%= $ldap_attributes_cn %>';list_ldap_attributes()">
<br/>
<div class="alert alert-danger" ng-hide="ldap_attributes || !cn">
User name <b>{{cn}}</b> not found in LDAP server
</div>
</div>
</div>
......@@ -7,11 +7,13 @@
</div>
<div class="col-md-1">
<input type="checkbox" ng-checked="attribute.allowed"
title="Last is mandatory when not allowed"
ng-click="set_ldap_access(attribute.id, !attribute.allowed, attribute.last)"
>
</div>
<div class="col-md-1">
<input type="checkbox" ng-checked="attribute.last"
title="Last is mandatory when not allowed"
ng-disabled="!attribute.allowed"
ng-click="set_ldap_access(attribute.id, attribute.allowed, !attribute.last)"
>
......@@ -26,7 +28,7 @@
><i class="fa fa-arrow-up" ></i></button>
</div>
<div class="col-md-1">
<button class="btn"
<button class="btn"
ng-click="delete_ldap_access(attribute.id)"><i class="fas fa-times"></i></button>
</div>
</div>
......
<div class="row">
<div class="row" ng-show="ldap_attributes || change_cn">
<div class="col-md-2">
<select ng-model="ldap_attribute" ng-change="ldap_entries=0;ldap_verified=false">
<select ng-model="ldap_attribute" ng-change="ldap_entries=0;ldap_verified=false"
ng-disabled="ldap_verifying"
>
<option ng-repeat="attribute in ldap_attributes" value="{{attribute}}">
{{attribute}}
</option>
......@@ -9,6 +11,7 @@
<div class="col-md-3">
<input ng-model="ldap_attribute_value" type="text"
ng-disabled="ldap_verifying"
ng-change="ldap_entries=0;ldap_verified=false">
</div>
......@@ -27,18 +30,27 @@
ng-disabled="ldap_verifying"
ng-click="count_ldap_entries()"
>verify</button>
<button ng-show="ldap_attribute && ldap_attribute_value"
ng-disabled="ldap_verifying || (!ldap_attribute_allowed && ! ldap_attribute_last)"
<button
ng-disabled="!ldap_attribute || !ldap_attribute_value || ldap_verifying
|| (!ldap_attribute_allowed && !ldap_attribute_last)"
ng-click="add_ldap_access()"
>save</button>
</div>
<div class="col-md-3">
<span ng-show="ldap_verifying">Verifying {{ldap_attribute}} ...</span>
<span ng-show="ldap_verified && !ldap_entries">No entries found</span>
<span ng-show="ldap_verified && ldap_entries">{{ldap_attribute}} = {{ldap_attribute_value}} has at least {{ldap_entries}} entries. </span>
<span ng-show="!ldap_attribute_allowed && !ldap_attribute_last">
Enable last for not allowed restrictions.
</span>
>add</button>
</div>
</div>
<div class="row" ng-show="ldap_attributes">
<div class="alert alert-danger"
ng-show="!ldap_attribute_allowed && !ldap_attribute_last">
Last is mandatory when not allowed.
</div>
<div class="alert alert-info" ng-show="ldap_verifying">
Verifying <i>{{ldap_attribute}} = {{ldap_attribute_value}}</i>
in the LDAP server. It may take long ...
</div>
<div class="alert alert-warning" ng-show="ldap_verified && !ldap_entries">
No entries found.
</div>
<div class="alert alert-success"
ng-show="ldap_verified && ldap_entries">
{{ldap_attribute}} = {{ldap_attribute_value}} has at least {{ldap_entries}} entries.
</div>
</div>
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