From a5525800d1bbcd6caa6c705509997d99d998a2af Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Sun, 18 Feb 2024 16:36:27 +0000 Subject: [PATCH 1/6] build: update deployment scripts --- package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d92b69e..9d6cd59 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,11 @@ "private": true, "scripts": { "dev": "vite", - "build": "vite build && rsync --delete -rP app artisan bootstrap composer.* config database lang public resources routes storage tests vendor ovhvps:~/track", + "build": "vite build", + "deploy": "rsync --delete -rP app artisan bootstrap composer.* config database lang resources routes storage tests ovhvps:~/track", + "deploy:public": "rsync --delete -rP public ovhvps:~/track", + "deploy:dependencies": "rsync --delete -rP vendor ovhvps:~/track", + "deploy:full": "npm run deploy && npm run deploy:public && npm run deploy:dependencies", "sync": "rsync -rP ./public/ ovhvps:~/track/public", "lint": "npm run lint:php; npm run lint:css", "lint:fix": "npm run lint:php:fix; npm run lint:css:fix", From ad30ee40d44c3c28b03cf723429d52abdf89fb0e Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Thu, 14 Mar 2024 19:24:18 +0100 Subject: [PATCH 2/6] build: update deployment commands --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9d6cd59..513dbcc 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "deploy": "rsync --delete -rP app artisan bootstrap composer.* config database lang resources routes storage tests ovhvps:~/track", "deploy:public": "rsync --delete -rP public ovhvps:~/track", "deploy:dependencies": "rsync --delete -rP vendor ovhvps:~/track", - "deploy:full": "npm run deploy && npm run deploy:public && npm run deploy:dependencies", - "sync": "rsync -rP ./public/ ovhvps:~/track/public", + "deploy:full": "npm run deploy && npm run deploy:public && npm run deploy:dependencies && npm run deploy:finish", + "deploy:finish": "ssh ovhvps 'cd track && docker compose down && docker system prune -f && docker compose up -d --build'", "lint": "npm run lint:php; npm run lint:css", "lint:fix": "npm run lint:php:fix; npm run lint:css:fix", "lint:php": "./vendor/bin/phpcs", From 26cf793943737ceb1ee92bccf78da2ddcb84772a Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Thu, 14 Mar 2024 19:25:31 +0100 Subject: [PATCH 3/6] feat: add fullscreen map --- resources/views/partials/head.blade.php | 2 ++ resources/views/tracker.blade.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/views/partials/head.blade.php b/resources/views/partials/head.blade.php index ed889c7..b1313c0 100644 --- a/resources/views/partials/head.blade.php +++ b/resources/views/partials/head.blade.php @@ -18,6 +18,8 @@ + + @vite(['resources/css/app.css', 'resources/js/app.js']) diff --git a/resources/views/tracker.blade.php b/resources/views/tracker.blade.php index 54086a9..5f2fc7d 100644 --- a/resources/views/tracker.blade.php +++ b/resources/views/tracker.blade.php @@ -52,7 +52,7 @@ /* * Initialise the map */ - var map = L.map('map'); + var map = L.map('map', { fullscreenControl: true }); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: 'OpenStreetMap' From fa80def46cbc76fd3dfb924c4e46aa990a2641a3 Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Thu, 14 Mar 2024 19:31:28 +0100 Subject: [PATCH 4/6] lint: run linter --- app/Console/Kernel.php | 2 +- app/Http/Controllers/TrackerController.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index c3a692a..a536563 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -30,7 +30,7 @@ class Kernel extends ConsoleKernel }); $schedule->command('digest:send --fortnightly') - ->twiceMonthly(1,16,'13:00') + ->twiceMonthly(1, 16, '13:00') ->onFailure(function () { Log::error("Fortnightly email digest send failed"); }); diff --git a/app/Http/Controllers/TrackerController.php b/app/Http/Controllers/TrackerController.php index 217db2c..3e0e5d1 100644 --- a/app/Http/Controllers/TrackerController.php +++ b/app/Http/Controllers/TrackerController.php @@ -49,7 +49,8 @@ class TrackerController extends Controller return view( 'error', [ - 'message' => "App timed out whilst downloading trip data from Wayward's servers. They may be down currently." + 'message' => "App timed out whilst downloading trip data" . + " from Wayward's servers. They may be down currently." ] ); } @@ -145,7 +146,7 @@ class TrackerController extends Controller // Otherwise, download the trip data from the Wayward API. if ($forceDownload) { Log::debug("Forcing download for '{$tripFileName}'."); - Storage::disk('local')->delete($tripFileName); + Storage::disk('local')->delete($tripFileName); } else { Log::debug("No cached trip file found for '{$tripFileName}'."); } @@ -230,9 +231,9 @@ class TrackerController extends Controller $dlng = (($result & 1) ? ~($result >> 1) : ($result >> 1)); $lng += $dlng; - array_push($points, (object)[ + array_push($points, (object)[ 'id' => $id++, - 'latitude' => $lat/100000, + 'latitude' => $lat/100000, 'longitude' => $lng/100000 ]); } From 56bc41f2079dfac482e5b33664ddba657228d027 Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Thu, 14 Mar 2024 20:11:07 +0100 Subject: [PATCH 5/6] ignore backup folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 71ab168..1851e34 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /public/*/videos /public/*/audio /storage/*.key +/backup /vendor .phpunit.result.cache Homestead.json From 28971a88763b887ed52c2616a044edc6e7f2d80a Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Thu, 14 Mar 2024 20:11:55 +0100 Subject: [PATCH 6/6] fix: show open checkin on map --- resources/views/tracker.blade.php | 94 ++++++++++++++++--------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/resources/views/tracker.blade.php b/resources/views/tracker.blade.php index 5f2fc7d..ce9a09a 100644 --- a/resources/views/tracker.blade.php +++ b/resources/views/tracker.blade.php @@ -16,9 +16,9 @@

