This is an automated email from the ASF dual-hosted git repository.
dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git
The following commit(s) were added to refs/heads/master by this push:
new eadda7cd3d [INLONG-10347][Dashboard] Add Agent IP field to PostgreSQL
data source (#10348)
eadda7cd3d is described below
commit eadda7cd3d23d1c4ca54ee378dbdbcd9b8ea28b5
Author: haifxu <[email protected]>
AuthorDate: Tue Jun 4 19:42:50 2024 +0800
[INLONG-10347][Dashboard] Add Agent IP field to PostgreSQL data source
(#10348)
---
.../src/plugins/sources/defaults/PostgreSQL.ts | 110 +++++++++++++++++++++
.../pages/GroupDetail/DataSources/DetailModal.tsx | 4 +-
2 files changed, 113 insertions(+), 1 deletion(-)
diff --git a/inlong-dashboard/src/plugins/sources/defaults/PostgreSQL.ts
b/inlong-dashboard/src/plugins/sources/defaults/PostgreSQL.ts
index b49b751201..bb42c816ab 100644
--- a/inlong-dashboard/src/plugins/sources/defaults/PostgreSQL.ts
+++ b/inlong-dashboard/src/plugins/sources/defaults/PostgreSQL.ts
@@ -22,6 +22,7 @@ import { RenderRow } from '@/plugins/RenderRow';
import { RenderList } from '@/plugins/RenderList';
import { SourceInfo } from '../common/SourceInfo';
import i18n from '@/i18n';
+import rulesPattern from '@/core/utils/pattern';
const { I18n } = DataWithBackend;
const { FieldDecorator, SyncField, IngestionField } = RenderRow;
@@ -31,6 +32,97 @@ export default class PostgreSQLSource
extends SourceInfo
implements DataWithBackend, RenderRow, RenderList
{
+ @FieldDecorator({
+ type: 'select',
+ rules: [{ required: true }],
+ props: values => ({
+ disabled: Boolean(values.id),
+ showSearch: true,
+ allowClear: true,
+ filterOption: false,
+ options: {
+ requestTrigger: ['onOpen', 'onSearch'],
+ requestService: keyword => ({
+ url: '/cluster/list',
+ method: 'POST',
+ data: {
+ keyword,
+ type: 'AGENT',
+ pageNum: 1,
+ pageSize: 10,
+ },
+ }),
+ requestParams: {
+ formatResult: result =>
+ result?.list?.map(item => ({
+ ...item,
+ label: item.displayName,
+ value: item.name,
+ })),
+ },
+ },
+ onChange: (value, option) => {
+ return {
+ clusterId: option.id,
+ };
+ },
+ }),
+ })
+ @ColumnDecorator()
+ @IngestionField()
+ @I18n('meta.Sources.File.ClusterName')
+ inlongClusterName: string;
+
+ @FieldDecorator({
+ type: 'text',
+ hidden: true,
+ })
+ @I18n('clusterId')
+ @IngestionField()
+ clusterId: number;
+
+ @FieldDecorator({
+ type: 'select',
+ rules: [
+ {
+ pattern: rulesPattern.ip,
+ message: i18n.t('meta.Sources.File.IpRule'),
+ required: true,
+ },
+ ],
+ props: values => ({
+ disabled: Boolean(values.id),
+ showSearch: true,
+ allowClear: true,
+ filterOption: false,
+ options: {
+ requestTrigger: ['onOpen', 'onSearch'],
+ requestService: keyword => ({
+ url: '/cluster/node/list',
+ method: 'POST',
+ data: {
+ keyword,
+ parentId: values.clusterId,
+ pageNum: 1,
+ pageSize: 10,
+ },
+ }),
+ requestParams: {
+ formatResult: result =>
+ result?.list?.map(item => ({
+ ...item,
+ label: item.ip,
+ value: item.ip,
+ })),
+ },
+ },
+ }),
+ })
+ @ColumnDecorator()
+ @IngestionField()
+ @I18n('meta.Sources.File.DataSourceIP')
+ agentIp: string;
+
@FieldDecorator({
type: 'input',
rules: [{ required: true }],
@@ -171,6 +263,24 @@ export default class PostgreSQLSource
@I18n('meta.Sources.PostgreSQL.decodingPluginName')
decodingPluginName: string;
+ @FieldDecorator({
+ type: 'select',
+ initialValue: 'GMT+8:00',
+ props: values => ({
+ disabled: Boolean(values.id),
+ options: [
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -2, -3, -4, -5, -6,
-7, -8, -9, -10, -11,
+ -12,
+ ].map(item => ({
+ label: Math.sign(item) === 1 || Math.sign(item) === 0 ?
`GMT+${item}:00` : `GMT${item}:00`,
+ value: Math.sign(item) === 1 || Math.sign(item) === 0 ?
`GMT+${item}:00` : `GMT${item}:00`,
+ })),
+ }),
+ })
+ @IngestionField()
+ @I18n('meta.Sources.File.TimeZone')
+ dataTimeZone: string;
+
parse(data) {
let obj = { ...data };
obj.tableNameList = obj.tableNameList.join(',');
diff --git
a/inlong-dashboard/src/ui/pages/GroupDetail/DataSources/DetailModal.tsx
b/inlong-dashboard/src/ui/pages/GroupDetail/DataSources/DetailModal.tsx
index 62af7bcbb7..4f1675a3d2 100644
--- a/inlong-dashboard/src/ui/pages/GroupDetail/DataSources/DetailModal.tsx
+++ b/inlong-dashboard/src/ui/pages/GroupDetail/DataSources/DetailModal.tsx
@@ -68,7 +68,9 @@ const Comp: React.FC<Props> = ({
const onOk = async () => {
const values = await form.validateFields();
const submitData = new Entity()?.stringify(values) || values;
- submitData.agentIp = submitData.agentIp.join(',');
+ if (submitData.agentIp instanceof Array) {
+ submitData.agentIp = submitData.agentIp.join(',');
+ }
const isUpdate = Boolean(id);
if (isUpdate) {
submitData.id = id;