This commit is contained in:
Fred Boniface 2024-07-02 20:16:57 +01:00
parent d09b24655a
commit 95e45c8cb1
7 changed files with 33 additions and 33 deletions

View File

@ -12,18 +12,17 @@
function turnOnLocation() {
location.set(true);
toast("To disable location, go to settings")
toast("To disable location, go to settings");
}
async function getNearestStations() {
const currLocation = await getCurrentLocation();
console.debug(`Current Latitude: ${currLocation.latitude}, Current Longitude: ${currLocation.longitude}`)
const apiPath = `/api/v2/live/station/nearest/${currLocation.latitude}/${currLocation.longitude}`
const res = await apiGet(apiPath)
console.log(res)
return res as any[]
console.debug(`Current Latitude: ${currLocation.latitude}, Current Longitude: ${currLocation.longitude}`);
const apiPath = `/api/v2/live/station/nearest/${currLocation.latitude}/${currLocation.longitude}`;
const res = await apiGet(apiPath);
console.log(res);
return res as any[];
}
</script>
<Island {variables}>
@ -38,13 +37,13 @@
<p>Fetching Location</p>
{:then stations}
<div id="buttons">
{#each stations as station}
<a class="link" href="/ldb?station={station["3ALPHA"]}">{station.NLCDESC} - {station.miles}mi</a>
{/each}
{#each stations as station}
<a class="link" href="/ldb?station={station['3ALPHA']}">{station.NLCDESC} - {station.miles}mi</a>
{/each}
</div>
{:catch err}
<p>Error: {err.message}</p>
{/await}
{/await}
{/if}
</Island>
@ -90,5 +89,5 @@
color: var(--island-link-color);
box-shadow: var(--box-shadow);
white-space: nowrap;
}
</style>
}
</style>

View File

@ -1,8 +1,8 @@
export async function getCurrentLocation(): Promise<locationObj> {
console.debug("Fetching location");
if (typeof window === 'undefined') {
console.error("Location fetch has run serverside - invalid method")
if (typeof window === "undefined") {
console.error("Location fetch has run serverside - invalid method");
}
if (!navigator.geolocation) {
@ -29,11 +29,11 @@ export async function getCurrentLocation(): Promise<locationObj> {
reject(error);
}
);
options
options;
});
}
export interface locationObj {
latitude: number
longitude: number
latitude: number;
longitude: number;
}

View File

@ -1,16 +1,16 @@
// src/stores.js
import { writable, type Writable } from 'svelte/store';
import { browser } from '$app/environment';
import { writable, type Writable } from "svelte/store";
import { browser } from "$app/environment";
// Initialize the store with a boolean value from local storage
export const location: Writable<boolean> = writable(fromLocalStorage('location', false));
toLocalStorage(location, 'location');
export const location: Writable<boolean> = writable(fromLocalStorage("location", false));
toLocalStorage(location, "location");
function fromLocalStorage(storageKey: string, fallback: boolean): boolean {
if (browser) {
const storedValue = localStorage.getItem(storageKey);
if (storedValue !== null && storedValue !== 'undefined') {
return storedValue === 'true';
if (storedValue !== null && storedValue !== "undefined") {
return storedValue === "true";
}
}
return fallback;
@ -23,4 +23,3 @@ function toLocalStorage(store: Writable<boolean>, storageKey: string) {
});
}
}

View File

@ -34,6 +34,7 @@
--overlay-island-bg-color: #3c6f79;
--box-shadow-color: rgba(0, 0, 0, 0.19);
--box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.19);
--box-shadow-dark: 2px 2px 4px rgba(0, 0, 0, 0.392);
--main-alert-color: #ed6d00;
--second-alert-color: #e77f00;
--main-warning-color: orange;

View File

@ -28,7 +28,10 @@
</p>
<p>The email server may store the address and message content as part of its regular operation, and your consent to this is implied when you sign up.</p>
<p>In addition to the host portion of your email address, a randomly generated UUID is stored for the purpose of authorizing access to the rail staff data.</p>
<p>If you enable location data, your location will be sent to the server when you navigate to the homepage to determine your closest stations. This data is never stored on the server after the nearest stations have been send to your device.</p>
<p>
If you enable location data, your location will be sent to the server when you navigate to the homepage to determine your closest stations. This data is never stored on the
server after the nearest stations have been send to your device.
</p>
<h2>Reporting an Issue</h2>
<p>When you report an issue, certain data is collected, including your browser's User Agent string and the size of the window in which you are viewing the website.</p>
<p>

View File

@ -9,11 +9,11 @@
const title = "Settings";
$: if ($location) {
getCurrentLocation()
getCurrentLocation();
}
function locationToast() {
toast("Settings updated")
toast("Settings updated");
}
</script>
@ -21,11 +21,11 @@
<QlSet />
<Island variables={{title: "Location"}}>
<Island variables={{ title: "Location" }}>
<p>Use your location to quickly check departure boards near you</p>
<div class="checkbox-container">
<label for="location_enable">Enabled</label>
<input id="location_enable" type="checkbox" bind:checked={$location} on:click={locationToast}>
<input id="location_enable" type="checkbox" bind:checked={$location} on:click={locationToast} />
</div>
</Island>

View File

@ -51,9 +51,7 @@
<p>
<Tooltip text="Go"><IconBrandGolang /></Tooltip>
<br />
<a class="data" href="https://git.fjla.uk/owlboard/mq-client" target="_blank"
>timetable-mgr<br /><span class="data">{data?.["mq-client"] || "Not installed"}</span></a
>
<a class="data" href="https://git.fjla.uk/owlboard/mq-client" target="_blank">timetable-mgr<br /><span class="data">{data?.["mq-client"] || "Not installed"}</span></a>
</p>
</Island>
{:catch}