This commit is contained in:
gsinghpal
2026-03-01 14:42:49 -05:00
parent b925766966
commit a3e85a23ef
28 changed files with 2283 additions and 195 deletions

View File

@@ -180,7 +180,21 @@ export class FusionClockKiosk extends Interaction {
lat = pos.coords.latitude;
lng = pos.coords.longitude;
} catch {
// GPS unavailable on kiosk device
// Native GPS unavailable -- try IP geolocation
}
if (lat === 0 && lng === 0) {
try {
const ipResp = await fetch("https://ipapi.co/json/");
if (ipResp.ok) {
const ipData = await ipResp.json();
if (ipData.latitude && ipData.longitude) {
lat = ipData.latitude;
lng = ipData.longitude;
}
}
} catch {
// IP geolocation also unavailable
}
}
const resp = await fetch("/fusion_clock/kiosk/clock", {

View File

@@ -199,15 +199,22 @@ export class FusionClockPortal extends Interaction {
(pos) => {
this._performClockAction(pos.coords.latitude, pos.coords.longitude, pos.coords.accuracy);
},
(err) => {
async () => {
let lat = 0, lng = 0;
try {
const ipResp = await fetch("https://ipapi.co/json/");
if (ipResp.ok) {
const ipData = await ipResp.json();
if (ipData.latitude && ipData.longitude) {
lat = ipData.latitude;
lng = ipData.longitude;
}
}
} catch {
// IP geolocation also unavailable
}
this._hideGPSOverlay();
let msg = "Could not get your location. ";
if (err.code === 1) msg += "Please allow location access.";
else if (err.code === 2) msg += "Location unavailable.";
else if (err.code === 3) msg += "Location request timed out.";
this._showToast(msg, "error");
this._shakeButton();
btn.disabled = false;
this._performClockAction(lat, lng, lat ? 5000 : 0);
},
{ enableHighAccuracy: true, timeout: 15000, maximumAge: 0 }
);

View File

@@ -398,10 +398,23 @@ export class FusionClockPortalFAB extends Interaction {
lat = pos.coords.latitude;
lng = pos.coords.longitude;
acc = pos.coords.accuracy;
} catch (geoErr) {
this._showError("Location access denied. Please enable GPS.");
if (this.actionBtn) this.actionBtn.disabled = false;
return;
} catch {
// Native GPS unavailable (common on desktops) -- try IP geolocation
}
}
if (lat === 0 && lng === 0) {
try {
const ipResp = await fetch("https://ipapi.co/json/");
if (ipResp.ok) {
const ipData = await ipResp.json();
if (ipData.latitude && ipData.longitude) {
lat = ipData.latitude;
lng = ipData.longitude;
acc = 5000;
}
}
} catch {
// IP geolocation also unavailable
}
}

View File

@@ -134,10 +134,23 @@ export class FusionClockFAB extends Component {
lat = pos.coords.latitude;
lng = pos.coords.longitude;
acc = pos.coords.accuracy;
} catch (geoErr) {
this.state.error = "Location access denied.";
this.state.loading = false;
return;
} catch {
// Native GPS unavailable (common on desktops) -- try IP geolocation
}
}
if (lat === 0 && lng === 0) {
try {
const ipResp = await fetch("https://ipapi.co/json/");
if (ipResp.ok) {
const ipData = await ipResp.json();
if (ipData.latitude && ipData.longitude) {
lat = ipData.latitude;
lng = ipData.longitude;
acc = 5000;
}
}
} catch {
// IP geolocation also unavailable
}
}