Skip to content

Add PWA web app#2

Open
Spiruel wants to merge 2 commits into
FindMyCat:mainfrom
Spiruel:main
Open

Add PWA web app#2
Spiruel wants to merge 2 commits into
FindMyCat:mainfrom
Spiruel:main

Conversation

@Spiruel

@Spiruel Spiruel commented Jun 10, 2026

Copy link
Copy Markdown

Adds a Progressive Web App to the cloud repo, served at /cat/ by the existing Traccar instance. It is the path of least resistance in replicating iOS app functionality, and producing a front-end that works on all devices.

No changes to the EMQX or Nginx Proxy Manager configuration. The only changes to the existing stack are one added volume mount in docker-compose.traccar.yml (already present in main) and an extended session timeout in traccar.xml.


Additions:

Web app (web-app/)

Live tracking

  • Full-screen MapLibre GL map (OSM tiles by default, configurable) with per-device emoji markers
  • Real-time position updates via Traccar WebSocket - same logic as the iOS app
  • Browser geolocation
  • Satellite / street map toggle (free Esri World Imagery basemap)

Device management

  • Login with session restore; 7-day session timeout configured in traccar.xml
  • Bottom drawer with tabs: Devices | Zones
  • Add, edit, and delete devices - name, uniqueId, emoji picker (matches iOS CRUD via POST/PUT/DELETE /api/devices with attributes.emoji)
  • Per-device: battery %, relative last-seen (refreshed every 20 s), reverse-geocoded address (Nominatim), online/offline status dot

Commands

  • Sound (ping) and Lost mode per device via Hologram cloud-to-device messaging — device looked up by uniqueId, matching iOS app behaviour
  • Geofence enter/exit toast notifications when the app is open (from Traccar WebSocket events payload)

Zones (geofences)

  • Add zones by tapping the map to place a centre point, then naming the zone and setting a radius
  • Zones render as labelled circles on the map
  • Assign zones to devices; Traccar permissions API manages the links
  • Edit and delete zones

Location history

  • Per-device history view: 1 h / 6 h / 24 h / 7 d presets
  • Renders the track as a polyline + position dots on the map
  • History is always available - Traccar stores all positions server-side continuously, regardless of whether the web app is open

PWA / offline

  • manifest.json + service worker: installable to home screen, cache-first for static assets, network-first for API calls
  • Offline banner when connectivity is lost; cached positions remain visible

UX

  • Logout button, loading overlay, error states with retry, toast notifications for command failures
  • Geofence placement mode (crosshair cursor, dismissible banner)

What is not implemented

  • Push notifications
  • UWB Precise FIind

Test plan

  • ./deploy-webapp.sh user@server — files land in /var/docker/traccar/web/cat/, config.js preserved if it exists
  • https://your-domain.com/cat/ — login screen, session restores on reload
  • Map loads, devices appear as emoji markers, WebSocket open in DevTools → Network → WS
  • Positions update in real time without a page refresh
  • Add device → appears in list and on map; edit name/emoji → reflected; delete → removed
  • Add zone → tap map, fill modal, save → circle appears on map, zone listed in Zones tab
  • Assign zone to device → enter zone with tracker → toast appears in browser
  • History button → track renders for selected time range; "✕ Live" dismisses it
  • Sound / Lost mode → request to /hologram/devices/… returns 200 (requires NPM /hologram/ proxy)
  • Satellite toggle → tiles switch; toggle again → street tiles return
  • Sign out → WebSocket closed (confirm in DevTools: connection gone, no reconnect loop)
  • Mobile Chrome/Safari → "Add to Home Screen" installs PWA, opens in standalone mode

Copilot AI review requested due to automatic review settings June 10, 2026 14:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Introduces a new FindMyCat browser-based PWA served from the Traccar instance, including UI screens (login/home), map + drawer components, Traccar/Hologram API clients, offline caching via service worker, and deployment tooling/config updates.

Changes:

  • Added a full static web app under web-app/ (screens, components, APIs, PWA manifest/service worker, styling).
  • Added local + production deployment support (nginx local proxy config, deploy script, Traccar volume mount).
  • Updated Traccar server configuration to extend session lifetime for better web UX.

Reviewed changes

