Use maps/v2 as main path for MapLibre maps

This commit is contained in:
Eugene Burmakin 2025-12-06 19:20:51 +01:00
parent e1b59a94d9
commit cb64b1aa88
15 changed files with 28 additions and 27 deletions

View file

@ -1,5 +1,5 @@
class MapsController < ApplicationController
def index
redirect_to maps_maplibre_path
redirect_to maps_v2_path
end
end

View file

@ -147,6 +147,6 @@ module ApplicationHelper
return map_path unless user_signed_in?
preferred_version = current_user.safe_settings.maps&.dig('preferred_version')
preferred_version == 'v2' ? maps_maplibre_path : map_path
preferred_version == 'v2' ? maps_v2_path : map_path
end
end

View file

@ -17,12 +17,12 @@
<div
data-map-controls-target="panel"
class="hidden lg:!block bg-base-100 rounded-lg shadow-lg p-4 mt-2 lg:mt-0">
<%= form_with url: maps_maplibre_path(import_id: params[:import_id]), method: :get do |f| %>
<%= form_with url: maps_v2_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) %>">
<%= link_to maps_maplibre_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 %>
<%= link_to maps_v2_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>
@ -37,7 +37,7 @@
<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) %>">
<%= link_to maps_maplibre_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 %>
<%= link_to maps_v2_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>
@ -51,18 +51,18 @@
<div class="w-full lg:w-1/12">
<div class="flex flex-col space-y-2 text-center">
<%= link_to "Today",
maps_maplibre_path(start_at: Time.current.beginning_of_day, end_at: Time.current.end_of_day, import_id: params[:import_id]),
maps_v2_path(start_at: Time.current.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">
<%= link_to "Last 7 days", maps_maplibre_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" %>
<%= link_to "Last 7 days", maps_v2_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">
<%= link_to "Last month", maps_maplibre_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" %>
<%= link_to "Last month", maps_v2_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>
</div>
</div>

View file

@ -118,11 +118,12 @@ Rails.application.routes.draw do
# Maps namespace
namespace :maps do
get '/maplibre', to: 'maplibre#index', as: :maplibre
get '/v2', to: 'maplibre#index', as: :v2
end
# Backward compatibility redirect
get '/maps_v2', to: redirect('/maps/maplibre')
# Backward compatibility redirects
get '/maps_v2', to: redirect('/maps/v2')
get '/maps/maplibre', to: redirect('/maps/v2')
namespace :api do
namespace :v1 do

View file

@ -7,7 +7,7 @@
* @param {Page} page - Playwright page object
*/
export async function navigateToMapsV2(page) {
await page.goto('/maps/maplibre');
await page.goto('/maps/v2');
}
/**

View file

@ -5,7 +5,7 @@ import { waitForMapLibre, waitForLoadingComplete } from '../helpers/setup.js'
test.describe('Area Selection in Maps V2', () => {
test.beforeEach(async ({ page }) => {
// Navigate to Maps V2 with specific date range that has data
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await waitForMapLibre(page)
await waitForLoadingComplete(page)

View file

@ -33,7 +33,7 @@ test.describe('Map Core', () => {
})
test('has valid initial center and zoom', async ({ page }) => {
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await waitForMapLibre(page)
await waitForLoadingComplete(page)
@ -83,7 +83,7 @@ test.describe('Map Core', () => {
test.describe('Data Bounds', () => {
test('fits map bounds to loaded data', async ({ page }) => {
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await waitForMapLibre(page)
await waitForLoadingComplete(page)
@ -96,7 +96,7 @@ test.describe('Map Core', () => {
test.describe('Lifecycle', () => {
test('cleans up and reinitializes on navigation', async ({ page }) => {
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await waitForLoadingComplete(page)
@ -114,7 +114,7 @@ test.describe('Map Core', () => {
})
test('reloads data when changing date range', async ({ page }) => {
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await waitForLoadingComplete(page)

View file

@ -9,7 +9,7 @@ import {
test.describe('Map Interactions', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await waitForLoadingComplete(page)
await page.waitForTimeout(500)

View file

@ -3,12 +3,12 @@ import { closeOnboardingModal } from '../../../helpers/navigation.js'
test.describe('Advanced Layers', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/maps/maplibre')
await page.goto('/maps/v2')
await page.evaluate(() => {
localStorage.removeItem('dawarich-maps-maplibre-settings')
})
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await page.waitForTimeout(2000)
})

View file

@ -3,7 +3,7 @@ import { closeOnboardingModal } from '../../../helpers/navigation.js'
test.describe('Heatmap Layer', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await page.waitForTimeout(2000)
})

View file

@ -9,7 +9,7 @@ import {
test.describe('Points Layer', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await waitForLoadingComplete(page)
await page.waitForTimeout(1500)

View file

@ -11,7 +11,7 @@ import {
test.describe('Routes Layer', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await waitForMapLibre(page)
await waitForLoadingComplete(page)

View file

@ -6,7 +6,7 @@ test.describe('Map Performance', () => {
test('map loads within acceptable time', async ({ page }) => {
const startTime = Date.now()
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await waitForMapLibre(page)
await waitForLoadingComplete(page)
@ -19,7 +19,7 @@ test.describe('Map Performance', () => {
})
test('handles large datasets efficiently', async ({ page }) => {
await page.goto('/maps/maplibre?start_at=2025-10-01T00:00&end_at=2025-10-31T23:59')
await page.goto('/maps/v2?start_at=2025-10-01T00:00&end_at=2025-10-31T23:59')
await closeOnboardingModal(page)
const startTime = Date.now()

View file

@ -18,7 +18,7 @@ test.describe('Location Search', () => {
test.setTimeout(60000)
test.beforeEach(async ({ page }) => {
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await waitForMapLibre(page)
await waitForLoadingComplete(page)

View file

@ -4,7 +4,7 @@ import { getLayerVisibility } from '../helpers/setup.js'
test.describe('Map Settings', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/maps/maplibre?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
await closeOnboardingModal(page)
await page.waitForTimeout(2000)
})