Class: Tiler::Api::V1::DashboardsController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- Tiler::Api::V1::DashboardsController
- Defined in:
- app/controllers/tiler/api/v1/dashboards_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
-
#settings ⇒ Object
PATCH /tiler/api/v1/dashboards/:id/settings Body: { settings: { tv_mode: true } } Merges into existing settings (does not replace) so callers can ship one key at a time.
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/controllers/tiler/api/v1/dashboards_controller.rb', line 18 def create @dashboard = Tiler::Dashboard.new(dashboard_params) if @dashboard.save render json: serialize(@dashboard), status: :created else render json: { errors: @dashboard.errors. }, status: :unprocessable_entity end end |
#destroy ⇒ Object
35 36 37 38 |
# File 'app/controllers/tiler/api/v1/dashboards_controller.rb', line 35 def destroy @dashboard.destroy! head :no_content end |
#index ⇒ Object
10 11 12 |
# File 'app/controllers/tiler/api/v1/dashboards_controller.rb', line 10 def index render json: Tiler::Dashboard.by_name.map { |d| serialize(d) } end |
#settings ⇒ Object
PATCH /tiler/api/v1/dashboards/:id/settings Body: { settings: { tv_mode: true } } Merges into existing settings (does not replace) so callers can ship one key at a time.
44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/tiler/api/v1/dashboards_controller.rb', line 44 def settings incoming = params.require(:settings).permit!.to_h merged = @dashboard.settings_hash.merge(incoming) if @dashboard.update(settings: merged.to_json) render json: serialize(@dashboard) else render json: { errors: @dashboard.errors. }, status: :unprocessable_entity end end |
#show ⇒ Object
14 15 16 |
# File 'app/controllers/tiler/api/v1/dashboards_controller.rb', line 14 def show render json: serialize(@dashboard) end |
#update ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/controllers/tiler/api/v1/dashboards_controller.rb', line 27 def update if @dashboard.update(dashboard_params) render json: serialize(@dashboard) else render json: { errors: @dashboard.errors. }, status: :unprocessable_entity end end |