Class: GeoLabels::DashboardController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- GeoLabels::DashboardController
- Defined in:
- app/controllers/geo_labels/dashboard_controller.rb
Instance Method Summary collapse
- #about ⇒ Object
-
#export ⇒ Object
SHOW action for the view to call the export_file action.
- #export_file ⇒ Object
- #import ⇒ Object
- #import_file ⇒ Object
- #main ⇒ Object
Instance Method Details
#about ⇒ Object
16 |
# File 'app/controllers/geo_labels/dashboard_controller.rb', line 16 def about; end |
#export ⇒ Object
SHOW action for the view to call the export_file action
19 20 21 22 |
# File 'app/controllers/geo_labels/dashboard_controller.rb', line 19 def export :read, GeoLabels::Contact :read, GeoLabels::Label end |
#export_file ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/geo_labels/dashboard_controller.rb', line 24 def export_file :read, GeoLabels::Contact :read, GeoLabels::Label = Time.now.utc.iso8601.first(19).gsub(/-|:/, '') respond_to do |format| format.yaml do send_data GeoLabels::Exporter.export_str, filename: "GeoLabels-export-#{}.yml", type: :text, disposition: :attachment end format.csv do send_data GeoLabels::Contact.to_csv, filename: "GeoLabels-export-#{}.csv", type: :text, disposition: :attachment end end end |
#import ⇒ Object
45 46 47 48 |
# File 'app/controllers/geo_labels/dashboard_controller.rb', line 45 def import :update, GeoLabels::Contact :update, GeoLabels::Label end |
#import_file ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/geo_labels/dashboard_controller.rb', line 50 def import_file :update, GeoLabels::Contact :update, GeoLabels::Label GeoLabels::Importer.import params[:file] redirect_to root_path, notice: 'File imported' rescue => e redirect_to import_path, alert: e. end |
#main ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/geo_labels/dashboard_controller.rb', line 6 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.includes(:labels).for_label_ids(label_ids, predication: params[:predication], states: states_array) end |