Unverified Commit 55cd77a8 authored by JR's avatar JR Committed by GitHub
Browse files

issue #1588 (#1597)

Use ldapGroup component for select group access machine
parent 7aebffee
<div> <div>
<input type="text" ng-model="$ctrl.group_selected" placeholder="Escriu el grup" <input type="text" ng-model="$ctrl.group_selected" placeholder="Search group"
ng-if="$ctrl.editable" ng-if="$ctrl.editable"
ng-required="!$ctrl.ngModel.$valid" ng-required="!$ctrl.ngModel.$valid"
uib-typeahead="name for name in $ctrl.getGroups($viewValue)" uib-typeahead="name for name in $ctrl.getGroups($viewValue)"
......
...@@ -6,6 +6,8 @@ export default { ...@@ -6,6 +6,8 @@ export default {
}, },
bindings: { bindings: {
editable: '<', editable: '<',
onAdd: '&',
onDelete: '&'
}, },
templateUrl: '/js/booking/ldapGroup.component.html', templateUrl: '/js/booking/ldapGroup.component.html',
controller: grpCtrl controller: grpCtrl
...@@ -39,8 +41,12 @@ function grpCtrl(apiLDAP, $scope, $timeout) { ...@@ -39,8 +41,12 @@ function grpCtrl(apiLDAP, $scope, $timeout) {
} else { } else {
self.selected_groups.push(self.group_selected); self.selected_groups.push(self.group_selected);
} }
self.onAdd({ group: self.group_selected})
self.group_selected = null; self.group_selected = null;
}; };
self.remove_ldap_group = group => self.selected_groups = remove_array_element(self.selected_groups,group); self.remove_ldap_group = group => {
self.selected_groups = remove_array_element(self.selected_groups,group)
self.onDelete({ group })
}
} }
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div ng-show="ldap_groups && !access_groups">
<i class="fas fa-sync-alt fa-spin"></i>
</div>
<button ng-enabled="allow_group" <ldap-groups name="groups"
ng-click="add_group_access(allow_group)">Add</button> ng-model="access_groups" editable="true"
<select ng-model="allow_group" on-add="add_group_access(group)"
ng-show="ldap_groups" on-delete="remove_group_access(group)"
ng-options="group for group in ldap_groups | orderBy:group" ></ldap-groups>
>
</select>
<div ng-show="ldap_groups && !access_groups"> <div class="card-body">
<i class="fas fa-sync-alt fa-spin"></i>
</div>
<div class="card-body">
<div class="alert alert-warning" ng-show="access_groups && access_groups.length == 0"> <div class="alert alert-warning" ng-show="access_groups && access_groups.length === 0">
<div ng-show="ldap_groups && ldap_groups.length == 0 "> <div ng-show="ldap_groups && ldap_groups.length === 0 ">
<%=l 'There are no LDAP groups defined.' %> <%=l 'There are no LDAP groups defined.' %>
% if ( $USER->is_admin ) { % if ( $USER->is_admin ) {
<a href="/admin/groups">Create one.</a> <a href="/admin/groups">Create one.</a>
% } % }
</div> </div>
<%=l 'This virtual machine has no group restrictions.' %> <%=l 'This virtual machine has no group restrictions.' %>
</div> </div>
<div ng-show="access_groups && access_groups.length > 0">
<b><%=l 'Only users from these groups will be allowed to execute this machine' %></b>
</div>
<div ng-show="access_groups && access_groups.length > 0"> </div>
<b><%=l 'Only users from these groups will be allowed to execute this machine' %></b>
</div>
<table ng-show="access_groups.length" class="card-table table-stripped"> </div>
<tbody>
<tr ng-repeat="group in access_groups">
<td>
<button ng-click="remove_group_access(group)"
class="badge badge-light text-blue">x</button>
<a ng-bind-html="group" href="/admin/group/{{group}}">{{group}}</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</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