From ca9f3ef82ee5535f5636ede20530b8fd28f850fe Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Mon, 2 Sep 2024 21:42:49 +0200 Subject: [PATCH] Enable export as GPX --- app/controllers/exports_controller.rb | 2 +- app/services/exports/create.rb | 2 +- app/views/points/index.html.erb | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb index 8af83728..0eb446a0 100644 --- a/app/controllers/exports_controller.rb +++ b/app/controllers/exports_controller.rb @@ -12,7 +12,7 @@ class ExportsController < ApplicationController export_name = "export_from_#{params[:start_at].to_date}_to_#{params[:end_at].to_date}" export = current_user.exports.create(name: export_name, status: :created) - ExportJob.perform_later(export.id, params[:start_at], params[:end_at], format: params[:format]) + ExportJob.perform_later(export.id, params[:start_at], params[:end_at], format: params[:file_format]) redirect_to exports_url, notice: 'Export was successfully initiated. Please wait until it\'s finished.' rescue StandardError => e diff --git a/app/services/exports/create.rb b/app/services/exports/create.rb index fa9143ba..4ae98f57 100644 --- a/app/services/exports/create.rb +++ b/app/services/exports/create.rb @@ -55,7 +55,7 @@ class Exports::Create end def points_data(points) - case format + case format.to_sym when :json then process_geojson_export(points) when :gpx then process_gpx_export(points) else raise ArgumentError, "Unsupported format: #{format}" diff --git a/app/views/points/index.html.erb b/app/views/points/index.html.erb index 2f21b667..2f57e6bd 100644 --- a/app/views/points/index.html.erb +++ b/app/views/points/index.html.erb @@ -22,14 +22,14 @@
- <%= link_to 'Export GeoJSON', exports_path(start_at: @start_at, end_at: @end_at, file_format: :json), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points withing timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "px-4 py-2 bg-green-500 text-white rounded-md join-item" %> + <%= link_to 'Export as GeoJSON', exports_path(start_at: @start_at, end_at: @end_at, file_format: :json), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points withing timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "px-4 py-2 bg-green-500 text-white rounded-md join-item" %> +
+
+
+
+ <%= link_to 'Export as GPX', exports_path(start_at: @start_at, end_at: @end_at, file_format: :gpx), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points withing timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "px-4 py-2 bg-green-500 text-white rounded-md join-item" %>
- <%#
%> - <%#
%> - <%# <%= link_to 'Export as GPX', exports_path(start_at: @start_at, end_at: @end_at, format: :gpx), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points withing timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "px-4 py-2 bg-green-500 text-white rounded-md join-item" %> - <%#
%> - <%#
%> <% end %>