Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(utils): iotdb type conversion to lowercase #85

Merged
merged 3 commits into from
Dec 18, 2024
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
6 changes: 6 additions & 0 deletions packages/utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @emqx/shared-ui-utils

## 0.0.16

### Patch Changes

- Fixed IoTDB batch template issue

## 0.0.15

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/utils/lib/__test__/useBatchSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,20 @@ describe('useBatchSettings', () => {
it('should process IoTDB data correctly', async () => {
const data = [
['timestamp', 'measurement', 'data_type', 'value'],
['2022-01-01', 'temperature', 'FLOAT', '25.5'],
['2022-01-02', 'humidity', 'INT32', '60'],
['2022-01-01', 'temperature', 'float', '25.5'],
['2022-01-02', 'humidity', 'int32', '60'],
]
const expectedOutput = [
{
timestamp: '2022-01-01',
measurement: 'temperature',
data_type: 'FLOAT',
data_type: 'float',
value: '25.5',
},
{
timestamp: '2022-01-02',
measurement: 'humidity',
data_type: 'INT32',
data_type: 'int32',
value: '60',
},
]
Expand Down
14 changes: 7 additions & 7 deletions packages/utils/lib/useBatchSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const useBatchSettings = (locale: 'zh' | 'en' = 'en') => {
messages: {
en: {
iotdbTemplateRemark:
'Measurement, Value, and Data Type are required fields. The Data Type can have the optional values BOOLEAN, INT32, INT64, FLOAT, DOUBLE, TEXT.',
'Measurement, Value, and Data Type are required fields. The Data Type can have the optional values boolean, int32, int64, float, double, text.',
invalidIsCharFlag: 'Invalid Char Value field: {isChar}',
uploadMaxRowsError:
'The number of rows in the CSV file exceeds the limit. Up to {max} rows of data are supported except for the header',
Expand All @@ -26,7 +26,7 @@ export const useBatchSettings = (locale: 'zh' | 'en' = 'en') => {
},
zh: {
iotdbTemplateRemark:
'字段、值、数据类型是必填选项,数据类型可选的值为 BOOLEAN、INT32、INT64、FLOAT、DOUBLE、TEXT',
'字段、值、数据类型是必填选项,数据类型可选的值为 boolean、int32、int64、float、double、text',
invalidIsCharFlag: '无效的字符标识符值:{isChar}',
uploadMaxRowsError: 'CSV 文件行数超过限制,除表头外,最多支持 {max} 行数据',
influxdbTemplateRemark: '在字段值后追加 i,InfluxDB 则将该数值存储为整数类型。',
Expand Down Expand Up @@ -54,10 +54,10 @@ hum,\${payload.hum},FALSE,
status,\${payload.status},FALSE,
`,
[BatchSettingTypes.IoTDB]: `Timestamp,Measurement,Data Type,Value,Remarks (Optional)
now,temp,FLOAT,\${payload.temp},"${t('iotdbTemplateRemark')}"
now,hum,FLOAT,\${payload.hum},
now,status,BOOLEAN,\${payload.status},
now,clientid,TEXT,\${clientid},
now,temp,float,\${payload.temp},"${t('iotdbTemplateRemark')}"
now,hum,float,\${payload.hum},
now,status,boolean,\${payload.status},
now,clientid,text,\${clientid},
`,
[BatchSettingTypes.InfluxDB]: `Field,Value,Remarks (Optional)
temp,\${payload.temp},
Expand Down Expand Up @@ -118,7 +118,7 @@ precip,\${payload.precip}i,"${t('datalayersTemplateRemark')}"
const processIoTDBData = (data: string[][]): Promise<Array<Record<string, any>>> => {
return new Promise((resolve, reject) => {
try {
const validDataTypes = ['BOOLEAN', 'INT32', 'INT64', 'FLOAT', 'DOUBLE', 'TEXT']
const validDataTypes = ['boolean', 'int32', 'int64', 'float', 'double', 'text']

const result = data
.slice(1)
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@emqx/shared-ui-utils",
"version": "0.0.15",
"version": "0.0.16",
"homepage": "https://emqx.io",
"license": "Apache-2.0",
"repository": {
Expand Down
Loading