mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Add links to view import points on the map and on the Points page on the Imports page
This commit is contained in:
parent
d2a8180a7f
commit
0f3268e6b6
9 changed files with 61 additions and 21 deletions
|
|
@ -5,4 +5,4 @@ DATABASE_NAME=dawarich_development
|
|||
DATABASE_PORT=5432
|
||||
REDIS_URL=redis://localhost:6379/1
|
||||
PHOTON_API_HOST='photon.komoot.io'
|
||||
DISTANCE_UNIT='mi'
|
||||
DISTANCE_UNIT='km'
|
||||
|
|
|
|||
11
CHANGELOG.md
11
CHANGELOG.md
|
|
@ -7,14 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
|
||||
## [0.13.5] — 2024-09-08
|
||||
|
||||
### Added
|
||||
|
||||
- Links to view import points on the map and on the Points page on the Imports page.
|
||||
|
||||
### Fixed
|
||||
|
||||
- The Imports page now loading faster.
|
||||
|
||||
### Changed
|
||||
|
||||
- Default value for `RAILS_MAX_THREADS` was changed to 10.
|
||||
- Visit suggestions background job was moved to its own low priority queue to prevent it from blocking other jobs.
|
||||
|
||||
### Fixed
|
||||
|
||||
- The Imports page now loading faster.
|
||||
|
||||
## [0.13.4] — 2024-09-06
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -4,8 +4,10 @@ class MapController < ApplicationController
|
|||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
@points = current_user.tracked_points.without_raw_data.where('timestamp >= ? AND timestamp <= ?', start_at,
|
||||
end_at).order(timestamp: :asc)
|
||||
@points = points
|
||||
.without_raw_data
|
||||
.where('timestamp >= ? AND timestamp <= ?', start_at, end_at)
|
||||
.order(timestamp: :asc)
|
||||
|
||||
@countries_and_cities = CountriesAndCities.new(@points).call
|
||||
@coordinates =
|
||||
|
|
@ -42,4 +44,16 @@ class MapController < ApplicationController
|
|||
|
||||
@distance.round(1)
|
||||
end
|
||||
|
||||
def points
|
||||
params[:import_id] ? points_from_import : points_from_user
|
||||
end
|
||||
|
||||
def points_from_import
|
||||
current_user.imports.find(params[:import_id]).points
|
||||
end
|
||||
|
||||
def points_from_user
|
||||
current_user.tracked_points
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@ class PointsController < ApplicationController
|
|||
def index
|
||||
order_by = params[:order_by] || 'desc'
|
||||
|
||||
@points =
|
||||
current_user
|
||||
.tracked_points
|
||||
@points = points
|
||||
.without_raw_data
|
||||
.where(timestamp: start_at..end_at)
|
||||
.order(timestamp: order_by)
|
||||
|
|
@ -19,6 +17,7 @@ class PointsController < ApplicationController
|
|||
@end_at = Time.zone.at(end_at)
|
||||
|
||||
@points_number = @points.except(:limit, :offset).size
|
||||
@imports = current_user.imports.order(created_at: :desc)
|
||||
end
|
||||
|
||||
def bulk_destroy
|
||||
|
|
@ -44,4 +43,16 @@ class PointsController < ApplicationController
|
|||
|
||||
Time.zone.parse(params[:end_at]).to_i
|
||||
end
|
||||
|
||||
def points
|
||||
params[:import_id] ? points_from_import : points_from_user
|
||||
end
|
||||
|
||||
def points_from_import
|
||||
current_user.imports.find(params[:import_id]).points
|
||||
end
|
||||
|
||||
def points_from_user
|
||||
current_user.tracked_points
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@
|
|||
<tr>
|
||||
<td>
|
||||
<%= link_to import.name, import, class: 'underline hover:no-underline' %> (<%= import.source %>)
|
||||
 
|
||||
<%= link_to '🗺️', map_path(import_id: import.id) %>
|
||||
 
