forked from apache/inlong
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INLONG-9427][Dashboard] Data access supports viewing operation logs
- Loading branch information
Showing
5 changed files
with
245 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
inlong-dashboard/src/ui/pages/GroupDetail/OperationLog/config.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import i18n from '@/i18n'; | ||
import { Tooltip } from 'antd'; | ||
import React from 'react'; | ||
|
||
const targetList = [ | ||
{ | ||
label: 'Group', | ||
value: 'GROUP', | ||
}, | ||
{ | ||
label: 'Stream', | ||
value: 'STREAM', | ||
}, | ||
{ | ||
label: 'Source', | ||
value: 'SOURCE', | ||
}, | ||
{ | ||
label: 'Sink', | ||
value: 'SINK', | ||
}, | ||
]; | ||
|
||
const typeList = [ | ||
{ | ||
label: 'Create', | ||
value: 'CREATE', | ||
}, | ||
{ | ||
label: 'Update', | ||
value: 'UPDATE', | ||
}, | ||
{ | ||
label: 'Delete', | ||
value: 'DELETE', | ||
}, | ||
{ | ||
label: 'Get', | ||
value: 'GET', | ||
}, | ||
]; | ||
|
||
export const getFormContent = inlongGroupId => [ | ||
{ | ||
type: 'select', | ||
label: i18n.t('pages.GroupDetail.OperationLog.Stream'), | ||
name: 'inlongStreamId', | ||
props: { | ||
options: { | ||
requestAuto: true, | ||
requestTrigger: ['onOpen', 'onSearch'], | ||
requestService: keyword => ({ | ||
url: '/stream/list', | ||
method: 'POST', | ||
data: { | ||
keyword, | ||
pageNum: 1, | ||
pageSize: 20, | ||
inlongGroupId, | ||
}, | ||
}), | ||
requestParams: { | ||
formatResult: result => | ||
result?.list?.map(item => ({ | ||
label: item.inlongStreamId, | ||
value: item.inlongStreamId, | ||
})), | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
type: 'select', | ||
label: i18n.t('pages.GroupDetail.OperationLog.OperationTarget'), | ||
name: 'operationTarget', | ||
props: { | ||
dropdownMatchSelectWidth: false, | ||
options: targetList, | ||
}, | ||
}, | ||
{ | ||
type: 'select', | ||
label: i18n.t('pages.GroupDetail.OperationLog.OperationType'), | ||
name: 'operationType', | ||
props: { | ||
dropdownMatchSelectWidth: false, | ||
options: typeList, | ||
}, | ||
}, | ||
]; | ||
|
||
export const getTableColumns = [ | ||
{ | ||
title: i18n.t('pages.GroupDetail.OperationLog.Table.GroupId'), | ||
dataIndex: 'inlongGroupId', | ||
}, | ||
{ | ||
title: i18n.t('pages.GroupDetail.OperationLog.Table.StreamId'), | ||
dataIndex: 'inlongStreamId', | ||
}, | ||
{ | ||
title: i18n.t('pages.GroupDetail.OperationLog.Table.Operator'), | ||
dataIndex: 'operator', | ||
}, | ||
{ | ||
title: i18n.t('pages.GroupDetail.OperationLog.Table.OperationType'), | ||
dataIndex: 'operationType', | ||
render: text => typeList.find(c => c.value === text)?.label || text, | ||
}, | ||
{ | ||
title: i18n.t('pages.GroupDetail.OperationLog.Table.OperationTarget'), | ||
dataIndex: 'operationTarget', | ||
render: text => targetList.find(c => c.value === text)?.label || text, | ||
}, | ||
{ | ||
title: i18n.t('pages.GroupDetail.OperationLog.Table.Log'), | ||
dataIndex: 'body', | ||
ellipsis: true, | ||
render: body => ( | ||
<Tooltip placement="topLeft" title={body}> | ||
{body} | ||
</Tooltip> | ||
), | ||
}, | ||
]; |
93 changes: 93 additions & 0 deletions
93
inlong-dashboard/src/ui/pages/GroupDetail/OperationLog/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* 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 HighTable from '@/ui/components/HighTable'; | ||
import { useRequest } from '@/ui/hooks'; | ||
import { CommonInterface } from '../common'; | ||
import { getFormContent, getTableColumns } from './config'; | ||
import { defaultSize } from '@/configs/pagination'; | ||
|
||
type Props = CommonInterface; | ||
|
||
const Comp: React.FC<Props> = ({ inlongGroupId }) => { | ||
const [options, setOptions] = useState({ | ||
pageSize: defaultSize, | ||
pageNum: 1, | ||
}); | ||
|
||
const { data: sourceData, run } = useRequest( | ||
{ | ||
url: '/operationLog/list', | ||
method: 'POST', | ||
data: { | ||
inlongGroupId, | ||
...options, | ||
}, | ||
}, | ||
{ | ||
refreshDeps: [options], | ||
}, | ||
); | ||
|
||
const pagination = { | ||
pageSize: options.pageSize, | ||
current: options.pageNum, | ||
total: sourceData?.total, | ||
}; | ||
const onChange = ({ current: pageNum, pageSize }) => { | ||
setOptions(prev => ({ | ||
...prev, | ||
pageNum, | ||
pageSize, | ||
})); | ||
}; | ||
|
||
const onFilter = allValues => { | ||
setOptions(prev => ({ | ||
...prev, | ||
...allValues, | ||
pageNum: 1, | ||
})); | ||
}; | ||
|
||
useEffect(() => { | ||
run(); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<HighTable | ||
filterForm={{ | ||
content: getFormContent(inlongGroupId), | ||
onFilter, | ||
}} | ||
table={{ | ||
columns: getTableColumns, | ||
dataSource: sourceData?.list, | ||
pagination: pagination, | ||
rowKey: 'inlongGroupId', | ||
onChange, | ||
}} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default Comp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters