mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Update routing
This commit is contained in:
parent
cb64b1aa88
commit
cc42428d24
25 changed files with 38 additions and 48 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class MapController < ApplicationController
|
class Map::LeafletController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
layout 'map', only: :index
|
layout 'map', only: :index
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
module Maps
|
module Map
|
||||||
class MaplibreController < ApplicationController
|
class MaplibreController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
layout 'map'
|
layout 'map'
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
class MapsController < ApplicationController
|
|
||||||
def index
|
|
||||||
redirect_to maps_v2_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -144,9 +144,9 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def preferred_map_path
|
def preferred_map_path
|
||||||
return map_path unless user_signed_in?
|
return map_v1_path unless user_signed_in?
|
||||||
|
|
||||||
preferred_version = current_user.safe_settings.maps&.dig('preferred_version')
|
preferred_version = current_user.safe_settings.maps&.dig('preferred_version')
|
||||||
preferred_version == 'v2' ? maps_v2_path : map_path
|
preferred_version == 'v2' ? map_v2_path : map_v1_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= render 'map/settings_modals' %>
|
<%= render 'map/leaflet/settings_modals' %>
|
||||||
|
|
||||||
<!-- Include Place Creation Modal -->
|
<!-- Include Place Creation Modal -->
|
||||||
<%= render 'shared/place_creation_modal' %>
|
<%= render 'shared/place_creation_modal' %>
|
||||||
|
|
@ -36,13 +36,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Settings panel -->
|
<!-- Settings panel -->
|
||||||
<%= render 'maps/maplibre/settings_panel' %>
|
<%= render 'map/maplibre/settings_panel' %>
|
||||||
|
|
||||||
<!-- Visit creation modal -->
|
<!-- Visit creation modal -->
|
||||||
<%= render 'maps/maplibre/visit_creation_modal' %>
|
<%= render 'map/maplibre/visit_creation_modal' %>
|
||||||
|
|
||||||
<!-- Area creation modal -->
|
<!-- Area creation modal -->
|
||||||
<%= render 'maps/maplibre/area_creation_modal' %>
|
<%= render 'map/maplibre/area_creation_modal' %>
|
||||||
|
|
||||||
<!-- Place creation modal (shared) -->
|
<!-- Place creation modal (shared) -->
|
||||||
<%= render 'shared/place_creation_modal' %>
|
<%= render 'shared/place_creation_modal' %>
|
||||||
|
|
@ -17,12 +17,12 @@
|
||||||
<div
|
<div
|
||||||
data-map-controls-target="panel"
|
data-map-controls-target="panel"
|
||||||
class="hidden lg:!block bg-base-100 rounded-lg shadow-lg p-4 mt-2 lg:mt-0">
|
class="hidden lg:!block bg-base-100 rounded-lg shadow-lg p-4 mt-2 lg:mt-0">
|
||||||
<%= form_with url: maps_v2_path(import_id: params[:import_id]), method: :get do |f| %>
|
<%= form_with url: map_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="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="w-full lg:w-1/12">
|
||||||
<div class="flex flex-col space-y-2">
|
<div class="flex flex-col space-y-2">
|
||||||
<span class="tooltip" data-tip="<%= human_date(start_at - 1.day) %>">
|
<span class="tooltip" data-tip="<%= human_date(start_at - 1.day) %>">
|
||||||
<%= 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 %>
|
<%= link_to map_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' %>
|
<%= icon 'chevron-left' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
<div class="w-full lg:w-1/12">
|
<div class="w-full lg:w-1/12">
|
||||||
<div class="flex flex-col space-y-2">
|
<div class="flex flex-col space-y-2">
|
||||||
<span class="tooltip" data-tip="<%= human_date(start_at + 1.day) %>">
|
<span class="tooltip" data-tip="<%= human_date(start_at + 1.day) %>">
|
||||||
<%= 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 %>
|
<%= link_to map_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' %>
|
<%= icon 'chevron-right' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -51,18 +51,18 @@
|
||||||
<div class="w-full lg:w-1/12">
|
<div class="w-full lg:w-1/12">
|
||||||
<div class="flex flex-col space-y-2 text-center">
|
<div class="flex flex-col space-y-2 text-center">
|
||||||
<%= link_to "Today",
|
<%= link_to "Today",
|
||||||
maps_v2_path(start_at: Time.current.beginning_of_day, end_at: Time.current.end_of_day, import_id: params[:import_id]),
|
map_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" %>
|
class: "btn btn-sm border border-base-300 hover:btn-ghost w-full" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full lg:w-2/12">
|
<div class="w-full lg: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 "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" %>
|
<%= link_to "Last 7 days", map_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>
|
</div>
|
||||||
<div class="w-full lg:w-2/12">
|
<div class="w-full lg: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 "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" %>
|
<%= link_to "Last month", map_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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -110,20 +110,15 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :metrics, only: [:index]
|
resources :metrics, only: [:index]
|
||||||
|
|
||||||
# V1 (Leaflet) - legacy
|
# Map namespace with versioning
|
||||||
get 'map', to: 'map#index'
|
namespace :map do
|
||||||
|
get '/v1', to: 'leaflet#index', as: :v1
|
||||||
# Main maps entry - redirects to MapLibre
|
|
||||||
get '/maps', to: 'maps#index', as: :maps
|
|
||||||
|
|
||||||
# Maps namespace
|
|
||||||
namespace :maps do
|
|
||||||
get '/v2', to: 'maplibre#index', as: :v2
|
get '/v2', to: 'maplibre#index', as: :v2
|
||||||
end
|
end
|
||||||
|
|
||||||
# Backward compatibility redirects
|
# Backward compatibility redirects
|
||||||
get '/maps_v2', to: redirect('/maps/v2')
|
get '/map', to: 'map/leaflet#index'
|
||||||
get '/maps/maplibre', to: redirect('/maps/v2')
|
get '/maps/v2', to: redirect('/map/v2')
|
||||||
|
|
||||||
namespace :api do
|
namespace :api do
|
||||||
namespace :v1 do
|
namespace :v1 do
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ setup('authenticate', async ({ page }) => {
|
||||||
// Click login button
|
// Click login button
|
||||||
await page.click('input[type="submit"][value="Log in"]');
|
await page.click('input[type="submit"][value="Log in"]');
|
||||||
|
|
||||||
// Wait for successful navigation
|
// Wait for successful navigation to map (v1 or v2 depending on user preference)
|
||||||
await page.waitForURL('/map', { timeout: 10000 });
|
await page.waitForURL(/\/map(\/v[12])?/, { timeout: 10000 });
|
||||||
|
|
||||||
// Save authentication state
|
// Save authentication state
|
||||||
await page.context().storageState({ path: authFile });
|
await page.context().storageState({ path: authFile });
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* @param {Page} page - Playwright page object
|
* @param {Page} page - Playwright page object
|
||||||
*/
|
*/
|
||||||
export async function navigateToMapsV2(page) {
|
export async function navigateToMapsV2(page) {
|
||||||
await page.goto('/maps/v2');
|
await page.goto('/map/v2');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { waitForMapLibre, waitForLoadingComplete } from '../helpers/setup.js'
|
||||||
test.describe('Area Selection in Maps V2', () => {
|
test.describe('Area Selection in Maps V2', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
// Navigate to Maps V2 with specific date range that has data
|
// Navigate to Maps V2 with specific date range that has data
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await waitForMapLibre(page)
|
await waitForMapLibre(page)
|
||||||
await waitForLoadingComplete(page)
|
await waitForLoadingComplete(page)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ test.describe('Map Core', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('has valid initial center and zoom', async ({ page }) => {
|
test('has valid initial center and zoom', async ({ page }) => {
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await waitForMapLibre(page)
|
await waitForMapLibre(page)
|
||||||
await waitForLoadingComplete(page)
|
await waitForLoadingComplete(page)
|
||||||
|
|
@ -83,7 +83,7 @@ test.describe('Map Core', () => {
|
||||||
|
|
||||||
test.describe('Data Bounds', () => {
|
test.describe('Data Bounds', () => {
|
||||||
test('fits map bounds to loaded data', async ({ page }) => {
|
test('fits map bounds to loaded data', async ({ page }) => {
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await waitForMapLibre(page)
|
await waitForMapLibre(page)
|
||||||
await waitForLoadingComplete(page)
|
await waitForLoadingComplete(page)
|
||||||
|
|
@ -96,7 +96,7 @@ test.describe('Map Core', () => {
|
||||||
|
|
||||||
test.describe('Lifecycle', () => {
|
test.describe('Lifecycle', () => {
|
||||||
test('cleans up and reinitializes on navigation', async ({ page }) => {
|
test('cleans up and reinitializes on navigation', async ({ page }) => {
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await waitForLoadingComplete(page)
|
await waitForLoadingComplete(page)
|
||||||
|
|
||||||
|
|
@ -114,7 +114,7 @@ test.describe('Map Core', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('reloads data when changing date range', async ({ page }) => {
|
test('reloads data when changing date range', async ({ page }) => {
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await waitForLoadingComplete(page)
|
await waitForLoadingComplete(page)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import {
|
||||||
|
|
||||||
test.describe('Map Interactions', () => {
|
test.describe('Map Interactions', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await waitForLoadingComplete(page)
|
await waitForLoadingComplete(page)
|
||||||
await page.waitForTimeout(500)
|
await page.waitForTimeout(500)
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@ import { closeOnboardingModal } from '../../../helpers/navigation.js'
|
||||||
|
|
||||||
test.describe('Advanced Layers', () => {
|
test.describe('Advanced Layers', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/maps/v2')
|
await page.goto('/map/v2')
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
localStorage.removeItem('dawarich-maps-maplibre-settings')
|
localStorage.removeItem('dawarich-maps-maplibre-settings')
|
||||||
})
|
})
|
||||||
|
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await page.waitForTimeout(2000)
|
await page.waitForTimeout(2000)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { closeOnboardingModal } from '../../../helpers/navigation.js'
|
||||||
|
|
||||||
test.describe('Heatmap Layer', () => {
|
test.describe('Heatmap Layer', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await page.waitForTimeout(2000)
|
await page.waitForTimeout(2000)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import {
|
||||||
|
|
||||||
test.describe('Points Layer', () => {
|
test.describe('Points Layer', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await waitForLoadingComplete(page)
|
await waitForLoadingComplete(page)
|
||||||
await page.waitForTimeout(1500)
|
await page.waitForTimeout(1500)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import {
|
||||||
|
|
||||||
test.describe('Routes Layer', () => {
|
test.describe('Routes Layer', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await waitForMapLibre(page)
|
await waitForMapLibre(page)
|
||||||
await waitForLoadingComplete(page)
|
await waitForLoadingComplete(page)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ test.describe('Map Performance', () => {
|
||||||
test('map loads within acceptable time', async ({ page }) => {
|
test('map loads within acceptable time', async ({ page }) => {
|
||||||
const startTime = Date.now()
|
const startTime = Date.now()
|
||||||
|
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await waitForMapLibre(page)
|
await waitForMapLibre(page)
|
||||||
await waitForLoadingComplete(page)
|
await waitForLoadingComplete(page)
|
||||||
|
|
@ -19,7 +19,7 @@ test.describe('Map Performance', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('handles large datasets efficiently', async ({ page }) => {
|
test('handles large datasets efficiently', async ({ page }) => {
|
||||||
await page.goto('/maps/v2?start_at=2025-10-01T00:00&end_at=2025-10-31T23:59')
|
await page.goto('/map/v2?start_at=2025-10-01T00:00&end_at=2025-10-31T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
|
|
||||||
const startTime = Date.now()
|
const startTime = Date.now()
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ test.describe('Location Search', () => {
|
||||||
test.setTimeout(60000)
|
test.setTimeout(60000)
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await waitForMapLibre(page)
|
await waitForMapLibre(page)
|
||||||
await waitForLoadingComplete(page)
|
await waitForLoadingComplete(page)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { getLayerVisibility } from '../helpers/setup.js'
|
||||||
|
|
||||||
test.describe('Map Settings', () => {
|
test.describe('Map Settings', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/maps/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
await page.goto('/map/v2?start_at=2025-10-15T00:00&end_at=2025-10-15T23:59')
|
||||||
await closeOnboardingModal(page)
|
await closeOnboardingModal(page)
|
||||||
await page.waitForTimeout(2000)
|
await page.waitForTimeout(2000)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ RSpec.describe 'Authentication', type: :request do
|
||||||
|
|
||||||
describe 'Route Protection' do
|
describe 'Route Protection' do
|
||||||
it 'redirects to sign in page when accessing protected routes while signed out' do
|
it 'redirects to sign in page when accessing protected routes while signed out' do
|
||||||
get map_path
|
get map_v1_path
|
||||||
expect(response).to redirect_to(new_user_session_path)
|
expect(response).to redirect_to(new_user_session_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue