Skip to content

Commit

Permalink
feat(frontend): 添加全局及业务下的资源标签管理功能 TencentBlueKing#7285
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 22019
  • Loading branch information
royalpioneer committed Oct 28, 2024
1 parent 068b26e commit 8a13f75
Show file tree
Hide file tree
Showing 90 changed files with 3,989 additions and 592 deletions.
20 changes: 20 additions & 0 deletions dbm-ui/frontend/lib/bk-icon/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ <h2 class="page-title">
</div>
<section class="tab-content single-color active" data-type="singleColor">
<ul class="icon-list">
<li class="icon-item" title="tags">
<span class="icon bk-dbm-icon db-icon-tags"></span>
<p class="icon-text">tags</p>
</li>
<li class="icon-item" title="check-circle-fill">
<span class="icon bk-dbm-icon db-icon-check-circle-fill"></span>
<p class="icon-text">check-circle-fill</p>
Expand Down Expand Up @@ -829,6 +833,10 @@ <h2 class="page-title">
<span class="icon bk-dbm-icon db-icon-dirty-host"></span>
<p class="icon-text">dirty-host</p>
</li>
<li class="icon-item" title="tag-3">
<span class="icon bk-dbm-icon db-icon-tag-3"></span>
<p class="icon-text">tag-3</p>
</li>
<li class="icon-item" title="saoba">
<span class="icon bk-dbm-icon db-icon-saoba"></span>
<p class="icon-text">saoba</p>
Expand Down Expand Up @@ -990,6 +998,12 @@ <h3 class="describe-title">如何使用</h3>
</section>
<section class="tab-content multiple-color" data-type="multipleColor">
<ul class="icon-list">
<li class="colorful-icon">
<svg class="icon svg-icon">
<use xlink:href="#db-icon-tags"></use>
</svg>
<p class="icon-text">tags</p>
</li>
<li class="colorful-icon">
<svg class="icon svg-icon">
<use xlink:href="#db-icon-check-circle-fill"></use>
Expand Down Expand Up @@ -2058,6 +2072,12 @@ <h3 class="describe-title">如何使用</h3>
</svg>
<p class="icon-text">dirty-host</p>
</li>
<li class="colorful-icon">
<svg class="icon svg-icon">
<use xlink:href="#db-icon-tag-3"></use>
</svg>
<p class="icon-text">tag-3</p>
</li>
<li class="colorful-icon">
<svg class="icon svg-icon">
<use xlink:href="#db-icon-saoba"></use>
Expand Down
Binary file modified dbm-ui/frontend/lib/bk-icon/fonts/iconcool.eot
Binary file not shown.
452 changes: 235 additions & 217 deletions dbm-ui/frontend/lib/bk-icon/fonts/iconcool.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dbm-ui/frontend/lib/bk-icon/fonts/iconcool.ttf
Binary file not shown.
Binary file modified dbm-ui/frontend/lib/bk-icon/fonts/iconcool.woff
Binary file not shown.
2 changes: 1 addition & 1 deletion dbm-ui/frontend/lib/bk-icon/iconcool.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbm-ui/frontend/lib/bk-icon/iconcool.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions dbm-ui/frontend/lib/bk-icon/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ url("fonts/iconcool.eot?#iefix") format("embedded-opentype");
-moz-osx-font-smoothing: grayscale;
}

