Skip to content

Commit

Permalink
refactor doc database (DataLinkDC#2834)
Browse files Browse the repository at this point in the history
* refactor doc

* refactor doc

* formate code

* formate code
  • Loading branch information
gaoyan1998 authored Dec 28, 2023
1 parent cdec3e0 commit 39d3a16
Show file tree
Hide file tree
Showing 10 changed files with 2,860 additions and 3,440 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public List<CascaderVO> loadConfigOptions() {
dataList.add(cascaderVO);
}

List<CascaderVO> voList = documentService.lambdaQuery().eq(Document::getCategory, "Variable").list().stream()
List<CascaderVO> voList = documentService.lambdaQuery().eq(Document::getType, "FLINK_OPTIONS").list().stream()
.map(d -> new CascaderVO(d.getName().replace("set ", "")))
.collect(Collectors.toList());

Expand Down
2,887 changes: 1,221 additions & 1,666 deletions dinky-admin/src/main/resources/db/db-h2-dml.sql

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dinky-web/src/locales/en-US/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ export default {
'rc.ci.version': 'Version',
'rc.ci.desc': 'Note',
'rc.ci.search': 'Search Name/Alias/Note',
'rc.doc.category': 'Document Type',
'rc.doc.category': 'Register Type',
'rc.doc.categoryPlaceholder': 'Please select the type of this Document!',
'rc.doc.create': 'Create Document',
'rc.doc.delete': 'Delete Document',
Expand All @@ -811,7 +811,7 @@ export default {
'rc.doc.fillValueHelp': 'Please enter the fill value',
'rc.doc.fillValuePlaceholder':
'Please enter the fill value, use the name in the editor to trigger the prompt eg',
'rc.doc.functionType': 'Function Type',
'rc.doc.functionType': 'Document Type',
'rc.doc.management': 'Document Management',
'rc.doc.modify': 'Modify Document',
'rc.doc.name': 'Name',
Expand Down
4 changes: 2 additions & 2 deletions dinky-web/src/locales/zh-CN/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ export default {
'rc.ci.version': '版本',
'rc.ci.desc': '描述',
'rc.ci.search': '搜索 名称/别名/备注',
'rc.doc.category': '文档类型',
'rc.doc.category': '注册类型',
'rc.doc.categoryPlaceholder': '请选择该文档所属类型!',
'rc.doc.create': '创建文档',
'rc.doc.delete': '删除文档',
Expand All @@ -778,7 +778,7 @@ export default {
'rc.doc.fillValue': '填充值',
'rc.doc.fillValueHelp': '请输入填充值',
'rc.doc.fillValuePlaceholder': '请输入填充值,编辑器内使用名称触发提示 eg',
'rc.doc.functionType': '函数类型',
'rc.doc.functionType': '文档类型',
'rc.doc.management': '文档管理',
'rc.doc.modify': '修改文档',
'rc.doc.name': '名称',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,25 @@

import CodeEdit from '@/components/CustomEditor/CodeEdit';
import {
DOCUMENT_CATEGORY,
DOCUMENT_FUNCTION_TYPE,
DOCUMENT_SUBTYPE,
VERSIONS
DOCUMENT_TYPE_ENUMS, VERSIONS, DOCUMENT_FUNCTION_TYPE_ENUMS, DOCUMENT_CATEGORY_ENUMS
} from '@/pages/RegCenter/Document/constans';
import { FORM_LAYOUT_PUBLIC } from '@/services/constants';
import { Document } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import {FORM_LAYOUT_PUBLIC} from '@/services/constants';
import {Document} from '@/types/RegCenter/data';
import {l} from '@/utils/intl';
import {
ProForm,
ProFormItem,
ProFormItem, ProFormSegmented,
ProFormSelect,
ProFormSwitch,
ProFormText,
ProFormTextArea
} from '@ant-design/pro-components';
import { FormInstance } from 'antd/es/form/hooks/useForm';
import { Values } from 'async-validator';
import { DefaultOptionType } from 'rc-select/lib/Select';
import React, { useState } from 'react';
import {FormInstance} from 'antd/es/form/hooks/useForm';
import {Values} from 'async-validator';
import {DefaultOptionType} from 'rc-select/lib/Select';
import React, {useState} from 'react';
import {ProFormDependency} from "@ant-design/pro-form";
import {JOB_TYPE} from "@/pages/DataStudio/LeftContainer/Project/constants";

type DocumentFormProps = {
values: Partial<Document>;
Expand All @@ -51,39 +50,39 @@ const CodeEditProps = {
};

const DocumentForm: React.FC<DocumentFormProps> = (props) => {
const { values, form } = props;
const {values, form} = props;

/**
* status
*/
const [codeFillValue, setCodeFillValue] = useState<string>(values.fillValue || '');

const [categoryList] = useState<DefaultOptionType[]>(
DOCUMENT_CATEGORY.map((item) => ({ label: item.text, value: item.value }))
);

const [typeList] = useState<DefaultOptionType[]>(
DOCUMENT_FUNCTION_TYPE.map((item) => ({
label: item.text,
value: item.value
}))
const {
FLINK_OPTIONS,
SQL_TEMPLATE,
FUN_UDF,
OTHER
} = DOCUMENT_TYPE_ENUMS;

const [CATEGORY_LIST] = useState<DefaultOptionType[]>(
Object.values(DOCUMENT_CATEGORY_ENUMS).map((item) => ({label: item.text, value: item.value}))
);

const [subTypeList] = useState<DefaultOptionType[]>(
DOCUMENT_SUBTYPE.map((item) => ({ label: item.text, value: item.value }))
const [FUNCTION_TYPES] = useState<DefaultOptionType[]>(
Object.values(DOCUMENT_FUNCTION_TYPE_ENUMS).map((item) => ({label: item.text, value: item.value}))
);

const [versionOptions] = useState<DefaultOptionType[]>(
VERSIONS.map((item) => ({ label: item.text, value: item.value }))
const [VERSION_OPTIONS] = useState<DefaultOptionType[]>(
VERSIONS.map((item) => ({label: item.text, value: item.value}))
);

/**
* code editor change callback
* @param value
*/
const handleFillValueChange = (value: string) => {
setCodeFillValue(value);
};
const onTypeAndNameChange = (type: string, name: string) => {
if (type == FLINK_OPTIONS.value) {
const fillValue = "set '" + name + "' = '${1:}'";
form.setFieldsValue({category: "Varible"});
form.setFieldsValue({fillValue: fillValue});
setCodeFillValue(fillValue);
}
}

/**
* form
Expand All @@ -92,60 +91,70 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
const documentFormRender = () => {
return (
<>
<ProFormText
name='name'
label={l('rc.doc.name')}
placeholder={l('rc.doc.namePlaceholder')}
rules={[{ required: true, message: l('rc.doc.namePlaceholder') }]}
/>

<ProFormSelect
name='category'
label={l('rc.doc.category')}
rules={[{ required: true, message: l('rc.doc.categoryPlaceholder') }]}
options={categoryList}
/>

<ProFormSelect
<ProFormSegmented
name='type'
label={l('rc.doc.functionType')}
rules={[{ required: true, message: l('rc.doc.typePlaceholder') }]}
options={typeList}
rules={[{required: true, message: l('rc.doc.typePlaceholder')}]}
valueEnum={DOCUMENT_TYPE_ENUMS}
/>

<ProFormSelect
name='subtype'
label={l('rc.doc.subFunctionType')}
rules={[{ required: true, message: l('rc.doc.subTypePlaceholder') }]}
options={subTypeList}
<ProFormText
name='name'
label={l('rc.doc.name')}
placeholder={l('rc.doc.namePlaceholder')}
rules={[{required: true, message: l('rc.doc.namePlaceholder')}]}
/>

<ProFormTextArea
name='description'
label={l('rc.doc.description')}
placeholder={l('rc.doc.descriptionPlaceholder')}
/>
<ProFormDependency name={['type', 'name']}>
{
({type, name}) => {
onTypeAndNameChange(type, name);
return <>
{type != FLINK_OPTIONS.value && type != OTHER.value &&
<ProFormSelect
name='subtype'
label={l('rc.doc.subFunctionType')}
rules={[{required: true, message: l('rc.doc.subTypePlaceholder')}]}
options={type == FUN_UDF.value ? FUNCTION_TYPES : JOB_TYPE}
/>}

<ProFormSelect
disabled={type == FLINK_OPTIONS.value}
name='category'
label={l('rc.doc.category')}
rules={[{required: true, message: l('rc.doc.categoryPlaceholder')}]}
options={CATEGORY_LIST}
/>
</>
}
}
</ProFormDependency>

<ProFormItem
name='fillValue'
label={l('rc.doc.fillValue')}
tooltip={l('rc.doc.fillValuePlaceholder')}
rules={[{ required: true, message: l('rc.doc.fillValueHelp') }]}
rules={[{required: true, message: l('rc.doc.fillValueHelp')}]}
>
<CodeEdit
onChange={handleFillValueChange}
code={codeFillValue}
language={'sql'}
enableSuggestions={false}
{...CodeEditProps}
/>
</ProFormItem>

<ProFormTextArea
name='description'
label={l('rc.doc.description')}
placeholder={l('rc.doc.descriptionPlaceholder')}
/>

<ProFormSelect
name='version'
label={l('rc.doc.version')}
rules={[{ required: true, message: l('rc.doc.versionPlaceholder') }]}
options={versionOptions}
rules={[{required: true, message: l('rc.doc.versionPlaceholder')}]}
options={VERSION_OPTIONS}
/>

<ProFormSwitch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ import { Authorized, HasAuthority } from '@/hooks/useAccess';
import DocumentDrawer from '@/pages/RegCenter/Document/components/DocumentDrawer';
import DocumentModalForm from '@/pages/RegCenter/Document/components/DocumentModal';
import {
DOCUMENT_CATEGORY,
DOCUMENT_CATEGORY_ENUMS,
DOCUMENT_FUNCTION_ENUMS,
DOCUMENT_FUNCTION_TYPE,
DOCUMENT_SUBTYPE,
DOCUMENT_SUBTYPE_ENUMS
DOCUMENT_TYPE_ENUMS,
DOCUMENT_FUNCTION_TYPE_ENUMS
} from '@/pages/RegCenter/Document/constans';
import { queryList } from '@/services/api';
import { handleAddOrUpdate, handleRemoveById, updateDataByParam } from '@/services/BusinessCrud';
Expand Down Expand Up @@ -111,29 +108,29 @@ const DocumentTableList: React.FC = () => {
return <a onClick={() => handleOpenDrawer(record)}>{dom}</a>;
}
},
{
title: l('rc.doc.category'),
sorter: true,
dataIndex: 'category',
filterMultiple: false,
filters: DOCUMENT_CATEGORY,
valueEnum: DOCUMENT_CATEGORY_ENUMS
},
{
title: l('rc.doc.functionType'),
sorter: true,
dataIndex: 'type',
filterMultiple: false,
filters: DOCUMENT_FUNCTION_TYPE,
valueEnum: DOCUMENT_FUNCTION_ENUMS
filterMultiple: true,
filters:true,
valueEnum: DOCUMENT_TYPE_ENUMS
},
{
title: l('rc.doc.subFunctionType'),
sorter: true,
dataIndex: 'subtype',
filters: DOCUMENT_SUBTYPE,
filterMultiple: false,
valueEnum: DOCUMENT_SUBTYPE_ENUMS
filters: true,
filterMultiple: true,
valueEnum: DOCUMENT_FUNCTION_TYPE_ENUMS
},
{
title: l('rc.doc.category'),
sorter: true,
dataIndex: 'category',
filterMultiple: true,
filters: true,
valueEnum: DOCUMENT_CATEGORY_ENUMS
},
{
title: l('rc.doc.description'),
Expand Down
Loading

0 comments on commit 39d3a16

Please sign in to comment.