diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index a4755f5a..7dbf32fe 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -240,5 +240,12 @@ "permissions": "Permissions", "settings": "Settings", "history": "History" + }, + "history": { + "title": "History and Downloads", + "data_preview": "Data Preview", + "no_data": "No data to display", + "download_selected": "Download Selected Range", + "search_text": "Filter Data Points" } } diff --git a/src/lib/i18n/locales/jp.json b/src/lib/i18n/locales/jp.json index 21571d00..a91baab7 100644 --- a/src/lib/i18n/locales/jp.json +++ b/src/lib/i18n/locales/jp.json @@ -255,5 +255,12 @@ "rename": " ", "new_name": "新しい名前" }, - "close": "閉じる" + "close": "閉じる", + "history": { + "title": "履歴", + "data_preview": "データプレビュー", + "no_data": "データがありません", + "download_selected": "選択したデータをダウンロード", + "search_text": "Filter Data Points" + } } diff --git a/src/routes/(api)/api/v1/devices/[dev_eui]/data/+server.ts b/src/routes/(api)/api/v1/devices/[dev_eui]/data/+server.ts index b1e4d2ba..6193d5d0 100644 --- a/src/routes/(api)/api/v1/devices/[dev_eui]/data/+server.ts +++ b/src/routes/(api)/api/v1/devices/[dev_eui]/data/+server.ts @@ -14,6 +14,7 @@ export const GET: RequestHandler = async ({ url, params, locals: { supabase, saf const from = query.get('from'); const to = query.get('to'); const dataPoints = query.get('data-points'); + const noLimit = query.get('no-limit' || 0); const csv = query.get('csv'); if (!dev_eui) { @@ -31,14 +32,16 @@ export const GET: RequestHandler = async ({ url, params, locals: { supabase, saf .eq('dev_eui', dev_eui) .order('created_at', { ascending: false }) - if (from) { - baseQuery = baseQuery.gte('created_at', moment(from).toISOString()); - } - if (to) { - baseQuery = baseQuery.lte('created_at', moment(to).toISOString()); - } + if (from) { + baseQuery = baseQuery.gte('created_at', moment(from).utc().toISOString()); + } + if (to) { + baseQuery = baseQuery.lte('created_at', moment(to).utc().toISOString()); + } + if (!noLimit) { baseQuery.range(startingPage, startingPage + itemsPerPage - 1); + } // Conditionally apply `.single()` if itemsPerPage is 1 let finalQuery = itemsPerPage === 1 ? baseQuery.single() : baseQuery; diff --git a/src/routes/app/devices/[dev_eui]/history/+page.svelte b/src/routes/app/devices/[dev_eui]/history/+page.svelte index 68ec40db..bfab3be1 100644 --- a/src/routes/app/devices/[dev_eui]/history/+page.svelte +++ b/src/routes/app/devices/[dev_eui]/history/+page.svelte @@ -1,107 +1,118 @@
History -

History and Downloads

+

{$_('history.title')}

@@ -152,9 +167,9 @@ /> -

Data Preview:

+

{$_('history.data_preview')}:

{#if chartKey === 0} -

No data to display

+

{$_('history.no_data')}

{/if} {#key chartKey}
@@ -170,7 +185,9 @@ on:click={() => downloadCSV('sensor')} size="lg" class="w-full" - rounded>Download Selected Range{$_('history.download_selected')}