Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).

[![Maintainability](https://qlty.sh/gh/CropWatchDevelopment/projects/CropWatch/maintainability.svg)](https://qlty.sh/gh/CropWatchDevelopment/projects/CropWatch)

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!
Expand Down
14 changes: 14 additions & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,13 +749,27 @@
"display_add_note": "Add Note",
"display_add_note_body": "Add a note for the telemetry entry at {createdAt} with temperature {temperature}°C.",
"display_add_note_title": "Add Note for {createdAt}",
"display_include_in_report": "Include in report",
"display_current_co2": "Current CO2",
"display_current_humidity": "Current Humidity",
"display_current_state": "Current state",
"display_current_temperature": "Current Temperature",
"display_depth": "Depth",
"display_device_data": "Device Data",
"display_enter_note_here": "Enter your note here...",
"display_note_body_label": "Note details",
"display_note_load_failed": "Failed to load notes for the selected month.",
"display_note_loading": "Loading notes…",
"display_note_no_notes_for_date": "No notes for this date.",
"display_note_no_notes_for_month": "No notes found for the selected month.",
"display_note_no_search_results": "No notes match your search.",
"display_note_report_excluded": "Excluded from report",
"display_note_report_included": "Included in report",
"display_note_search_placeholder": "Search notes...",
"display_note_show_only_dates_with_notes": "Show only dates with notes",
"display_note_title_label": "Note title",
"display_note_title_placeholder": "Enter a short title",
"display_note_untitled": "Untitled note",
"display_generic_view": "Generic view",
"display_last_updated": "Last updated",
"display_latest_reading": "Latest reading",
Expand Down
14 changes: 14 additions & 0 deletions messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,13 +749,27 @@
"display_add_note": "メモを追加",
"display_add_note_body": "{createdAt} のテレメトリエントリに、温度 {temperature}°C のメモを追加します。",
"display_add_note_title": "{createdAt} のメモを追加",
"display_include_in_report": "レポートに含める",
"display_current_co2": "現在の CO2",
"display_current_humidity": "現在の湿度",
"display_current_state": "現在の状態",
"display_current_temperature": "現在の温度",
"display_depth": "深さ",
"display_device_data": "デバイスデータ",
"display_enter_note_here": "ここにメモを入力してください...",
"display_note_body_label": "メモ内容",
"display_note_load_failed": "選択した月のメモを読み込めませんでした。",
"display_note_loading": "メモを読み込み中…",
"display_note_no_notes_for_date": "この日付のメモはありません。",
"display_note_no_notes_for_month": "選択した月のメモはありません。",
"display_note_no_search_results": "検索条件に一致するメモはありません。",
"display_note_report_excluded": "レポートに含めない",
"display_note_report_included": "レポートに含める",
"display_note_search_placeholder": "メモを検索...",
"display_note_show_only_dates_with_notes": "メモがある日付のみ表示",
"display_note_title_label": "メモのタイトル",
"display_note_title_placeholder": "短いタイトルを入力してください",
"display_note_untitled": "無題のメモ",
"display_generic_view": "汎用表示",
"display_last_updated": "最終更新",
"display_latest_reading": "最新の読み取り",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"packageManager": "pnpm@10.18.2+sha512.9fb969fa749b3ade6035e0f109f0b8a60b5d08a1a87fdf72e337da90dcc93336e2280ca4e44f2358a649b83c17959e9993e777c2080879f3801e6f0d999ad3dd",
"dependencies": {
"@cropwatchdevelopment/cwui": "0.1.74",
"@cropwatchdevelopment/cwui": "0.1.77",
"@supabase/supabase-js": "^2.98.0"
}
}
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/lib/api/api.dtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ export interface ReportDto {
id: number;
report_id: string;
name: string;
data_pull_interval?: number | null;
dev_eui: string;
created_at: string;
user_id?: string | null;
Expand All @@ -317,6 +318,7 @@ export interface ReportDto {

export interface CreateReportRequest {
created_at?: string;
data_pull_interval?: number;
dev_eui: string;
id?: number;
name: string;
Expand Down
4 changes: 4 additions & 0 deletions src/lib/api/api.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ describe('ApiService created_at timezone handling', () => {
});

await api.createAirNote({
title: 'Fan maintenance',
note: 'Check telemetry row',
include_in_report: true,
created_at: '2026-03-08T07:00:00.000-05:00',
dev_eui: 'device-123'
});

expect(JSON.parse(serializedBody)).toEqual({
title: 'Fan maintenance',
note: 'Check telemetry row',
include_in_report: true,
created_at: '2026-03-08T12:00:00.000Z',
dev_eui: 'device-123'
});
Expand Down
20 changes: 19 additions & 1 deletion src/lib/api/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ const TRIGGERED_RULES_COUNT_ENDPOINT =
const REPORT_HISTORY_ENDPOINT = `${REPORTS_BASE_ENDPOINT}/history/{dev_eui}`;
const REPORT_DOWNLOAD_ENDPOINT = `${REPORTS_BASE_ENDPOINT}/download/{dev_eui}/{report_id}/{reportName}`;
const RULE_BY_ID_ENDPOINT = `${RULES_BASE_ENDPOINT}/{id}`;
const AIR_NOTES_CREATE_ENDPOINT = publicEnv.PUBLIC_AIR_NOTES_ENDPOINT ?? '/air-notes';
const AIR_NOTES_CREATE_ENDPOINT = publicEnv.PUBLIC_AIR_NOTES_ENDPOINT ?? '/air/notes';
const GET_AIR_NOTES_ENDPOINT =
publicEnv.PUBLIC_GET_AIR_NOTES_ENDPOINT ?? '/air/notes/{dev_eui}/month/{month}/year/{year}';
const SOIL_ENDPOINT = '/soil/{dev_eui}';
const TRAFFIC_ENDPOINT = '/traffic/{dev_eui}';
const TRAFFIC_MONTHLY_ENDPOINT = '/traffic/{dev_eui}/monthly';
Expand Down Expand Up @@ -935,6 +937,8 @@ export class ApiService {

public createAirNote(payload: {
note: string;
title: string;
include_in_report: boolean;
created_at: string;
dev_eui: string;
}): Promise<Record<string, unknown> | null> {
Expand All @@ -944,6 +948,20 @@ export class ApiService {
});
}

public getAllAirNotesForMonth(payload: {
dev_eui: string;
date: Date;
}): Promise<Record<string, unknown> | null> {
const requestUrl = replacePathParams(GET_AIR_NOTES_ENDPOINT, {
dev_eui: payload.dev_eui,
month: String(payload.date.getMonth() + 1).padStart(2, '0'),
year: String(payload.date.getFullYear())
});
return this.request<Record<string, unknown> | null>(requestUrl, {
method: 'GET'
});
}

public updateDevice(
devEui: string,
payload: Record<string, unknown>
Expand Down
34 changes: 7 additions & 27 deletions src/lib/components/displays/AirDisplay/AirDisplay.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import type { AirRow } from './interfaces/AirRow.interface';
import type { Note } from './interfaces/note.interface';
import NotesViewDialog from './dialogs/notes-view-dialog.svelte';
import { parseAirNotesResponse } from './utils/air-notes';
import Icon from '$lib/components/Icon.svelte';
import CHECK_CIRCLE_ICON from '$lib/images/icons/check_circle.svg';

Expand All @@ -43,7 +44,7 @@
let noteOverridesByDevice = $state<Record<string, Record<string, Note[]>>>({});
let tableRevision = $state(0);
let noteOverrides = $derived(noteOverridesByDevice[devEui] ?? {});
let hasCo2: boolean = $state(
let hasCo2 = $derived(
historicalData.every((row) => row.co2 !== undefined && row.co2 !== null && row.co2 !== 0)
);

Expand All @@ -57,16 +58,7 @@
dev_eui: String(row.dev_eui ?? ''),
alerts: Array.isArray(row.alerts) ? (row.alerts as AirRow['alerts']) : [],
cw_air_annotations:
noteOverrides[String(row.created_at ?? '')] ??
(Array.isArray(row.cw_air_annotations)
? row.cw_air_annotations.map((annotation) => ({
id: String(
annotation.id ?? `${annotation.created_at ?? 'note'}-${annotation.note ?? index}`
),
note: String(annotation.note ?? ''),
created_at: String(annotation.created_at ?? '')
}))
: [])
noteOverrides[String(row.created_at ?? '')] ?? parseAirNotesResponse(row.cw_air_annotations)
}));
}

Expand Down Expand Up @@ -121,10 +113,7 @@
return Math.sqrt(variance);
})(),
count: historicalData.length,
lastReading:
historicalData.length > 0
? Number(historicalData.at(0)?.temperature_c) || 0
: 0,
lastReading: historicalData.length > 0 ? Number(historicalData.at(0)?.temperature_c) || 0 : 0,
trend: 'up'
};
});
Expand All @@ -147,10 +136,7 @@
return Math.sqrt(variance);
})(),
count: historicalData.length,
lastReading:
historicalData.length > 0
? Number(historicalData.at(0)?.humidity) || 0
: 0,
lastReading: historicalData.length > 0 ? Number(historicalData.at(0)?.humidity) || 0 : 0,
trend: 'up'
};
});
Expand Down Expand Up @@ -361,10 +347,7 @@
return Math.sqrt(variance);
})(),
count: historicalData.length,
lastReading:
historicalData.length > 0
? Number(historicalData.at(0)?.co2) || 0
: 0,
lastReading: historicalData.length > 0 ? Number(historicalData.at(0)?.co2) || 0 : 0,
trend: 'up'
}}
unit="ppm"
Expand Down Expand Up @@ -412,10 +395,7 @@
</div>
</div>

<CwCard
title={m.display_telemetry_table()}
elevated
>
<CwCard title={m.display_telemetry_table()} elevated>
{#key tableKey}
<CwDataTable
{columns}
Expand Down
Loading
Loading