.db-icon-tags:before {
content: "\e206";
}
.db-icon-check-circle-fill:before {
content: "\e1a7";
}
Expand Down Expand Up @@ -557,6 +560,9 @@ url("fonts/iconcool.eot?#iefix") format("embedded-opentype");
.db-icon-dirty-host:before {
content: "\e1ca";
}
.db-icon-tag-3:before {
content: "\e207";
}
.db-icon-saoba:before {
content: "\e1f4";
}
Expand Down
7 changes: 5 additions & 2 deletions dbm-ui/frontend/src/components/disk-pop-info/DiskPopInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<BkPopover
:popover-delay="[0, 300]"
theme="light"
trigger="hover"
:trigger="trigger"
:width="430">
<span style="padding: 0 10px">
<slot />
Expand All @@ -26,9 +26,12 @@
interface Props {
data: DbResourceModel['storage_device'];
trigger?: 'hover' | 'click' | 'manual' | undefined;
}
const props = defineProps<Props>();
const props = withDefaults(defineProps<Props>(), {
trigger: 'hover',
});
const { t } = useI18n();
Expand Down
155 changes: 155 additions & 0 deletions dbm-ui/frontend/src/components/review-data-dialog/Index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<!--
* 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>
<BkDialog
class="review-data-dialog"
:is-loading="props.loading"
:is-show="isShow"
:title="props.title"
@closed="handleClose">
<div class="container">
<div class="tip">
{{ props.tip }}
</div>
<div class="selected-wrapper">
<div class="selected-title">
{{ t('已选择以下') }} <span class="selected-count">{{ props.selected.length }}</span> {{ t('台主机') }}
</div>
<div class="selected-content">
<div
v-for="item in props.selected"
:key="item"
class="selected-item">
{{ item }}
</div>
</div>
</div>
</div>
<template #footer>
<div class="footer">
<BkButton
style="width: 88px"
theme="primary"
@click="handleConfirm"
>{{ t('确定') }}</BkButton
>
<BkButton
class="ml-9 operation-btn"
style="width: 88px"
@click="handleClose"
>{{ t('取消') }}</BkButton
>
</div>
</template>
</BkDialog>
</template>

<script setup lang="tsx">
import { useI18n } from 'vue-i18n';
interface Props {
title: string;
tip: string;
loading: boolean;
selected: string[];
}
interface Emits {
(e: 'confirm'): void;
(e: 'cancel'): void;
}
const props = defineProps<Props>();
const emits = defineEmits<Emits>();
const isShow = defineModel('isShow', {
default: false,
type: Boolean,
});
const { t } = useI18n();
const handleConfirm = () => {
emits('confirm');
isShow.value = false;
};
const handleClose = () => {
emits('cancel');
isShow.value = false;
};
</script>

<style lang="less" scoped>
.container {
font-size: 14px;
.tip {
background: #f5f6fa;
border-radius: 2px;
padding: 12px 16px;
margin-bottom: 8px;
}
.selected-wrapper {
border: 1px solid #eaebf0;
border-radius: 2px;
max-height: 192px;
overflow-y: auto;
.selected-title {
width: 100%;
padding: 5px 16px;
background: #f0f1f5;
color: #313238;
position: sticky;
top: 0;
.selected-count {
font-weight: 700;
}
}
.selected-content {
font-size: 12px;
.selected-item {
padding: 6px 16px;
&:nth-child(even) {
background-color: #fafbfd;
}
&:nth-child(odd) {
background-color: #ffffff;
}
}
}
}
}
.footer {
display: flex;
justify-content: center;
}
</style>

<style lang="less">
.review-data-dialog {
.bk-dialog-footer {
background-color: #fff !important;
border: none !important;
padding-top: 0 !important;
padding-bottom: 24px !important;
}
}
</style>
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export * from './useDebouncedRef';
export * from './useDefaultPagination';
export * from './useEventBus';
export * from './useFormItem';
export * from './useFormModel';
export * from './useIsWidthOverflow';
export * from './useLinkQueryColumnSerach';
export * from './useListeners';
Expand Down
32 changes: 32 additions & 0 deletions dbm-ui/frontend/src/hooks/useFormModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 { reactive } from 'vue';

