Class: Nquery::DashboardsController
Constant Summary
AuthorizesCollection::COLLECTION_REQUIREMENTS
Instance Method Summary
collapse
#breadcrumbs, #set_breadcrumbs
Instance Method Details
#archive ⇒ Object
44
45
46
47
|
# File 'app/controllers/nquery/dashboards_controller.rb', line 44
def archive
@dashboard.archive!
redirect_to dashboards_path, notice: "Dashboard archived."
end
|
#destroy ⇒ Object
39
40
41
42
|
# File 'app/controllers/nquery/dashboards_controller.rb', line 39
def destroy
@dashboard.destroy
redirect_to dashboards_path, notice: "Dashboard removed."
end
|
#edit ⇒ Object
24
25
26
|
# File 'app/controllers/nquery/dashboards_controller.rb', line 24
def edit
@collections = assignable_collections
end
|
#index ⇒ Object
12
13
14
|
# File 'app/controllers/nquery/dashboards_controller.rb', line 12
def index
@dashboards = filter_viewable_dashboards(Dashboard.active.includes(:collection).order(:name))
end
|
#show ⇒ Object
16
17
18
19
20
21
22
|
# File 'app/controllers/nquery/dashboards_controller.rb', line 16
def show
@dashboard_cards = @dashboard.dashboard_cards
.joins(:chart)
.merge(Chart.active)
.includes(:chart)
@card_results = @dashboard_cards.index_with { |card| chart_result(card.chart) }
end
|
#unarchive ⇒ Object
49
50
51
52
|
# File 'app/controllers/nquery/dashboards_controller.rb', line 49
def unarchive
@dashboard.unarchive!
redirect_to dashboard_path(@dashboard), notice: "Dashboard unarchived."
end
|
#update ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/nquery/dashboards_controller.rb', line 28
def update
@collections = assignable_collections
authorize_collection_access!(Collection.find(dashboard_params[:collection_id]), required: :curate) if dashboard_params[:collection_id].present?
if @dashboard.update(dashboard_params)
redirect_to dashboard_path(@dashboard), notice: "Dashboard updated."
else
render :edit, status: :unprocessable_content
end
end
|
#update_layout ⇒ Object
54
55
56
57
58
59
60
|
# File 'app/controllers/nquery/dashboards_controller.rb', line 54
def update_layout
card_layouts.each do |card_id, layout|
card = @dashboard.dashboard_cards.find(card_id)
card.update(pos_x: layout[:x], pos_y: layout[:y], width: layout[:w], height: layout[:h])
end
head :ok
end
|