Move trip to partial

This commit is contained in:
Eugene Burmakin 2024-11-28 16:11:04 +01:00
parent 71cd9d507b
commit 5c09e5b0f9
8 changed files with 47 additions and 48 deletions

View file

@ -5,7 +5,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
# 0.17.1 - 2024-11-27
# 0.18.0 - 2024-11-28
## The Trips release
You can now create, edit and delete trips. To create a trip, click on the "New Trip" button on the Trips page. Provide a name, date and time for start and end of the trip. You can add your own notes to the trip as well.
If you have points tracked during provided timeframe, they will be automatically added to the trip and will be shown on the trip map.
Also, if you have Immich integrated, you will see photos from the trip on the trip page, along with a link to look at them on Immich.
### Added
- The Trips feature. Read above for more details.
### Changed
- Maps are now not so rough on the edges.
# 0.17.2 - 2024-11-27
### Fixed

View file

@ -1,2 +0,0 @@
module TripsHelper
end

View file

@ -22,7 +22,7 @@ class Trip < ApplicationRecord
user,
start_date: started_at.to_date.to_s,
end_date: ended_at.to_date.to_s
).call
).call.reject { |asset| asset['type'].downcase == 'video' }
# let's count what photos are more: vertical or horizontal and select the ones that are more
vertical_photos = immich_photos.select { _1['exifInfo']['orientation'] == '6' }

View file

@ -52,7 +52,7 @@ class Immich::RequestPhotos
page += 1
end
data.flatten.reject { |asset| asset['type'].downcase == 'video' }
data.flatten
end
def headers

View file

@ -1,2 +1,24 @@
<div id="<%= dom_id trip %>">
</div>
<%= link_to trip, class: "block hover:shadow-lg rounded-lg" do %>
<div class="card bg-base-200 shadow-xl hover:shadow-2xl transition-shadow duration-200" data-trip-id="<%= trip.id %>" id="trip-<%= trip.id %>">
<div class="card-body">
<h2 class="card-title justify-center">
<span class="hover:underline"><%= trip.name %></span>
</h2>
<p class="text-sm text-gray-600 text-center">
<%= "#{human_date(trip.started_at)} #{human_date(trip.ended_at)}, #{trip.distance} #{DISTANCE_UNIT}" %>
</p>
<div style="width: 100%; aspect-ratio: 1/1;"
id="map-<%= trip.id %>"
class="rounded-lg"
data-controller="trip-map"
data-trip-map-trip-id-value="<%= trip.id %>"
data-trip-map-coordinates-value="<%= trip.points.pluck(:latitude, :longitude, :battery, :altitude, :timestamp, :velocity, :id, :country).to_json %>"
data-trip-map-api-key-value="<%= current_user.api_key %>"
data-trip-map-user-settings-value="<%= current_user.settings.to_json %>"
data-trip-map-timezone-value="<%= Rails.configuration.time_zone %>"
data-trip-map-distance-unit-value="<%= DISTANCE_UNIT %>">
</div>
</div>
</div>
<% end %>

View file

@ -27,30 +27,7 @@
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 my-4">
<% @trips.each do |trip| %>
<%= link_to trip, class: "block hover:shadow-lg rounded-lg" do %>
<div class="card bg-base-200 shadow-xl hover:shadow-2xl transition-shadow duration-200" data-trip-id="<%= trip.id %>" id="trip-<%= trip.id %>">
<div class="card-body">
<h2 class="card-title justify-center">
<span class="hover:underline"><%= trip.name %></span>
</h2>
<p class="text-sm text-gray-600 text-center">
<%= "#{human_date(trip.started_at)} #{human_date(trip.ended_at)}, #{trip.distance} #{DISTANCE_UNIT}" %>
</p>
<div style="width: 100%; aspect-ratio: 1/1;"
id="map-<%= trip.id %>"
class="rounded-lg"
data-controller="trip-map"
data-trip-map-trip-id-value="<%= trip.id %>"
data-trip-map-coordinates-value="<%= trip.points.pluck(:latitude, :longitude, :battery, :altitude, :timestamp, :velocity, :id, :country).to_json %>"
data-trip-map-api-key-value="<%= current_user.api_key %>"
data-trip-map-user-settings-value="<%= current_user.settings.to_json %>"
data-trip-map-timezone-value="<%= Rails.configuration.time_zone %>"
data-trip-map-distance-unit-value="<%= DISTANCE_UNIT %>">
</div>
</div>
</div>
<% end %>
<%= render 'trip', trip: trip %>
<% end %>
</div>
<% end %>

View file

@ -3,7 +3,6 @@
require 'sidekiq/web'
Rails.application.routes.draw do
resources :trips
mount ActionCable.server => '/cable'
mount Rswag::Api::Engine => '/api-docs'
mount Rswag::Ui::Engine => '/api-docs'
@ -31,6 +30,7 @@ Rails.application.routes.draw do
resources :visits, only: %i[index update]
resources :places, only: %i[index destroy]
resources :exports, only: %i[index create destroy]
resources :trips
resources :points, only: %i[index] do
collection do
delete :bulk_destroy

16
db/schema.rb generated
View file

@ -196,21 +196,6 @@ ActiveRecord::Schema[7.2].define(version: 2024_11_28_095325) do
t.index ["user_id"], name: "index_trips_on_user_id"
end
create_table "user_digests", force: :cascade do |t|
t.bigint "user_id", null: false
t.integer "kind", default: 0, null: false
t.datetime "start_at", null: false
t.datetime "end_at"
t.integer "distance", default: 0, null: false
t.text "countries", default: [], array: true
t.text "cities", default: [], array: true
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["distance"], name: "index_user_digests_on_distance"
t.index ["kind"], name: "index_user_digests_on_kind"
t.index ["user_id"], name: "index_user_digests_on_user_id"
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
@ -253,7 +238,6 @@ ActiveRecord::Schema[7.2].define(version: 2024_11_28_095325) do
add_foreign_key "points", "visits"
add_foreign_key "stats", "users"
add_foreign_key "trips", "users"
add_foreign_key "user_digests", "users"
add_foreign_key "visits", "areas"
add_foreign_key "visits", "places"
add_foreign_key "visits", "users"