From f40303ff95f0c8722e493dfb7ed528e913a40ad6 Mon Sep 17 00:00:00 2001 From: sebsel Date: Mon, 10 Jul 2017 23:59:28 +0200 Subject: [PATCH] first take at default timezone option --- compass/app/Http/Controllers/Controller.php | 10 ++++++++- compass/database/schema.sql | 2 ++ compass/resources/views/map.blade.php | 2 +- compass/resources/views/settings.blade.php | 24 +++++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/compass/app/Http/Controllers/Controller.php b/compass/app/Http/Controllers/Controller.php index 77b4f7f..a4ccb5f 100644 --- a/compass/app/Http/Controllers/Controller.php +++ b/compass/app/Http/Controllers/Controller.php @@ -96,7 +96,7 @@ class Controller extends BaseController ], 'range_from' => $request->input('from') ?: '', 'range_to' => $request->input('to') ?: '', - 'range_tz' => $request->input('tz') ?: 'America/Los_Angeles' + 'range_tz' => $request->input('tz') ?: $db->timezone ]); } @@ -188,6 +188,14 @@ class Controller extends BaseController 'ping_urls' => $request->input('ping_urls'), ]); + return redirect('/settings/'.$db->name); + } else if($request->input('timezone')) { + DB::table('databases')->where('id', $db->id) + ->update([ + 'timezone' => $request->input('timezone'), + 'metric' => $request->input('metric'), + ]); + return redirect('/settings/'.$db->name); } } diff --git a/compass/database/schema.sql b/compass/database/schema.sql index 12c5d9b..5e5d275 100644 --- a/compass/database/schema.sql +++ b/compass/database/schema.sql @@ -15,6 +15,8 @@ CREATE TABLE `databases` ( `micropub_endpoint` varchar(255) NOT NULL, `micropub_token` varchar(1024) NOT NULL, `ping_urls` varchar(1024) NOT NULL, + `timezone` varchar(100) NOT NULL DEFAULT 'UTC', + `metric` boolean NOT NULL DEFAULT 1, PRIMARY KEY (`id`), KEY `read_token` (`read_token`), KEY `write_token` (`write_token`) diff --git a/compass/resources/views/map.blade.php b/compass/resources/views/map.blade.php index d120a04..2eadcba 100644 --- a/compass/resources/views/map.blade.php +++ b/compass/resources/views/map.blade.php @@ -35,7 +35,7 @@ $days = array_fill(1,31,['#']); $start = new DateTime('2008-05-30T00:00:00-0800'); $end = new DateTime(); - $end->setTimeZone(new DateTimeZone('America/Los_Angeles')); + $end->setTimeZone(new DateTimeZone($database->timezone)); $i = clone $start; while((int)$i->format('Y') <= (int)$end->format('Y') && (int)$i->format('M') <= (int)$end->format('M')) { ?> diff --git a/compass/resources/views/settings.blade.php b/compass/resources/views/settings.blade.php index b334d00..59d64f2 100644 --- a/compass/resources/views/settings.blade.php +++ b/compass/resources/views/settings.blade.php @@ -60,6 +60,30 @@
+

Settings

+ +

Here you can pick a default timezone and system of measurement to display this database in.

+ +
+
+
+ + +
+ +
+ + +
+ + +
+
+
+

Realtime Micropub Export

Enter a Micropub endpoint and token below and any trips that are written to this database will be sent to the endpoint as well.