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): mysql 、TendbCluster的 dbmodule 添加 alias name 字段 #8148

Merged
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
8 changes: 7 additions & 1 deletion dbm-ui/frontend/src/services/source/cmdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ export function getBizs(params = {} as { action: string }) {
/**
* 创建数据库模块
*/
export function createModules(params: { db_module_name: string; cluster_type: string; biz_id: number }) {
export function createModules(params: {
db_module_name: string;
alias_name: string;
cluster_type: string;
biz_id: number;
}) {
return http.post<{
db_module_id: number;
db_module_name: string;
Expand Down Expand Up @@ -83,6 +88,7 @@ export function getUserGroupList(params: { bk_biz_id: number }) {
export function getModules(params: { bk_biz_id: number; cluster_type: string }) {
return http.get<
{
alias_name: string;
bk_biz_id: number;
db_module_id: number;
name: string;
Expand Down
20 changes: 10 additions & 10 deletions dbm-ui/frontend/src/services/source/ticket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,16 @@ export const createAppAbbr = (params: { db_app_abbr: string; id: number }) =>
/**
* 创建模块
*/
export const createModules = (params: { db_module_name: string; cluster_type: string; id: number }) =>
http.post<{
db_module_id: number;
db_module_name: string;
cluster_type: string;
bk_biz_id: number;
bk_set_id: number;
bk_modules: { bk_module_name: string; bk_module_id: string }[];
name: string;
}>(`/apis/cmdb/${params.id}/create_module/`, params);
// export const createModules = (params: { db_module_name: string; cluster_type: string; id: number }) =>
// http.post<{
// db_module_id: number;
// db_module_name: string;
// cluster_type: string;
// bk_biz_id: number;
// bk_set_id: number;
// bk_modules: { bk_module_name: string; bk_module_id: string }[];
// name: string;
// }>(`/apis/cmdb/${params.id}/create_module/`, params);

/**
* 保存模块配置
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
bk_biz_id: globalBizsStore.currentBizId,
db_module_id: id,
},
query: { module_name: name },
query: { alias_name: name },
});
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@

.apply-instance {
:deep(.item-input) {
width: 462px;
width: 435px;
}

.input-desc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@
}

:deep(.item-input) {
width: 462px;
width: 435px;
}

.resource-pool-item {
Expand Down
22 changes: 11 additions & 11 deletions dbm-ui/frontend/src/views/db-manage/mysql/apply/ApplyMySQL.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
:key="item.db_module_id"
action-id="dbconfig_view"
:biz-id="formdata.bk_biz_id"
:name="item.name"
:name="item.alias_name"
:permission="item.permission.dbconfig_view"
resource="mysql" />
<template
Expand Down Expand Up @@ -191,7 +191,7 @@
<DomainTable
v-model:domains="formdata.details.domains"
:formdata="formdata"
:module-name="moduleName"
:module-alias-name="moduleAliasName"
:ticket-type="dbType" />
</BkFormItem>
<BkFormItem
Expand Down Expand Up @@ -573,12 +573,12 @@
});
const hostSpecInfo = computed(() => fetchState.hostSpecs.find((info) => info.spec === formdata.details.spec));
const typeInfo = computed(() => mysqlType[dbType as MysqlTypeString]);
const moduleName = computed(() => {
const moduleAliasName = computed(() => {
const item = fetchState.moduleList.find((item) => item.db_module_id === formdata.details.db_module_id);
return item?.name ?? '';
return item?.alias_name ?? '';
});
const tableData = computed(() => {
if (moduleName.value && formdata.details.db_app_abbr) {
if (moduleAliasName.value && formdata.details.db_app_abbr) {
return formdata.details.domains;
}
return [];
Expand Down Expand Up @@ -738,8 +738,8 @@
}));
const previewData = computed(() =>
tableData.value.map(({ key }: { key: string }) => ({
domain: `${moduleName.value}db.${key}.${formdata.details.db_app_abbr}.db`,
slaveDomain: `${moduleName.value}db.${key}.${formdata.details.db_app_abbr}.db`,
domain: `${moduleAliasName.value}db.${key}.${formdata.details.db_app_abbr}.db`,
slaveDomain: `${moduleAliasName.value}db.${key}.${formdata.details.db_app_abbr}.db`,
disasterDefence: t('同城跨园区'),
deployStructure: typeInfo.value.name,
version: leveConfig.db_version,
Expand Down Expand Up @@ -873,10 +873,10 @@
return;
}
const moduleInfo = fetchState.moduleList.find((item) => item.db_module_id === formdata.details.db_module_id);
const moduleName = moduleInfo?.name ?? '';
const moduleNameQuery = moduleName
const moduleAliasName = moduleInfo?.alias_name ?? '';
const moduleAliasNameQuery = moduleAliasName
? {
module_name: moduleName,
alias_name: moduleAliasName,
}
: {};
isBindModule.value = true;
Expand All @@ -888,7 +888,7 @@
db_module_id: formdata.details.db_module_id,
},
query: {
...moduleNameQuery,
...moduleAliasNameQuery,
},
});
window.open(url.href, '_blank');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class="batch-edit__domain"
:style="{ '--offset': `${state.offsetWidth}px` }">
<p class="batch-edit__domain-name">
<span ref="moduleNameRef">{{ moduleName }}db.</span>
<span ref="moduleAliasNameRef">{{ moduleAliasName }}db.</span>
<span class="batch-edit__domain-underline" />.{{ appName }}.db
</p>
<BkInput
Expand Down Expand Up @@ -73,7 +73,7 @@
import { nameRegx } from '@common/regex';

interface Props {
moduleName?: string;
moduleAliasName?: string;
appName?: string;
}

Expand All @@ -82,7 +82,7 @@
}

withDefaults(defineProps<Props>(), {
moduleName: '',
moduleAliasName: '',
appName: '',
});
const emits = defineEmits<Emits>();
Expand Down Expand Up @@ -116,13 +116,13 @@
/**
* 获取输入框 arrow 偏移量
*/
const moduleNameRef = ref<HTMLSpanElement>();
const moduleAliasNameRef = ref<HTMLSpanElement>();
watch(
() => state.isShow,
(show) => {
nextTick(() => {
if (moduleNameRef.value) {
state.offsetWidth = moduleNameRef.value.offsetWidth + 22;
if (moduleAliasNameRef.value) {
state.offsetWidth = moduleAliasNameRef.value.offsetWidth + 22;
}
});
if (show === false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
key: string
}
interface Props {
moduleName: string,
moduleAliasName: string,
formdata: IFormdata,
ticketType: string
}
Expand All @@ -74,11 +74,11 @@
const isMysqlSingle = computed(() => props.ticketType === TicketTypes.MYSQL_SINGLE_APPLY);
/**
* 表单展示数据
* 没有 moduleName 和 appName 则不展示 table 数据
* 没有 moduleAliasName 和 appName 则不展示 table 数据
*/
const tableData = computed(() => {
const { moduleName, formdata } = props;
if (moduleName && (formdata.details.db_app_abbr)) {
const { moduleAliasName, formdata } = props;
if (moduleAliasName && (formdata.details.db_app_abbr)) {
return formdata.details.domains;
}
return [];
Expand Down Expand Up @@ -130,7 +130,7 @@
? null
: <BatchEdit
v-bk-tooltips={t('快捷编辑_可通过换行分隔_快速编辑多个域名')}
moduleName={props.moduleName}
moduleAliasName={props.moduleAliasName}
appName={props.formdata.details.db_app_abbr}
onChange={handleBatchEditDomains} />
}
Expand Down Expand Up @@ -186,7 +186,7 @@
function renderDomain(rowIndex: number, isMain = false) {
return (
<div class="domain-address">
<span>{props.moduleName}{isMain ? 'db.' : 'dr.'}</span>
<span>{props.moduleAliasName}{isMain ? 'db.' : 'dr.'}</span>
{
isMain
? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
onSuccess(modules) {
// const moduleList: IListItem[] = [];
const { moduleName } = props.data!;
const currentModule = modules.find((moduleItem) => moduleItem.name === moduleName);
const currentModule = modules.find((moduleItem) => moduleItem.alias_name === moduleName);
if (currentModule) {
const currentCharset = currentModule.db_module_info.conf_items.find(
(confItem) => confItem.conf_name === 'charset',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
onSuccess(modules) {
const moduleList: IListItem[] = [];
const { moduleName } = props.data!;
const currentModule = modules.find((moduleItem) => moduleItem.name === moduleName);
const currentModule = modules.find((moduleItem) => moduleItem.alias_name === moduleName);
if (currentModule) {
const currentCharset = currentModule.db_module_info.conf_items.find(
(confItem) => confItem.conf_name === 'charset',
Expand All @@ -299,7 +299,7 @@
moduleList.push({
...moduleItem,
id: moduleItem.db_module_id,
name: moduleItem.name,
name: moduleItem.alias_name,
});
}
});
Expand Down
6 changes: 3 additions & 3 deletions dbm-ui/frontend/src/views/db-manage/riak/apply/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
:key="item.db_module_id"
action-id="dbconfig_view"
:biz-id="formData.bk_biz_id"
:label="item.name"
:name="item.name"
:label="item.alias_name"
:name="item.alias_name"
:permission="item.permission.dbconfig_view"
resource="riak"
:value="item.db_module_id" />
Expand Down Expand Up @@ -348,7 +348,7 @@
...formData,
details: {
...formData.details,
db_module_name: moduleListValue[moduleIndex].name,
db_module_name: moduleListValue[moduleIndex].alias_name,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
:key="item.db_module_id"
action-id="dbconfig_view"
:biz-id="formData.bk_biz_id"
:label="item.name"
:label="item.alias_name"
:permission="item.permission.dbconfig_view"
resource="sqlserver"
:value="item.db_module_id" />
Expand Down Expand Up @@ -150,7 +150,7 @@
v-model:domains="formData.details.domains"
:db-app-abbr="formData.details.db_app_abbr"
:is-sqlserver-single="isSingleType"
:module-name="moduleName" />
:module-alias-name="moduleAliasName" />
</BkFormItem>
<BkFormItem
:label="t('服务器选择')"
Expand Down Expand Up @@ -365,7 +365,7 @@

const formRef = ref();
const backendRef = ref();
const moduleName = ref('');
const moduleAliasName = ref('');
const moduleRef = ref();
const isBindModule = ref(false);
const isShowPreview = ref(false);
Expand Down Expand Up @@ -434,7 +434,7 @@
);

const tableData = computed(() => {
if (moduleName.value && formData.details.db_app_abbr) {
if (moduleAliasName.value && formData.details.db_app_abbr) {
return formData.details.domains;
}
return [];
Expand All @@ -445,8 +445,8 @@
(accumulator, { key }) => [
...accumulator,
{
domain: `${moduleName.value}db.${key}.${formData.details.db_app_abbr}.db`,
slaveDomain: `${moduleName.value}db.${key}.${formData.details.db_app_abbr}.db`,
domain: `${moduleAliasName.value}db.${key}.${formData.details.db_app_abbr}.db`,
slaveDomain: `${moduleAliasName.value}db.${key}.${formData.details.db_app_abbr}.db`,
disasterDefence: t('同城跨园区'),
deployStructure: isSingleType ? t('单节点部署') : t('主从部署'),
version: dbVersion.value,
Expand Down Expand Up @@ -540,7 +540,7 @@
(newDbModuleId) => {
if (newDbModuleId) {
const module = (moduleList.value || []).find((item) => item.db_module_id === formData.details.db_module_id);
moduleName.value = module ? module.name : '';
moduleAliasName.value = module ? module.alias_name : '';

fetchModulesDetails({
bk_biz_id: Number(formData.bk_biz_id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class="batch-edit-domain"
:style="{ '--offset': `${stateOffsetWidth}px` }">
<p class="batch-edit-domain-name">
<span ref="moduleNameRef"> {{ moduleName }}db. </span>
<span ref="moduleNameRef"> {{ moduleAliasName }}db. </span>
<span class="batch-edit-domain-underline" />
.{{ appName }}.db
</p>
Expand Down Expand Up @@ -63,7 +63,7 @@
import { nameRegx } from '@common/regex';

interface Props {
moduleName: string;
moduleAliasName: string;
appName: string;
}

Expand All @@ -72,7 +72,7 @@
}

withDefaults(defineProps<Props>(), {
moduleName: '',
moduleAliasName: '',
appName: '',
});
const emits = defineEmits<Emits>();
Expand Down
Loading
Loading