Class: GeoLabels::DashboardController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- GeoLabels::DashboardController
- Defined in:
- app/controllers/geo_labels/dashboard_controller.rb
Instance Method Summary collapse
Instance Method Details
#export ⇒ Object
15 16 17 |
# File 'app/controllers/geo_labels/dashboard_controller.rb', line 15 def export # SHOW action for the view to call the export_file action end |
#export_file ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/controllers/geo_labels/dashboard_controller.rb', line 19 def export_file = Time.now.utc.iso8601.first(19).gsub(/-|:/, '') send_data GeoLabels::Exporter.export_str, filename: "GeoLabels-export-#{}.yml", type: :text, disposition: :attachment end |
#import ⇒ Object
27 28 29 |
# File 'app/controllers/geo_labels/dashboard_controller.rb', line 27 def import # SHOW action for the view to call the import_file action end |
#import_file ⇒ Object
31 32 33 34 35 36 |
# File 'app/controllers/geo_labels/dashboard_controller.rb', line 31 def import_file Importer.import params[:file] redirect_to root_path, notice: 'File imported' rescue => e redirect_to import_path, alert: e. end |
#main ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/geo_labels/dashboard_controller.rb', line 5 def main return unless params[:label_ids].present? label_ids = params[:label_ids] # fomantic-ui uses comma separated id values label_ids = label_ids.to_s.split(',') unless label_ids.is_a?(Array) states_array = (params[:states].presence || 'approved').split(',') @contacts = Contact.geocoded.for_label_ids(label_ids, predication: params[:predication], states: states_array) end |