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
44 changes: 43 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -986,5 +986,47 @@
"rule_action_forever_acknowledge_responsibility": "You are responsible for periodically verifying that this device remains in the correct state. CropWatch will not change it back for you.",
"rule_action_forever_acknowledge_option": "I understand and accept responsibility for monitoring this device.",
"rule_action_forever_acknowledge_confirm": "I Understand, Continue",
"rule_action_revert_on_reset": "Revert relay state when the rule resets"
"rule_action_revert_on_reset": "Revert relay state when the rule resets",
"sensor_temperature": "Temperature",
"sensor_humidity": "Humidity",
"sensor_moisture": "Moisture",
"sensor_co2": "CO₂",
"sensor_co": "CO",
"sensor_pressure": "Pressure",
"sensor_ec": "Electrical Conductivity",
"sensor_ph": "pH",
"sensor_depth": "Depth",
"sensor_battery": "Battery",
"sensor_voltage": "Voltage",
"sensor_current": "Current",
"sensor_watts": "Power",
"sensor_rainfall": "Rainfall",
"sensor_wind_speed": "Wind Speed",
"sensor_wind_direction": "Wind Direction",
"sensor_lux": "Light",
"sensor_uv_index": "UV Index",
"sensor_smoke_detected": "Smoke Detected",
"sensor_vape_detected": "Vape Detected",
"sensor_spo2": "SpO₂",
"sensor_relay_1": "Relay 1",
"sensor_relay_2": "Relay 2",
"sensor_people_count": "People",
"sensor_car_count": "Vehicles",
"sensor_value_on": "ON",
"sensor_value_off": "OFF",
"sensor_value_true": "Yes",
"sensor_value_false": "No",
"dashboard_view_table": "Table",
"dashboard_view_cards": "Cards",
"dashboard_no_devices": "No devices to display.",
"dashboard_no_data_yet": "No data yet",
"dashboard_loading_details": "Loading details…",
"dashboard_column_name": "Device",
"dashboard_column_location": "Location",
"dashboard_column_group": "Group",
"dashboard_column_primary": "Primary",
"dashboard_column_secondary": "Secondary",
"dashboard_column_last_updated": "Last Updated",
"dashboard_load_more": "Load more",
"dashboard_no_location": "No Location"
}
44 changes: 43 additions & 1 deletion messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -986,5 +986,47 @@
"rule_action_forever_acknowledge_responsibility": "このデバイスが正しい状態にあることを定期的に確認する責任は、お客様にあります。CropWatchが自動で元に戻すことはありません。",
"rule_action_forever_acknowledge_option": "このデバイスの監視責任を理解し、引き受けます。",
"rule_action_forever_acknowledge_confirm": "理解しました、続行",
"rule_action_revert_on_reset": "ルールがリセットされた時にリレーの状態を元に戻す"
"rule_action_revert_on_reset": "ルールがリセットされた時にリレーの状態を元に戻す",
"sensor_temperature": "温度",
"sensor_humidity": "湿度",
"sensor_moisture": "水分量",
"sensor_co2": "CO₂",
"sensor_co": "CO",
"sensor_pressure": "気圧",
"sensor_ec": "電気伝導度",
"sensor_ph": "pH",
"sensor_depth": "水深",
"sensor_battery": "バッテリー",
"sensor_voltage": "電圧",
"sensor_current": "電流",
"sensor_watts": "電力",
"sensor_rainfall": "降水量",
"sensor_wind_speed": "風速",
"sensor_wind_direction": "風向",
"sensor_lux": "照度",
"sensor_uv_index": "UV指数",
"sensor_smoke_detected": "煙検出",
"sensor_vape_detected": "蒸気検出",
"sensor_spo2": "SpO₂",
"sensor_relay_1": "リレー 1",
"sensor_relay_2": "リレー 2",
"sensor_people_count": "人数",
"sensor_car_count": "車両数",
"sensor_value_on": "オン",
"sensor_value_off": "オフ",
"sensor_value_true": "はい",
"sensor_value_false": "いいえ",
"dashboard_view_table": "テーブル",
"dashboard_view_cards": "カード",
"dashboard_no_devices": "表示するデバイスがありません。",
"dashboard_no_data_yet": "データがまだありません",
"dashboard_loading_details": "詳細を読み込み中…",
"dashboard_column_name": "デバイス",
"dashboard_column_location": "場所",
"dashboard_column_group": "グループ",
"dashboard_column_primary": "主要",
"dashboard_column_secondary": "補助",
"dashboard_column_last_updated": "最終更新",
"dashboard_load_more": "さらに読み込む",
"dashboard_no_location": "場所未設定"
}
59 changes: 59 additions & 0 deletions src/lib/api/api.dtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,65 @@ export interface LatestPrimaryDataQuery extends PaginationQuery {
name?: string;
}

export interface DashboardQuery extends PaginationQuery {
group?: string;
locationGroup?: string;
location?: string;
name?: string;
}

export interface DashboardDeviceType {
id: number;
name: string;
data_table_v2: string;
primary_data_v2: string;
secondary_data_v2: string;
default_upload_interval: number | null;
}

export interface DashboardLocation {
location_id: number;
name: string;
group: string | null;
}

export interface DashboardLatest {
created_at: string | null;
primary: number | string | boolean | null;
secondary: number | string | boolean | null;
}

export interface DashboardRow {
dev_eui: string;
name: string;
group: string | null;
upload_interval: number | null;
last_data_updated_at: string | null;
device_type: DashboardDeviceType;
location: DashboardLocation | null;
latest: DashboardLatest | null;
}

