Compare commits

..

No commits in common. "3e62eb8d376f7c19eac8d9a74fba7fc3c591cf99" and "f269b2cd8c570282d47f14dfa15e7aee89d30946" have entirely different histories.

3 changed files with 31 additions and 23 deletions

View file

@ -60,13 +60,13 @@ details h2 {
.other-links li { .other-links li {
background-color: #5adefc; background-color: #5adefc;
float: left; float: left;
margin-left: 1.5em; margin-right: 1.5em;
border: 2px solid white; border: 2px solid white;
border-radius: 1em; border-radius: 1em;
} }
.other-links li:first-of-type { .other-links li:first-of-type {
margin-left: 0; margin-right: 0;
} }
.other-links li:hover { .other-links li:hover {
@ -113,7 +113,6 @@ details h2 {
grid-column-start: 1; grid-column-start: 1;
grid-column-end: 3; grid-column-end: 3;
border-top: 5px solid black; border-top: 5px solid black;
padding: 0 1em;
} }
.checkin { .checkin {

View file

@ -65,8 +65,8 @@
</li> </li>
@endforeach @endforeach
</ol> </ol>
@if (!$showAllCheckins) @if ($trip->is_active)
<p><a id="allCheckinsLink" href="?show=all">Show all checkins</a></p> <p><a id="allCheckinsLink" href="#">Show all checkins</a></p>
@endif @endif
</section> </section>
</main> </main>
@ -141,6 +141,11 @@
).addTo(map).setZIndexOffset(1000); ).addTo(map).setZIndexOffset(1000);
currLocation.bindPopup('<p>Current location</p>').openPopup(); 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. * Changes the currently-selected popup.
*/ */

View file

@ -1,34 +1,38 @@
<?php <?php
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Storage; 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 () { Route::get('/past-trips', function () {
return view('past-trips'); return view('past-trips');
}); });
Route::get('/{tripId?}', function (Request $request, $tripId = null) { Route::get('/{tripId?}/{showAll?}', function ($tripId = null, $showAll = false) {
if (!$tripId && !config('app.current_trip_id')) return view('no-trip'); 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 3 hours old, * If there is a file in the local cache that is less than 5 hours old,
* use that. * use that.
*/ */
$tripFileName = ( $tripId ?? config('app.current_trip_id') ) . '.json'; $tripFileName = $tripId ?? config('app.current_trip_id') . '.json';
if (Storage::disk('local')->exists($tripFileName)) { if (Storage::disk('local')->exists($tripFileName)) {
$cachedData = json_decode(Storage::disk('local')->get($tripFileName)); $cachedData = json_decode(Storage::disk('local')->get($tripFileName));
if ($cachedData->trip->is_active) {
$cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at); $cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at);
$now = new DateTime(); $now = new DateTime();
if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 3) { if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 5) {
return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($viewMode === 'all')]); return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($showAll === 'all')]);
}
} else {
return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($viewMode === 'all')]);
} }
} }
@ -57,8 +61,8 @@ Route::get('/{tripId?}', function (Request $request, $tripId = null) {
} }
} }
return view('tracker', ['trip' => $data->trip, 'showAllCheckins' => ($viewMode === 'all')]); return view('tracker', ['trip' => $data->trip, 'showAllCheckins' => ($showAll === 'all')]);
} else { } else {
return 'Something went wrong'; return 'Something went wrong';
} }
})->where('tripId', '[0-9a-z]{20}'); });