diff --git a/ui/src/components/EventsTable/index.tsx b/ui/src/components/EventsTable/index.tsx index 6beaf922e..9d7bc8a79 100644 --- a/ui/src/components/EventsTable/index.tsx +++ b/ui/src/components/EventsTable/index.tsx @@ -27,118 +27,17 @@ interface EventsTableProps { cardType?: 'card' | 'proCard'; collapsible?: boolean; defaultExpand?: boolean; + overView?: boolean; // 多个资源需要加上fiilter name?: string; } -const columns: ColumnsType = [ - { - title: intl.formatMessage({ - id: 'OBDashboard.components.EventsTable.Namespace', - defaultMessage: '命名空间', - }), - dataIndex: 'namespace', - key: 'namespace', - width: 120, - render: (text) => {text}, - }, - { - title: intl.formatMessage({ - id: 'OBDashboard.components.EventsTable.Type', - defaultMessage: '类型', - }), - dataIndex: 'type', - key: 'type', - filters: [ - { - text: intl.formatMessage({ - id: 'OBDashboard.components.EventsTable.Normal', - defaultMessage: '正常', - }), - value: 'Normal', - }, - { - text: intl.formatMessage({ - id: 'OBDashboard.components.EventsTable.Warning', - defaultMessage: '警告', - }), - value: 'Warning', - }, - ], - - onFilter: (value: any, record) => { - return record.type === value; - }, - render: (text) => { - const value = findByValue(EVENTSTABLE_STATUS_LIST, text); - return {value.label}; - }, - width: 120, - }, - { - title: intl.formatMessage({ - id: 'OBDashboard.components.EventsTable.NumberOfOccurrences', - defaultMessage: '发生次数', - }), - dataIndex: 'count', - key: 'count', - width: 130, - }, - { - title: intl.formatMessage({ - id: 'OBDashboard.components.EventsTable.FirstOccurrenceTime', - defaultMessage: '第一次发生时间', - }), - dataIndex: 'firstOccur', - key: 'firstOccur', - width: 210, - }, - { - title: intl.formatMessage({ - id: 'OBDashboard.components.EventsTable.RecentOccurrenceTime', - defaultMessage: '最近发生时间', - }), - dataIndex: 'lastSeen', - key: 'lastSeen', - width: 210, - }, - { - title: intl.formatMessage({ - id: 'OBDashboard.components.EventsTable.Cause', - defaultMessage: '原因', - }), - dataIndex: 'reason', - key: 'reason', - width: 160, - render: (text) => {text || '-'}, - }, - { - title: intl.formatMessage({ - id: 'OBDashboard.components.EventsTable.AssociatedObjects', - defaultMessage: '关联对象', - }), - dataIndex: 'object', - key: 'object', - width: 150, - render: (val) => , - }, - { - title: intl.formatMessage({ - id: 'OBDashboard.components.EventsTable.Information', - defaultMessage: '信息', - }), - dataIndex: 'message', - key: 'message', - width: 220, - render: (val) => , - }, -]; - export default function EventsTable({ objectType, cardType, collapsible = false, defaultExpand = false, name, + overView, }: EventsTableProps) { const defaultParams: API.EventParams = {}; if (objectType) { @@ -175,6 +74,131 @@ export default function EventsTable({ ); }; + const namespaceList = data?.map((item) => ({ + text: item.namespace, + value: item.namespace, + })); + + const namespaceFilterList = namespaceList?.reduce((prev, curr) => { + const found = prev.find( + (item) => item.text === curr.text && item.value === curr.value, + ); + return found ? prev : [...prev, curr]; + }, []); + + const columns: ColumnsType = [ + { + title: intl.formatMessage({ + id: 'OBDashboard.components.EventsTable.Namespace', + defaultMessage: '命名空间', + }), + dataIndex: 'namespace', + key: 'namespace', + width: 120, + + ...(overView + ? { + filters: namespaceFilterList, + onFilter: (value: any, record) => { + return record.namespace === value; + }, + } + : {}), + + render: (text) => {text}, + }, + { + title: intl.formatMessage({ + id: 'OBDashboard.components.EventsTable.Type', + defaultMessage: '类型', + }), + dataIndex: 'type', + key: 'type', + filters: [ + { + text: intl.formatMessage({ + id: 'OBDashboard.components.EventsTable.Normal', + defaultMessage: '正常', + }), + value: 'Normal', + }, + { + text: intl.formatMessage({ + id: 'OBDashboard.components.EventsTable.Warning', + defaultMessage: '警告', + }), + value: 'Warning', + }, + ], + + onFilter: (value: any, record) => { + return record.type === value; + }, + render: (text) => { + const value = findByValue(EVENTSTABLE_STATUS_LIST, text); + return {value.label}; + }, + width: 120, + }, + { + title: intl.formatMessage({ + id: 'OBDashboard.components.EventsTable.NumberOfOccurrences', + defaultMessage: '发生次数', + }), + dataIndex: 'count', + key: 'count', + width: 130, + }, + { + title: intl.formatMessage({ + id: 'OBDashboard.components.EventsTable.FirstOccurrenceTime', + defaultMessage: '第一次发生时间', + }), + dataIndex: 'firstOccur', + key: 'firstOccur', + width: 210, + }, + { + title: intl.formatMessage({ + id: 'OBDashboard.components.EventsTable.RecentOccurrenceTime', + defaultMessage: '最近发生时间', + }), + dataIndex: 'lastSeen', + key: 'lastSeen', + width: 210, + }, + { + title: intl.formatMessage({ + id: 'OBDashboard.components.EventsTable.Cause', + defaultMessage: '原因', + }), + dataIndex: 'reason', + key: 'reason', + width: 160, + render: (text) => {text || '-'}, + }, + { + title: intl.formatMessage({ + id: 'OBDashboard.components.EventsTable.AssociatedObjects', + defaultMessage: '关联对象', + }), + dataIndex: 'object', + key: 'object', + width: 150, + render: (val) => , + }, + { + title: intl.formatMessage({ + id: 'OBDashboard.components.EventsTable.Information', + defaultMessage: '信息', + }), + dataIndex: 'message', + key: 'message', + width: 220, + render: (val) => , + }, + ]; + return ( { /> - + - + { {access.systemread || access.systemwrite ? ( <> - + diff --git a/ui/src/pages/Tenant/index.tsx b/ui/src/pages/Tenant/index.tsx index e9d5382ce..3f340ca91 100644 --- a/ui/src/pages/Tenant/index.tsx +++ b/ui/src/pages/Tenant/index.tsx @@ -70,7 +70,11 @@ export default function TenantPage() { /> - +