Class: Kanaui::ReportsController

Inherits:
EngineController show all
Defined in:
app/controllers/kanaui/reports_controller.rb

Instance Method Summary collapse

Methods inherited from EngineController

#current_tenant_user, #get_layout, #options_for_klient

Instance Method Details

#createObject



12
13
14
15
16
17
# File 'app/controllers/kanaui/reports_controller.rb', line 12

def create
  Kanaui::DashboardHelper::DashboardApi.create_report(report_from_params.to_json, options_for_klient)

  flash[:notice] = 'Report successfully created'
  redirect_to :action => :index
end

#destroyObject



39
40
41
42
43
44
# File 'app/controllers/kanaui/reports_controller.rb', line 39

def destroy
  Kanaui::DashboardHelper::DashboardApi.delete_report(params.require(:id), options_for_klient)

  flash[:notice] = 'Report successfully deleted'
  redirect_to :action => :index
end

#editObject



19
20
21
22
23
# File 'app/controllers/kanaui/reports_controller.rb', line 19

def edit
  @report = JSON.parse(Kanaui::DashboardHelper::DashboardApi.available_reports(options_for_klient))
                .find { |x| x['reportName'] == params.require(:id) }
                .deep_symbolize_keys
end

#indexObject



4
5
6
# File 'app/controllers/kanaui/reports_controller.rb', line 4

def index
  @reports = JSON.parse(Kanaui::DashboardHelper::DashboardApi.available_reports(options_for_klient)).map(&:deep_symbolize_keys)
end

#newObject



8
9
10
# File 'app/controllers/kanaui/reports_controller.rb', line 8

def new
  @report = {}
end

#refreshObject



32
33
34
35
36
37
# File 'app/controllers/kanaui/reports_controller.rb', line 32

def refresh
  Kanaui::DashboardHelper::DashboardApi.refresh_report(params.require(:id), options_for_klient)

  flash[:notice] = 'Report refresh successfully scheduled'
  redirect_to :action => :index
end

#updateObject



25
26
27
28
29
30
# File 'app/controllers/kanaui/reports_controller.rb', line 25

def update
  Kanaui::DashboardHelper::DashboardApi.update_report(params.require(:id), report_from_params.to_json, options_for_klient)

  flash[:notice] = 'Report successfully updated'
  redirect_to :action => :index
end