diff --git a/resources/views/tracker.blade.php b/resources/views/tracker.blade.php index d70a79b..673f7ba 100644 --- a/resources/views/tracker.blade.php +++ b/resources/views/tracker.blade.php @@ -20,6 +20,9 @@

@if ($trip->is_active) Where in the World is Ben? @else {{ $trip->name }} @endif

@@ -41,7 +44,13 @@
    - @foreach(array_slice(array_reverse($trip->checkins), 0, 15) as $checkin) + @if($showAllCheckins) + @php $checkinsList = array_reverse($trip->checkins) @endphp + @else + @php $checkinsList = array_slice(array_reverse($trip->checkins), 0, 10) @endphp + @endif + + @foreach($checkinsList as $checkin)
  1. @@ -56,6 +65,9 @@
  2. @endforeach
+ @if ($trip->is_active) +

Show all checkins

+ @endif
@@ -100,11 +112,17 @@ * (to help provide context). */ map.fitBounds([ - @foreach(array_slice(array_reverse($trip->locations), 0, 25) as $location) + @if ($trip->is_active) + @foreach(array_slice(array_reverse($trip->locations), 0, 25) as $location) [{{ $location->latitude }}, {{$location->longitude }}], - @endforeach + @endforeach + @else + @foreach($trip->locations as $location) + [{{ $location->latitude }}, {{$location->longitude }}], + @endforeach + @endif ]); - map.zoomOut(2); + @if ($trip->is_active) map.zoomOut(2.5); @endif /* * Add the current location marker. @@ -123,6 +141,11 @@ ).addTo(map).setZIndexOffset(1000); currLocation.bindPopup('

Current location

').openPopup(); + /* + * Add all checkins link href. + */ + document.getElementById("allCheckinsLink").href = window.location.pathname + '/all'; + /* * Changes the currently-selected popup. */ diff --git a/routes/web.php b/routes/web.php index 1e7ff84..7e0b8f7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -19,7 +19,7 @@ Route::get('/past-trips', function () { return view('past-trips'); }); -Route::get('/{tripId?}', function ($tripId = null) { +Route::get('/{tripId?}/{showAll?}', function ($tripId = null, $showAll = false) { if (!$tripId && !config('app.current_trip_id')) return view('no-trip'); /* @@ -32,7 +32,7 @@ Route::get('/{tripId?}', function ($tripId = null) { $cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at); $now = new DateTime(); if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 5) { - return view('tracker', ['trip' => $cachedData->trip]); + return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($showAll === 'all')]); } } @@ -61,7 +61,7 @@ Route::get('/{tripId?}', function ($tripId = null) { } } - return view('tracker', ['trip' => $data->trip]); + return view('tracker', ['trip' => $data->trip, 'showAllCheckins' => ($showAll === 'all')]); } else { return 'Something went wrong'; }