Skip to content

Commit

Permalink
fix(frontend): 资源池主机列表设置不生效 TencentBlueKing#9210
Browse files Browse the repository at this point in the history
  • Loading branch information
hLinx committed Jan 25, 2025
1 parent cdd3869 commit 67d61c2
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 144 deletions.
1 change: 0 additions & 1 deletion dbm-ui/frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
import '@blueking/notice-component/dist/style.css';
const userProfileStore = useUserProfile();
userProfileStore.fetchProfile();
const { t, locale } = useI18n();
const systemEnvironStore = useSystemEnviron();
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/common/const/userPersonalSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ export enum UserPersonalSettings {
SPECIFICATION_TABLE_SETTINGS = 'SPECIFICATION_TABLE_SETTINGS',
SERVICE_APPLY_FAVOR = 'SERVICE_APPLY_FAVOR',
RESOURCE_POOL_SELECTOR_SETTINGS = 'RESOURCE_POOL_SELECTOR_SETTINGS',
RESOURCE_POOL_HOST_LIST_SETTINGS = 'RESOURCE_POOL_HOST_LIST_SETTINGS',
}
12 changes: 5 additions & 7 deletions dbm-ui/frontend/src/hooks/useTableSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ export const useTableSettings = (key: string, defaultSettings: Settings) => {

// 获取用户配置的表头信息
const settings = shallowRef<{ checked?: string[]; disabled?: string[]; size?: string }>();
if (userProfileStore.profile[key]) {
settings.value = {
checked: userProfileStore.profile[key].checked || defaultSettings.checked,
disabled: defaultSettings.disabled,
size: userProfileStore.profile[key].size || defaultSettings.size || 'small',
};
}
settings.value = {
checked: userProfileStore.profile[key]?.checked || defaultSettings.checked,
disabled: defaultSettings.disabled,
size: userProfileStore.profile[key]?.size || defaultSettings.size || 'small',
};

/**
* 更新表头设置
Expand Down
6 changes: 1 addition & 5 deletions dbm-ui/frontend/src/stores/globalBizs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ export const useGlobalBizs = defineStore('GlobalBizs', {
const userProfileStore = useUserProfile();

// 获取最新用户个人配置
try {
await userProfileStore.fetchProfile();
} catch (e) {
console.log(e);
}
await userProfileStore.fetchProfile();

const activatedBizId = userProfileStore.profile[UserPersonalSettings.ACTIVATED_APP];
const favors = userProfileStore.profile[UserPersonalSettings.APP_FAVOR] || [];
Expand Down
41 changes: 29 additions & 12 deletions dbm-ui/frontend/src/views/resource-manage/pool/host-list/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
show-settings
@clear-search="handleClearSearch"
@selection="handleSelection"
@setting-change="handleSettingChange" />
@setting-change="updateTableSettings" />
<ImportHost
v-model:is-show="isShowImportHost"
@change="handleImportHostChange" />
Expand All @@ -98,6 +98,10 @@
removeResource,
} from '@services/source/dbresourceResource';

import { useTableSettings } from '@hooks';

import { UserPersonalSettings } from '@common/const';

import DiskPopInfo from '@components/disk-pop-info/DiskPopInfo.vue';
import HostAgentStatus from '@components/host-agent-status/Index.vue';

Expand All @@ -111,16 +115,10 @@
import ImportHostBtn from './components/ImportHostBtn.vue';
import RenderTable from './components/RenderTable.vue';
import SearchBox from './components/search-box/Index.vue';
import useTableSetting from './hooks/useTableSetting';

const { t } = useI18n();
const router = useRouter();

const {
setting: tableSetting,
handleChange: handleSettingChange,
} = useTableSetting();

const searchBoxRef = ref();
const tableRef = ref();
const selectionHostIdList = ref<number[]>([]);
Expand Down Expand Up @@ -150,13 +148,13 @@
},
{
label: t('所属业务'),
field: 'forBizDisplay',
field: 'for_biz',
minWidth: 170,
render: ({ data }: {data: DbResourceModel}) => data.forBizDisplay || '--',
},
{
label: t('所属DB类型'),
field: 'resourceTypeDisplay',
field: 'resource_type',
minWidth: 150,
render: ({ data }: {data: DbResourceModel}) => data.resourceTypeDisplay || '--',
},
Expand All @@ -175,7 +173,7 @@
{
label: t('操作系统类型'),
field: 'os_type',
minWidth: 100,
minWidth: 180,
render: ({ data }: {data: DbResourceModel}) => data.os_type || '--',
},
{
Expand All @@ -197,7 +195,7 @@
},
{
label: t('内存'),
field: 'bkMemText',
field: 'bk_mem',
minWidth: 100,
render: ({ data }: {data: DbResourceModel}) => data.bkMemText || '0 M',
},
Expand All @@ -215,7 +213,6 @@
},
{
label: t('操作'),
field: 'id',
fixed: 'right',
width: 100,
render: ({ data }: {data: DbResourceModel}) => (
Expand All @@ -235,6 +232,26 @@
},
];

const { settings: tableSetting, updateTableSettings } = useTableSettings(UserPersonalSettings.RESOURCE_POOL_HOST_LIST_SETTINGS, {
disabled: ['ip'],
checked: [
'ip',
'bk_cloud_name',
'agent_status',
'for_biz',
'resource_type',
'rack_id',
'device_class',
'city',
'sub_zone',
'bk_cpu',
'bk_mem',
'bk_disk',
'os_type',
],
});


const fetchData = () => {
tableRef.value.fetchData(searchParams);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
:max-height="tableMaxHeight"
:pagination="pagination"
:pagination-heihgt="60"
remote-pagination
show-overflow-tooltip
v-bind="$attrs"
@column-sort="handleColumnSortChange"
@page-limit-change="handlePageLimitChange"
Expand Down

This file was deleted.

0 comments on commit 67d61c2

Please sign in to comment.