Copilot reviewed 27 out of 30 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
web-app/src/utils.js Adds a small fetch wrapper with AbortController timeout.
web-app/src/store.js Introduces a minimal reactive state store for the web app.
web-app/src/screens/login.js Adds login screen rendering + async login handling.
web-app/src/screens/home.js Adds main map + drawer screen orchestration, sockets, history, zones.
web-app/src/components/map.js Adds MapLibre-based map wrapper (markers, geofences, history track, placement).
web-app/src/components/geofence-modal.js Adds modal to create/edit zones and assign to devices.
web-app/src/components/drawer.js Adds device/zones drawer UI + reverse-geocode enrichment and actions.
web-app/src/components/device-modal.js Adds modal to create/edit devices with emoji picker.
web-app/src/app.js Adds hash-based routing and startup session bootstrap.
web-app/src/api/traccar.js Adds Traccar REST client + WebSocket client with reconnect.
web-app/src/api/hologram.js Adds Hologram command client (lookup + send message).
web-app/src/api/geocode.js Adds Nominatim reverse geocoding helper with cache/rate limiting.
web-app/service-worker.js Adds offline caching strategy for app assets and some network-first routes.
web-app/nginx-local.conf Adds local nginx config to serve /cat/ and proxy /api + /hologram.
web-app/manifest.json Adds PWA manifest for installability and scoped start URL.
web-app/index.html Adds app shell with MapLibre CDN and module entrypoint.
web-app/dev.sh Adds simple local static dev server for UI-only testing.
web-app/css/app.css Adds full dark-theme styling for screens, drawer, modals, toasts.
web-app/config.js Adds runtime config file (currently committed) for host/keys/tiles.
web-app/config.example.js Adds template config intended for copying into config.js.
web-app/PLAN.md Adds extensive design/architecture/deployment plan documentation.
web-app/DEPLOY.md Adds step-by-step deployment guide for production and local modes.
traccar.xml Extends Traccar session timeout to 7 days.
docker-compose.webapp.yml Adds local nginx container for web-app + proxying to traccar/hologram.
docker-compose.traccar.yml Mounts web app into Traccar web root so it can serve /cat/.
deploy-webapp.sh Adds rsync-based deployment script to push web assets to server.
README.md Expands repo README with stack/deploy/local-dev instructions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web-app/src/api/traccar.js Outdated
Comment on lines +169 to +176
const reconnect = () => {
if (!closed && !unloading) {
timer = setTimeout(connect, 3000);
}
};

ws.onclose = reconnect;
ws.onerror = reconnect;
Comment on lines +167 to +169
export function showTrack(positions) {
if (!_map || !positions?.length) return
const sorted = [...positions].sort((a, b) => new Date(a.fixTime) - new Date(b.fixTime))
Comment thread web-app/config.js
Comment on lines +1 to +7
window.FINDMYCAT_CONFIG = {
traccarHost: "",
hologramApiKey: "",
hologramOrgId: 0,
tileUrl: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
tileAttribution: "&copy; <a href='https://openstreetmap.org'>OpenStreetMap</a> contributors",
};
Comment thread web-app/src/store.js
Comment on lines +30 to +40
* Return the current state object.
* @returns {{ devices: Device[], positions: Position[] }}
*/
export function getState() {
return state;
}

/**
* Merge patch into state and notify all listeners.
* @param {Partial<{ devices: Device[], positions: Position[] }>} patch
*/
Comment thread web-app/src/api/traccar.js Outdated
Comment on lines +6 to +7
const host = window.FINDMYCAT_CONFIG?.traccarHost;
const API = host ? "https://" + host + "/api" : "/api";
Comment on lines +198 to +203
export function toggleMapStyle() {
isSatellite = !isSatellite
const tileUrl = window.FINDMYCAT_CONFIG?.tileUrl || DEFAULT_TILE_URL
_map?.getSource("raster-tiles")?.setTiles([isSatellite ? SAT_TILE_URL : tileUrl])
return isSatellite
}
Comment thread web-app/src/components/drawer.js Outdated
Comment on lines +230 to +233
export function updateZones(geofences, geofenceDevices, devices, callbacks) {
if (geofences !== undefined) lastGeofences = geofences
if (geofenceDevices !== undefined) lastGeofenceDevices = geofenceDevices
if (devices !== undefined && callbacks !== undefined) lastCallbacks = callbacks
return
}

const deviceById = new Map(lastDevices.map(d => [d.id, d]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants