Class: Blazer::DashboardsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Blazer::DashboardsController
- Defined in:
- app/controllers/blazer/dashboards_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 13 def create @dashboard = Blazer::Dashboard.new if update_dashboard(@dashboard) redirect_to dashboard_path(@dashboard) else render :new end end |
#destroy ⇒ Object
56 57 58 59 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 56 def destroy @dashboard.destroy redirect_to dashboards_path end |
#edit ⇒ Object
45 46 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 45 def edit end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 5 def index @dashboards = Blazer::Dashboard.order(:name) end |
#new ⇒ Object
9 10 11 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 9 def new @dashboard = Blazer::Dashboard.new end |
#show ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 23 def show @queries = @dashboard.dashboard_queries.order(:position).preload(:query).map(&:query) @queries.each do |query| process_vars(query.statement) end @bind_vars ||= [] @smart_vars = {} @sql_errors = [] data_sources = @queries.map { |q| Blazer.data_sources[q.data_source] }.uniq @bind_vars.each do |var| data_sources.each do |data_source| query = data_source.smart_variables[var] if query rows, error, cached_at = data_source.run_statement(query) ((@smart_vars[var] ||= []).concat(rows.map { |v| v.values.reverse })).uniq! @sql_errors << error if error end end end end |
#update ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/controllers/blazer/dashboards_controller.rb', line 48 def update if update_dashboard(@dashboard) redirect_to dashboard_path(@dashboard) else render :edit end end |