Skip to content

Commit

Permalink
Merge remote-tracking branch 'goto/release-1.2.0' into release-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmatrhd committed Jul 31, 2024
2 parents 4aa6f92 + 00828a4 commit 1a2f679
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions app/controllers/api/v1/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,19 @@ def remove_user
end

def list_admins
group = Group.find(params[:id])
group = Group.find_by_id(params[:id])
return head :not_found unless group.present?

users = group.group_admins.joins(:user).
select('users.id, users.email, users.name, users.active, group_admins.created_at as join_date').
where('users.active = ?', true)
render json: users, status: :ok
end

def associated_vpns
group = Group.find(params[:id])
group = Group.find_by_id(params[:id])
return head :not_found unless group.present?

vpns = group.vpns
render json: vpns, status: :ok
end
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/api/v1/vpns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ class ::Api::V1::VpnsController < ::Api::V1::BaseController

def index
vpns = Vpn.order(:id).page(params[:page]).per(params[:per_page])
vpns = vpns.where("name LIKE ?", "%#{params[:q]}%") if params[:q].present?
render json: vpns, status: :ok
end

def associated_groups
vpn = Vpn.find(params[:id])
vpn = Vpn.find_by_id(params[:id])
return head :not_found unless vpn.present?

groups = vpn.groups
groups = groups.where("name LIKE ?", "%#{params[:q]}%") if params[:q].present?
render json: groups, status: :ok
end

Expand Down

0 comments on commit 1a2f679

Please sign in to comment.