Class: SetupController

Inherits:
ApplicationController
  • Object
show all
Includes:
FeatureGetterHelper
Defined in:
app/controllers/setup_controller.rb

Instance Method Summary collapse

Instance Method Details

#cartodbObject



31
32
33
34
35
36
37
38
39
# File 'app/controllers/setup_controller.rb', line 31

def cartodb
    Cartoset::Config.update params[:settings]

    Cartoset::Config.setup_cartodb

    session[:return_to] = setup_path(:step_id => 2)

    redirect_to '/auth/cartodb' and return
end

#create_features_tableObject



51
52
53
54
55
56
57
58
59
# File 'app/controllers/setup_controller.rb', line 51

def create_features_table
  table = {}

  if params[:qqfile] && request.body.present?
    table = FeaturesDataImporter.start request.body
  end

  render :json => table.to_json
end

#features_table_dataObject



41
42
43
44
45
46
47
48
49
# File 'app/controllers/setup_controller.rb', line 41

def features_table_data
  table_name = params[:table_name]
  if table_name
    @table  = CartoDB::Connection.table table_name
    records = CartoDB::Connection.records table_name, {}
    @rows = records.rows if records
  end
  render :layout => false
end

#stepObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/setup_controller.rb', line 9

def step
  step_id = params[:step_id] || 0

  case step_id
  when "1"
    @settings = OpenStruct.new Cartoset::Config.settings
  when "2"
    Cartoset::Config.set_cartodb_credentials current_user
    @settings = OpenStruct.new Cartoset::Config.settings
  when "3"
    Cartoset::Config.update params[:settings]

    result = CartoDB::Connection.tables || []
    @tables = result.tables
  when "4"
    @table = CartoDB::Connection.table params[:features_table]
    Cartoset::Config.update :features_table => @table.name
  end

  render "step#{step_id}"
end