Skip to content

Commit 87dba64

Browse files
authored
Merge pull request #4125 from hLinx/feature_master
Feature master
2 parents 5ca07ba + 855b877 commit 87dba64

File tree

13 files changed

+175
-100
lines changed

13 files changed

+175
-100
lines changed

src/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@blueking/bk-user-selector": "0.0.29-beta.8",
2121
"@blueking/date-picker": "3.0.4",
2222
"@blueking/crypto-js-sdk": "0.0.5",
23-
"@blueking/ip-selector": "1.0.1-beta.21",
23+
"@blueking/ip-selector": "1.0.1-beta.26",
2424
"@blueking/login-modal": "1.0.6",
2525
"@blueking/notice-component-vue2": "2.0.6-beta.5",
2626
"@blueking/paas-login": "0.0.11",

src/frontend/src/components/global-variable/edit/host.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
</div>
4949
<jb-ip-selector
5050
ref="ipSelector"
51+
:config="ipSelectorConfig"
5152
:original-value="originalExecuteObjectsInfo"
5253
:show-dialog="isShowChooseIp"
5354
show-view
@@ -127,6 +128,26 @@
127128
immediate: true,
128129
},
129130
},
131+
created() {
132+
this.ipSelectorConfig = {};
133+
// 业务集和租户集场景不支持动态分组和容器
134+
if (window.PROJECT_CONFIG.SCOPE_TYPE === 'biz_set') {
135+
this.ipSelectorConfig = {
136+
panelList: [
137+
'staticTopo',
138+
'dynamicTopo',
139+
'manualInput',
140+
],
141+
};
142+
} else if (window.PROJECT_CONFIG.SCOPE_TYPE === 'tenant_set') {
143+
this.ipSelectorConfig = {
144+
panelList: [
145+
'staticTopo',
146+
'manualInput',
147+
],
148+
};
149+
}
150+
},
130151
methods: {
131152
/**
132153
* @desc 解析默认值

src/frontend/src/components/jb-ip-selector/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
getAbnormalIpv6HostList() {
5858
return this.$refs.ipSelector.getAbnormalIpv6HostList();
5959
},
60+
getContainerList() {
61+
return this.$refs.ipSelector.getContainerList();
62+
},
6063
resetValue() {
6164
this.$refs.ipSelector.resetValue();
6265
},

src/frontend/src/components/task-step/common/execute-target/index.vue

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,19 @@
153153
{{ $t('刷新状态') }}
154154
</bk-button>
155155
</template>
156-
156+
<template v-if="isShowContainerAction">
157+
<bk-button
158+
class="mr10"
159+
type="primary"
160+
@click="handleCopyContainerID">
161+
{{ $t('复制容器 ID') }}
162+
</bk-button>
163+
<bk-button
164+
class="mr10"
165+
@click="handleClearAll">
166+
<span>{{ $t('清空') }}</span>
167+
</bk-button>
168+
</template>
157169
<bk-input
158170
v-if="isShowHostSearchInput"
159171
class="ip-search"
@@ -260,7 +272,17 @@
260272
if (this.isGolbalVariableType) {
261273
return false;
262274
}
263-
return !ExecuteTargetModel.isExecuteObjectsInfoEmpty(this.localExecuteObjectsInfo);
275+
return Object.keys(this.localExecuteObjectsInfo.containerList).length < 1 && !ExecuteTargetModel.isExecuteObjectsInfoEmpty(this.localExecuteObjectsInfo);
276+
},
277+
/**
278+
* @desc 是否显示容器结果快捷操作
279+
* @returns {Boolean}
280+
*/
281+
isShowContainerAction() {
282+
if (this.isGolbalVariableType) {
283+
return false;
284+
}
285+
return Object.keys(this.localExecuteObjectsInfo.containerList).length > 0;
264286
},
265287
/**
266288
* @desc 清除异常主机是否可用
@@ -577,6 +599,12 @@
577599
this.isCopyLoading = false;
578600
});
579601
},
602+
handleCopyContainerID() {
603+
this.$refs.ipSelector.getContainerList().then((containList) => {
604+
const containerIdStr = containList.map(item => item.uid).join('\n');
605+
execCopy(containerIdStr, `${I18n.t('复制成功')}${containList.length}${I18n.t('个容器 ID')}`);
606+
});
607+
},
580608
/**
581609
* @desc 复制所有主机数据
582610
*/

src/frontend/src/domain/model/execution/task-instance.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* IN THE SOFTWARE.
2424
*/
2525

26+
import DOMPurify from 'dompurify';
27+
2628
import Model from '@model/model';
2729

2830
import {
@@ -184,7 +186,7 @@ export default class TaskInstance extends Model {
184186
disabled: '#C4C6CC',
185187
evicted: '#EA3636',
186188
};
187-
return `<span style="color: ${statusColorMap[calcStatusGroup(this.status)]}">${this.statusDesc}</span>`;
189+
return DOMPurify.sanitize(`<span style="color: ${statusColorMap[calcStatusGroup(this.status)]}">${this.statusDesc}</span>`);
188190
}
189191

190192
/**

src/frontend/src/i18n/language/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,5 +577,6 @@
577577
"语言切换失败,请稍后重试": "Language switch failed, please try again later.",
578578
"时区": "timezone",
579579
"nav时区信息": "The personal time zone you set, the website will display all time-related information based on this. It can be modified in {link}",
580-
"个人设置": "Personal Settings"
580+
"个人设置": "Personal Settings",
581+
"个容器 ID": "Container ID(s)"
581582
}

src/frontend/src/i18n/language/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,5 +577,6 @@
577577
"语言切换失败,请稍后重试": "语言切换失败,请稍后重试",
578578
"时区": "时区",
579579
"nav时区信息": "您设置的个人时区,网站将根据此展示所有时间相关信息。可在{link}中修改",
580-
"个人设置": "个人设置"
580+
"个人设置": "个人设置",
581+
"个容器 ID": "个容器 ID"
581582
}

src/frontend/src/views/home/index/components/agent/components/action-extend.vue

Lines changed: 88 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,53 @@
2727

2828
<template>
2929
<div
30+
v-if="allHostList.length > 0"
3031
class="server-panel-action-extend"
3132
@click.stop=""
3233
@mouseleave="handleHide">
33-
<icon type="more" />
34+
<div v-bk-tooltips="$t('复制所有')">
35+
<icon type="more" />
36+
</div>
3437
<div
3538
ref="popoverContent"
3639
class="server-action-extend-content"
3740
@click="handleWraperClick"
3841
@mouseleave="handleClose"
3942
@mouseover="handleShow">
40-
<template v-if="copyable">
41-
<div
42-
class="action-item"
43-
@click="handleCopyAll">
44-
{{ $t('复制所有 IP') }}
45-
</div>
46-
<div
47-
class="action-item"
48-
@click="handleCopyFail">
49-
{{ $t('复制异常 IP') }}
50-
</div>
51-
</template>
52-
<slot />
43+
<div
44+
class="action-item"
45+
@click="() => handleCopyIPv4()">
46+
IPV4
47+
</div>
48+
<div
49+
class="action-item"
50+
@click="() => handleCopyIPv4(true)">
51+
{{ $t('管控区域 ID:IPv4') }}
52+
</div>
53+
<div
54+
class="action-item"
55+
@click="() => handleCopyIPv6()">
56+
IPV6
57+
</div>
58+
<div
59+
class="action-item"
60+
@click="() => handleCopyIPv6(true)">
61+
{{ $t('管控区域 ID:IPv6') }}
62+
</div>
63+
<div
64+
class="action-item"
65+
@click="handleCopyHostId">
66+
{{ $t('主机 ID') }}
67+
</div>
5368
</div>
5469
</div>
5570
</template>
5671
<script>
72+
73+
import _ from 'lodash';
74+
75+
import HomeService from '@service/home';
76+
5777
import {
5878
execCopy,
5979
} from '@utils/assist';
@@ -69,26 +89,45 @@
6989
type: Array,
7090
default: () => [],
7191
},
72-
invalidList: {
73-
type: Array,
74-
default: () => [],
92+
agentStatus: {
93+
type: Number,
7594
},
76-
copyable: {
77-
type: Boolean,
78-
default: false,
95+
},
96+
data() {
97+
return {
98+
allHostList: [],
99+
};
100+
},
101+
watch: {
102+
agentStatus: {
103+
handler() {
104+
if (this.agentStatus > -1) {
105+
this.fetchData();
106+
}
107+
},
108+
immediate: true,
79109
},
80110
},
81111
created() {
82112
this.id = `action_extend_${Math.random()}_${Math.random()}`;
83113
},
84-
mounted() {
85-
this.init();
86-
},
87114
beforeDestroy() {
88115
instanceMap[this.id].hide();
89116
delete instanceMap[this.id];
90117
},
91118
methods: {
119+
fetchData() {
120+
HomeService.fetchAgentStatus({
121+
agentStatus: this.agentStatus,
122+
}).then((data) => {
123+
this.allHostList = data.data;
124+
if (this.allHostList.length > 0) {
125+
setTimeout(() => {
126+
this.init();
127+
});
128+
}
129+
});
130+
},
92131
/**
93132
* @desc 弹层面板初始化
94133
*/
@@ -123,44 +162,36 @@
123162
this.handleClose();
124163
}, 3000);
125164
},
126-
/**
127-
* @desc 复制所有主机
128-
*/
129-
handleCopyAll() {
130-
if (this.list.length < 1 && this.invalidList.length < 1) {
131-
this.messageWarn(I18n.t('你还未选择主机'));
165+
166+
handleCopyIPv4(withNet = false) {
167+
const allIP = _.filter(this.allHostList.map(host => (withNet ? `${host.cloudArea.id}:${host.ip}` : host.ip)), item => !!item);
168+
169+
if (allIP.length < 1) {
170+
this.messageWarn(I18n.t('home.没有可复制的 IPv4'));
132171
return;
133172
}
134-
let allIP = this.list.map(host => host.ip);
135-
const allInvalidList = this.invalidList.map(host => host.ip);
136-
allIP = [
137-
...allIP, ...allInvalidList,
138-
];
139-
execCopy(allIP.join('\n'), `${I18n.t('复制成功')}${allIP.length}${I18n.t('个IP')}`);
173+
execCopy(allIP.join('\n'), `${I18n.t('home.复制成功')}${allIP.length}${I18n.t('home.个IP')}`);
140174
},
141-
/**
142-
* @desc 复制异常主机
143-
*/
144-
handleCopyFail() {
145-
if (this.list.length < 1 && this.invalidList.length < 1) {
146-
this.messageWarn(I18n.t('你还未选择主机'));
175+
handleCopyIPv6(withNet = false) {
176+
const ipv6HostList = _.filter(this.allHostList, host => !!host.ipv6);
177+
if (ipv6HostList.length < 1) {
178+
this.messageWarn(I18n.t('home.没有可复制的 IPv6'));
147179
return;
148180
}
149-
let allFailIp = [];
150-
this.list.forEach((currentHost) => {
151-
if (!currentHost.alive) {
152-
allFailIp.push(currentHost.ip);
153-
}
154-
});
155-
if (allFailIp.length < 1 && this.invalidList.length < 1) {
156-
this.messageWarn(I18n.t('暂无异常主机'));
181+
const allIP = _.filter(ipv6HostList.map(host => (withNet ? `${host.cloudArea.id}:${host.ipv6}` : host.ipv6)), item => !!item);
182+
183+
execCopy(allIP.join('\n'), `${I18n.t('home.复制成功')}${allIP.length}${I18n.t('home.个IP')}`);
184+
},
185+
/**
186+
* @desc 复制主机ID
187+
*/
188+
handleCopyHostId() {
189+
const allHostId = this.allHostList.map(host => host.hostId);
190+
if (allHostId.length < 1) {
191+
this.messageWarn(I18n.t('home.没有可复制的主机ID'));
157192
return;
158193
}
159-
const allInvalidList = this.invalidList.map(host => host.ip);
160-
allFailIp = [
161-
...allFailIp, ...allInvalidList,
162-
];
163-
execCopy(allFailIp.join('\n'), `${I18n.t('复制成功')}${allFailIp.length}${I18n.t('个异常IP')}`);
194+
execCopy(allHostId.join('\n'), `${I18n.t('home.复制成功')}${allHostId.length}${I18n.t('home.个主机ID')}`);
164195
},
165196
handleShow() {
166197
clearTimeout(this.leaveTimer);
@@ -172,12 +203,6 @@
172203
};
173204
</script>
174205
<style lang="postcss">
175-
html[lang="en-US"] {
176-
.server-action-extend-content {
177-
width: 154px;
178-
}
179-
}
180-
181206
.server-panel-action-extend {
182207
position: absolute;
183208
top: 50%;
@@ -212,18 +237,18 @@
212237
}
213238
214239
.server-action-extend-content {
215-
width: 93px;
216-
font-size: 14px;
240+
font-size: 12px;
217241
line-height: 32px;
218242
color: #63656e;
219243
background: #fff;
220244
border: 1px solid #f0f1f5;
221245
box-shadow: 0 2px 1px 0 rgb(185 203 222 / 50%);
222246
223247
.action-item {
224-
padding-left: 15px;
248+
padding: 0 15px;
225249
cursor: pointer;
226250
251+
227252
&:hover {
228253
color: #3a84ff;
229254
background: #e5efff;

src/frontend/src/views/home/index/components/agent/components/host-list.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
6565
export default {
6666
props: {
67-
statusType: {
68-
type: String,
69-
default: '',
67+
agentStatus: {
68+
type: Number,
69+
required: true,
7070
},
7171
},
7272
data() {
@@ -88,7 +88,7 @@
8888
const pageSize = this.pagination.limit;
8989
const start = parseInt(this.pagination.current - 1, 10) * pageSize;
9090
const params = {
91-
agentStatus: this.statusType === 'fail' ? 0 : 1,
91+
agentStatus: this.agentStatus,
9292
start,
9393
pageSize,
9494
};

0 commit comments

Comments
 (0)