Compare commits
2 commits
f269b2cd8c
...
3e62eb8d37
Author | SHA1 | Date | |
---|---|---|---|
3e62eb8d37 | |||
1cf3c3004b |
3 changed files with 23 additions and 31 deletions
|
@ -60,13 +60,13 @@ details h2 {
|
|||
.other-links li {
|
||||
background-color: #5adefc;
|
||||
float: left;
|
||||
margin-right: 1.5em;
|
||||
margin-left: 1.5em;
|
||||
border: 2px solid white;
|
||||
border-radius: 1em;
|
||||
}
|
||||
|
||||
.other-links li:first-of-type {
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.other-links li:hover {
|
||||
|
@ -113,6 +113,7 @@ details h2 {
|
|||
grid-column-start: 1;
|
||||
grid-column-end: 3;
|
||||
border-top: 5px solid black;
|
||||
padding: 0 1em;
|
||||
}
|
||||
|
||||
.checkin {
|
||||
|
|
|
@ -65,8 +65,8 @@
|
|||
</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
@if ($trip->is_active)
|
||||
<p><a id="allCheckinsLink" href="#">Show all checkins</a></p>
|
||||
@if (!$showAllCheckins)
|
||||
<p><a id="allCheckinsLink" href="?show=all">Show all checkins</a></p>
|
||||
@endif
|
||||
</section>
|
||||
</main>
|
||||
|
@ -141,11 +141,6 @@
|
|||
).addTo(map).setZIndexOffset(1000);
|
||||
currLocation.bindPopup('<p>Current location</p>').openPopup();
|
||||
|
||||
/*
|
||||
* Add all checkins link href.
|
||||
*/
|
||||
document.getElementById("allCheckinsLink").href = window.location.pathname + '/all';
|
||||
|
||||
/*
|
||||
* Changes the currently-selected popup.
|
||||
*/
|
||||
|
|
|
@ -1,38 +1,34 @@
|
|||
<?php
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::get('/past-trips', function () {
|
||||
return view('past-trips');
|
||||
});
|
||||
|
||||
Route::get('/{tripId?}/{showAll?}', function ($tripId = null, $showAll = false) {
|
||||
Route::get('/{tripId?}', function (Request $request, $tripId = null) {
|
||||
if (!$tripId && !config('app.current_trip_id')) return view('no-trip');
|
||||
|
||||
|
||||
$viewMode = $request->input('show', null);
|
||||
|
||||
/*
|
||||
* If there is a file in the local cache that is less than 5 hours old,
|
||||
* If there is a file in the local cache that is less than 3 hours old,
|
||||
* use that.
|
||||
*/
|
||||
$tripFileName = $tripId ?? config('app.current_trip_id') . '.json';
|
||||
$tripFileName = ( $tripId ?? config('app.current_trip_id') ) . '.json';
|
||||
if (Storage::disk('local')->exists($tripFileName)) {
|
||||
$cachedData = json_decode(Storage::disk('local')->get($tripFileName));
|
||||
$cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at);
|
||||
$now = new DateTime();
|
||||
if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 5) {
|
||||
return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($showAll === 'all')]);
|
||||
if ($cachedData->trip->is_active) {
|
||||
$cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at);
|
||||
$now = new DateTime();
|
||||
if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 3) {
|
||||
return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($viewMode === 'all')]);
|
||||
}
|
||||
} else {
|
||||
return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($viewMode === 'all')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,8 +57,8 @@ Route::get('/{tripId?}/{showAll?}', function ($tripId = null, $showAll = false)
|
|||
}
|
||||
}
|
||||
|
||||
return view('tracker', ['trip' => $data->trip, 'showAllCheckins' => ($showAll === 'all')]);
|
||||
return view('tracker', ['trip' => $data->trip, 'showAllCheckins' => ($viewMode === 'all')]);
|
||||
} else {
|
||||
return 'Something went wrong';
|
||||
}
|
||||
});
|
||||
})->where('tripId', '[0-9a-z]{20}');
|
||||
|
|
Loading…
Reference in a new issue