Skip to content

Commit

Permalink
Merge pull request TencentBlueKing#1752 from Tencent/master
Browse files Browse the repository at this point in the history
merge: master to 3.7.x
  • Loading branch information
wangyu096 authored Feb 21, 2023
2 parents 98aeaa1 + 83def8c commit 7312591
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"keywords": [],
"license": "ISC",
"dependencies": {
"@blueking/ip-selector": "0.0.1-beta.64",
"@blueking/ip-selector": "0.0.1-beta.66",
"@blueking/paas-login": "0.0.11",
"@blueking/user-selector": "^1.0.7",
"@vue/composition-api": "^1.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
<div
class="action-item"
@click="handleCopyAll">
{{ $t('复制全部IP') }}
{{ $t('复制所有 IP') }}
</div>
<div
class="action-item"
@click="handleCopyFail">
{{ $t('复制异常IP') }}
{{ $t('复制异常 IP') }}
</div>
</template>
<slot />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<template>
<div>
<div
ref="handleRef"
class="dropdown-menu-group"
:class="{
active: isActive
}">
<slot />
<i class="toggle-flag bk-icon icon-angle-right" />
</div>
<div
ref="popRef"
style="padding: 5px 0; margin: -0.3rem -0.6rem;"
@click="handleClick">
<slot name="action" />
</div>
</div>
</template>
<script setup>
import Tippy from 'bk-magic-vue/lib/utils/tippy';
import {
onBeforeUnmount,
onMounted,
ref,
} from 'vue';
const handleRef = ref();
const popRef = ref();
const isActive = ref(false);
let tippyInstance;
const handleClick = () => {
tippyInstance.hide();
};
onMounted(() => {
tippyInstance = Tippy(handleRef.value, {
arrow: false,
allowHTML: false,
content: popRef.value,
placement: 'right-start',
trigger: 'mouseenter',
theme: 'light',
hideOnClick: false,
ignoreAttributes: true,
animateFill: false,
boundary: 'window',
interactive: true,
distance: 6,
onShow () {
isActive.value = true;
},
onHide () {
isActive.value = false;
},
});
});
onBeforeUnmount(() => {
if (tippyInstance) {
tippyInstance.hide();
tippyInstance.destroy();
tippyInstance = null;
}
});
</script>
<style lang="postcss">
.dropdown-menu-group {
display: flex;
height: 32px;
padding: 0 10px;
font-size: 12px;
color: #63656e;
align-items: center;
cursor: pointer;
&.active {
color: #3a84ff;
background: #f5f6fa;
}
.toggle-flag {
margin-left: auto;
font-size: 16px;
}
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<template>
<div class="host-dropdown-menu">
<div
ref="handleRef"
@mouseenter="handleShow">
<slot />
</div>
<div
ref="popRef"
style="width: 98px; padding: 5px 0; margin: -0.3rem -0.6rem;">
<slot name="menu" />
</div>
</div>
</template>
<script setup>
import Tippy from 'bk-magic-vue/lib/utils/tippy';
import {
onBeforeUnmount,
onMounted,
ref,
} from 'vue';
const handleRef = ref();
const popRef = ref();
const isActive = ref(false);
let tippyInstance;
const handleShow = () => {
tippyInstance.show();
};
onMounted(() => {
tippyInstance = Tippy(handleRef.value, {
arrow: false,
allowHTML: false,
content: popRef.value,
placement: 'bottom-start',
trigger: 'manual',
theme: 'light',
hideOnClick: true,
animateFill: false,
interactive: true,
boundary: 'window',
distance: 6,
onShow () {
isActive.value = true;
},
onHide () {
isActive.value = false;
},
});
});
onBeforeUnmount(() => {
if (tippyInstance) {
tippyInstance.hide();
tippyInstance.destroy();
tippyInstance = null;
}
});
</script>
<style lang="postcss" scoped>
.host-dropdown-menu {
display: block;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<div
class="dropdown-menu-item"
v-on="listeners">
<slot />
</div>
</template>
<script setup>
import { useListeners } from 'vue';
const listeners = useListeners();
</script>
<style lang="postcss" scoped>
.dropdown-menu-item {
display: flex;
height: 32px;
padding: 0 10px;
font-size: 12px;
color: #63656e;
align-items: center;
cursor: pointer;
&:hover {
color: #3a84ff;
background: #f5f6fa;
}
}
</style>
104 changes: 61 additions & 43 deletions src/frontend/src/components/task-step/common/execute-target/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,40 @@
</compose-form-item>
</template>
<template v-if="isShowServerAction">
<bk-dropdown-menu>
<dropdown-menu>
<bk-button
slot="dropdown-trigger"
class="mr10"
type="primary">
<span>{{ $t('复制IP') }}</span>
<span>{{ $t('复制 IP') }}</span>
<icon
class="action-flag"
type="down-small" />
</bk-button>
<ul
slot="dropdown-content"
class="bk-dropdown-list">
<li><a @click="handleCopyAll">{{ $t('全部IP') }}</a></li>
<li><a @click="handleCopyFail">{{ $t('异常IP') }}</a></li>
</ul>
</bk-dropdown-menu>
<template slot="menu">
<dropdown-menu-group>
<span>{{ $t('所有 IP') }}</span>
<template slot="action">
<dropdown-menu-item @click="handleCopyIPv4">
IPv4
</dropdown-menu-item>
<dropdown-menu-item @click="handleCopyIPv6">
IPv6
</dropdown-menu-item>
</template>
</dropdown-menu-group>
<dropdown-menu-group>
<span>{{ $t('异常 IP') }}</span>
<template slot="action">
<dropdown-menu-item @click="handleCopyAbnormalIPv4">
IPv4
</dropdown-menu-item>
<dropdown-menu-item @click="handleCopyAbnormalIPv6">
IPv6
</dropdown-menu-item>
</template>
</dropdown-menu-group>
</template>
</dropdown-menu>
<bk-button
class="mr10"
@click="handleClearAll">
Expand All @@ -117,6 +134,7 @@
{{ $t('刷新状态') }}
</bk-button>
</template>

<bk-input
v-if="isShowHostSearchInput"
class="ip-search"
Expand All @@ -125,16 +143,6 @@
:value="searchText"
@change="handleHostSearch" />
</div>

<!-- <server-panel
v-show="isShowServerPanel"
ref="serverPanel"
class="view-server-panel"
:host-node-info="localHost"
:search-mode="Boolean(searchText)"
:search-data="searchData"
editable
@on-change="handleHostChange" /> -->
<ip-selector
ref="ipSelector"
:show-dialog="isShowChooseIp"
Expand All @@ -144,10 +152,6 @@
@change="handleHostChange"
@close-dialog="handleCloseIpSelector" />
</jb-form-item>
<!-- <choose-ip
v-model="isShowChooseIp"
:host-node-info="localHost"
@on-change="handleHostChange" /> -->
</div>
</template>
<script>
Expand All @@ -159,15 +163,18 @@

import ComposeFormItem from '@components/compose-form-item';

import DropdownMenu from './components/dropdown-menu';
import DropdownMenuGroup from './components/dropdown-menu/group';
import DropdownMenuItem from './components/dropdown-menu/item';

import I18n from '@/i18n';
// import ChooseIp from '@components/choose-ip';
// import ServerPanel from '@components/choose-ip/server-panel';

export default {
components: {
ComposeFormItem,
// ChooseIp,
// ServerPanel,
DropdownMenu,
DropdownMenuGroup,
DropdownMenuItem,
},
inheritAttrs: false,
props: {
Expand Down Expand Up @@ -362,29 +369,41 @@
handleCloseIpSelector () {
this.isShowChooseIp = false;
},
/**
* @desc 复制所有主机
*/
handleCopyAll () {
const allIP = this.$refs.ipSelector.getHostIpList();
handleCopyIPv4 () {
const allIP = this.$refs.ipSelector.getHostIpv4List();
if (allIP.length < 1) {
this.messageWarn(I18n.t('你还未选择主机'));
this.messageWarn(I18n.t('没有可复制的 IPv4'));
return;
}

execCopy(allIP.join('\n'), `${I18n.t('复制成功')}(${allIP.length}${I18n.t('个IP')})`);
},
/**
* @desc 复制所有异常主机
*/
handleCopyFail () {
const abnormalHostIpList = this.$refs.ipSelector.getAbnormalHostIpList();
if (abnormalHostIpList.length < 1) {
this.messageWarn(I18n.t('暂无异常主机'));
handleCopyIPv6 () {
const allIP = this.$refs.ipSelector.getHostIpv6List();
if (allIP.length < 1) {
this.messageWarn(I18n.t('没有可复制的 IPv6'));
return;
}

execCopy(allIP.join('\n'), `${I18n.t('复制成功')}(${allIP.length}${I18n.t('个IP')})`);
},
handleCopyAbnormalIPv4 () {
const allIP = this.$refs.ipSelector.getAbnormalHostIpv4List();
if (allIP.length < 1) {
this.messageWarn(I18n.t('没有可复制的异常 IPv4'));
return;
}

execCopy(abnormalHostIpList.join('\n'), `${I18n.t('复制成功')}(${abnormalHostIpList.length}${I18n.t('个IP')})`);
execCopy(allIP.join('\n'), `${I18n.t('复制成功')}(${allIP.length}${I18n.t('个IP')})`);
},
handleCopyAbnormalIPv6 () {
const allIP = this.$refs.ipSelector.getAbnormalHostIpv6List();
if (allIP.length < 1) {
this.messageWarn(I18n.t('没有可复制的异常 IPv6'));
return;
}

execCopy(allIP.join('\n'), `${I18n.t('复制成功')}(${allIP.length}${I18n.t('个IP')})`);
},
/**
* @desc 复制所有主机数据
Expand All @@ -405,7 +424,6 @@
*/
handleHostSearch (search) {
this.searchText = _.trim(search);
// this.searchData = Object.freeze(this.$refs.serverPanel.getAllHost(search));
},
},
};
Expand Down
Loading

0 comments on commit 7312591

Please sign in to comment.