Skip to content

Commit

Permalink
added data notation to dashboard, and added notations to location dat…
Browse files Browse the repository at this point in the history
…dapoints
  • Loading branch information
CropWatchDevelopment committed May 9, 2024
1 parent 60ddcd2 commit 8d5313d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/lib/components/ui/dashboardCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -145,7 +146,7 @@
{#each Object.keys(data) as dataPointKey}
<div class="px-3 pb-3 flex border-b">
<p class="basis-1/2 text-base">{$_(dataPointKey)}</p>
<p class="basis-1/2 text-base">{data[dataPointKey]}</p>
<p class="basis-1/2 text-base flex flex-row">{data[dataPointKey]} <span class="text-sm text-slate-500 flex-grow">{nameToNotation(dataPointKey)}</span></p>
</div>
{/each}
{/await}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 24 additions & 0 deletions src/lib/utilities/nameToNotation.ts
Original file line number Diff line number Diff line change
@@ -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 '';
}
}
12 changes: 7 additions & 5 deletions src/routes/app/locations/[location_id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tables<'cw_locations'>> = browser
? fetch(`/api/v1/locations/${$page.params.location_id}`, { method: 'GET' }).then((r) =>
Expand Down Expand Up @@ -107,15 +109,15 @@
{#await getDeviceData(device.dev_eui)}
<ProgressCircle />
{:then dev_data}
<div class="flex flex-col text-center text-neutral-content text-xl">
<h2>{device.cw_devices.name}</h2>
<div class="flex flex-row flex-wrap justify-center">
{#each Object.keys(dev_data) as d}
<div class="flex flex-col text-center text-neutral-content text-xl">
<h2>{device.cw_devices.name}</h2>
<div class="flex flex-row flex-wrap justify-center">
{#each Object.keys(dev_data) as d}
<SquareCard
title={$_(d)}
titleColor={'#4FDE6F'}
value={dev_data[d]}
unit={'ºC'}
unit={nameToNotation(d)}
message={'Status coming soon'}
/>
{/each}
Expand Down

0 comments on commit 8d5313d

Please sign in to comment.