export function useFormModel<T extends object>(initialState: T) {
const formModel = reactive({ ...initialState }) as T;

function resetForm() {
Object.assign(formModel, initialState);
}

function setForm(values: Partial<T>) {
Object.assign(formModel, values);
}

return {
formModel,
resetForm,
setForm,
};
}
2 changes: 2 additions & 0 deletions dbm-ui/frontend/src/layout/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
],
[menuEnum.observableManage]: ['DBHASwitchEvents', 'inspectionManage'],
[menuEnum.configManage]: [
'BizResourcePool',
'BizResourceTag',
'DbConfigure',
'DBMonitorStrategy',
'DBMonitorAlarmGroup',
Expand Down
30 changes: 30 additions & 0 deletions dbm-ui/frontend/src/layout/components/ConfigManage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,36 @@
:active-key="currentActiveKey"
:opened-keys="[parentKey]"
@click="handleMenuChange">
<BkMenuGroup :name="t('资源管理')">
<BkMenuItem
key="BizResourcePool"
v-db-console="'bizConfigManage.businessResourcePool'">
<template #icon>
<DbIcon
svg
type="list" />
</template>
<span
v-overflow-tips.right
class="text-overflow">
{{ t('资源池') }}
</span>
</BkMenuItem>
<BkMenuItem
key="BizResourceTag"
v-db-console="'bizConfigManage.businessResourceTag'">
<template #icon>
<DbIcon
svg
type="tag-3" />
</template>
<span
v-overflow-tips.right
class="text-overflow">
{{ t('资源标签') }}
</span>
</BkMenuItem>
</BkMenuGroup>
<BkMenuGroup :name="t('业务配置')">
<BkMenuItem
key="DbConfigure"
Expand Down
14 changes: 14 additions & 0 deletions dbm-ui/frontend/src/layout/components/ResourceManage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@
{{ t('污点主机处理') }}
</span>
</BkMenuItem>
<BkMenuItem
key="resourceTagsManagement"
v-db-console="'resourceManage.resourceTagsManagement'">
<template #icon>
<DbIcon
svg
type="tag-3" />
</template>
<span
v-overflow-tips.right
class="text-overflow">
{{ t('资源标签管理') }}
</span>
</BkMenuItem>
<BkMenuItem
key="resourcePoolOperationRecord"
v-db-console="'resourceManage.resourceOperationRecord'">
Expand Down
24 changes: 24 additions & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,7 @@
"已选实例": "已选实例",
"新建订阅规则": "新建订阅规则",
"确认批量删除n个实例?": "确认批量删除 {n} 个实例?",
"确认批量删除n个标签?": "确认批量删除 {n} 个标签?",
"确认批量禁用n个实例?": "确认批量禁用 {n} 个实例?",
"部署dumper实例ID": "部署 dumper 实例 ID",
"接收端集群与端口": "接收端集群与端口",
Expand Down Expand Up @@ -3545,5 +3546,28 @@
"新只读主机": "新只读主机",
"请输入n台IP_英文逗号或换行分隔": "请输入 {n} 台IP_英文逗号或换行分隔",
"请输入n台IP": "请输入 {n} 台IP",
"标签": "标签",
"新建标签": "新建标签",
"请输入标签关键字": "请输入标签关键字",
"绑定的IP": "绑定的IP",
"确认删除该标签值?": "确认删除该标签值?",
"资源标签": "资源标签",
"更新成功": "更新成功",
"该标签已被绑定 ,不能删除": "该标签已被绑定 ,不能删除",
"设置属性": "设置属性",
"添加资源归属": "添加资源归属",
"转为公共资源": "转为公共资源",
"移入待回收池": "移入待回收池",
"移入故障池": "移入故障池",
"撤销导入": "撤销导入",
"搜索 IP 多个 | 或换行(Shift + Enter)分隔": "搜索 IP 多个 | 或换行(Shift + Enter)分隔",
"标签搜索": "标签搜索",
"资源归属": "资源归属",
"确认批量将 {n} 台主机转入回收池?": "确认批量将 {n} 台主机转入回收池?",
"确认将 {n} 台主机转为公共资源?": "确认将 {n} 台主机转为公共资源?",
"确认批量将 {n} 台主机转入故障池?": "确认批量将 {n} 台主机转入故障池?",
"确认批量撤销 {n} 台主机的导入?": "确认批量撤销 {n} 台主机的导入?",
"已选择以下": "已选择以下",
"共n台": "共 {0} 台",
"这行勿动!新增翻译请在上一行添加!": ""
}
Loading

0 comments on commit 8a13f75

Please sign in to comment.