Class: Jpi::V1::Admin::Impac::WidgetsController
- Inherits:
-
BaseResourceController
- Object
- BaseResourceController
- Jpi::V1::Admin::Impac::WidgetsController
- Defined in:
- app/controllers/mno_enterprise/jpi/v1/admin/impac/widgets_controller.rb
Overview
From the Admin panel, an admin can:
-
add widgets to staff dashboards (passing the dashboard id)
-
add widgets to template dashboards (passing the dashboard template id)
-
update any widget (passing its id)
-
delete any widget (passing its id)
Instance Method Summary collapse
-
#create ⇒ Object
POST /mnoe/jpi/v1/admin/impac/dashboard_templates/:id/widgets POST /mnoe/jpi/v1/admin/impac/dashboards/:id/widgets.
-
#destroy ⇒ Object
DELETE /mnoe/jpi/v1/admin/impac/widgets/:id.
-
#update ⇒ Object
PUT /mnoe/jpi/v1/admin/impac/widgets/:id.
Instance Method Details
#create ⇒ Object
POST /mnoe/jpi/v1/admin/impac/dashboard_templates/:id/widgets POST /mnoe/jpi/v1/admin/impac/dashboards/:id/widgets
11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/mno_enterprise/jpi/v1/admin/impac/widgets_controller.rb', line 11 def create return render json: { errors: { message: "#{container} not found" } }, status: :not_found unless dashboard.present? @widget = dashboard..create() return render json: { errors: ( && .errors).to_a }, status: :bad_request unless .present? && .valid? MnoEnterprise::EventLogger.info('widget_create', current_user.id, "#{container} Widget Creation", ) @no_content = true render 'show' end |
#destroy ⇒ Object
DELETE /mnoe/jpi/v1/admin/impac/widgets/:id
34 35 36 37 38 39 40 41 |
# File 'app/controllers/mno_enterprise/jpi/v1/admin/impac/widgets_controller.rb', line 34 def destroy unless .present? && .destroy return render json: { errors: 'Cannot delete widget' }, status: :bad_request end MnoEnterprise::EventLogger.info('widget_delete', current_user.id, "#{container} Widget Deletion", ) head status: :ok end |
#update ⇒ Object
PUT /mnoe/jpi/v1/admin/impac/widgets/:id
23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/mno_enterprise/jpi/v1/admin/impac/widgets_controller.rb', line 23 def update unless .present? && .update() return render json: { errors: 'Cannot update widget' }, status: :bad_request end MnoEnterprise::EventLogger.info('widget_update', current_user.id, "#{container} Widget Update", ) @nocontent = !params['metadata'] render 'show' end |