|
||||
<%= link_to '📋', points_path(import_id: import.id) %>
|
||||
</td>
|
||||
<td>
|
||||
<%= "#{number_with_delimiter import.points_count}" %>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<div class='w-4/5 mt-8'>
|
||||
<div class="flex flex-col space-y-4 mb-4 w-full">
|
||||
<%= form_with url: map_path, method: :get do |f| %>
|
||||
<%= form_with url: map_path(import_id: params[:import_id]), method: :get do |f| %>
|
||||
<div class="flex flex-col md:flex-row md:space-x-4 md:items-end">
|
||||
<div class="w-full md:w-2/12">
|
||||
<div class="flex flex-col space-y-2">
|
||||
|
|
@ -23,17 +23,17 @@
|
|||
</div>
|
||||
<div class="w-full md:w-2/12">
|
||||
<div class="flex flex-col space-y-2 text-center">
|
||||
<%= link_to "Yesterday", map_path(start_at: Date.yesterday.beginning_of_day, end_at: Date.yesterday.end_of_day), class: "px-4 py-2 bg-gray-500 text-white rounded-md" %>
|
||||
<%= link_to "Yesterday", map_path(start_at: Date.yesterday.beginning_of_day, end_at: Date.yesterday.end_of_day, import_id: params[:import_id]), class: "px-4 py-2 bg-gray-500 text-white rounded-md" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full md:w-2/12">
|
||||
<div class="flex flex-col space-y-2 text-center">
|
||||
<%= link_to "Last 7 days", map_path(start_at: 1.week.ago.beginning_of_day, end_at: Time.current.end_of_day), class: "px-4 py-2 bg-gray-500 text-white rounded-md" %>
|
||||
<%= 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: "px-4 py-2 bg-gray-500 text-white rounded-md" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full md:w-2/12">
|
||||
<div class="flex flex-col space-y-2 text-center">
|
||||
<%= link_to "Last month", map_path(start_at: 1.month.ago.beginning_of_day, end_at: Time.current.end_of_day), class: "px-4 py-2 bg-gray-500 text-white rounded-md" %>
|
||||
<%= 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: "px-4 py-2 bg-gray-500 text-white rounded-md" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,20 +1,26 @@
|
|||
<% content_for :title, 'Points' %>
|
||||
|
||||
<div class="w-full">
|
||||
<%= form_with url: points_path, method: :get do |f| %>
|
||||
<%= form_with url: points_path(import_id: params[:import_id]), method: :get do |f| %>
|
||||
<div class="flex flex-col md:flex-row md:space-x-4 md:items-end">
|
||||
<div class="w-full md:w-3/12">
|
||||
<div class="w-full md:w-2/12">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<%= f.label :start_at, class: "text-sm font-semibold" %>
|
||||
<%= f.datetime_local_field :start_at, class: "rounded-md w-full", value: @start_at %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full md:w-3/12">
|
||||
<div class="w-full md:w-2/12">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<%= f.label :end_at, class: "text-sm font-semibold" %>
|
||||
<%= f.datetime_local_field :end_at, class: "rounded-md w-full", value: @end_at %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full md:w-2/12">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<%= f.label :import, class: "text-sm font-semibold" %>
|
||||
<%= f.select :import_id, options_for_select(@imports.map { |i| [i.name, i.id] }, params[:import_id]), { include_blank: true }, class: "rounded-md w-full" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full md:w-1/12">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<%= f.submit "Search", class: "px-4 py-2 bg-blue-500 text-white rounded-md" %>
|
||||
|
|
@ -48,8 +54,8 @@
|
|||
</div>
|
||||
<div class="flex justify-end">
|
||||
<span class="mr-2">Order by:</span>
|
||||
<%= link_to 'Newest', points_path(order_by: :desc), class: 'btn btn-xs btn-primary mx-1' %>
|
||||
<%= link_to 'Oldest', points_path(order_by: :asc), class: 'btn btn-xs btn-primary mx-1' %>
|
||||
<%= link_to 'Newest', points_path(order_by: :desc, import_id: params[:import_id]), class: 'btn btn-xs btn-primary mx-1' %>
|
||||
<%= link_to 'Oldest', points_path(order_by: :asc, import_id: params[:import_id]), class: 'btn btn-xs btn-primary mx-1' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<div tabindex="0" role="button" class="btn m-1">Select year</div>
|
||||
<ul tabindex="0" class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52">
|
||||
<% current_user.stats.years.each do |year| %>
|
||||
<li><%= link_to year, map_url(year_timespan(year).merge(year: year)) %></li>
|
||||
<li><%= link_to year, map_url(year_timespan(year).merge(year: year, import_id: params[:import_id])) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
<% (1..12).to_a.each_slice(3) do |months| %>
|
||||
<% months.each do |month_number| %>
|
||||
<% if past?(year, month_number) && points_exist?(year, month_number, current_user) %>
|
||||
<%= link_to Date::ABBR_MONTHNAMES[month_number], map_url(timespan(month_number, year)), class: 'btn btn-default' %>
|
||||
<%= link_to Date::ABBR_MONTHNAMES[month_number], map_url(timespan(month_number, year).merge(import_id: params[:import_id])), class: 'btn btn-default' %>
|
||||
<% else %>
|
||||
<div class='btn btn-disabled'><%= Date::ABBR_MONTHNAMES[month_number] %></div>
|
||||
<% end %>
|
||||
|
|
|
|||
Loading…
Reference in a new issue