From 7f88e07e8305e21706fd0e7d9c83ce392e54c0f6 Mon Sep 17 00:00:00 2001 From: Abdou TOP Date: Wed, 29 Oct 2025 10:12:23 +0000 Subject: [PATCH 1/2] DT-75: Add Docker support for ClickHouse (#76) --- web/components/DataViewer.tsx | 152 ++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 web/components/DataViewer.tsx diff --git a/web/components/DataViewer.tsx b/web/components/DataViewer.tsx new file mode 100644 index 0000000..5bbcfef --- /dev/null +++ b/web/components/DataViewer.tsx @@ -0,0 +1,152 @@ +import { X, Trash2, Copy, Check } from 'lucide-preact' +import { api, ApiOutput } from '../lib/api.ts' +import { effect } from '@preact/signals' +import { url } from '../lib/router.tsx' + +type TableColumn = ApiOutput['GET/api/deployment/schema']['tables'][number]['columns'][number] +// type Log = ApiOutput[''] +const schema = api['GET/api/deployment/schema'].signal() +const tablesMap = new Map([]) + +effect(() => { + const tables = schema.data?.tables ?? [] + tablesMap.clear() + for (const { table, columns } of tables) { + tablesMap.set(table, columns) + } +}) + +const getFieldType = (value: unknown): string => { + if (value === null) return 'null' + if (typeof value === 'number') { + return Number.isInteger(value) ? 'int8' : 'float' + } + if (typeof value === 'boolean') return 'boolean' + if (typeof value === 'object') return 'json' + return 'text' +} + +const data={ + id: 1, + name: 'John Doe', + email: 'john.doe@example.com', + attributes: { role: 'admin', active: true, age: 30 }, + } +export const RowDetail = () => { +const {tab,table} = url.params + + // const handleInputChange = (key: string, inputValue: string) => { + // if (!onChange) return + + // const originalValue = data[key] + // const fieldType = getFieldType(originalValue) + + // let parsedValue: any = inputValue + + // if (fieldType === 'int8') { + // parsedValue = inputValue === '' ? 0 : parseInt(inputValue, 10) + // } else if (fieldType === 'float') { + // parsedValue = inputValue === '' ? 0 : parseFloat(inputValue) + // } else if (fieldType === 'boolean') { + // parsedValue = inputValue === 'true' + // } + + // onChange(key, parsedValue) + // } + + return ( +
+
+
+

Edit row

+ {/* {tableName && ( +

+ {tableName} +

+ )} */} +
+
+ {/* {onDelete && ( */} + + {/* )} */} + {/* {onClose && ( */} + + {/* )} */} +
+
+ + {/* Content */} + {data ? ( + <> +
+
+ {Object.entries(data).map(([key, value]) => { + const type = getFieldType(value) + return ( +
+ + {type === 'json' ? ( +