Skip to content

Commit

Permalink
Merge branch 'master' into INLONG-10816
Browse files Browse the repository at this point in the history
  • Loading branch information
Ybszzzziz authored Aug 21, 2024
2 parents b8c6971 + ee7f3d9 commit c78ba3d
Show file tree
Hide file tree
Showing 39 changed files with 1,443 additions and 835 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ public class DataNodeType {
public static final String PULSAR = "PULSAR";
public static final String CLS = "CLS";
public static final String ELASTICSEARCH = "ELASTICSEARCH";
public static final String HTTP = "HTTP";
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public class SinkType {
public static final String CLS = "CLS";
public static final String ELASTICSEARCH = "ELASTICSEARCH";
public static final String STARROCKS = "STARROCKS";
public static final String HTTP = "HTTP";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.
*/

package org.apache.inlong.common.pojo.sort.dataflow.sink;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Map;

@EqualsAndHashCode(callSuper = true)
@Data
public class HttpSinkConfig extends SinkConfig {

private String path;
private String method;
private Map<String, String> headers;
private Integer maxRetryTimes;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
@JsonSubTypes.Type(value = EsSinkConfig.class, name = SinkType.ELASTICSEARCH),
@JsonSubTypes.Type(value = PulsarSinkConfig.class, name = SinkType.PULSAR),
@JsonSubTypes.Type(value = KafkaSinkConfig.class, name = SinkType.KAFKA),
@JsonSubTypes.Type(value = HttpSinkConfig.class, name = SinkType.HTTP),
})
public abstract class SinkConfig implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.
*/

package org.apache.inlong.common.pojo.sort.node;

import lombok.Data;

@Data
public class HttpNodeConfig extends NodeConfig {

private String baseUrl;
private Boolean enableCredential;
private String username;
private String password;
private Integer maxConnect;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
@JsonSubTypes.Type(value = EsNodeConfig.class, name = DataNodeType.ELASTICSEARCH),
@JsonSubTypes.Type(value = PulsarNodeConfig.class, name = DataNodeType.PULSAR),
@JsonSubTypes.Type(value = KafkaNodeConfig.class, name = DataNodeType.KAFKA),
@JsonSubTypes.Type(value = HttpNodeConfig.class, name = DataNodeType.HTTP),
})
public abstract class NodeConfig implements Serializable {

Expand Down
3 changes: 3 additions & 0 deletions inlong-dashboard/src/ui/locales/cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,9 @@
"pages.GroupDetail.Delay.AverageTitle": "平均传输时延 (ms)",
"pages.GroupDetail.Delay.RealTimeTitle": "传输时延 (ms)",
"pages.GroupDetail.Stream.Preview": "数据预览",
"pages.GroupDetail.Stream.Original": "原文",
"pages.GroupDetail.Stream.ShowOriginal": "显示原文",
"pages.GroupDetail.Stream.Closed": "关闭",
"pages.GroupDetail.Stream.Dt": "数据时间 (dt)",
"pages.GroupDetail.Stream.Content": "数据内容",
"pages.GroupDetail.Stream.Number": "数据条数",
Expand Down
3 changes: 3 additions & 0 deletions inlong-dashboard/src/ui/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,9 @@
"pages.GroupDetail.Delay.AverageTitle": "Average transmission delay (ms)",
"pages.GroupDetail.Delay.RealTimeTitle": "Transmission delay (ms)",
"pages.GroupDetail.Stream.Preview": "Data preview",
"pages.GroupDetail.Stream.Original": "Original",
"pages.GroupDetail.Stream.ShowOriginal": "Show Original",
"pages.GroupDetail.Stream.Closed": "Close",
"pages.GroupDetail.Stream.Dt": "Data time(dt)",
"pages.GroupDetail.Stream.Content": "Data content",
"pages.GroupDetail.Stream.Number": "Records number",
Expand Down
132 changes: 104 additions & 28 deletions inlong-dashboard/src/ui/pages/GroupDetail/DataStream/PreviewModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/

import React, { useState } from 'react';
import { Modal, Table, Radio, RadioChangeEvent } from 'antd';
import { Modal, Table, Radio, RadioChangeEvent, Button, Card } from 'antd';
import { ModalProps } from 'antd/es/modal';
import { useRequest, useUpdateEffect } from '@/ui/hooks';
import i18n from '@/i18n';
import { ColumnsType } from 'antd/es/table';
import { timestampFormat } from '@/core/utils';
import dayjs from 'dayjs';

export interface Props extends ModalProps {
inlongGroupId: string;
Expand All @@ -33,29 +33,18 @@ export interface Props extends ModalProps {

const Comp: React.FC<Props> = ({ inlongGroupId, inlongStreamId, ...modalProps }) => {
const [position, setPosition] = useState(1);

const [originalModal, setOriginalModal] = useState({
open: false,
record: {},
});
interface DataType {
id: React.Key;
dt: string;
body: string;
}

const detailColumns: ColumnsType<DataType> = [
{
title: 'ID',
dataIndex: 'id',
},
{
title: i18n.t('pages.GroupDetail.Stream.Dt'),
dataIndex: 'dt',
render: text => text && timestampFormat(text),
},
{
title: i18n.t('pages.GroupDetail.Stream.Content'),
dataIndex: 'body',
ellipsis: true,
render: text => <a>{text}</a>,
},
];
const onShowOriginModal = record => {
setOriginalModal({ open: true, record: record });
};

const { data: previewData, run: getPreviewData } = useRequest(
{
Expand All @@ -72,10 +61,80 @@ const Comp: React.FC<Props> = ({ inlongGroupId, inlongStreamId, ...modalProps })
},
);

const getColumn = () => {
let exitsId = false;
const result = previewData?.[0]?.fieldList?.reduce((acc, cur) => {
if (cur['fieldName'] === 'id') {
exitsId = true;
}
const width =
(cur['fieldName'].length > cur['fieldValue'].length
? cur['fieldName'].length
: cur['fieldValue'].length) * 10;
acc.push({
title: cur['fieldName'],
key: cur['fieldName'],
dataIndex: cur['fieldName'],
width: width >= 100 ? width : 100,
});
return acc;
}, []);
if (result) {
if (exitsId) {
return result;
}
return [{ title: 'id', key: 'id', dataIndex: 'id', width: 100 }].concat([...result]);
}
return;
};

const detailColumns: ColumnsType<DataType> = [
{
title: i18n.t('pages.GroupDetail.Stream.Dt'),
key: 'dt',
width: 200,
dataIndex: 'dt',
},
].concat(
(getColumn() ? getColumn() : []).concat([
{
title: 'operation',
key: 'operation',
fixed: 'right',
width: 100,
render: (text, record: any) => (
<>
<Button
type="link"
onClick={() => {
onShowOriginModal(record);
}}
>
{i18n.t('pages.GroupDetail.Stream.ShowOriginal')}
</Button>
</>
),
},
]),
);
const convertListToMap = () => {
const result = [];
for (let i = 0; i < previewData?.length; i++) {
const temp = previewData?.[i]?.fieldList.reduce((acc, item) => {
acc[item.fieldName] = item.fieldValue;
return acc;
}, {});
temp['id'] = temp['id'] ? temp['id'] : i;
temp['headers'] = previewData?.[i]?.headers;
temp['body'] = previewData?.[i]?.body;
temp['dt'] = dayjs(previewData?.[i]?.dt).format('YYYY-MM-DD HH:mm:ss');
result.push(temp);
}
return result;
};
const onChange = ({ target: { value } }: RadioChangeEvent) => {
setPosition(value);
};

useUpdateEffect(() => {
if (modalProps.open) {
if (inlongStreamId) {
Expand All @@ -102,14 +161,31 @@ const Comp: React.FC<Props> = ({ inlongGroupId, inlongStreamId, ...modalProps })
</div>
<Table
columns={detailColumns}
dataSource={previewData}
dataSource={convertListToMap()}
scroll={{ x: 950 }}
rowKey={'id'}
expandable={{
expandedRowRender: record => <p style={{ margin: 0 }}>{record.body}</p>,
rowExpandable: record => record.id !== 'Not Expandable',
expandRowByClick: true,
}}
></Table>

<Modal
width={800}
open={originalModal.open}
title={i18n.t('pages.GroupDetail.Stream.Original')}
onCancel={() => setOriginalModal(prev => ({ ...prev, open: false }))}
footer={[
<Button key="back" onClick={() => setOriginalModal(prev => ({ ...prev, open: false }))}>
{i18n.t('pages.GroupDetail.Stream.Closed')}
</Button>,
]}
>
<div>
<Card title="headers" bordered={false} style={{ width: 700 }}>
<p style={{ margin: 0 }}>{JSON.stringify(originalModal?.record['headers'])}</p>
</Card>
<Card title="body" bordered={false} style={{ width: 700, marginTop: 10 }}>
<p style={{ margin: 0 }}>{originalModal?.record['body']}</p>
</Card>
</div>
</Modal>
</Modal>
);
};
Expand Down
Loading

0 comments on commit c78ba3d

Please sign in to comment.