diff --git a/inlong-dashboard/src/plugins/sinks/defaults/Cls.ts b/inlong-dashboard/src/plugins/sinks/defaults/Cls.ts new file mode 100644 index 00000000000..4a55390022b --- /dev/null +++ b/inlong-dashboard/src/plugins/sinks/defaults/Cls.ts @@ -0,0 +1,183 @@ +/* + * 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 { DataWithBackend } from '@/plugins/DataWithBackend'; +import { RenderRow } from '@/plugins/RenderRow'; +import { RenderList } from '@/plugins/RenderList'; +import i18n from '@/i18n'; +import EditableTable from '@/ui/components/EditableTable'; +import { SinkInfo } from '../common/SinkInfo'; +import { sourceFields } from '../common/sourceFields'; +import NodeSelect from '@/ui/components/NodeSelect'; + +const { I18n } = DataWithBackend; +const { FieldDecorator, SyncField } = RenderRow; +const { ColumnDecorator } = RenderList; + +const targetTypes = ['int', 'long', 'float', 'double', 'string', 'date', 'timestamp'].map(item => ({ + label: item, + value: item, +})); + +export default class ClsSink extends SinkInfo implements DataWithBackend, RenderRow, RenderList { + @FieldDecorator({ + type: 'input', + rules: [{ required: true }], + props: values => ({ + disabled: [110, 130].includes(values?.status), + }), + }) + @ColumnDecorator() + @I18n('Topic Name') + @SyncField() + topicName: string; + + @FieldDecorator({ + type: 'input', + rules: [{ required: true }], + props: values => ({ + disabled: [110, 130].includes(values?.status), + }), + }) + @ColumnDecorator() + @I18n('meta.Sinks.Cls.Tag') + @SyncField() + tag: string; + + @FieldDecorator({ + type: 'input', + rules: [{ required: true }], + props: values => ({ + disabled: [110, 130].includes(values?.status), + }), + }) + @ColumnDecorator() + @SyncField() + @I18n('meta.Sinks.Cls.Tokenizer') + tokenizer: string; + + @FieldDecorator({ + type: 'select', + rules: [{ required: true }], + props: values => ({ + disabled: [110, 130].includes(values?.status), + options: [ + { + label: i18n.t('meta.Sinks.Cls.SaveTime.Week'), + value: 7, + }, + { + label: i18n.t('meta.Sinks.Cls.SaveTime.Month'), + value: 30, + }, + { + label: i18n.t('meta.Sinks.Cls.SaveTime.HalfAYear'), + value: 182, + }, + { + label: i18n.t('meta.Sinks.Cls.SaveTime.OneYear'), + value: 365, + }, + ], + }), + }) + @I18n('meta.Sinks.Cls.SaveTime') + @SyncField() + saveTime: number; + + @FieldDecorator({ + type: NodeSelect, + rules: [{ required: true }], + props: values => ({ + disabled: [110, 130].includes(values?.status), + nodeType: 'CLS', + }), + }) + @I18n('meta.Sinks.DataNodeName') + @SyncField() + @ColumnDecorator() + dataNodeName: string; + + @FieldDecorator({ + type: EditableTable, + props: values => ({ + size: 'small', + canDelete: ![110, 130].includes(values?.status), + columns: getFieldListColumns(values), + canBatchAdd: true, + upsertByFieldKey: true, + }), + }) + sinkFieldList: Record[]; +} + +const getFieldListColumns = sinkValues => { + return [ + ...sourceFields, + { + title: `CLS${i18n.t('meta.Sinks.Cls.FieldName')}`, + dataIndex: 'fieldName', + initialValue: '', + rules: [ + { required: true }, + { + pattern: /^[a-z][0-9a-z_]*$/, + message: i18n.t('meta.Sinks.Cls.FieldNameRule'), + }, + ], + props: (text, record, idx, isNew) => ({ + disabled: [110, 130].includes(sinkValues?.status as number) && !isNew, + }), + }, + { + title: `CLS${i18n.t('meta.Sinks.Cls.FieldType')}`, + dataIndex: 'fieldType', + initialValue: targetTypes[0].value, + type: 'select', + props: (text, record, idx, isNew) => ({ + options: targetTypes, + disabled: [110, 130].includes(sinkValues?.status as number) && !isNew, + }), + rules: [{ required: true, message: `${i18n.t('meta.Sinks.FieldTypeMessage')}` }], + }, + { + title: i18n.t('meta.Sinks.Cls.IsMetaField'), + dataIndex: 'isMetaField', + initialValue: 0, + type: 'select', + props: (text, record, idx, isNew) => ({ + options: [ + { + label: i18n.t('basic.Yes'), + value: 1, + }, + { + label: i18n.t('basic.No'), + value: 0, + }, + ], + }), + }, + { + title: i18n.t('meta.Sinks.Cls.FieldDescription'), + dataIndex: 'fieldComment', + initialValue: '', + }, + ]; +}; diff --git a/inlong-dashboard/src/plugins/sinks/defaults/index.ts b/inlong-dashboard/src/plugins/sinks/defaults/index.ts index d404bd2a0d7..1c16d86085d 100644 --- a/inlong-dashboard/src/plugins/sinks/defaults/index.ts +++ b/inlong-dashboard/src/plugins/sinks/defaults/index.ts @@ -31,6 +31,11 @@ export const allDefaultSinks: MetaExportWithBackendList = [ value: 'CLICKHOUSE', LoadEntity: () => import('./ClickHouse'), }, + { + label: 'Cls', + value: 'CLS', + LoadEntity: () => import('./Cls'), + }, { label: 'Doris', value: 'DORIS', diff --git a/inlong-dashboard/src/ui/locales/cn.json b/inlong-dashboard/src/ui/locales/cn.json index 5d96950de73..fa24482312c 100644 --- a/inlong-dashboard/src/ui/locales/cn.json +++ b/inlong-dashboard/src/ui/locales/cn.json @@ -369,6 +369,19 @@ "meta.Sinks.Pulsar.Tenant": "Pulsar 租户", "meta.Sinks.Pulsar.Namespace": "命名空间", "meta.Sinks.Pulsar.PartitionNum": "分区数", + "meta.Sinks.Cls.SaveTime": "日志保存时间", + "meta.Sinks.Cls.SaveTime.Week": "一周", + "meta.Sinks.Cls.SaveTime.Month": "一月", + "meta.Sinks.Cls.SaveTime.HalfAYear": "半年", + "meta.Sinks.Cls.SaveTime.OneYear": "一年", + "meta.Sinks.Cls.Tag": "标签", + "meta.Sinks.Cls.Tokenizer": "分词规则", + "meta.Sinks.Cls.FieldName": "字段名", + "meta.Sinks.Cls.FieldType": "字段类型", + "meta.Sinks.Cls.FieldDescription": "字段描述", + "meta.Sinks.Cls.IsMetaField": "是否为元字段", + "meta.Sinks.Cls.FieldFormat": "字段格式", + "meta.Sinks.Cls.FieldNameRule": "以英文字母或下划线开头,只能包含英文字母、数字、下划线", "meta.Group.InlongGroupId": "数据流组 ID", "meta.Group.InlongGroupIdRules": "只能包含英文字母、数字、点号(.)、中划线(-)、下划线(_)", "meta.Group.InlongGroupName": "数据流组名称", diff --git a/inlong-dashboard/src/ui/locales/en.json b/inlong-dashboard/src/ui/locales/en.json index 31e9e18707b..d19ae4fb247 100644 --- a/inlong-dashboard/src/ui/locales/en.json +++ b/inlong-dashboard/src/ui/locales/en.json @@ -369,6 +369,19 @@ "meta.Sinks.Pulsar.Tenant": "Pulsar Tenant", "meta.Sinks.Pulsar.Namespace": "Namespace", "meta.Sinks.Pulsar.PartitionNum": "Partition Number", + "meta.Sinks.Cls.SaveTime": "Log save time", + "meta.Sinks.Cls.SaveTime.Week": "One week", + "meta.Sinks.Cls.SaveTime.Month": "One month", + "meta.Sinks.Cls.SaveTime.HalfAYear": "Half a year", + "meta.Sinks.Cls.SaveTime.OneYear": "One year", + "meta.Sinks.Cls.Tag": "Tag", + "meta.Sinks.Cls.Tokenizer": "Tokenizer Rule", + "meta.Sinks.Cls.FieldName": "FieldName", + "meta.Sinks.Cls.FieldType": "FieldType", + "meta.Sinks.Cls.FieldDescription": "Field description", + "meta.Sinks.Cls.IsMetaField": "IsMetaField", + "meta.Sinks.Cls.FieldFormat": "FieldFormat", + "meta.Sinks.Cls.FieldNameRule": "At the beginning of lowercase letters, only lowercase letters, numbers, and underscores", "meta.Group.InlongGroupId": "Inlong Group ID", "meta.Group.InlongGroupIdRules": "Only English letters, numbers, dots(.), minus(-), and underscores(_)", "meta.Group.InlongGroupName": "Inlong Group Name",