Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): 污点主机与资源操作记录搜索增强 #4650 #4667

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@
class="table-box"
:columns="columns"
:data="state.tableData"
:height="500"
:is-anomalies="state.isAnomalies"
:is-searching="state.search.length > 0"
:max-height="528"
:pagination="{
...state.pagination,
small: true,
Expand Down
41 changes: 26 additions & 15 deletions dbm-ui/frontend/src/hooks/useLinkQueryColumnSerach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { ISearchValue } from 'bkui-vue/lib/search-select/utils';
import _ from 'lodash';
import { useI18n } from 'vue-i18n';

import { queryBizClusterAttrs } from '@services/source/dbbase';
import { queryBizClusterAttrs, queryResourceAdministrationAttrs } from '@services/source/dbbase';

import { useGlobalBizs } from '@stores';

Expand All @@ -37,7 +37,7 @@ export type SearchAttrs = Record<string, {
type ColumnCheckedMap = Record<string, string[]>;

export const useLinkQueryColumnSerach = (
clusterType: ClusterTypes,
searchType: string,
attrs: string[],
fetchDataFn = () => {},
isCluster = true,
Expand All @@ -60,23 +60,34 @@ export const useLinkQueryColumnSerach = (
return [];
});

const resourceTypes = ['spotty_host', 'resource_record'];

const sortValue: {
ordering?: string,
} = {};

if (isQueryAttrs) {
const attrsObj = isCluster ? {
cluster_attrs: attrs.join(','),
} : {
instances_attrs: attrs.join(','),
};
let requestHandler;
if (resourceTypes.includes(searchType)) {
requestHandler = queryResourceAdministrationAttrs({
resource_type: searchType,
});
} else {
const attrsObj = isCluster ? {
cluster_attrs: attrs.join(','),
} : {
instances_attrs: attrs.join(','),
};

// 查询表头筛选列表
requestHandler = queryBizClusterAttrs({
bk_biz_id: currentBizId,
cluster_type: searchType as ClusterTypes,
...attrsObj,
});
}

// 查询表头筛选列表
queryBizClusterAttrs({
bk_biz_id: currentBizId,
cluster_type: clusterType,
...attrsObj,
}).then((resultObj) => {
requestHandler.then((resultObj) => {
columnAttrs.value = resultObj;
searchAttrs.value = Object.entries(resultObj).reduce((results, item) => {
Object.assign(results, {
Expand Down Expand Up @@ -202,8 +213,8 @@ export const useLinkQueryColumnSerach = (
return;
}
const values = item.values ? item.values.reduce((results, value) => {
const idList = _.uniq(`${value.id}`.split(batchSplitRegex));
const nameList = _.uniq(`${value.name}`.split(batchSplitRegex));
const idList = _.uniq(`${value.id.trim()}`.split(batchSplitRegex));
const nameList = _.uniq(`${value.name.trim()}`.split(batchSplitRegex));
results.push(...idList.map((id, index) => ({
id,
name: nameList[index],
Expand Down
19 changes: 19 additions & 0 deletions dbm-ui/frontend/src/services/source/dbbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,22 @@ export function queryBizClusterAttrs(params: {
>
>(`${path}/query_biz_cluster_attrs/`, params);
}

/**
* 查询资源池,污点主机管理表头筛选数据
*/
export function queryResourceAdministrationAttrs(params: {
resource_type: string;
limit?: number;
offset?: number;
}) {
return http.get<
Record<
string,
{
value: string;
text: string;
}[]
>
>(`${path}/query_resource_administration_attrs/`, params);
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@
{
name: t('IP 或 IP:Port'),
id: 'instance',
multiple: true,
},
{
name: t('访问入口'),
id: 'domain',
multiple: true,
},
{
name: 'ID',
Expand All @@ -200,7 +202,6 @@
{
name: t('集群名称'),
id: 'name',
logical: ',',
},
{
name: t('管控区域'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,12 @@
{
name: t('IP 或 IP:Port'),
id: 'instance',
multiple: true,
},
{
name: t('访问入口'),
id: 'domain',
multiple: true,
},
{
name: 'ID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,12 @@
{
name: t('IP 或 IP:Port'),
id: 'instance',
multiple: true,
},
{
name: t('访问入口'),
id: 'domain',
multiple: true,
},
{
name: 'ID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,12 @@
{
name: t('IP 或 IP:Port'),
id: 'instance',
multiple: true,
},
{
name: t('访问入口'),
id: 'domain',
multiple: true,
},
{
name: 'ID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
{
name: t('IP 或 IP:Port'),
id: 'instance',
multiple: true,
},
{
name: t('访问入口'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@
{
name: t('IP 或 IP:Port'),
id: 'instance',
multiple: true,
},
{
name: t('访问入口'),
id: 'domain',
multiple: true,
},
{
name: 'ID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,12 @@
{
name: t('IP 或 IP:Port'),
id: 'instance',
multiple: true,
},
{
name: t('访问入口'),
id: 'domain',
multiple: true,
},
{
name: t('集群名称'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,12 @@
{
name: t('IP 或 IP:Port'),
id: 'instance',
multiple: true,
},
{
name: t('访问入口'),
id: 'domain',
multiple: true,
},
{
name: 'ID',
Expand Down
Loading
Loading