Enable export as GPX

This commit is contained in:
Eugene Burmakin 2024-09-02 21:42:49 +02:00
parent 942c84fb07
commit ca9f3ef82e
3 changed files with 8 additions and 8 deletions

View file

@ -12,7 +12,7 @@ class ExportsController < ApplicationController
export_name = "export_from_#{params[:start_at].to_date}_to_#{params[:end_at].to_date}" 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) 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.' redirect_to exports_url, notice: 'Export was successfully initiated. Please wait until it\'s finished.'
rescue StandardError => e rescue StandardError => e

View file

@ -55,7 +55,7 @@ class Exports::Create
end end
def points_data(points) def points_data(points)
case format case format.to_sym
when :json then process_geojson_export(points) when :json then process_geojson_export(points)
when :gpx then process_gpx_export(points) when :gpx then process_gpx_export(points)
else raise ArgumentError, "Unsupported format: #{format}" else raise ArgumentError, "Unsupported format: #{format}"

View file

@ -22,14 +22,14 @@
</div> </div>
<div class="w-full md:w-2/12"> <div class="w-full md:w-2/12">
<div class="flex flex-col space-y-2 text-center"> <div class="flex flex-col space-y-2 text-center">
<%= 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" %>
</div>
</div>
<div class="w-full md:w-2/12">
<div class="flex flex-col space-y-2 text-center">
<%= 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" %>
</div> </div>
</div> </div>
<%# <div class="w-full md:w-2/12"> %>
<%# <div class="flex flex-col space-y-2 text-center"> %>
<%# <%= 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" %>
<%# </div> %>
<%# </div> %>
</div> </div>
<% end %> <% end %>