dawarich/app/views/map/index.html.erb

106 lines
5 KiB
Text
Raw Normal View History

2024-06-12 15:10:53 -04:00
<% content_for :title, 'Map' %>
2025-10-30 14:16:38 -04:00
<!-- Date Navigation Controls - Native Page Element -->
2025-11-19 13:17:30 -05:00
<div class="w-full px-4 bg-base-100" data-controller="map-controls">
<!-- Mobile: Compact Toggle Button -->
2025-10-30 14:16:38 -04:00
<div class="lg:hidden flex justify-center">
<button
type="button"
data-action="click->map-controls#toggle"
class="btn btn-primary w-96 shadow-lg">
<span data-map-controls-target="toggleIcon">
<%= icon 'chevron-down' %>
</span>
<span class="ml-2"><%= human_date(@start_at) %></span>
</button>
</div>
<!-- Expandable Panel (hidden on mobile by default, always visible on desktop) -->
<div
data-map-controls-target="panel"
2025-10-30 14:16:38 -04:00
class="hidden lg:!block bg-base-100 rounded-lg shadow-lg p-4 mt-2 lg:mt-0">
<%= form_with url: map_path(import_id: params[:import_id]), method: :get do |f| %>
<div class="flex flex-col space-y-4 lg:flex-row lg:space-y-0 lg:space-x-4 lg:items-end">
<div class="w-full lg:w-1/12">
<div class="flex flex-col space-y-2">
<span class="tooltip" data-tip="<%= human_date(@start_at - 1.day) %>">
2025-11-19 13:17:30 -05:00
<%= link_to map_path(start_at: @start_at - 1.day, end_at: @end_at - 1.day, import_id: params[:import_id]), class: "btn btn-sm border border-base-300 hover:btn-ghost w-full" do %>
<%= icon 'chevron-left' %>
<% end %>
</span>
2024-05-23 14:12:23 -04:00
</div>
</div>
<div class="w-full lg:w-2/12 tooltip tooltip-bottom" data-tip="Start date and time">
2025-11-19 13:17:30 -05:00
<%= f.datetime_local_field :start_at, include_seconds: false, class: "input input-sm input-bordered hover:cursor-pointer hover:input-primary w-full", value: @start_at %>
</div>
<div class="w-full lg:w-2/12 tooltip tooltip-bottom" data-tip="End date and time">
2025-11-19 13:17:30 -05:00
<%= f.datetime_local_field :end_at, include_seconds: false, class: "input input-sm input-bordered hover:cursor-pointer hover:input-primary w-full", value: @end_at %>
</div>
<div class="w-full lg:w-1/12">
<div class="flex flex-col space-y-2">
<span class="tooltip" data-tip="<%= human_date(@start_at + 1.day) %>">
2025-11-19 13:17:30 -05:00
<%= link_to map_path(start_at: @start_at + 1.day, end_at: @end_at + 1.day, import_id: params[:import_id]), class: "btn btn-sm border border-base-300 hover:btn-ghost w-full" do %>
<%= icon 'chevron-right' %>
<% end %>
</span>
2024-05-23 14:12:23 -04:00
</div>
</div>
<div class="w-full lg:w-1/12">
<div class="flex flex-col space-y-2">
2025-11-19 13:17:30 -05:00
<%= f.submit "Search", class: "btn btn-sm btn-primary hover:btn-info w-full" %>
</div>
</div>
<div class="w-full lg:w-1/12">
<div class="flex flex-col space-y-2 text-center">
<%= link_to "Today",
map_path(start_at: Time.current.beginning_of_day, end_at: Time.current.end_of_day, import_id: params[:import_id]),
2025-11-19 13:17:30 -05:00
class: "btn btn-sm border border-base-300 hover:btn-ghost w-full" %>
</div>
</div>
<div class="w-full lg:w-2/12">
<div class="flex flex-col space-y-2 text-center">
2025-11-19 13:17:30 -05:00
<%= link_to "Last 7 days", map_path(start_at: 1.week.ago.beginning_of_day, end_at: Time.current.end_of_day, import_id: params[:import_id]), class: "btn btn-sm border border-base-300 hover:btn-ghost w-full" %>
</div>
</div>
<div class="w-full lg:w-2/12">
<div class="flex flex-col space-y-2 text-center">
2025-11-19 13:17:30 -05:00
<%= link_to "Last month", map_path(start_at: 1.month.ago.beginning_of_day, end_at: Time.current.end_of_day, import_id: params[:import_id]), class: "btn btn-sm border border-base-300 hover:btn-ghost w-full" %>
</div>
2024-10-02 17:41:46 -04:00
</div>
2024-06-25 15:57:22 -04:00
</div>
<% end %>
</div>
</div>
2025-10-30 14:16:38 -04:00
<!-- Map Container - Fills remaining space -->
<div class="w-full h-full">
<div
id='map'
class="w-full h-full"
data-controller="maps points add-visit family-members"
data-points-target="map"
data-api_key="<%= current_user.api_key %>"
data-self_hosted="<%= @self_hosted %>"
data-user_settings='<%= current_user.safe_settings.settings.to_json %>'
data-user_theme="<%= current_user&.theme || 'dark' %>"
data-coordinates='<%= @coordinates.to_json.html_safe %>'
data-tracks='<%= @tracks.to_json.html_safe %>'
data-distance="<%= @distance %>"
data-points_number="<%= @points_number %>"
data-timezone="<%= Rails.configuration.time_zone %>"
data-features='<%= @features.to_json.html_safe %>'
data-user_tags='<%= current_user.tags.ordered.select(:id, :name, :icon, :color).as_json.to_json.html_safe %>'
data-home_coordinates='<%= @home_coordinates.to_json.html_safe %>'
2025-10-30 14:16:38 -04:00
data-family-members-features-value='<%= @features.to_json.html_safe %>'
data-family-members-user-theme-value="<%= current_user&.theme || 'dark' %>">
<div data-maps-target="container" class="w-full h-full">
<div id="fog" class="fog"></div>
</div>
2024-05-23 14:12:23 -04:00
</div>
</div>
2024-08-28 14:24:35 -04:00
<%= render 'map/settings_modals' %>
2025-11-17 16:34:38 -05:00
<!-- Include Place Creation Modal -->
<%= render 'shared/place_creation_modal' %>