Skip to content

Commit

Permalink
[INLONG-11379][Dashboard] Redis sink Properties saving problem (#11380)
Browse files Browse the repository at this point in the history
  • Loading branch information
wohainilaodou authored Oct 22, 2024
1 parent 6596da9 commit 827a739
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 29 deletions.
57 changes: 28 additions & 29 deletions inlong-dashboard/src/plugins/sinks/defaults/Redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,35 +295,6 @@ export default class RedisSink extends SinkInfo implements DataWithBackend, Rend
@I18n('meta.Sinks.Redis.Ttl')
ttl: number;

@FieldDecorator({
type: EditableTable,
props: values => ({
size: 'small',
editing: ![110].includes(values?.status),
columns: getFieldListColumns(values),
canBatchAdd: true,
upsertByFieldKey: true,
}),
})
@IngestionField()
sinkFieldList: Record<string, unknown>[];

@FieldDecorator({
type: EditableTable,
initialValue: [],
props: values => ({
size: 'small',
editing: ![110].includes(values?.status),
columns: getFieldListColumns(values).filter(
item => item.dataIndex !== 'sourceFieldName' && item.dataIndex !== 'sourceFieldType',
),
canBatchAdd: true,
upsertByFieldKey: true,
}),
})
@SyncCreateTableField()
createTableField: Record<string, unknown>[];

@FieldDecorator({
type: EditableTable,
rules: [{ required: false }],
Expand Down Expand Up @@ -352,6 +323,34 @@ export default class RedisSink extends SinkInfo implements DataWithBackend, Rend
@IngestionField()
@I18n('meta.Sinks.Redis.ExtList')
properties: string;
@FieldDecorator({
type: EditableTable,
props: values => ({
size: 'small',
editing: ![110].includes(values?.status),
columns: getFieldListColumns(values),
canBatchAdd: true,
upsertByFieldKey: true,
}),
})
@IngestionField()
sinkFieldList: Record<string, unknown>[];

@FieldDecorator({
type: EditableTable,
initialValue: [],
props: values => ({
size: 'small',
editing: ![110].includes(values?.status),
columns: getFieldListColumns(values).filter(
item => item.dataIndex !== 'sourceFieldName' && item.dataIndex !== 'sourceFieldType',
),
canBatchAdd: true,
upsertByFieldKey: true,
}),
})
@SyncCreateTableField()
createTableField: Record<string, unknown>[];

@FieldDecorator({
type: 'inputnumber',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ const Comp: React.FC<DetailModalProps> = ({
formatResult: result => new Entity()?.parse(result) || result,
onSuccess: result => {
setSinkType(result.sinkType);
if (result.sinkType === 'REDIS') {
result.properties = Object.entries(result.properties).map(([key, value]) => ({
keyName: key,
keyValue: value,
}));
}
form.setFieldsValue(result);
},
},
Expand Down Expand Up @@ -158,6 +164,19 @@ const Comp: React.FC<DetailModalProps> = ({
if (startProcess) {
submitData.startProcess = true;
}
if (sinkType === 'REDIS') {
if (Array.isArray(submitData.properties) && submitData.properties.length > 0) {
const propertiesObject = submitData.properties.reduce((acc, item) => {
if (item.keyName && item.keyValue !== undefined) {
acc[item.keyName] = item.keyValue;
}
return acc;
}, {});
submitData.properties = propertiesObject;
} else {
submitData.properties = {};
}
}
await request({
url: isUpdate ? '/sink/update' : '/sink/save',
method: 'POST',
Expand Down

0 comments on commit 827a739

Please sign in to comment.