Browse Source

first take at default timezone option

pull/6/head
sebsel 7 years ago
parent
commit
f40303ff95
4 changed files with 36 additions and 2 deletions
  1. +9
    -1
      compass/app/Http/Controllers/Controller.php
  2. +2
    -0
      compass/database/schema.sql
  3. +1
    -1
      compass/resources/views/map.blade.php
  4. +24
    -0
      compass/resources/views/settings.blade.php

+ 9
- 1
compass/app/Http/Controllers/Controller.php View File

@ -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);
}
}

+ 2
- 0
compass/database/schema.sql View File

@ -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`)

+ 1
- 1
compass/resources/views/map.blade.php View File

@ -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')) {
?>

+ 24
- 0
compass/resources/views/settings.blade.php View File

@ -60,6 +60,30 @@
<br>
<h2>Settings</h2>
<p>Here you can pick a default timezone and system of measurement to display this database in.</p>
<div class="panel">
<form action="/settings/{{ $database->name }}" method="post" class="ui form">
<div class="field">
<label for="timezone">Timezone</label>
<input name="timezone" type="text" class="pure-input-1" value="{{ $database->timezone }}">
</div>
<div class="field">
<label for="metric">System</label>
<select name="metric" class="pure-input-1">
<option value="0" {{ $database->metric ? '' : 'selected' }}>Imperial (miles)</option>
<option value="1" {{ $database->metric ? 'selected' : '' }}>Metric (kilometer)</option>
</select>
</div>
<button type="submit" class="ui button primary">Save</button>
</form>
</div>
<br>
<h2>Realtime Micropub Export</h2>
<p>Enter a Micropub endpoint and token below and any trips that are written to this database will be sent to the endpoint as well.</p>

Loading…
Cancel
Save