15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/easy_admin/dashboards_controller.rb', line 15
def card
@dashboard_instance = @dashboard_class.new(dashboard_params)
@card = @dashboard_class.find_card(params[:card_name])
unless @card
render json: { error: "Card not found" }, status: :not_found
return
end
@card_data = @dashboard_instance.card_data(@card[:name])
respond_to do |format|
format.html
format.turbo_stream
format.json { render json: @card_data }
end
rescue => e
@error_message = e.message
respond_to do |format|
format.html { render template: 'easy_admin/dashboards/card_error' }
format.turbo_stream { render template: 'easy_admin/dashboards/card_error' }
format.json { render json: { error: e.message }, status: :server_error }
end
end
|