Class: Jpi::V1::Admin::Impac::DashboardTemplatesController
- Inherits:
-
BaseResourceController
- Object
- BaseResourceController
- Jpi::V1::Admin::Impac::DashboardTemplatesController
- Defined in:
- app/controllers/mno_enterprise/jpi/v1/admin/impac/dashboard_templates_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /mnoe/jpi/v1/admin/impac/dashboard_templates.
-
#destroy ⇒ Object
DELETE /mnoe/jpi/v1/admin/impac/dashboard_templates/1.
-
#index ⇒ Object
Instance methods ================================================================== GET /mnoe/jpi/v1/admin/impac/dashboard_templates.
-
#show ⇒ Object
GET /mnoe/jpi/v1/admin/impac/dashboard_templates/1.
-
#update ⇒ Object
PATCH/PUT /mnoe/jpi/v1/admin/impac/dashboard_templates/1.
Instance Method Details
#create ⇒ Object
POST /mnoe/jpi/v1/admin/impac/dashboard_templates
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/mno_enterprise/jpi/v1/admin/impac/dashboard_templates_controller.rb', line 31 def create @dashboard_template = MnoEnterprise::Impac::Dashboard.new(dashboard_template_params.merge(dashboard_type: 'template')) # Abort on failure unless @dashboard_template.save return render json: { errors: dashboard_template.errors }, status: :bad_request end MnoEnterprise::EventLogger.info('dashboard_template_create', current_user.id, 'Dashboard Template Creation', dashboard_template) render 'show' end |
#destroy ⇒ Object
DELETE /mnoe/jpi/v1/admin/impac/dashboard_templates/1
57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/mno_enterprise/jpi/v1/admin/impac/dashboard_templates_controller.rb', line 57 def destroy return render json: { errors: { message: 'Dashboard template not found' } }, status: :not_found unless dashboard_template # Abort on failure unless dashboard_template.destroy return render json: { errors: 'Cannot destroy dashboard template' }, status: :bad_request end MnoEnterprise::EventLogger.info('dashboard_template_delete', current_user.id, 'Dashboard Template Deletion', dashboard_template) head status: :ok end |
#index ⇒ Object
Instance methods
GET /mnoe/jpi/v1/admin/impac/dashboard_templates
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/mno_enterprise/jpi/v1/admin/impac/dashboard_templates_controller.rb', line 8 def index if params[:terms] # For search mode @dashboard_templates = [] JSON.parse(params[:terms]).map { |t| @dashboard_templates = @dashboard_templates | dashboard_templates.where(Hash[*t]) } response.headers['X-Total-Count'] = @dashboards_templates.count else @dashboard_templates = dashboard_templates @dashboard_templates = @dashboard_templates.limit(params[:limit]) if params[:limit] @dashboard_templates = @dashboard_templates.skip(params[:offset]) if params[:offset] @dashboard_templates = @dashboard_templates.order_by(params[:order_by]) if params[:order_by] @dashboard_templates = @dashboard_templates.where(params[:where]) if params[:where] @dashboard_templates = @dashboard_templates.all.fetch response.headers['X-Total-Count'] = @dashboard_templates.[:pagination][:count] end end |
#show ⇒ Object
GET /mnoe/jpi/v1/admin/impac/dashboard_templates/1
26 27 28 |
# File 'app/controllers/mno_enterprise/jpi/v1/admin/impac/dashboard_templates_controller.rb', line 26 def show render json: { errors: { message: 'Dashboard template not found' } }, status: :not_found unless dashboard_template.present? end |
#update ⇒ Object
PATCH/PUT /mnoe/jpi/v1/admin/impac/dashboard_templates/1
44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/mno_enterprise/jpi/v1/admin/impac/dashboard_templates_controller.rb', line 44 def update return render json: { errors: { message: 'Dashboard template not found' } }, status: :not_found unless dashboard_template # Abort on failure unless dashboard_template.update(dashboard_template_params) return render json: { errors: dashboard_template.errors }, status: :bad_request end MnoEnterprise::EventLogger.info('dashboard_template_update', current_user.id, 'Dashboard Template Update', dashboard_template) render 'show' end |