Skip to content

Commit

Permalink
Merge pull request #164 from dbrgn/csv-import
Browse files Browse the repository at this point in the history
CSV Import
  • Loading branch information
dbrgn authored Mar 31, 2024
2 parents 323cbcb + 49fa550 commit 4139478
Show file tree
Hide file tree
Showing 18 changed files with 1,891 additions and 10 deletions.
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ anyhow = "1"
base64 = "0.22"
chrono = { version = "0.4", features = ["serde"] }
clap = "4"
csv = "1.3.0"
diesel = { version = "2.1.4", features = ["postgres", "chrono"] }
diesel-geography = { version = "0.2", features = ["serde"], git = "https://github.com/66np/diesel-geography", rev = "059c553" }
diesel_migrations = { version = "2", features = ["postgres"] }
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/lib/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export function formatTime(time: Date): string {
return time.toISOString().slice(11, 16);
}

/**
* Format a datetime as "YYYY-mm-dd hh:mm".
*/
export function formatDateTime(datetime: Date): string {
return `${formatDate(datetime)} ${formatTime(datetime)}`;
}

/**
* Format a distance in km.
*
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
<a href="mailto:flugbuech@bargen.dev">flugbuech@bargen.dev</a>.
</p>

<h4 class="title is-size-5">Can I import or export flights?</h4>
<p class="content">Data import from CSV is possible. Export is not yet implemented.</p>

<h4 class="title is-size-5">Where can I find the source code or report bugs?</h4>
<p class="content">On <a href="https://github.com/dbrgn/flugbuech">GitHub</a>.</p>

Expand All @@ -79,9 +82,14 @@
<h3 class="title is-size-3">News</h3>
<h4 class="title is-size-5">2024</h4>
<ul class="content">
<li>
<strong>1.4.</strong> Do you have a lot of old flights logged in a spreadsheet application (like
Excel or Google Sheets), and don't want to type all this information into Flugbuech by hand? In
that case, try the new <a href="/flights/import/csv/">CSV import</a>!
</li>
<li>
<strong>19.3.</strong> You can now opt-in to an occasional newsletter
<a href="/profile/">in your user profile</a>!
<a href="/profile/">in your user profile</a>.
</li>
<li>
<strong>13.3.</strong> After a longer development break, the complete Flugbuech UI has been
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/routes/flights/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,12 @@
<p class="content">
You've logged {data.flights.length} flight{data.flights.length === 1 ? '' : 's'} so far!
</p>
<p class="content">

<p class="content" style="display: flex; justify-content: space-between;">
<a href="/flights/add/" class="button is-primary">Add flight</a>
<a href="/flights/import/csv/" class="button is-light">Import from CSV</a>
</p>

<table class="table is-fullwidth is-striped is-hoverable">
<thead>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/flights/FlightForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
// Form values
// Note: Values for number inputs must allow null!
let files: FileList | undefined = undefined;
let igcBase64: string | undefined = undefined;
let files: FileList | undefined;
let igcBase64: string | undefined;
let number: number | null = flight?.number ?? null;
let glider: number | undefined = flight?.gliderId ?? lastGliderId;
// Note: For the select input value binding to work correctly, entries from `locations` must be
Expand Down
Loading

0 comments on commit 4139478

Please sign in to comment.