Skip to content

Commit

Permalink
fix: 智能监控容器场景产品验收问题修复 (#4924)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaolicheng-github authored Feb 10, 2025
1 parent 53fe0a4 commit 8644973
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,17 @@ export default class FilterByCondition extends tsc<IProps> {
return;
}
this.loading = true;
const filterDict = {};
for (const key in this.filterBy) {
if (this.filterBy[key]?.length) {
filterDict[key] = JSON.parse(JSON.stringify(this.filterBy[key]));
}
}
this.filterByOptions = new FilterByOptions({
...this.commonParams,
page_size: 10,
page_type: 'scrolling',
filter_dict: {},
filter_dict: filterDict,
with_history: false,
query_string: this.searchValue,
});
Expand Down Expand Up @@ -195,6 +201,9 @@ export default class FilterByCondition extends tsc<IProps> {
filterDict[item.key] = item.value;
}
this.$emit('change', filterDict);
this.filterByOptions.setCommonParams({
filter_dict: filterDict,
});
}
this.oldLocalFilterBy = JSON.parse(JSON.stringify(filterBy));
}
Expand Down Expand Up @@ -296,6 +305,7 @@ export default class FilterByCondition extends tsc<IProps> {
onHidden: () => {
this.destroyPopoverInstance();
this.setTagList();
this.filterByOptions.setIsUpdate(false);
this.updateActive = '';
this.addValueSelected = new Map();
this.workloadValueSelected = '';
Expand Down Expand Up @@ -490,12 +500,14 @@ export default class FilterByCondition extends tsc<IProps> {
// name: item.name,
name: item.id,
}));
values.unshift(
...otherIds.map(id => ({
id: id,
name: id,
}))
);
if (this.groupSelected !== EDimensionKey.workload) {
values.unshift(
...otherIds.map(id => ({
id: id,
name: id,
}))
);
}
tag.values = values;
break;
}
Expand Down Expand Up @@ -544,6 +556,7 @@ export default class FilterByCondition extends tsc<IProps> {
} else {
this.addValueSelected.set(item.id, new Set(item.values.map(v => v.id)));
}
this.filterByOptions.setIsUpdate(true);
this.setGroupOptions();
this.handleAdd({ target } as any);
this.handleSearchChange('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const sceneDimensionMap = {
export class FilterByOptions {
commonParams: Record<string, any> = {}; // 通用参数
dimensionData = []; // 维度数据
isUpdate = false;
pageMap: Record<string, number> = {}; // 分页数据
pageSize = 10;
scenario = 'performance';
Expand Down Expand Up @@ -167,20 +168,39 @@ export class FilterByOptions {
}

queryStringParams(dimension: EDimensionKey, categoryDim?: string) {
const dimensionIndex = [
EDimensionKey.namespace,
EDimensionKey.workload,
EDimensionKey.pod,
EDimensionKey.container,
];
const filterDict = {};
if (!this.isUpdate) {
for (const key of dimensionIndex) {
if (key === dimension) {
break;
}
if (this.commonParams.filter_dict?.[key]?.length) {
filterDict[key] = this.commonParams.filter_dict[key];
}
}
}
if (this.commonParams.query_string) {
return {
query_string: this.commonParams.query_string,
filter_dict:
dimension === EDimensionKey.workload && categoryDim
filter_dict: {
...filterDict,
...(dimension === EDimensionKey.workload && categoryDim
? {
[EDimensionKey.workload]: `${categoryDim}:`,
}
: {},
: {}),
},
};
}
return {
query_string: dimension === EDimensionKey.workload && categoryDim ? `${categoryDim}:` : '',
filter_dict: {},
filter_dict: filterDict,
};
}

Expand Down Expand Up @@ -250,14 +270,21 @@ export class FilterByOptions {
return this.dimensionData;
}

setIsUpdate(v: boolean) {
this.isUpdate = v;
}
setPage(page: number, dimension: EDimensionKey, categoryDim?: string) {
if (dimension === EDimensionKey.workload && categoryDim) {
this.pageMap[`${dimension}_____${categoryDim}`] = page;
}
this.pageMap[dimension] = page;
}

async setWorkloadOverview(params: any) {
const data = await workloadOverview(params).catch(() => []);
const data = await workloadOverview({
...params,
namespace: this.isUpdate ? undefined : this.commonParams?.filter_dict?.namespace?.join?.(',') || undefined,
}).catch(() => []);
for (const dim of this.dimensionData) {
if (dim.id === EDimensionKey.workload) {
let total = 0;
Expand Down

0 comments on commit 8644973

Please sign in to comment.