diff --git a/src/lib/components/ui/dashboardCard.svelte b/src/lib/components/ui/dashboardCard.svelte index 634b90fa..99a7c5c2 100644 --- a/src/lib/components/ui/dashboardCard.svelte +++ b/src/lib/components/ui/dashboardCard.svelte @@ -13,6 +13,7 @@ import { _ } from 'svelte-i18n'; import moment from 'moment'; import EditLocationNameDialog from './EditLocationNameDialog.svelte'; + import { nameToNotation } from '$lib/utilities/nameToNotation'; export let data; const locationId = data.location_id; @@ -145,7 +146,7 @@ {#each Object.keys(data) as dataPointKey}

{$_(dataPointKey)}

-

{data[dataPointKey]}

+

{data[dataPointKey]} {nameToNotation(dataPointKey)}

{/each} {/await} diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index dfb15fce..a4755f5a 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -59,7 +59,8 @@ "app": { "loading_message": "Loading Content...", "loading_translations_message": "Loading Translations...", - "loading": "Loading..." + "loading": "Loading...", + "devices": "Devices" }, "location": { "map_card_title": "Overview Map" diff --git a/src/lib/utilities/nameToNotation.ts b/src/lib/utilities/nameToNotation.ts new file mode 100644 index 00000000..69a633dd --- /dev/null +++ b/src/lib/utilities/nameToNotation.ts @@ -0,0 +1,24 @@ +export const nameToNotation = (name: string) => { + switch (name) { + case 'humidity': + case 'soil_moisture': + return '%'; + case 'temperature': + case 'soil_temperatureC': + return '°C'; + case 'soil_EC': + return 'dS/m'; + case 'soil_N': + return 'mg/kg'; + case 'soil_P': + return 'mg/kg'; + case 'soil_K': + return 'mg/kg'; + case 'soil_PH': + return 'pH'; + case 'co2_level': + return 'ppm'; + default: + return ''; + } +} \ No newline at end of file diff --git a/src/routes/app/locations/[location_id]/+page.svelte b/src/routes/app/locations/[location_id]/+page.svelte index 636e3a7a..897ff029 100644 --- a/src/routes/app/locations/[location_id]/+page.svelte +++ b/src/routes/app/locations/[location_id]/+page.svelte @@ -11,6 +11,8 @@ import { mdiMoleculeCo2 } from '@mdi/js'; import DarkCard2 from '$lib/components/ui/DarkCard2.svelte'; import SquareCard from '$lib/components/ui/SquareCard.svelte'; + import { json } from '@sveltejs/kit'; + import { nameToNotation } from '$lib/utilities/nameToNotation'; const location: Promise> = browser ? fetch(`/api/v1/locations/${$page.params.location_id}`, { method: 'GET' }).then((r) => @@ -107,15 +109,15 @@ {#await getDeviceData(device.dev_eui)} {:then dev_data} -
-

{device.cw_devices.name}

-
- {#each Object.keys(dev_data) as d} +
+

{device.cw_devices.name}

+
+ {#each Object.keys(dev_data) as d} {/each}