Unverified Commit a45fb097 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Refactor][web] refactor register center's document (#1828)

* added register center's document list * modify desc show type
parent d12da17a
......@@ -23,6 +23,7 @@ import org.dinky.common.result.ProTableResult;
import org.dinky.common.result.Result;
import org.dinky.model.Document;
import org.dinky.service.DocumentService;
import org.dinky.utils.MessageResolverUtils;
import java.util.ArrayList;
import java.util.List;
......@@ -41,12 +42,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* DocumentController
*
* @author wenmo
* @since 2021/6/3
*/
/** DocumentController */
@Slf4j
@RestController
@RequestMapping("/api/document")
......@@ -55,24 +51,41 @@ public class DocumentController {
private final DocumentService documentService;
/** 新增或者更新 */
/**
* save or update
*
* @param document {@link Document}
* @return {@link Result} of {@link Void}
* @throws Exception {@link Exception}
*/
@PutMapping
public Result<Void> saveOrUpdate(@RequestBody Document document) throws Exception {
if (documentService.saveOrUpdate(document)) {
return Result.succeed("新增成功");
return Result.succeed(MessageResolverUtils.getMessage("save.success"));
} else {
return Result.failed("新增失败");
return Result.failed(MessageResolverUtils.getMessage("save.failed"));
}
}
/** 动态查询列表 */
/**
* query documents
*
* @param para {@link JsonNode}
* @return {@link ProTableResult} of {@link Document}
*/
@PostMapping
public ProTableResult<Document> listDocuments(@RequestBody JsonNode para) {
return documentService.selectForProTable(para);
}
/** 批量删除 */
/**
* batch delete, this method is deprecated, please use {@link #deleteMul(JsonNode)} instead.
*
* @param para
* @return
*/
@DeleteMapping
@Deprecated
public Result<Void> deleteMul(@RequestBody JsonNode para) {
if (para.size() > 0) {
List<Integer> error = new ArrayList<>();
......@@ -92,16 +105,60 @@ public class DocumentController {
}
}
/** 获取指定ID的信息 */
/**
* delete document by id
*
* @param id {@link Integer}
* @return {@link Result} of {@link Void}
*/
@DeleteMapping("/delete")
public Result<Void> deleteById(@RequestParam Integer id) {
if (documentService.removeById(id)) {
return Result.succeed(MessageResolverUtils.getMessage("delete.success"));
} else {
return Result.failed(MessageResolverUtils.getMessage("delete.failed"));
}
}
/**
* delete document by id
*
* @param id {@link Integer}
* @return {@link Result} of {@link Void}
*/
@PutMapping("/enable")
public Result<Void> enable(@RequestParam Integer id) {
if (documentService.enable(id)) {
return Result.succeed(MessageResolverUtils.getMessage("modify.success"));
} else {
return Result.failed(MessageResolverUtils.getMessage("modify.failed"));
}
}
/**
* get document by id
*
* @param document
* @return {@link Result} of {@link Document}
* @throws {@link Exception}
*/
@PostMapping("/getOneById")
public Result<Document> getOneById(@RequestBody Document document) throws Exception {
document = documentService.getById(document.getId());
return Result.succeed(document, "获取成功");
return Result.succeed(document, MessageResolverUtils.getMessage("response.get.success"));
}
/** 根据版本号获取自动补全内容 */
/**
* get document by version
*
* @param version {@link String}
* @return {@link Result} of {@link Document}
* @throws {@link Exception}
*/
@GetMapping("/getFillAllByVersion")
public Result<List<Document>> getFillAllByVersion(@RequestParam String version) {
return Result.succeed(documentService.getFillAllByVersion(version), "获取成功");
return Result.succeed(
documentService.getFillAllByVersion(version),
MessageResolverUtils.getMessage("response.get.success"));
}
}
......@@ -24,13 +24,22 @@ import org.dinky.model.Document;
import java.util.List;
/**
* DocumentService
*
* @author wenmo
* @since 2021/6/3 14:35
*/
/** DocumentService */
public interface DocumentService extends ISuperService<Document> {
/**
* QUERY document fill value by version
*
* @param version
* @return
*/
List<Document> getFillAllByVersion(String version);
/**
* document enable or disable
*
* @param id
* @return
*/
Boolean enable(Integer id);
}
......@@ -31,12 +31,7 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
/**
* DocumentServiceImpl
*
* @author wenmo
* @since 2021/6/3 14:36
*/
/** DocumentServiceImpl */
@Service
public class DocumentServiceImpl extends SuperServiceImpl<DocumentMapper, Document>
implements DocumentService {
......@@ -50,4 +45,11 @@ public class DocumentServiceImpl extends SuperServiceImpl<DocumentMapper, Docume
return baseMapper.selectList(new QueryWrapper<Document>().eq("enabled", 1));
}
}
@Override
public Boolean enable(Integer id) {
Document document = baseMapper.selectById(id);
document.setEnabled(!document.getEnabled());
return updateById(document);
}
}
......@@ -37,6 +37,9 @@
<if test='param.description!=null and param.description!=""'>
and a.description like "%${param.description}%"
</if>
<if test='param.category!=null and param.category!=""'>
and a.category = #{param.category}
</if>
<if test='param.type!=null and param.type!=""'>
and a.type = #{param.type}
</if>
......
......@@ -141,7 +141,7 @@ export default [
path: '/registration/document',
name: 'document',
icon: 'BookOutlined',
// component: './RegistrationCenter/Document',
component: './RegCenter/Document',
},
{
path: '/registration/fragment',
......
......@@ -49,7 +49,7 @@ const RoleList: React.FC = () => {
const handleDeleteSubmit = async (id: number) => {
// TODO: DELETE role interface is use /api/role , because of the backend interface 'DeleteMapping' is repeat , in the future, we need to change the interface to /api/role (ROLE)
await handleRemoveById(API_CONSTANTS.ROLE_DELETE, id);
actionRef.current?.reloadAndRest?.();
actionRef.current?.reload?.();
}
......
......@@ -70,7 +70,7 @@ const TenantFormList: React.FC = () => {
const handleDeleteSubmit = async (id : number) => {
// TODO: delete tenant interface is use /api/tenant/delete , because of the backend interface 'DeleteMapping' is repeat , in the future, we need to change the interface to /api/tenant (TENANT)
await handleRemoveById(API_CONSTANTS.TENANT_DELETE, id);
actionRef.current?.reloadAndRest?.();
actionRef.current?.reload?.();
};
/**
......
......@@ -66,7 +66,7 @@ const UserTableList: React.FC = () => {
);
if (success) {
handleAssignRoleTransferOpen(false);
actionRef?.current?.reloadAndRest?.();
actionRef.current?.reload?.();
form.resetFields();
}
setLoading(false);
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import React, {useEffect, useState} from 'react';
import {Form, Modal, Select} from 'antd';
import {l} from "@/utils/intl";
import {Document} from "@/types/RegCenter/data";
import {FORM_LAYOUT_PUBLIC, NORMAL_MODAL_OPTIONS} from "@/services/constants";
import {ProForm, ProFormItem, ProFormSwitch, ProFormText, ProFormTextArea} from "@ant-design/pro-components";
import CodeEdit from "@/components/CustomMonacoEditor/CodeEdit";
import {
DOCUMENT_CATEGORY,
DOCUMENT_FUNCTION_TYPE,
DOCUMENT_SUBTYPE,
VERSIONS
} from "@/pages/RegCenter/Document/constans";
export type DocumentFormProps = {
onCancel: (flag?: boolean) => void;
onSubmit: (values: Partial<Document>) => void;
modalVisible: boolean;
values: Partial<Document>;
};
const FormItem = Form.Item;
const Option = Select.Option;
const CodeEditProps ={
height : "25vh",
lineNumbers: "on",
}
const DocumentForm: React.FC<DocumentFormProps> = (props) => {
/**
* status
*/
const [form] = Form.useForm();
const [codeFillValue, setCodeFillValue] = useState<string>(props.values.fillValue || '');
const [categoryList, setCategoryList] = useState<JSX.Element[]>([]);
const [typeList, setTypeList] = useState<JSX.Element[]>([]);
const [subTypeList, setSubTypeList] = useState<JSX.Element[]>([]);
const [versionOptions, setVersionOptions] = useState<JSX.Element[]>([]);
const [formVals, setFormVals] = useState<Partial<Document>>({
id: props.values.id,
name: props.values.name,
category: props.values.category,
type: props.values.type,
subtype: props.values.subtype,
description: props.values.description,
fillValue: props.values.fillValue,
version: props.values.version,
likeNum: props.values.likeNum,
enabled: props.values.enabled,
});
useEffect(() => {
let versionOptions: JSX.Element[] =[]
let categoryOptions: JSX.Element[] =[]
let typeOptions: JSX.Element[] =[]
let subTypeOptions: JSX.Element[] =[]
/**
* generate version options
*/
VERSIONS.map((item) => {
versionOptions.push(<Option value={item.value}>{item.text}</Option>)
})
setVersionOptions(versionOptions)
/**
* generate category options
*/
DOCUMENT_CATEGORY.map((item) => {
categoryOptions.push(<Option value={item.value}>{item.value}</Option>)
})
setCategoryList(categoryOptions)
/**
* generate subType options
*/
DOCUMENT_SUBTYPE.map((item) => {
subTypeOptions.push(<Option value={item.value}>{item.value}</Option>)
})
setSubTypeList(subTypeOptions)
/**
* generate type options
*/
DOCUMENT_FUNCTION_TYPE.map((item) => {
typeOptions.push(<Option value={item.value}>{item.value}</Option>)
})
setTypeList(typeOptions)
},[])
/**
* 1. onSubmit: submit callback
* 2. onCancel: cancel callback
* 3. modalVisible: modal visible
*/
const {
onSubmit: handleSubmit,
onCancel: handleModalVisible,
modalVisible,
} = props;
/**
* code editor change callback
* @param value
*/
const handleFillValueChange =(value: string) => {
setCodeFillValue(value);
}
/**
* form submit callback
*/
const submitForm = async () => {
const fieldsValue = await form.validateFields();
setFormVals({...formVals, ...fieldsValue});
handleSubmit({...formVals, ...fieldsValue});
};
/**
* form
* @constructor
*/
const DocumentFormRender = () => {
return (
<>
<ProFormText
name="name"
label={l('rc.doc.name')}
placeholder={l('rc.doc.namePlaceholder')}
rules={[{required: true, message: l('rc.doc.namePlaceholder')}]}
/>
<ProFormItem
name="category"
label={l('rc.doc.category')}
rules={[{required: true, message: l('rc.doc.categoryPlaceholder')}]}
>
<Select autoClearSearchValue showSearch allowClear>
{categoryList}
</Select>
</ProFormItem>
<ProFormItem
name="type"
label={l('rc.doc.functionType')}
rules={[{required: true, message: l('rc.doc.typePlaceholder')}]}
>
<Select autoClearSearchValue showSearch allowClear>
{typeList}
</Select>
</ProFormItem>
<ProFormItem
name="subtype"
label={l('rc.doc.subFunctionType')}
rules={[{required: true, message: l('rc.doc.subTypePlaceholder')}]}
>
<Select autoClearSearchValue showSearch allowClear>
{subTypeList}
</Select>
</ProFormItem>
<ProFormTextArea
name="description"
label={l('rc.doc.description')}
placeholder={l('rc.doc.descriptionPlaceholder')}
/>
<ProFormItem
name="fillValue"
label={l('rc.doc.fillValue')}
rules={[{required: true, message: l('rc.doc.fillValueHelp')}]}
>
<CodeEdit
onChange={(value =>{handleFillValueChange(value)})}
code={codeFillValue}
language={"sql"}
{...CodeEditProps}
/>
</ProFormItem>
<FormItem
name="version"
label={l('rc.doc.version')}
rules={[{required: true, message: l('rc.doc.versionPlaceholder')}]}
>
<Select autoClearSearchValue showSearch allowClear>
{versionOptions}
</Select>
</FormItem>
<ProFormSwitch
name="enabled"
label={l('global.table.isEnable')}
rules={[{required: true, message: l('rc.doc.enabledPlaceholder')}]}
checkedChildren={l('button.enable')} unCheckedChildren={l('button.disable')}
/>
</>
);
};
/**
* render
*/
return (
<Modal
{...NORMAL_MODAL_OPTIONS}
title={formVals.id ? l('rc.doc.modify') : l('rc.doc.create')}
open={modalVisible}
onOk={() => submitForm()}
onCancel={() => handleModalVisible()}
>
<ProForm
{...FORM_LAYOUT_PUBLIC}
form={form}
submitter={false}
layout={'horizontal'}
initialValues={formVals}
>
{DocumentFormRender()}
</ProForm>
</Modal>
);
};
export default DocumentForm;
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import React from "react";
import {Select} from "antd";
/**
* document category
*/
export const DOCUMENT_CATEGORY = [
{
text: 'Variable',
value: 'Variable',
}, {
text: 'Module',
value: 'Module',
}, {
text: 'Operator',
value: 'Operator',
}, {
text: 'Function',
value: 'Function',
}, {
text: 'Property',
value: 'Property',
}, {
text: 'Method',
value: 'Method',
}, {
text: 'Reference',
value: 'Reference',
},
];
/**
* document category enum map
*/
export const DOCUMENT_CATEGORY_ENUMS = {
'Variable': {text: 'Variable'},
'Module': {text: 'Module'},
'Operator': {text: 'Operator'},
'Function': {text: 'Function'},
'Property': {text: 'Property'},
'Method': {text: 'Method'},
'Reference': {text: 'Reference'},
};
/**
* document type
*/
export const DOCUMENT_FUNCTION_TYPE = [
{
text: '优化参数',
value: '优化参数',
},
{
text: '建表语句',
value: '建表语句',
},
{
text: 'CataLog',
value: 'CataLog',
},
{
text: '设置参数',
value: '设置参数',
},
{
text: '内置函数',
value: '内置函数',
},
{
text: 'UDF',
value: 'UDF',
},
{
text: 'Other',
value: 'Other',
}
];
/**
* document function type enum map
*/
export const DOCUMENT_FUNCTION_ENUMS = {
'优化参数': {text: '优化参数'},
'建表语句': {text: '建表语句'},
'CataLog': {text: 'CataLog'},
'设置参数': {text: '设置参数'},
'内置函数': {text: '内置函数'},
'UDF': {text: 'UDF'},
'Other': {text: 'Other'},
};
export const DOCUMENT_SUBTYPE = [
{
text: 'Batch/Streaming',
value: 'Batch/Streaming',
}, {
text: 'Batch',
value: 'Batch',
}, {
text: 'Streaming',
value: 'Streaming',
}, {
text: 'Other',
value: 'Other',
}, {
text: '比较函数',
value: '比较函数',
}, {
text: '逻辑函数',
value: '逻辑函数',
}, {
text: '算术函数',
value: '算术函数',
}, {
text: '字符串函数',
value: '字符串函数',
}, {
text: '时间函数',
value: '时间函数',
}, {
text: '类型转换函数功能',
value: '类型转换函数功能',
}, {
text: '条件函数',
value: '条件函数',
}, {
text: 'Collection 函数',
value: 'Collection 函数',
}, {
text: 'Value Construction函数',
value: 'Value Construction函数',
}, {
text: 'Value Access函数',
value: 'Value Access函数',
}, {
text: '分组函数',
value: '分组函数',
}, {
text: 'hash函数',
value: 'hash函数',
}, {
text: '聚合函数',
value: '聚合函数',
}, {
text: '列函数',
value: '列函数',
}, {
text: '表值聚合函数',
value: '表值聚合函数',
}, {
text: '其他函数',
value: '其他函数',
},
]
export const DOCUMENT_SUBTYPE_ENUMS = {
'Batch/Streaming': {text: 'Batch/Streaming'},
'Batch': {text: 'Batch'},
'Streaming': {text: 'Streaming'},
'Other': {text: 'Other'},
'比较函数': {text: '比较函数'},
'逻辑函数': {text: '逻辑函数'},
'算术函数': {text: '算术函数'},
'字符串函数': {text: '字符串函数'},
'时间函数': {text: '时间函数'},
'条件函数': {text: '条件函数'},
'类型转换函数功能': {text: '类型转换函数功能'},
'Collection 函数': {text: 'Collection 函数'},
'Value Construction函数': {text: 'Value Construction函数'},
'Value Access函数': {text: 'Value Access函数'},
'分组函数': {text: '分组函数'},
'hash函数': {text: 'hash函数'},
'聚合函数': {text: '聚合函数'},
'列函数': {text: '列函数'},
'表值聚合函数': {text: '表值聚合函数'},
'其他函数': {text: '其他函数'},
}
/**
* versions select options
*/
export const VERSIONS = [
{
text: 'Flink-1.12',
value: '1.12',
},
{
text: 'Flink-1.13',
value: '1.13',
},
{
text: 'Flink-1.14',
value: '1.14',
},
{
text: 'Flink-1.15',
value: '1.15',
},{
text: 'Flink-1.16',
value: '1.16',
},{
text: 'Flink-1.17',
value: '1.17',
},{
text: 'All Versions',
value: 'All Versions',
},
]
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {EditTwoTone, PlusOutlined} from '@ant-design/icons';
import {Button, Drawer, Popconfirm, Space, Switch} from 'antd';
import React, {useRef, useState} from 'react';
import {PageContainer} from '@ant-design/pro-layout';
import type {ActionType, ProColumns} from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
import ProDescriptions from '@ant-design/pro-descriptions';
import DocumentForm from "./components/DocumentForm";
import {l} from "@/utils/intl";
import {Document} from "@/types/RegCenter/data";
import {queryList} from "@/services/api";
import {
DOCUMENT_CATEGORY,
DOCUMENT_CATEGORY_ENUMS,
DOCUMENT_FUNCTION_ENUMS,
DOCUMENT_FUNCTION_TYPE, DOCUMENT_SUBTYPE, DOCUMENT_SUBTYPE_ENUMS
} from "@/pages/RegCenter/Document/constans";
import {API_CONSTANTS, PROTABLE_OPTIONS_PUBLIC, STATUS_ENUM, STATUS_MAPPING} from "@/services/constants";
import CodeShow from "@/components/CustomMonacoEditor/CodeShow";
import {DangerDeleteIcon} from "@/components/Icons/CustomIcons";
import {handleAddOrUpdate, handleRemoveById, updateEnabled} from "@/services/BusinessCrud";
import TextArea from "antd/es/input/TextArea";
const DocumentTableList: React.FC = (props: any) => {
const [modalVisible, handleModalVisible] = useState<boolean>(false);
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
const [formValues, setFormValues] = useState({});
const actionRef = useRef<ActionType>();
const [row, setRow] = useState<Document>();
const [loading, setLoading] = useState<boolean>(false);
/**
* delete document by id
* @param id
*/
const handleDeleteSubmit = async (id: number) => {
await handleRemoveById(API_CONSTANTS.DOCUMENT_DELETE, id);
actionRef.current?.reload?.();
}
/**
* enable or disable document
* @param value
*/
const handleChangeEnable = async (value: Partial<Document>) => {
setLoading(true);
await updateEnabled(API_CONSTANTS.DOCUMENT_ENABLE, {id: value.id});
setLoading(false);
actionRef.current?.reload?.();
};
/**
* added document var
* @param value
*/
const handleAddSubmit = async (value: Partial<Document>) => {
const success = await handleAddOrUpdate(API_CONSTANTS.DOCUMENT, value);
if (success) {
handleModalVisible(!modalVisible);
setFormValues({});
if (actionRef.current) {
actionRef.current.reload();
}
}
}
/**
* update document var
* @param value
*/
const handleUpdateSubmit = async (value: Partial<Document>) => {
const success = await handleAddOrUpdate(API_CONSTANTS.DOCUMENT, value);
if (success) {
handleUpdateModalVisible(!updateModalVisible);
setFormValues({});
if (actionRef.current) {
actionRef.current.reload();
}
}
}
/**
* columns
*/
const columns: ProColumns<Document>[] = [
{
title: l('rc.doc.name'),
dataIndex: 'name',
sorter: true,
width: '20vw',
render: (dom, entity) => {
return <a onClick={() => setRow(entity)}>{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
},
{
title: l('rc.doc.subFunctionType'),
sorter: true,
dataIndex: 'subtype',
filters: DOCUMENT_SUBTYPE,
filterMultiple: false,
valueEnum: DOCUMENT_SUBTYPE_ENUMS,
},
{
title: l('rc.doc.description'),
dataIndex: 'description',
ellipsis: true,
hideInTable: true,
renderText: (text: string) => {
return <TextArea value={text} autoSize readOnly />;
}
}, {
title: l('rc.doc.fillValue'),
dataIndex: 'fillValue',
hideInTable: true,
hideInSearch: true,
render: (_,record) => {
return <CodeShow code={record.fillValue} />
}
},
{
title: l('rc.doc.version'),
sorter: true,
dataIndex: 'version',
hideInForm: false,
hideInSearch: true,
hideInTable: true,
},
{
title: l('global.table.isEnable'),
dataIndex: 'enabled',
hideInSearch: true,
filters: STATUS_MAPPING(),
filterMultiple: false,
valueEnum: STATUS_ENUM(),
render: (_, record) => {
return <>
<Space>
<Switch
key={record.id}
checkedChildren={l("status.enabled")}
unCheckedChildren={l("status.disabled")}
checked={record.enabled}
onChange={() => handleChangeEnable(record)}/>
</Space>
</>;
},
},
{
title: l('global.table.createTime'),
dataIndex: 'createTime',
sorter: true,
hideInTable: true,
hideInSearch: true,
valueType: 'dateTime',
},
{
title: l('global.table.lastUpdateTime'),
dataIndex: 'updateTime',
sorter: true,
hideInTable: true,
hideInSearch: true,
valueType: 'dateTime',
},
{
title: l('global.table.operate'),
valueType: 'option',
render: (_, record) => [
<Button
className={"options-button"}
key={"DocumentEdit"}
icon={<EditTwoTone/>}
title={l("button.edit")}
onClick={() => {
setFormValues(record);
handleUpdateModalVisible(true);
}}
/>,
<Popconfirm
placement="topRight"
title={l("button.delete")}
description={l("rc.doc.deleteConfirm")}
onConfirm={() => {
handleDeleteSubmit(record.id);
}}
okText={l("button.confirm")}
cancelText={l("button.cancel")}
>
<Button key={'deleteDocumentIcon'} icon={<DangerDeleteIcon/>}/>
</Popconfirm>
],
},
];
return (
<PageContainer title={false}>
<ProTable<Document>
{...PROTABLE_OPTIONS_PUBLIC}
loading={loading}
headerTitle={l('rc.doc.Management')}
actionRef={actionRef}
toolBarRender={() => [
<Button type="primary" onClick={() => handleModalVisible(true)}>
<PlusOutlined/> {l('button.create')}
</Button>,
]}
request={(params, sorter, filter:any) => queryList(API_CONSTANTS.DOCUMENT, {...params, sorter, filter})}
columns={columns}
/>
<DocumentForm
onSubmit={(value) => {
handleAddSubmit(value)
}}
onCancel={() => {
handleModalVisible(false);
}}
modalVisible={modalVisible}
values={{}}
/>
{formValues && Object.keys(formValues).length ? (
<DocumentForm
onSubmit={(value) => {
handleUpdateSubmit(value)
}}
onCancel={() => {
handleUpdateModalVisible(false);
setFormValues({});
}}
modalVisible={updateModalVisible}
values={formValues}
/>
) : null
}
<Drawer
width={'50%'}
visible={!!row}
onClose={() => {
setRow(undefined);
}}
closable={false}
>
{row?.id && (
<ProDescriptions<Document>
column={1}
title={row.name}
request={async () => ({
data: row,
})}
params={{
id: row.id,
}}
columns={columns as any}
/>
)}
</Drawer>
</PageContainer>
)
;
};
export default DocumentTableList;
......@@ -62,7 +62,7 @@ const GlobalVarList: React.FC = (props: any) => {
*/
const handleDeleteSubmit = async (id: number) => {
await handleRemoveById(API_CONSTANTS.GLOBAL_VARIABLE_DELETE, id);
actionRef.current?.reloadAndRest?.();
actionRef.current?.reload?.();
}
......
......@@ -69,6 +69,16 @@ export const API_CONSTANTS = {
GLOBAL_VARIABLE_DELETE: "/api/fragment/delete",
// global variable enable or disable
GLOBAL_VARIABLE_ENABLE: "/api/fragment/enable",
// --- registries center ---
// document list
DOCUMENT: "/api/document",
// delete document by id
DOCUMENT_DELETE: "/api/document/delete",
// document enable or disable
DOCUMENT_ENABLE: "/api/document/enable",
};
......@@ -147,7 +157,10 @@ export const PROTABLE_OPTIONS_PUBLIC = {
},
tableStyle: {height: "58vh"},
rowKey: "id",
search: {labelWidth: 120}
search: {
labelWidth: 120, // must be number
span: 4,
},
};
/**
......
......@@ -17,7 +17,7 @@
import {TENANT_ID} from "@/services/constants";
import cookies from "js-cookie";
import {THEME,CODE_EDIT_THEME} from "@/types/Public/data";
import {THEME, CODE_EDIT_THEME} from "@/types/Public/data";
import {editor} from "monaco-editor";
/**
......@@ -50,7 +50,7 @@ export function parseJsonStr(jsonStr: string) {
/**
* get theme by localStorage's theme
*/
export function getLocalTheme () {
export function getLocalTheme() {
return localStorage.getItem(THEME.NAV_THEME);
}
......@@ -58,7 +58,7 @@ export function getLocalTheme () {
* get code edit theme by localStorage's theme
* @constructor
*/
export function ConvertCodeEditTheme () {
export function ConvertCodeEditTheme() {
/**
* user can define a new theme by calling the defineTheme method on the editor.
......@@ -68,15 +68,18 @@ export function ConvertCodeEditTheme () {
inherit: true, // 是否继承基础主题配置 , 默认为 true, is to inherit the base theme
// rules is an array of rules. The array must not be sparse (i.e. do not use holes).
rules: [
{ token: 'comment', foreground: '#008800', fontStyle: 'italic' },
{ token: 'keyword', foreground: '#f30282', fontStyle: 'bold' },
{ token: 'string', foreground: '#0b14cc' },
{ token: 'delimiter', foreground: '#ffffff' }
{token: 'comment', foreground: '#008800', fontStyle: 'italic'},
{token: 'keyword', foreground: '#f30282', fontStyle: 'bold'},
{token: 'string', foreground: '#ffffff'},
{token: 'delimiter', foreground: '#ff0026'},
{token: 'readonly', foreground: '#ffffff', background: '#141414', fontStyle: 'italic'},
{token: 'number', foreground: '#ffffff'},
],
// colors is an object of color identifiers and their color values.
colors: {
'editor.background': '#141414', // editor background color
'editor.lineHighlightBackground': '#0000ff20', // editor line highlight background color
'editor.lineHighlightBackground': '#141414', // editor line highlight background color
'editorLineNumber.foreground': '#ffffff', // editor line number color
'editorCursor.foreground': '#ffffff', // editor cursor color
'editorIndentGuide.background': '#ffffff', // editor indent guide color
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment