Change exposed volume

This commit is contained in:
Eugene Burmakin 2024-06-12 21:02:42 +02:00
parent 3f68ce5e37
commit 7daac8a887
8 changed files with 146 additions and 65 deletions

View file

@ -5,6 +5,51 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.6.0] — 2024-06-12
### Added
- Exports page to list existing exports download them or delete them
### Changed
- Exporting process now is done in the background, so user can close the browser tab and come back later to download the file. The status of the export can be checked on the Exports page.
Deleting Export file will only delete the file, not the points in the database.
⚠️ BREAKING CHANGES: ⚠️
Volume, exposed to the host machine for placing files to import was changed. See the changes below.
Path for placing files to import was changed from `tmp/imports` to `public/imports`.
```diff
...
dawarich_app:
image: freikin/dawarich:latest
container_name: dawarich_app
volumes:
- gem_cache:/usr/local/bundle/gems
- - tmp:/var/app/tmp
+ - public:/var/app/public/imports
...
```
```diff
...
volumes:
db_data:
gem_cache:
shared_data:
- tmp:
+ public:
```
---
## [0.5.3] — 2024-06-10 ## [0.5.3] — 2024-06-10
### Added ### Added

File diff suppressed because one or more lines are too long

View file

@ -1,32 +1,47 @@
<% content_for :title, "Exports" %> <% content_for :title, "Exports" %>
<div class="w-full"> <div class="w-full">
<div class="flex justify-between items-center"> <div class="flex justify-between items-center mb-5">
<h1 class="font-bold text-4xl">Exports</h1> <h1 class="font-bold text-4xl">Exports</h1>
</div> </div>
<div id="imports" class="min-w-full"> <div id="exports" class="min-w-full">
<div class="overflow-x-auto"> <% if @exports.empty? %>
<table class="table"> <div class="hero min-h-80 bg-base-200">
<thead> <div class="hero-content text-center">
<tr> <div class="max-w-md">
<th>Name</th> <h1 class="text-5xl font-bold">Hello there!</h1>
<th>Status</th> <p class="py-6">
<th>Actions</th> Here you'll find your exports, created on <%= link_to 'Points', points_url, class: 'link' %> page. But now there are none.
</tr> </p>
</thead> </div>
<tbody> </div>
<% @exports.each do |export| %> </div>
<% else %>
<div class="overflow-x-auto">
<table class="table">
<thead>
<tr> <tr>
<td><%= export.name %></td> <th>Name</th>
<td><%= export.status %></td> <th>Status</th>
<td> <th>Actions</th>
<%= link_to 'Download', export.url, class: "px-4 py-2 bg-blue-500 text-white rounded-md", download: export.name %>
<%= link_to 'Delete', export, data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?", turbo_method: :delete }, method: :delete, class: "px-4 py-2 bg-red-500 text-white rounded-md" %>
</tr> </tr>
<% end %> </thead>
</tbody> <tbody>
</table> <% @exports.each do |export| %>
</div> <tr>
<td><%= export.name %></td>
<td><%= export.status %></td>
<td>
<% if export.completed? %>
<%= link_to 'Download', export.url, class: "px-4 py-2 bg-blue-500 text-white rounded-md", download: export.name %>
<% end %>
<%= link_to 'Delete', export, data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?", turbo_method: :delete }, method: :delete, class: "px-4 py-2 bg-red-500 text-white rounded-md" %>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</div> </div>
</div> </div>

View file

@ -5,33 +5,46 @@
</div> </div>
<div id="imports" class="min-w-full"> <div id="imports" class="min-w-full">
<div class="overflow-x-auto"> <% if @imports.empty? %>
<table class="table"> <div class="hero min-h-80 bg-base-200">
<!-- head --> <div class="hero-content text-center">
<thead> <div class="max-w-md">
<tr> <h1 class="text-5xl font-bold">Hello there!</h1>
<th>Name</th> <p class="py-6">
<th>Processed</th> Here you'll find your imports, But now there are none. Let's <%= link_to 'create one', new_import_path, class: 'link' %>!
<th>Doubles</th> </p>
<th>Created at</th> </div>
</tr> </div>
</thead> </div>
<tbody> <% else %>
<% @imports.each do |import| %> <div class="overflow-x-auto">
<table class="table">
<!-- head -->
<thead>
<tr> <tr>
<td> <th>Name</th>
<%= link_to import.name, import, class: 'underline hover:no-underline' %> (<%= import.source %>) <th>Processed</th>
</td> <th>Doubles</th>
<td> <th>Created at</th>
<%= "✅" if import.processed == import.raw_points %>
<%= "#{import.processed}/#{import.raw_points}" %>
</td>
<td><%= import.doubles %></td>
<td><%= import.created_at.strftime("%d.%m.%Y, %H:%M") %></td>
</tr> </tr>
<% end %> </thead>
</tbody> <tbody>
</table> <% @imports.each do |import| %>
</div> <tr>
<td>
<%= link_to import.name, import, class: 'underline hover:no-underline' %> (<%= import.source %>)
</td>
<td>
<%= "✅" if import.processed == import.raw_points %>
<%= "#{import.processed}/#{import.raw_points}" %>
</td>
<td><%= import.doubles %></td>
<td><%= import.created_at.strftime("%d.%m.%Y, %H:%M") %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</div> </div>
</div> </div>

