-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: expose groups and vpns related list APIs #216
base: master
Are you sure you want to change the base?
Changes from 1 commit
76cf467
1df080b
b70e4bb
5d88f13
5a424e0
27189c2
f829a48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
class ::Api::V1::GroupsController < ::Api::V1::BaseController | ||
def index | ||
groups = Group.order(:id).page(params[:page]).per(params[:per_page]) | ||
render json: groups, status: :ok | ||
end | ||
|
||
def create | ||
if current_user.admin? | ||
@group = Group.new(group_params) | ||
|
@@ -40,6 +45,19 @@ def add_user | |
head :no_content | ||
end | ||
|
||
def list_admins | ||
group = Group.find(params[:id]) | ||
users = group.group_admins.joins(:user). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we also check if users in |
||
select('users.id, users.email, users.name, users.active, group_admins.created_at as join_date') | ||
render json: users, status: :ok | ||
end | ||
|
||
def associated_vpns | ||
group = Group.find(params[:id]) | ||
vpns = group.vpns | ||
render json: vpns, status: :ok | ||
end | ||
|
||
private | ||
|
||
def group_params | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
class ::Api::V1::VpnsController < ::Api::V1::BaseController | ||
before_action :set_vpn, only: [:assign_group] | ||
|
||
def index | ||
vpns = Vpn.order(:id).page(params[:page]).per(params[:per_page]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, default |
||
render json: vpns, status: :ok | ||
end | ||
|
||
def associated_groups | ||
vpn = Vpn.find(params[:id]) | ||
groups = vpn.groups | ||
render json: groups, status: :ok | ||
end | ||
|
||
def create | ||
if current_user.admin? | ||
@vpn = Vpn.new(vpn_params) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add the default
page
andper_page
if it's not provided by user