export interface DashboardPage {
rows: DashboardRow[];
total: number;
skip: number;
take: number;
}

export interface DashboardLocationGroup {
key: string;
location: DashboardLocation | null;
devices: DashboardRow[];
}

export interface DashboardLocationPage {
groups: DashboardLocationGroup[];
total: number;
skip: number;
take: number;
}

export interface SensorTimeSeriesPoint {
created_at: string;
dev_eui: string;
Expand Down
55 changes: 55 additions & 0 deletions src/lib/api/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import type {
CreateLocationRequest,
CreateReportRequest,
CreateRuleRequest,
DashboardLocationPage,
DashboardPage,
DashboardQuery,
DeviceDataWithinRangeQuery,
DeviceListQuery,
DeviceDto,
Expand Down Expand Up @@ -116,6 +119,9 @@ const DEVICE_BY_DEV_EUI_ENDPOINT = '/devices/{dev_eui}';
const DEVICE_DATA_ENDPOINT = '/devices/{dev_eui}/data';
const DEVICE_DATA_WITHIN_RANGE_ENDPOINT = '/devices/{dev_eui}/data-within-range';
const DEVICE_LATEST_DATA_ENDPOINT = '/devices/{dev_eui}/latest-data';
const DASHBOARD_DEVICES_ENDPOINT = '/dashboard/devices';
const DASHBOARD_LOCATIONS_ENDPOINT = '/dashboard/locations';
const DASHBOARD_DEVICE_LATEST_ENDPOINT = '/dashboard/devices/{dev_eui}/latest';
const LOCATIONS_ENDPOINT = '/locations';
const LOCATION_BY_ID_ENDPOINT = '/locations/{id}';
const LOCATION_PERMISSION_ENDPOINT = '/locations/{id}/permission';
Expand Down Expand Up @@ -839,6 +845,55 @@ export class ApiService {
return normalizePaginatedListResponse<DeviceTypeDto>(payload).data ?? [];
}

public getDashboardDevices(
query: DashboardQuery = {},
options: ApiMethodOptions = {}
): Promise<DashboardPage> {
return this.request<DashboardPage>(DASHBOARD_DEVICES_ENDPOINT, {
method: 'GET',
signal: options.signal,
query: {
skip: query.skip,
take: query.take,
group: query.group,
name: query.name,
location: query.location,
locationGroup: query.locationGroup
}
});
}

public getDashboardLocations(
query: DashboardQuery = {},
options: ApiMethodOptions = {}
): Promise<DashboardLocationPage> {
return this.request<DashboardLocationPage>(DASHBOARD_LOCATIONS_ENDPOINT, {
method: 'GET',
signal: options.signal,
query: {
skip: query.skip,
take: query.take,
group: query.group,
name: query.name,
location: query.location,
locationGroup: query.locationGroup
}
});
}

public getDashboardDeviceLatest(
devEui: string,
options: ApiMethodOptions = {}
): Promise<Record<string, unknown> | null> {
return this.request<Record<string, unknown> | null>(
replacePathParams(DASHBOARD_DEVICE_LATEST_ENDPOINT, { dev_eui: devEui }),
{
method: 'GET',
signal: options.signal
}
);
}

public getLatestPrimaryDeviceData(
query: LatestPrimaryDataQuery = {},
options: ApiMethodOptions = {}
Expand Down
9 changes: 2 additions & 7 deletions src/lib/appContext.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { Profile } from './interfaces/profile.interface';
import { createCwAlarmScheduler } from '@cropwatchdevelopment/cwui';
import type { RuleDto, TriggeredRulesCountResponse } from './api/api.service';
import type { LocationDto } from './api/api.dtos';
import type { DeviceTypeLookup } from './components/dashboard/dashboard-device-data';

const DEVICE_STALE_MINUTES = 10;
const deviceAlarms = createCwAlarmScheduler();
Expand All @@ -21,7 +20,6 @@ export interface AppContext {
deviceGroups?: string[];
locationGroups?: string[];
locations?: LocationDto[];
deviceTypeLookup: DeviceTypeLookup;
deviceStatuses: { online: number; offline: number };
totalDeviceCount?: number;
rules: IRule[];
Expand All @@ -39,7 +37,6 @@ export const defaultAppContext: AppContext = {
profile: undefined,
session: null,
devices: [],
deviceTypeLookup: { byModel: {}, idToModel: {} },
deviceStatuses: { online: 0, offline: 0 },
totalDeviceCount: 0,
rules: [],
Expand All @@ -64,8 +61,7 @@ export function createAppContext(initial: Partial<AppContext> = {}): AppContext
profile: undefined,
session: null,
devices: [],
deviceTypeLookup: { byModel: {}, idToModel: {} },
deviceStatuses: { online: 0, offline: 0 },
deviceStatuses: { online: 0, offline: 0 },
totalDeviceCount: 0,
rules: [],
triggeredRules: [],
Expand All @@ -84,8 +80,7 @@ export function createAppContext(initial: Partial<AppContext> = {}): AppContext
profile: undefined,
session: null,
devices: [],
deviceTypeLookup: { byModel: {}, idToModel: {} },
deviceStatuses: { online: 0, offline: 0 },
deviceStatuses: { online: 0, offline: 0 },
totalDeviceCount: 0,
rules: [],
triggeredRules: [],
Expand Down
Loading
Loading