forked from TencentBlueKing/blueking-dbm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(frontend): mongodb工具箱重构 TencentBlueKing#8498
- Loading branch information
Showing
18 changed files
with
1,859 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
* | ||
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
* the specific language governing permissions and limitations under the License. | ||
*/ | ||
import { useRequest } from 'vue-request'; | ||
import { useRoute } from 'vue-router'; | ||
|
||
import type { DetailBase } from '@services/model/ticket/details/common'; | ||
import TicketModel from '@services/model/ticket/ticket'; | ||
import { getTicketDetails } from '@services/source/ticket'; | ||
|
||
import { TicketTypes } from '@common/const'; | ||
|
||
export function useTicketDetail<T extends DetailBase>( | ||
ticketType: TicketTypes, | ||
options: { | ||
onSuccess: (data: TicketModel<T>) => void; | ||
}, | ||
) { | ||
const route = useRoute(); | ||
const { ticketId } = route.query; | ||
|
||
if (!ticketId) { | ||
return; | ||
} | ||
|
||
useRequest(getTicketDetails, { | ||
defaultParams: [{ id: Number(ticketId) }, { permission: 'catch' }], | ||
onSuccess(ticketData) { | ||
if (ticketType !== ticketData.ticket_type) { | ||
return; | ||
} | ||
options.onSuccess(ticketData as TicketModel<T>); | ||
}, | ||
}); | ||
} | ||
|
||
// export function useTicketDetail( | ||
// ticketType: TicketTypes | TicketTypes[], | ||
// options: { | ||
// onSuccess: (data: TicketModel<unknown>, matchingType: TicketTypes) => void; | ||
// }, | ||
// ) { | ||
// const route = useRoute(); | ||
// const { ticketId } = route.query; | ||
// const { onSuccess } = options; | ||
// if (!ticketId) { | ||
// return; | ||
// } | ||
// useRequest(getTicketDetails, { | ||
// defaultParams: [{ id: Number(ticketId) }, { permission: 'catch' }], | ||
// onSuccess(ticketData) { | ||
// const ticketTypeList = Array.isArray(ticketType) ? ticketType : [ticketType]; | ||
// if (!ticketTypeList.includes(ticketData.ticket_type)) { | ||
// return; | ||
// } | ||
// onSuccess(ticketData, ticketData.ticket_type); | ||
// }, | ||
// }); | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
...i/frontend/src/views/db-manage/common/toolbox-field/column/db-table-name-column/Index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<template> | ||
<EditableColumn | ||
:field="field" | ||
:label="label" | ||
:min-width="200" | ||
:required="required" | ||
:rules="rules"> | ||
<template #headAppend> | ||
<BatchEditColumn | ||
v-model="isShowBatchEdit" | ||
:title="label" | ||
type="taginput" | ||
@change="handleBatchEditChange"> | ||
<span | ||
v-bk-tooltips="t('统一设置:将该列统一设置为相同的值')" | ||
class="batch-select-button" | ||
@click="handleBatchEditShow"> | ||
<DbIcon type="bulk-edit" /> | ||
</span> | ||
</BatchEditColumn> | ||
</template> | ||
<div | ||
ref="root" | ||
class="edit-table-name-content" | ||
@click="handleShowTips"> | ||
<EditableTagInput | ||
v-model="modelValue" | ||
allow-auto-match | ||
allow-create | ||
clearable | ||
:disabled="disabled" | ||
has-delete-icon | ||
:placeholder="placeholder" /> | ||
<div style="display: none"> | ||
<div | ||
ref="pop" | ||
style="font-size: 12px; line-height: 24px; color: #63656e"> | ||
<slot name="tip" /> | ||
</div> | ||
</div> | ||
</div> | ||
</EditableColumn> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import tippy, { type Instance, type SingleTarget } from 'tippy.js'; | ||
import { type VNode } from 'vue'; | ||
import type { ComponentProps } from 'vue-component-type-helpers'; | ||
import { useI18n } from 'vue-i18n'; | ||
import { Column as EditableColumn } from '@components/editable-table/Index.vue'; | ||
import BatchEditColumn from '@views/db-manage/common/batch-edit-column/Index.vue'; | ||
interface Props { | ||
label: string; | ||
field: string; | ||
placeholder: string; | ||
rules: NonNullable<ComponentProps<typeof EditableColumn>['rules']>; | ||
required?: boolean; | ||
disabled?: boolean; | ||
} | ||
interface Emits { | ||
(e: 'batch-edit', value: string[]): void; | ||
} | ||
interface Slots { | ||
tip: VNode; | ||
} | ||
withDefaults(defineProps<Props>(), { | ||
required: true, | ||
disabled: false, | ||
}); | ||
const emits = defineEmits<Emits>(); | ||
const modelValue = defineModel<string[]>({ | ||
required: true, | ||
}); | ||
const slots = defineSlots<Slots>(); | ||
const { t } = useI18n(); | ||
let tippyIns: Instance | undefined; | ||
const isShowBatchEdit = ref(false); | ||
const rootRef = useTemplateRef('root'); | ||
const popRef = useTemplateRef('pop'); | ||
const handleBatchEditShow = () => { | ||
isShowBatchEdit.value = true; | ||
}; | ||
const handleBatchEditChange = (value: string | string[]) => { | ||
emits('batch-edit', value as string[]); | ||
}; | ||
const handleShowTips = () => { | ||
tippyIns?.show(); | ||
}; | ||
onMounted(() => { | ||
nextTick(() => { | ||
if (slots.tip && rootRef.value !== null) { | ||
tippyIns = tippy(rootRef.value as SingleTarget, { | ||
content: popRef.value, | ||
placement: 'top', | ||
appendTo: () => document.body, | ||
theme: 'light', | ||
maxWidth: 'none', | ||
trigger: 'manual', | ||
interactive: true, | ||
arrow: true, | ||
offset: [0, 18], | ||
zIndex: 9998, | ||
hideOnClick: true, | ||
}); | ||
} | ||
}); | ||
}); | ||
onBeforeUnmount(() => { | ||
if (slots.tip && tippyIns) { | ||
tippyIns.hide(); | ||
tippyIns.unmount(); | ||
tippyIns.destroy(); | ||
tippyIns = undefined; | ||
} | ||
}); | ||
</script> | ||
|
||
<style lang="less" scoped> | ||
.batch-select-button { | ||
font-size: 14px; | ||
color: #3a84ff; | ||
cursor: pointer; | ||
} | ||
.edit-table-name-content { | ||
width: 100%; | ||
} | ||
</style> |
60 changes: 60 additions & 0 deletions
60
dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/spec-block-column/Index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!-- | ||
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
* | ||
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License athttps://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
* the specific language governing permissions and limitations under the License. | ||
--> | ||
|
||
<template> | ||
<EditableColumn | ||
:label="t('当前规格')" | ||
:width="200"> | ||
<EditableBlock :placeholder="placeholder"> | ||
{{ data?.name ? `${data.name} ${showCounts ? t('((n))台', { n: data?.count }) : ''}` : '' }} | ||
<SpecPanel | ||
v-if="data" | ||
:data="data" | ||
:show-qps="showQps"> | ||
<DbIcon | ||
class="visible-icon ml-4" | ||
type="visible1" /> | ||
</SpecPanel> | ||
</EditableBlock> | ||
</EditableColumn> | ||
</template> | ||
<script setup lang="ts"> | ||
import type { ComponentProps } from 'vue-component-type-helpers'; | ||
import { useI18n } from 'vue-i18n'; | ||
|
||
import SpecPanel from './components/Panel.vue'; | ||
|
||
interface Props { | ||
data?: ComponentProps<typeof SpecPanel>['data']; | ||
placeholder?: string; | ||
showCounts?: boolean; | ||
showQps?: boolean; | ||
} | ||
|
||
withDefaults(defineProps<Props>(), { | ||
data: undefined, | ||
placeholder: undefined, | ||
showCounts: true, | ||
showQps: false, | ||
}); | ||
|
||
const { t } = useI18n(); | ||
</script> | ||
|
||
<style lang="less" scoped> | ||
.visible-icon { | ||
font-size: 16px; | ||
color: #3a84ff; | ||
cursor: pointer; | ||
} | ||
</style> |
Oops, something went wrong.