Tracking started: {!! render_date_difference($trip->date_start) !!} | - {{ ($trip->is_active) ? "Active" : "Ended" }} | + {{ ($trip->is_active) ? "Active" : "Ended" }} | @if ($trip->is_active) - {{ ($trip->is_tracking) ? "Currently tracking" : "Not currently tracking" }} + {{ ($trip->is_tracking) ? "Currently tracking" : "Not currently tracking" }} @endif (Last update: {!! render_date_difference($trip->updated_at) !!})

@@ -82,7 +82,7 @@ /* * Populate all the checkins and popup texts. - * + */ var checkinMarkers = []; var marker = null, popupMarkup = null; var markerIcon = L.icon({ @@ -94,43 +94,44 @@ shadowUrl: "images/marker-shadow.png", tooltipAnchor: [16, -28] }); - @foreach($trip->checkins as $checkin) - marker = L.marker([{{ $checkin->location->latitude }}, {{ $checkin->location->longitude }}], - { - icon: markerIcon - }).addTo(map); - - @php $popupContent = null; @endphp - @php - $embed = null; - if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) { - if (preg_match("/\.webm/", $filepath[1])) { - $embed = ''; - } elseif (preg_match("/\.ogg/", $filepath[1])) { - $embed = ''; - } - $checkin->note = preg_replace("/\[\[[^\]]+\]\]/", $embed, $checkin->note); - } - @endphp - @php $popupContent =''; @endphp - - popupMarkup = ``; - popupMarkup += `{!! $popupContent !!}`; - @if($checkin->image_url) - popupMarkup += ''; - @endif - marker.bindPopup(popupMarkup).openPopup(); - - checkinMarkers[{{ $checkin->id }}] = marker; + @foreach($trip->checkins as $checkin) + marker = L.marker([{{ $checkin->location->latitude }}, {{ $checkin->location->longitude }}], + { + icon: markerIcon + }); + + @php + $popupContent = null; + $embed = null; + if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) { + if (preg_match("/\.webm/", $filepath[1])) { + $embed = ''; + } elseif (preg_match("/\.ogg/", $filepath[1])) { + $embed = ''; + } + $checkin->note = preg_replace("/\[\[[^\]]+\]\]/", $embed, $checkin->note); + } + $popupContent =''; + @endphp + + popupMarkup = ``; + popupMarkup += `{!! $popupContent !!}`; + @if($checkin->image_url) + popupMarkup += ''; + @endif + marker.bindPopup(popupMarkup).openPopup(); + + checkinMarkers[{{ $checkin->id }}] = marker; @endforeach - */ + /* * Fit the map to the last 25 locations, and then zoom out * (to help provide context). @@ -139,11 +140,11 @@ @if ($trip->is_active) @foreach(array_slice(array_reverse($trip->checkins), 0, 25) as $checkin) [{{ $checkin->location->latitude }}, {{$checkin->location->longitude }}], - @endforeach + @endforeach @else @foreach($trip->locations as $location) [{{ $location->latitude }}, {{$location->longitude }}], - @endforeach + @endforeach @endif ]); @if ($trip->is_active) map.zoomOut(2.5); @endif @@ -152,7 +153,6 @@ * Add the current location marker. * * If this goes before the `fitBounds()`, it ends up uncentered. - * TODO: Revisit once fixed with other popups. */ var currLocationMarker = L.icon({ iconUrl: 'images/current-location-icon.png', @@ -165,24 +165,26 @@ icon: currLocationMarker } ).addTo(map).setZIndexOffset(1000); - currLocation.bindPopup('

Current location

').openPopup(); + @if($trip->is_active) currLocation.bindPopup('

Current location

').openPopup(); @endif /* * Changes the currently-selected popup. */ function toggleCheckin(isOpen, checkinId) { if (isOpen) { - var checkins = document.querySelectorAll('details'); + const checkins = document.querySelectorAll('details'); checkinMarkers[checkinId].openPopup(); + checkinMarkers[checkinId].addTo(map); - checkins.forEach(checkin => { + for (checkin of checkins) { if (checkin.id != checkinId && checkin.open) checkin.open = false; - }); - console.log(checkinMarkers[checkinId].getLatLng()); + } + map.setView(new L.LatLng(checkinMarkers[checkinId].getLatLng().lat + 0.03, checkinMarkers[checkinId].getLatLng().lng)); } else { checkinMarkers[checkinId].closePopup(); + checkinMarkers[checkinId].removeFrom(map); } }