diff --git a/app/components/FileConfigSetting/index.tsx b/app/components/FileConfigSetting/index.tsx index 5f08723b..62d04f4c 100644 --- a/app/components/FileConfigSetting/index.tsx +++ b/app/components/FileConfigSetting/index.tsx @@ -29,6 +29,7 @@ const DelimiterConfigModal = (props: { onConfirm: (string) => void }) => { value={value} onChange={(e) => setValue(e.target.value)} placeholder={intl.get('import.enterDelimiter')} + onClick={(e) => e.stopPropagation()} /> - - )} - - - ); + const items: CollapseProps['items'] = [ + { + key: 'default', + label: , + extra: , + children: ( + <> + {files.map((item: ITagFileItem | IEdgeFileItem, index) => ( + + ))} + {!!name && ( +
+ +
+ )} + + ), + }, + ]; + return ; }; export default observer(SchemaConfig); diff --git a/app/pages/Schema/SchemaConfig/Edit/CommonEdit/PropertiesForm.tsx b/app/pages/Schema/SchemaConfig/Edit/CommonEdit/PropertiesForm.tsx index 965e4a3f..75052009 100644 --- a/app/pages/Schema/SchemaConfig/Edit/CommonEdit/PropertiesForm.tsx +++ b/app/pages/Schema/SchemaConfig/Edit/CommonEdit/PropertiesForm.tsx @@ -9,16 +9,16 @@ import styles from './index.module.less'; const confirm = Modal.confirm; interface IProps { - editType: ISchemaType + editType: ISchemaType; initialRequired: boolean; data: any; editDisabled: boolean; onBeforeEdit: (index: number | null) => void; - onEdit: (config: IAlterForm) => void; + onEdit: (config: IAlterForm) => boolean; } interface IEditProperty extends IProperty { - alterType: AlterType + alterType: AlterType; } const itemLayout = { wrapperCol: { @@ -27,13 +27,14 @@ const itemLayout = { }; const PropertiesForm = (props: IProps) => { - const { - editType, - initialRequired, - data: { name, properties, ttlConfig }, + const { + editType, + initialRequired, + data: { name, properties, ttlConfig }, editDisabled, - onEdit, - onBeforeEdit } = props; + onEdit, + onBeforeEdit, + } = props; const { intl } = useI18n(); const [list, setList] = useState(properties); const [editField, setEditField] = useState(null); @@ -48,13 +49,13 @@ const PropertiesForm = (props: IProps) => { useEffect(() => { setPropertyRequired(initialRequired); }, [initialRequired]); - + useEffect(() => { form.resetFields(); }, [editField]); - const handleClearProperties = e => { + const handleClearProperties = (e) => { const clear = e.target.checked; - if(clear) { + if (clear) { setPropertyRequired(clear); handlePropertyAdd(); } else { @@ -63,10 +64,12 @@ const PropertiesForm = (props: IProps) => { content: intl.get('schema.cancelPropmt'), okText: intl.get('common.yes'), cancelText: intl.get('common.no'), - onOk: () => { - setPropertyRequired(clear); + onOk: async () => { if (properties.length > 0) { - handlePropertyDelete(properties); + const isSuccess = await handlePropertyDelete(properties); + isSuccess && setPropertyRequired(clear); + } else { + setPropertyRequired(clear); } }, }); @@ -89,9 +92,8 @@ const PropertiesForm = (props: IProps) => { onBeforeEdit(list.length); }; - const handlePropertyDelete = async (fields: IProperty[]) => { - onEdit({ + const isSuccess = await onEdit({ type: editType, name, action: 'DROP', @@ -99,6 +101,7 @@ const PropertiesForm = (props: IProps) => { fields, }, }); + return isSuccess; }; const handleEditBefore = (data: IProperty, index: number) => { @@ -120,12 +123,12 @@ const PropertiesForm = (props: IProps) => { onBeforeEdit(null); if (editField?.alterType === 'ADD') { setList(list.slice(0, -1)); - if(list.length === 1) { + if (list.length === 1) { setPropertyRequired(false); } } }; - + const handlePropertyUpdate = (values) => { const { name: propertyName, type, value, comment, allowNull, fixedLength } = values; const { alterType } = editField!; @@ -134,14 +137,16 @@ const PropertiesForm = (props: IProps) => { name, action: alterType, config: { - fields: [{ - name: propertyName, - type, - value, - comment, - allowNull, - fixedLength - }], + fields: [ + { + name: propertyName, + type, + value, + comment, + allowNull, + fixedLength, + }, + ], }, }); }; @@ -150,11 +155,7 @@ const PropertiesForm = (props: IProps) => { form.setFieldsValue({ value: '' }); }; return ( -
+ {intl.get('schema.defineFields')} @@ -163,34 +164,41 @@ const PropertiesForm = (props: IProps) => {
- - {intl.get('common.propertyName')} - {intl.get('common.dataType')} + + {intl.get('common.propertyName')} + + + {intl.get('common.dataType')} + {intl.get('common.allowNull')} {intl.get('common.defaults')} {intl.get('common.comment')} {list.map((item, index) => { - return editRow === index - ? - : + ) : ( + handleEditBefore(item, index)} - />; + /> + ); })}
diff --git a/app/pages/Schema/SchemaConfig/Edit/CommonEdit/index.tsx b/app/pages/Schema/SchemaConfig/Edit/CommonEdit/index.tsx index d4e76524..bd06d1b0 100644 --- a/app/pages/Schema/SchemaConfig/Edit/CommonEdit/index.tsx +++ b/app/pages/Schema/SchemaConfig/Edit/CommonEdit/index.tsx @@ -32,14 +32,14 @@ interface IPropertyItem { interface IData { name: string; comment: string; - properties: IProperty[], + properties: IProperty[]; ttlConfig: { - duration: string, - col: string - } + duration: string; + col: string; + }; } interface IProps { - editType: ISchemaType + editType: ISchemaType; } const ConfigEdit = (props: IProps) => { const { editType } = props; @@ -48,7 +48,9 @@ const ConfigEdit = (props: IProps) => { const { intl } = useI18n(); const [editName, setEditName] = useState(''); const [editKey, setEditKey] = useState(null); - const { schema: { getTagOrEdgeDetail, getTagOrEdgeInfo, alterField, getIndexTree } } = useStore(); + const { + schema: { getTagOrEdgeDetail, getTagOrEdgeInfo, alterField, getIndexTree }, + } = useStore(); const [tempComment, setTempComment] = useState(''); const [loading, setLoading] = useState(false); const [data, setData] = useState({ @@ -57,8 +59,8 @@ const ConfigEdit = (props: IProps) => { properties: [], ttlConfig: { col: '', - duration: '' - } + duration: '', + }, } as IData); const [ttlRequired, setTtlRequired] = useState(false); const [propertiesRequired, setPropertiesRequired] = useState(false); @@ -69,16 +71,13 @@ const ConfigEdit = (props: IProps) => { const getDetails = async () => { const _editName = state[editType]; - if(!_editName) { + if (!_editName) { history.push(`/schema/${editType}/list`); } setEditName(_editName); setLoading(true); const createGql = await getTagOrEdgeDetail(editType, _editName); - const { code: propCode, data: propData } = await getTagOrEdgeInfo( - editType, - _editName, - ); + const { code: propCode, data: propData } = await getTagOrEdgeInfo(editType, _editName); setLoading(false); if (createGql) { const fieldInfo = propCode === 0 ? propData.tables : []; @@ -90,17 +89,16 @@ const ConfigEdit = (props: IProps) => { const reg = /CREATE (?:TAG|EDGE)\s`.+`\s\((.*)\)\s+(ttl_duration = \d+),\s+(ttl_col = ".*?")(, comment = ".*")?/gm; const str = data.replace(/[\r\n]/g, ' '); const infoList = reg.exec(str) || []; - const properties: IProperty[] = fieldInfo.map(i => ({ - name: i.Field, - showType: i.Type, - type: i.Type.startsWith('fixed_string') ? 'fixed_string' : i.Type, - allowNull: i.Null === 'YES', - comment: i.Comment === '_EMPTY_' ? '' : i.Comment, - value: i.Default === '_EMPTY_' ? '' : convertBigNumberToString(i.Default), - fixedLength: i.Type.startsWith('fixed_string') - ? i.Type.replace(/[fixed_string(|)]/g, '') - : '', - })) || []; + const properties: IProperty[] = + fieldInfo.map((i) => ({ + name: i.Field, + showType: i.Type, + type: i.Type.startsWith('fixed_string') ? 'fixed_string' : i.Type, + allowNull: i.Null === 'YES', + comment: i.Comment === '_EMPTY_' ? '' : i.Comment, + value: i.Default === '_EMPTY_' ? '' : convertBigNumberToString(i.Default), + fixedLength: i.Type.startsWith('fixed_string') ? i.Type.replace(/[fixed_string(|)]/g, '') : '', + })) || []; const duration = infoList[2]?.split(' = ')[1] || ''; const col = infoList[3]?.split(' = ')[1].replace(/"/g, '') || ''; const comment = infoList[4]?.split(' = ')[1].slice(1, -1) || ''; @@ -114,8 +112,8 @@ const ConfigEdit = (props: IProps) => { properties, ttlConfig: { col, - duration - } + duration, + }, }); setTempComment(comment); }; @@ -134,6 +132,7 @@ const ConfigEdit = (props: IProps) => { await getDetails(); setEditKey(null); } + return res.code === 0; }; const handleCommentUpdate = async () => { setLoading(true); @@ -156,15 +155,13 @@ const ConfigEdit = (props: IProps) => { setLoading(true); const res = (await getIndexTree(editType)) || []; setLoading(false); - const hasIndex = res.some(i => i.name === editName); + const hasIndex = res.some((i) => i.name === editName); return hasIndex; }; return (
- + @@ -179,36 +176,24 @@ const ConfigEdit = (props: IProps) => { className={styles.inputComment} defaultValue={data.comment} value={tempComment} - onChange={e => setTempComment(e.target.value)} + onChange={(e) => setTempComment(e.target.value)} /> {editKey !== 'comment' ? ( <> - ) : ( <> - - )} - @@ -219,15 +204,16 @@ const ConfigEdit = (props: IProps) => { editDisabled={editKey !== null} onBeforeEdit={(index) => setEditKey(index !== null ? `properties[${index}]` : null)} initialRequired={propertiesRequired} - onEdit={handleAlter} - data={data} /> - + setEditKey(type === null ? null : 'ttl')} /> diff --git a/package-lock.json b/package-lock.json index 508f05ca..a87993b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,7 @@ "mobx-react-lite": "^3.4.3", "query-string": "^7.1.1", "react": "^18.2.0", - "react-beautiful-dnd": "^13.0.0", + "react-beautiful-dnd": "^13.1.1", "react-color": "^2.19.3", "react-copy-to-clipboard": "^5.1.0", "react-dom": "^18.2.0", @@ -6906,9 +6906,9 @@ } }, "node_modules/react-beautiful-dnd": { - "version": "13.1.0", - "resolved": "https://registry.npmmirror.com/react-beautiful-dnd/-/react-beautiful-dnd-13.1.0.tgz", - "integrity": "sha512-aGvblPZTJowOWUNiwd6tNfEpgkX5OxmpqxHKNW/4VmvZTNTbeiq7bA3bn5T+QSF2uibXB0D1DmJsb1aC/+3cUA==", + "version": "13.1.1", + "resolved": "https://registry.npmmirror.com/react-beautiful-dnd/-/react-beautiful-dnd-13.1.1.tgz", + "integrity": "sha512-0Lvs4tq2VcrEjEgDXHjT98r+63drkKEgqyxdA7qD3mvKwga6a5SscbdLPO2IExotU1jW8L0Ksdl0Cj2AF67nPQ==", "dependencies": { "@babel/runtime": "^7.9.2", "css-box-model": "^1.2.0", @@ -6919,8 +6919,8 @@ "use-memo-one": "^1.1.1" }, "peerDependencies": { - "react": "^16.8.5 || ^17.0.0", - "react-dom": "^16.8.5 || ^17.0.0" + "react": "^16.8.5 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.5 || ^17.0.0 || ^18.0.0" } }, "node_modules/react-beautiful-dnd/node_modules/memoize-one": { @@ -13757,9 +13757,9 @@ } }, "react-beautiful-dnd": { - "version": "13.1.0", - "resolved": "https://registry.npmmirror.com/react-beautiful-dnd/-/react-beautiful-dnd-13.1.0.tgz", - "integrity": "sha512-aGvblPZTJowOWUNiwd6tNfEpgkX5OxmpqxHKNW/4VmvZTNTbeiq7bA3bn5T+QSF2uibXB0D1DmJsb1aC/+3cUA==", + "version": "13.1.1", + "resolved": "https://registry.npmmirror.com/react-beautiful-dnd/-/react-beautiful-dnd-13.1.1.tgz", + "integrity": "sha512-0Lvs4tq2VcrEjEgDXHjT98r+63drkKEgqyxdA7qD3mvKwga6a5SscbdLPO2IExotU1jW8L0Ksdl0Cj2AF67nPQ==", "requires": { "@babel/runtime": "^7.9.2", "css-box-model": "^1.2.0", diff --git a/package.json b/package.json index e43ff4b7..bf71776a 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "mobx-react-lite": "^3.4.3", "query-string": "^7.1.1", "react": "^18.2.0", - "react-beautiful-dnd": "^13.0.0", + "react-beautiful-dnd": "^13.1.1", "react-color": "^2.19.3", "react-copy-to-clipboard": "^5.1.0", "react-dom": "^18.2.0", diff --git a/server/api/studio/internal/model/sketch.go b/server/api/studio/internal/model/sketch.go index 7a82f275..846152a4 100644 --- a/server/api/studio/internal/model/sketch.go +++ b/server/api/studio/internal/model/sketch.go @@ -10,8 +10,8 @@ type Sketch struct { ID int `gorm:"column:id;primaryKey;autoIncrement"` BID string `gorm:"column:b_id;not null;type:char(32);uniqueIndex;comment:sketch id"` Name string `gorm:"column:name;type:varchar(255);not null"` - Schema string `gorm:"column:schema;"` - Snapshot string `gorm:"column:snapshot;type:text;"` + Schema string `gorm:"column:schema;type:mediumtext;"` + Snapshot string `gorm:"column:snapshot;type:mediumtext;"` Host string `gorm:"column:host;type:varchar(256);not null"` Username string `gorm:"column:username;type:varchar(128);not null"` CreateTime time.Time `gorm:"column:create_time;type:datetime;autoCreateTime"` diff --git a/server/api/studio/internal/model/taskInfo.go b/server/api/studio/internal/model/taskInfo.go index 45c382ce..bef49bf5 100644 --- a/server/api/studio/internal/model/taskInfo.go +++ b/server/api/studio/internal/model/taskInfo.go @@ -27,7 +27,7 @@ type TaskInfo struct { TaskStatus string `gorm:"column:task_status;"` TaskMessage string `gorm:"column:task_message;"` Stats Stats `gorm:"embedded"` - RawConfig string `gorm:"column:raw_config;type:text;"` + RawConfig string `gorm:"column:raw_config;type:mediumtext;"` CreateTime time.Time `gorm:"column:create_time;type:datetime;autoCreateTime"` UpdateTime time.Time `gorm:"column:update_time;type:datetime;autoUpdateTime"` diff --git a/vite.config.ts b/vite.config.ts index 8b8f7e97..5cee2c1c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -37,6 +37,7 @@ const htmlPlugin = (data?: Record): Plugin => { export default defineConfig({ build: { target: 'esnext', + sourcemap: true, }, plugins: [ react(),