View file

@ -8,11 +8,24 @@
<p class='mb-3'>Import takes a while to finish, so you might want to run it in <code>screen</code> session.</p> <p class='mb-3'>Import takes a while to finish, so you might want to run it in <code>screen</code> session.</p>
<p>1. Upload your Records.json file to your server</p> <p class='mt-5 mb-2'>1. Upload your Records.json file to your server</p>
<p>2. Copy you Records.json to the <code>tmp</code> folder: <code>$ docker cp Records.json dawarich_app:/var/app/tmp/Records.json</code></p> <p class='mt-5 mb-2'>2. Copy you Records.json to the <code>tmp</code> folder:
<p>3. Attach to the docker container: <code>$ docker exec -it dawarich_app sh</code></p> <div class="mockup-code">
<p>4. Run the rake task: <code>$ bundle exec rake import:big_file['tmp/Records.json','user@example.com']</code></p> <pre data-prefix="$"><code>docker cp Records.json dawarich_app:/var/app/public/imports/Records.json</code></pre>
<p>5. Wait patiently for process to finish</p> </div>
</p>
<p class='mt-5 mb-2'>3. Attach to the docker container:
<div class="mockup-code">
<pre data-prefix="$"><code>docker exec -it dawarich_app sh</code></pre>
</div>
</p>
<p class='mt-5 mb-2'>4. Run the rake task:
<div class="mockup-code">
<pre data-prefix="$"><code>bundle exec rake import:big_file['public/imports/Records.json','user@example.com']</code>
</pre>
</div>
</p>
<p class='mt-5 mb-2'>5. Wait patiently for process to finish</p>
<p class='mt-3'>You can monitor progress in <a href="/sidekiq" class="underline">Sidekiq UI</a></p> <p class='mt-3'>You can monitor progress in <a href="/sidekiq" class="underline">Sidekiq UI</a></p>
</span> </span>

View file

@ -21,27 +21,22 @@
</div> </div>
<div class="w-full md:w-2/12"> <div class="w-full md: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 "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" %> <%= 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-gray-500 text-white rounded-md" %>
</div> </div>
</div> </div>
<div class="w-full md:w-2/12"> <div class="w-full md: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 "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" %> <%= 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" %>
</div> </div>
</div> </div>
<div class="w-full md:w-2/12"> <div class="w-full md: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", 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" %> <%= 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" %>
</div> </div>
</div> </div>
</div> </div>
<% end %> <% end %>
<div role="alert" class="alert alert-warning">
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>
<span>Warning: Starting release 0.4.0 it's HIGHLY RECOMMENDED to switch from <code>/api/v1/points</code> to <code>/api/v1/owntracks/points</code> API endpoint. Please read more at <a href="https://github.com/Freika/dawarich/releases/tag/0.4.0" class='underline hover:no-underline'>0.4.0 release notes</a></span>
</div>
<div <div
class="w-full" class="w-full"
data-controller="maps" data-controller="maps"

View file

@ -22,7 +22,7 @@
</div> </div>
<div class="w-full md:w-2/6"> <div class="w-full md:w-2/6">
<div class="flex flex-col space-y-2 text-center"> <div class="flex flex-col space-y-2 text-center">
<%= link_to 'Export points', exports_path(start_at: @start_at, end_at: @end_at), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points withing timeframe, selected between 'Start at' and 'End at' inputs", turbo_method: :post }, class: "px-4 py-2 bg-blue-500 text-white rounded-md" %> <%= link_to 'Export points', exports_path(start_at: @start_at, end_at: @end_at), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points withing timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "px-4 py-2 bg-green-500 text-white rounded-md" %>
</div> </div>
</div> </div>
</div> </div>

View file

@ -25,7 +25,7 @@ services:
container_name: dawarich_app container_name: dawarich_app
volumes: volumes:
- gem_cache:/usr/local/bundle/gems - gem_cache:/usr/local/bundle/gems
- tmp:/var/app/tmp - public:/var/app/public
networks: networks:
- dawarich - dawarich
ports: ports:
@ -78,4 +78,4 @@ volumes:
db_data: db_data:
gem_cache: gem_cache:
shared_data: shared_data:
tmp: public: