Skip to content

Commit

Permalink
translations
Browse files Browse the repository at this point in the history
  • Loading branch information
CropWatchDevelopment committed May 7, 2024
1 parent 07c2a45 commit 9c3012a
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 72 deletions.
63 changes: 33 additions & 30 deletions src/lib/components/rules/Rules.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -121,61 +121,64 @@
<input type="hidden" id="dev_eui" name="dev_eui" bind:value={$page.params.dev_eui} />
<div class="mx-4 flex flex-col gap-4">
<div>
<label for="name" class="text-surface-100">Rule Name:</label>
<TextField label="Name" id="name" name="name" required bind:value={ruleGroup.ruleName} />
<label for="name" class="text-surface-100">{$_('rules.rule_name')}:</label>
<TextField label={$_('rules.ruleName')} id="name" name="name" required bind:value={ruleGroup.ruleName} />
</div>

<div class="m-4">
<p class="text-surface-100">{$_('rules.rule_criteria')}:</p>
{#await dataItem}
loading data items
{:then dataItem}
{#if ruleGroup.cw_rule_criteria.length == 0}
<p class="text-surface-100 text-center">{$_('rules.no_rule_criteria')}</p>
{:else}
{#each ruleGroup.cw_rule_criteria as singleRule, i}
<SubRule bind:root={singleRule} dataItem={dataItem}>
<!-- <button on:click={() => onDelete(i)} color="danger">Delete</button> -->
</SubRule>
AND
{/each}
{/if}
{/await}

<div class="flex flex-row mt-4">
<Button on:click={() => onAdd()} icon={mdiPlus} variant="outline" color="success"
>{$_('rules.add_condition_button')}</Button
>
</div>
</div>

<div>
<label for="type" class="text-surface-100">Notification Type:</label>
<label for="type" class="text-surface-100">{$_('rules.notification_type')}:</label>
<SelectField
bind:value={ruleGroup.babylon_notifier_type}
name="babylon_notifier_type"
id="babylon_notifier_type_control"
options={[
{ value: 1, label: '1' },
{ value: 2, label: '2' }
{ value: 1, label: $_('rules.notification_email') },
{ value: 2, label: 'SMS' }
]}
/>
</div>

<div>
<label for="action_recipient" class="text-surface-100">Recipient(s):</label>
<div class="mb-4">
<label for="action_recipient" class="text-surface-100">{$_('rules.recipients')}:</label>
<TextField
label="Name"
label={$_('rules.emails')}
id="action_recipient"
name="action_recipient"
required
bind:value={ruleGroup.action_recipient}
/>
</div>
</div>
<div class="m-4">
<p class="text-surface-100">{$_('rules.rule_criteria')}:</p>
{#await dataItem}
loading data items
{:then dataItem}
{#if ruleGroup.cw_rule_criteria.length == 0}
<p class="text-surface-100 text-center">{$_('rules.no_rule_criteria')}</p>
{:else}
{#each ruleGroup.cw_rule_criteria as singleRule, i}
<SubRule bind:root={singleRule} dataItem={dataItem}>
<!-- <button on:click={() => onDelete(i)} color="danger">Delete</button> -->
</SubRule>
{/each}
{/if}
{/await}
</div>
<div class="flex flex-row my-4">
<Button on:click={() => onAdd()} icon={mdiPlus} variant="outline" color="success"
>Add condition</Button
>
</div>

<Button
type="submit"
disabled={!ruleGroup.cw_rule_criteria || ruleGroup.cw_rule_criteria.length == 0}
variant="fill"
color="primary"
class="w-full">{isNew ? 'Create' : 'Update'}</Button
class="w-full">{isNew ? $_('rules.create') : 'Update'}</Button
>
</form>
21 changes: 11 additions & 10 deletions src/lib/components/rules/SubRule.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { uuidv4 } from '$lib/utilities/uuidv4';
import { SelectField, TextField } from 'svelte-ux';
import type { Tables } from '../../../database.types';
import { _ } from 'svelte-i18n';
// export const latestData;
export let root: Tables<'cw_rule_criteria'>;
Expand All @@ -19,23 +20,23 @@
<div class="flex flex-col gap-2">
<div class="flex flex-row gap-1 justify-between">
<div>
<label for="action_recipient" class="text-surface-100">IF </label>
<label for="action_recipient" class="text-surface-100">{$_('rules.if')} </label>
<SelectField
classes={{ root: 'w-full' }}
placeholder="Sensor Data To Watch"
label="Data"
placeholder={$_('rules.select_data')}
label={$_('rules.data')}
bind:value={root.subject}
options={Object.keys(dataItem ?? {}).map((key) => {
return { label: key, value: key };
return { label: $_(key), value: key };
})}
/>
</div>

<div>
<label for="action_recipient" class="text-surface-100">IS </label>
<label for="action_recipient" class="text-surface-100">{$_('rules.is')}</label>
<SelectField
class="w-20"
label="Operator"
label={$_('rules.operator')}
bind:value={root.operator}
options={[
{ value: '=', label: '=' },
Expand All @@ -49,15 +50,15 @@
</div>

<div>
<label for="action_recipient" class="text-surface-100">Value: </label>
<TextField type="decimal" label="Trigger Value" bind:value={root.trigger_value} />
<label for="action_recipient" class="text-surface-100">{$_('rules.thresholdValue')}: </label>
<TextField type="decimal" label={$_('rules.trigger_value')} bind:value={root.trigger_value} />
</div>
</div>
<div>
<label for="action_recipient" class="text-surface-100"
>And Reset when {root.subject} Return to:
>{$_('rules.and_reset_when')} {$_(root.subject)} {$_('rules.returns_to')}:
</label>
<TextField type="decimal" label="Reset Rule Value" bind:value={root.reset_value} />
<TextField type="decimal" label={$_('rules.reset_rule_value')} bind:value={root.reset_value} />
</div>
</div>
</div>
19 changes: 10 additions & 9 deletions src/lib/components/ui/DevicePermission.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { mdiAccount, mdiPlus, mdiTrashCan } from '@mdi/js';
import { toast } from '@zerodevx/svelte-toast';
import { Button, ListItem, SelectField, TextField } from 'svelte-ux';
import { _ } from 'svelte-i18n';
export let devEui;
export let permissions;
Expand Down Expand Up @@ -71,29 +72,29 @@
>
<input type="hidden" name="dev_eui" value={devEui} />
<div>
<label for="email" class="text-surface-100">Email:</label>
<TextField name="email" label="User E-Mail" />
<label for="email" class="text-surface-100">{$_('permissions.email')}:</label>
<TextField name="email" label={$_('permissions.user_email')} />
</div>
<div>
<label for="role" class="text-surface-100">Role: {permission_level}</label>
<label for="role" class="text-surface-100">{$_('permissions.role')}:</label>
<input type="hidden" name="permission_level" value={permission_level} />
<SelectField
label="Role"
label={$_('permissions.role')}
id="permission_level"
bind:value={permission_level}
options={[
{ value: '1', label: 'Admin (view, Edit, Update, Delete)' },
{ value: '2', label: 'User (view data, Download Data' },
{ value: '3', label: 'Viewer (view data only)' }
{ value: '1', label: $_('permissions.admin') },
{ value: '2', label: $_('permissions.user') },
{ value: '3', label: $_('permissions.viewer') }
]}
/>
</div>
<Button variant="fill" type="submit" icon={mdiPlus} color="primary" class="mt-2 w-full"
>Add Permission</Button
>{$_('permissions.add_permission')}</Button
>
</form>

<p class="text-surface-100 mt-5 mb-2">The following logins have access to this device:</p>
<p class="text-surface-100 mt-5 mb-2">{$_('permissions.following_have_access')}:</p>
<ul>
{#each permissions as permission}
<ListItem
Expand Down
12 changes: 8 additions & 4 deletions src/lib/components/ui/dashboardCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import thermometerImage from '$lib/images/UI/cw_thermometer.png';
import moistureImage from '$lib/images/UI/cw_moisture.png';
import { onMount } from 'svelte';
import { Button, Card, Collapse, ProgressCircle } from 'svelte-ux';
import { Button, Card, Collapse, Icon, ProgressCircle } from 'svelte-ux';
import { get, writable } from 'svelte/store';
import { isDayTime } from '$lib/utilities/isDayTime';
import { goto } from '$app/navigation';
import { mdiEye } from '@mdi/js';
import { mdiArrowRight, mdiArrowRightCircle, mdiEye, mdiLink } from '@mdi/js';
import { _ } from 'svelte-i18n';
import moment from 'moment';
Expand Down Expand Up @@ -80,7 +80,11 @@
</div>
</a>
<div class="pl-2 pt-2">
<h2 class="text-xl my-3">{locationName ?? '--'}</h2>
<h2 class="text-xl my-3 flex flex-row">
{locationName ?? '--'}
<span class="flex flex-grow" />
<Button variant="outline" color="primary" icon={mdiArrowRight} on:click={() => goto(`app/locations/${locationId}`)} />
</h2>
<div class="flex">
<p class="basis-1/3"></p>
<div class="basis-1/3 text-xs flex flex-row justify-center">
Expand Down Expand Up @@ -134,7 +138,7 @@
{#if device.data}
{#await latestDeviceData(device)}
<div class="w-full h-full flex flex-row justify-center my-1">
<ProgressCircle /> {$_('app.loading')}
<ProgressCircle /> {$_('app.loading_message')}
</div>
{:then data}
{#each Object.keys(data) as dataPointKey}
Expand Down
37 changes: 35 additions & 2 deletions src/lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,47 @@
"new_rule": "New Rule",
"no_rules_created": "You have not created any rules for this sensor yet.",
"rule_criteria": "Rule Criteria",
"no_rule_criteria": "No Rule Criteria yet..."
"no_rule_criteria": "No Rule Criteria yet...",
"title": "Rules and custom alerts",
"loadingRules": "Loading Rules",
"rule_name": "Rule Name",
"notification_email": "E-Mail",
"notification_type": "Notification Type",
"recipients": "Recipient(s)",
"emails": "E-Mail Address(s)",
"ruleName": "name",
"and_reset_when": "And Re-Activate rule when",
"returns_to": "returns to",
"trigger_value": "Trigger Value",
"data": "Data",
"reset_rule_value": "Reset Value",
"operator": "Operator",
"if": "IF",
"is": "IS",
"select_data": "Sensor Data to Watch",
"thresholdValue": "Value",
"add_condition_button": "Add Condition",
"create": "Create"
},
"dashboardCard": {
"Rainfall": "Rainfall",
"Humidity": "Humidity",
"Windspeed": "Windspeed",
"PrimaryData": "Primary Data",
"secondaryData": "Secondary Data",
"Details": "Details"
"Details": "Details",
"primaryData": "Primary Data",
"dashboard": "Dashboard"
},
"permissions": {
"permissions": "Device Permissions",
"email": "E-Mail",
"user_email": "User E-Mail",
"following_have_access": "The following users have access to this device",
"role": "Select a Role",
"admin": "Admin (View, Edit, Update, Delete)",
"user": "User (View Data, Download Data)",
"viewer": "Viewer (Read Data Only)",
"add_permission": "Add Permission"
}
}
42 changes: 36 additions & 6 deletions src/lib/i18n/locales/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,35 @@
"permissions": "権限"
},
"rules": {
"title": "ルール設定",
"description": "新規ルールの作成または既存ルールの編集は以下から。",
"no_rules_created": "このセンサーのルールはまだ作成されていません。",
"new_rule": "ルールの追加",
"edit_rule": "編集",
"delete_rule": "削除",
"rule_statistics": "統計"
"rule_statistics": "統計",
"loadingRules": "ルールを読み込んでいます...",
"rule_name": "ルール名",
"notification_email": "Eメール",
"notification_type": "通知タイプ",
"recipients": "受信者",
"emails": "Eメール",
"rule_criteria": "ルール条件",
"ruleName": "名称",
"no_rule_criteria": "ルール条件がありません",
"and_reset_when": "そして、",
"returns_to": "が戻ったらルールを再び有効にする (リセット数値の設定なしではルールは一度しか適用されません。)",
"trigger_value": "閾値",
"data": "データ",
"reset_rule_value": "ルール値のリセット",
"operator": "演算子",
"if": "もし",
"is": "",
"select_data": "監視するセンサーデータ",
"thresholdValue": "",
"add_condition_button": "条件の追加",
"create": "作成"
},



"temperature": "温度",
"humidity": "湿度",
"soil_moisture": "土壌水分量",
Expand All @@ -200,10 +219,21 @@
"soil_PH": "土壌pH",
"soil_pH": "土壌pH",
"time": "時間",
"lastSeen": "最後に閲覧",
"lastSeen": "最終接続",
"ago": "",
"optimal": "最適",
"difference": "",
"temp_humidity": "温度/湿度",
"filter": "フィルター"
"filter": "フィルター",
"permissions": {
"permissions": "デバイス権限",
"email": "Eメール",
"user_email": "Eメール",
"role": "役割を選択する",
"admin": "管理者(閲覧、編集、更新、削除)",
"user": "ユーザー(データ閲覧、データダウンロード)",
"viewer": "閲覧者(データ閲覧のみ)",
"add_permission": "アクセス許可",
"following_have_access": "次のユーザーはこのデバイスにアクセスできます。"
}
}
19 changes: 12 additions & 7 deletions src/routes/app/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import DashboardCard from '$lib/components/ui/dashboardCard.svelte';
import bellImage from '$lib/images/UI/cw-bell.svg';
import filterImage from '$lib/images/UI/cw_filter_button.svg';
import { mdiViewDashboard } from '@mdi/js';
import { _ } from 'svelte-i18n';
import { Icon } from 'svelte-ux';
export let data;
const { locations } = data;
</script>
Expand All @@ -14,26 +16,29 @@

<section>
<div class="px-4">
<!-- JSON -->
<!-- JSON -->
<!-- BELL -->
<div class="py-1 my-5">
<div class="flex justify-end w-full h-7">
<!-- <div class="flex justify-end w-full h-7">
<img src={bellImage} alt="" />
</div>
</div> -->
</div>

<!-- TITLE and Filter -->
<div class="flex justify-between mb-6">
<!-- TITLE -->
<h2 class=" font-light text-2xl text-surface-100">{$_('dashboardCard.dashboard')}</h2>
<h2 class=" font-light text-2xl text-surface-100">
<Icon data={mdiViewDashboard} class="w-6 h-6" />
{$_('dashboardCard.dashboard')}
</h2>

<!-- Filter -->
<div class="flex align-baseline justify-center items-center">
<!-- <div class="flex align-baseline justify-center items-center">
<div class="w-3">
<img src={filterImage} alt="" />
</div>
<p class="text-surface-100 px-1">{$_('filter')}</p>
</div>
<p class="text-surface-100 px-1">{$_('filter')}</p>
</div> -->
</div>
<!-- CARDS -->
{#each locations as location}
Expand Down
Loading

0 comments on commit 9c3012a

Please sign in to comment.