2017-04-18 19:09:07 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Admin
|
|
|
|
class InstancesController < BaseController
|
2020-12-14 08:06:34 +00:00
|
|
|
before_action :set_instances, only: :index
|
2019-07-30 09:10:46 +00:00
|
|
|
before_action :set_instance, only: :show
|
|
|
|
|
2017-04-18 19:09:07 +00:00
|
|
|
def index
|
2017-11-11 19:23:33 +00:00
|
|
|
authorize :instance, :index?
|
2017-04-18 19:09:07 +00:00
|
|
|
end
|
|
|
|
|
2019-01-08 12:39:49 +00:00
|
|
|
def show
|
|
|
|
authorize :instance, :show?
|
2017-07-20 21:07:13 +00:00
|
|
|
end
|
|
|
|
|
2017-04-18 19:09:07 +00:00
|
|
|
private
|
|
|
|
|
2019-07-30 09:10:46 +00:00
|
|
|
def set_instance
|
2020-12-14 08:06:34 +00:00
|
|
|
@instance = Instance.find(params[:id])
|
|
|
|
end
|
2019-07-30 09:10:46 +00:00
|
|
|
|
2020-12-14 08:06:34 +00:00
|
|
|
def set_instances
|
|
|
|
@instances = filtered_instances.page(params[:page])
|
2019-07-30 09:10:46 +00:00
|
|
|
end
|
|
|
|
|
2017-09-13 10:30:07 +00:00
|
|
|
def filtered_instances
|
2019-07-30 09:10:46 +00:00
|
|
|
InstanceFilter.new(whitelist_mode? ? { allowed: true } : filter_params).results
|
2017-09-13 10:30:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def filter_params
|
2020-01-20 14:55:03 +00:00
|
|
|
params.slice(*InstanceFilter::KEYS).permit(*InstanceFilter::KEYS)
|
2017-09-13 10:30:07 +00:00
|
|
|
end
|
2017-04-18 19:09:07 +00:00
|
|
|
end
|
|
|
|
end
|