Skip to content

Commit

Permalink
feat: 全量日志支持选择执行应用
Browse files Browse the repository at this point in the history
  • Loading branch information
KT-core committed Oct 16, 2024
1 parent 8b2da22 commit dd94d3b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
4 changes: 4 additions & 0 deletions frontend/src/api/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export const updateLogRuleApi = (params) => {
export const deleteLogRuleApi = (params) => {
return post(`/api/log/rule/delete`, params)
}
//获取指定service的route map
export const getLogRuleServiceRouteRuleApi = (params) => {
return get(`/api/log/rule/service`, params)
}

//——————全量日志->接入外部表
// 获取所有外部表
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Form, Input, Modal, Select, Tooltip } from 'antd'
import React, { useEffect, useState } from 'react'
import LogRouteRuleFormList from './component/LogRouteRuleFormList'
import { addLogRuleApi, getLogRuleApi, updateLogRuleApi } from 'src/api/logs'
import {
addLogRuleApi,
getLogRuleApi,
getLogRuleServiceRouteRuleApi,
updateLogRuleApi,
} from 'src/api/logs'
import { showToast } from 'src/utils/toast'
import { useLogsContext } from 'src/contexts/LogsContext'
import { getServiceListApi } from 'src/api/service'
Expand Down Expand Up @@ -70,9 +75,10 @@ const ConfigLogRuleModal = ({ modalVisible, closeModal, logRuleInfo }) => {
title: '日志解析规则配置成功',
color: 'success',
})

getLogTableInfo()
closeModal()
})
getLogTableInfo()
closeModal()
}
function updateLogRule(logRuleParams) {
updateLogRuleApi({
Expand All @@ -84,7 +90,6 @@ const ConfigLogRuleModal = ({ modalVisible, closeModal, logRuleInfo }) => {
title: '日志解析规则配置成功',
color: 'success',
})

closeModal()
getLogTableInfo()
})
Expand Down Expand Up @@ -121,6 +126,26 @@ const ConfigLogRuleModal = ({ modalVisible, closeModal, logRuleInfo }) => {
})
.catch((error) => console.log(error))
}
const getServiceRouteRule = (serviceName) => {
getLogRuleServiceRouteRuleApi({
serviceName: serviceName,
}).then((res) => {
let result = form.getFieldValue('routeRule') || []

Object.entries(res?.routeRule)?.forEach(([key, value]) => {
result.push({
key: {
key: key,
value: key,
label: key,
},
value: value,
})
})
result = result.filter((item) => item.key && item.value)
form.setFieldValue('routeRule', result)
})
}
return (
<Modal
title={'日志解析规则配置'}
Expand Down Expand Up @@ -165,7 +190,11 @@ const ConfigLogRuleModal = ({ modalVisible, closeModal, logRuleInfo }) => {
<Input placeholder="规则描述" />
</Form.Item>
<Form.Item label="执行应用" name="serviceName">
<Select options={serviceList} placeholder="请选择执行规则的应用"></Select>
<Select
options={serviceList}
placeholder="请选择执行规则的应用"
onChange={(value) => getServiceRouteRule(value)}
></Select>
</Form.Item>
<LogRouteRuleFormList />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ const ConfigTableModal = ({ modalVisible, closeModal }) => {
title: '接入日志表配置成功',
color: 'success',
})

getLogTableInfo()
closeModal()
})
getLogTableInfo()
closeModal()
}
function saveLogRule() {
form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
position: relative;
display: flex;
flex: 1;
width: calc(100% - 40px);
// width: calc(100% - 40px);
margin-right: 8px;
.inputBox {
z-index: 1;
Expand Down

0 comments on commit dd94d3b

Please sign in to comment.