Module: Nquery::ChartActions

Extended by:
ActiveSupport::Concern
Included in:
ChartsController, Dashboard::ChartsController
Defined in:
app/controllers/concerns/nquery/chart_actions.rb

Instance Method Summary collapse

Instance Method Details

#archiveObject



44
45
46
47
# File 'app/controllers/concerns/nquery/chart_actions.rb', line 44

def archive
  @chart.archive!
  redirect_to after_chart_action_path, notice: "Chart archived."
end

#destroyObject



39
40
41
42
# File 'app/controllers/concerns/nquery/chart_actions.rb', line 39

def destroy
  @chart.destroy
  redirect_to after_chart_action_path, notice: "Chart removed."
end

#editObject



19
20
21
22
# File 'app/controllers/concerns/nquery/chart_actions.rb', line 19

def edit
  load_chart_builder_assigns
  render "nquery/charts/edit"
end

#embedObject



49
50
51
52
53
# File 'app/controllers/concerns/nquery/chart_actions.rb', line 49

def embed
  @embed_token = EmbedToken.active.find_by(resource_type: "Nquery::Chart", resource_id: @chart.id)
  @embed_url = @embed_token ? embed_public_chart_url(token: EmbedTokenService.signed_token_for(@embed_token)) : nil
  render "nquery/charts/embed"
end

#showObject



14
15
16
17
# File 'app/controllers/concerns/nquery/chart_actions.rb', line 14

def show
  @result = chart_result(@chart)
  render "nquery/charts/show"
end

#updateObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/concerns/nquery/chart_actions.rb', line 24

def update
  if @chart.update(chart_params)
    respond_to do |format|
      format.html { redirect_to after_chart_save_path, notice: "Chart updated." }
      format.turbo_stream do
        flash.now[:notice] = "Chart updated."
        render template: "nquery/charts/update"
      end
    end
  else
    load_chart_builder_assigns
    render "nquery/charts/edit", status: :unprocessable_content
  end
end