Commit 549d85df authored by Francesc Guasch's avatar Francesc Guasch
Browse files

feat(frontend): remove group

parent a6cd5375
......@@ -874,8 +874,9 @@ ravadaApp.directive("solShowMachine", swMach)
};
$scope.remove_group = function() {
$scope.confirm_remove=false;
$http.post("/ldap/group/remove/"+group).then(function(response) {
$http.get("/ldap/group/remove/"+group).then(function(response) {
$scope.error=response.data.error;
$scope.removed = true;
});
};
......
......@@ -314,6 +314,9 @@ get '/admin/group/#name' => sub($c) {
push @{$c->stash->{js}}, '/js/admin.js';
my $group = Ravada::Auth::LDAP::search_group(name => $c->stash('name'));
return $c->render( text => "Error: group ".$c->stash('name')." not found."
."<a href='/admin/groups/'>Groups</a>"
, status => 302) if !$group;
$c->stash(object_class => [ grep !/^top$/,$group->get_value('objectClass')]);
return $c->render( template => "/main/admin_group");
};
......@@ -1705,6 +1708,12 @@ post '/ldap/group/remove_member' => sub($c) {
};
get '/ldap/group/remove/(:group)' => sub($c) {
return access_denied($c) if !$USER->can_manage_groups;
eval { Ravada::Auth::LDAP::remove_group($c->stash('group')) };
return $c->render( json => { error => ($@ or '') });
};
get '/booking' => sub($c) {
return $c->render(template => '/ng-templates/error'
,message => "LDAP is required to set up bookings. "
......
......@@ -17,7 +17,7 @@
</div>
</div>
<div class="card-body">
<div ng-show="<%= $_user->can_manage_groups %>">
<div ng-show="<%= $_user->can_manage_groups %> && !removed">
<%=l 'New group member' %>
<input type="text" ng-model="username_filter"
ng-change="list_users()"
......@@ -33,7 +33,12 @@
<button ng-show="new_member && new_member.name"
ng-click="add_member(new_member.name)">Add</button>
</div>
{{error}}
<div ng-show="!removed">
<div class="alert alert-danger" ng-show="error">{{error}}</div>
<div class="alert alert-warning" ng-show="!error && group_members.length==0">No members found</div>
</div>
<table class="table table-striped" ng-show="group_members.length>0">
<thead>
<tr>
......@@ -51,11 +56,11 @@
</tr>
</tbody>
</table>
<div class="alert alert-warning" ng-show="group_members.length==0">No members found</div>
<div class="alert alert-warning" ng-show="removed"><%=l 'This group has been removed.'%></div>
<input type="button" class="btn btn-outline-secondary"
ng-show="group_members && group_members.length==0
&& !confirm_remove"
&& !removed && !confirm_remove"
ng-click="confirm_remove=true"
value="Remove group"/>
<div ng-show="confirm_remove" class="card">
......
Markdown is supported
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