mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 01:01:39 -05:00
Added new buttons to map page and removed "Your data" page
This commit is contained in:
parent
36767ffa77
commit
4962d48910
10 changed files with 64 additions and 72 deletions
|
|
@ -10,12 +10,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
### Added
|
||||
|
||||
- Now user can hover on route and see when it started, when it ended and how much time it took to travel
|
||||
- New buttons to quickly move to today's, yesterday's and 7 days data on the map
|
||||
- "Download JSON" button to points page
|
||||
|
||||
### Fixed
|
||||
|
||||
- Timestamps in export form are now correctly assigned from the first and last points tracked by the user
|
||||
- Routes are now being split based both on distance and time. If the time between two consecutive points is more than 60 minutes, the route is split into two separate routes. This improves visibility of the routes on the map.
|
||||
|
||||
### Changed
|
||||
|
||||
- Removed "Your data" page as its function was replaced by "Download JSON" button on the points page
|
||||
|
||||
---
|
||||
|
||||
## [0.4.2] — 2024-05-29
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -3,11 +3,6 @@
|
|||
class ExportController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
@start_at = Time.zone.at(start_at)
|
||||
@end_at = Time.zone.at(end_at)
|
||||
end
|
||||
|
||||
def download
|
||||
export = current_user.export_data(start_at:, end_at:)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class PointsController < ApplicationController
|
|||
current_user
|
||||
.tracked_points
|
||||
.without_raw_data
|
||||
.where('timestamp >= ? AND timestamp <= ?', start_at, end_at)
|
||||
.where(timestamp: start_at..end_at)
|
||||
.order(timestamp: :asc)
|
||||
.paginate(page: params[:page], per_page: 50)
|
||||
|
||||
|
|
|
|||
|
|
@ -61,14 +61,14 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def time_framed_points(start_at, end_at)
|
||||
return points.without_raw_data if start_at.nil? && end_at.nil?
|
||||
return tracked_points.without_raw_data if start_at.nil? && end_at.nil?
|
||||
|
||||
if start_at && end_at
|
||||
points.without_raw_data.where('timestamp >= ? AND timestamp <= ?', start_at, end_at)
|
||||
tracked_points.without_raw_data.where('timestamp >= ? AND timestamp <= ?', start_at, end_at)
|
||||
elsif start_at
|
||||
points.without_raw_data.where('timestamp >= ?', start_at)
|
||||
tracked_points.without_raw_data.where('timestamp >= ?', start_at)
|
||||
elsif end_at
|
||||
points.without_raw_data.where('timestamp <= ?', end_at)
|
||||
tracked_points.without_raw_data.where('timestamp <= ?', end_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,36 +9,40 @@ class ExportSerializer
|
|||
end
|
||||
|
||||
def call
|
||||
{ user_email => { 'dawarich-export' => export_points } }.to_json
|
||||
Oj.dump({ user_email => { 'dawarich-export' => export_points } })
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def export_points
|
||||
points.map do |point|
|
||||
{
|
||||
lat: point.latitude,
|
||||
lon: point.longitude,
|
||||
bs: battery_status(point),
|
||||
batt: point.battery,
|
||||
p: point.ping,
|
||||
alt: point.altitude,
|
||||
acc: point.accuracy,
|
||||
vac: point.vertical_accuracy,
|
||||
vel: point.velocity,
|
||||
conn: connection(point),
|
||||
SSID: point.ssid,
|
||||
BSSID: point.bssid,
|
||||
m: trigger(point),
|
||||
tid: point.tracker_id,
|
||||
tst: point.timestamp.to_i,
|
||||
inrids: point.inrids,
|
||||
inregions: point.in_regions,
|
||||
topic: point.topic
|
||||
}
|
||||
points.in_groups_of(1000, false).flat_map do |group|
|
||||
group.map { |point| export_point(point) }
|
||||
end
|
||||
end
|
||||
|
||||
def export_point(point)
|
||||
{
|
||||
lat: point.latitude,
|
||||
lon: point.longitude,
|
||||
bs: battery_status(point),
|
||||
batt: point.battery,
|
||||
p: point.ping,
|
||||
alt: point.altitude,
|
||||
acc: point.accuracy,
|
||||
vac: point.vertical_accuracy,
|
||||
vel: point.velocity,
|
||||
conn: connection(point),
|
||||
SSID: point.ssid,
|
||||
BSSID: point.bssid,
|
||||
m: trigger(point),
|
||||
tid: point.tracker_id,
|
||||
tst: point.timestamp.to_i,
|
||||
inrids: point.inrids,
|
||||
inregions: point.in_regions,
|
||||
topic: point.topic
|
||||
}
|
||||
end
|
||||
|
||||
def battery_status(point)
|
||||
case point.battery_status
|
||||
when 'unplugged' then 'u'
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
<div class="w-full">
|
||||
<div class='m-5'>
|
||||
<h1 class='text-3xl font-bold'>Export Data</h1>
|
||||
|
||||
<div role="alert" class="alert alert-info my-5">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
|
||||
<span>Default selected timeframes are based on first and last geopoint timestamps</span>
|
||||
</div>
|
||||
|
||||
<%= form_with url: export_download_path, method: :get, data: { turbo: false } do |f| %>
|
||||
<div class="flex flex-col md:flex-row md:space-x-4 md:items-end">
|
||||
<div class="w-full md:w-1/3">
|
||||
<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-1/3">
|
||||
<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-1/3">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<%= f.submit "Download JSON", class: "px-4 py-2 bg-blue-500 text-white rounded-md" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2,23 +2,38 @@
|
|||
<div class="flex flex-col space-y-4 mb-4 w-full">
|
||||
<%= form_with url: map_path, 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-1/3">
|
||||
<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-1/3">
|
||||
<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-1/3">
|
||||
<div class="w-full md:w-2/12">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<%= f.submit "Search", class: "px-4 py-2 bg-blue-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 "Today", map_path(start_at: Time.current.beginning_of_day, end_at: Time.current.end_of_day), class: "px-4 py-2 bg-blue-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 "Yesterday", map_path(start_at: Date.yesterday.beginning_of_day, end_at: Date.yesterday.end_of_day), class: "px-4 py-2 bg-blue-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-blue-500 text-white rounded-md" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,23 +3,28 @@
|
|||
<div class="w-full">
|
||||
<%= form_with url: points_path, 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-1/3">
|
||||
<div class="w-full md:w-2/6">
|
||||
<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-1/3">
|
||||
<div class="w-full md:w-2/6">
|
||||
<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-1/3">
|
||||
<div class="w-full md:w-2/6">
|
||||
<div class="flex flex-col space-y-2">
|
||||
<%= f.submit "Search", class: "px-4 py-2 bg-blue-500 text-white rounded-md" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full md:w-2/6">
|
||||
<div class="flex flex-col space-y-2 text-center">
|
||||
<%= link_to 'Download JSON', export_download_path(start_at: @start_at, end_at: @end_at), data: { turbo: false }, class: "px-4 py-2 bg-blue-500 text-white rounded-md" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ Rails.application.routes.draw do
|
|||
mount Sidekiq::Web => '/sidekiq'
|
||||
|
||||
get 'settings/theme', to: 'settings#theme'
|
||||
get 'export', to: 'export#index'
|
||||
get 'export/download', to: 'export#download'
|
||||
|
||||
resources :imports
|
||||
|
|
|
|||
Loading…
Reference in a new issue