aops-hermes/009-fix-hot-patch-prompts-are-only-executed-if-executed.patch
Hu gang f090d2ff01 fix hot patch prompts are only executed ifexecuted
(cherry picked from commit b94d7e2e764ec9920b93a1c53d73841d3a355c9f)
2023-12-27 18:58:11 +08:00

159 lines
5.4 KiB
Diff

From a554b248224e1d4ab8030cb3c353eb835ed654ce Mon Sep 17 00:00:00 2001
From: Hu gang <18768366022@163.com>
Date: Tue, 26 Dec 2023 16:54:57 +0800
Subject: [PATCH] fix: hot patch prompts are only executed if executed
immediately
---
.../assests/components/HostChartInfo.vue | 2 +-
src/views/leaks/LeakTaskDetail.vue | 44 +++++++++++++++++--
.../components/CreateRepairTaskDrawer.vue | 7 ++-
3 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/src/views/assests/components/HostChartInfo.vue b/src/views/assests/components/HostChartInfo.vue
index d9e8fe7..8a144d8 100644
--- a/src/views/assests/components/HostChartInfo.vue
+++ b/src/views/assests/components/HostChartInfo.vue
@@ -124,7 +124,7 @@ export default {
getHostMetrics({
query_ip: this.queryIp
}).then((res) => {
- if (res) {
+ if (res.data) {
this.metrics = res.data.results;
if (this.selectedMetrics.length < 1) {
this.selectedMetrics = res.data.results.slice(0, 4);
diff --git a/src/views/leaks/LeakTaskDetail.vue b/src/views/leaks/LeakTaskDetail.vue
index 134a0cb..38bc4f2 100644
--- a/src/views/leaks/LeakTaskDetail.vue
+++ b/src/views/leaks/LeakTaskDetail.vue
@@ -170,7 +170,12 @@
</span>
</div>
<div v-if="['cve fix', 'cve rollback'].includes(taskType)" slot="expandedRowRender" slot-scope="record">
- <a-table rowKey="id" :columns="innerColumns" :data-source="record.rpms || []" :pagination="false">
+ <a-table
+ :rowKey="(innerrecord) => innerrecord.installed_rpm + innerrecord[rpmTypeMap[taskType]]"
+ :columns="innerColumns"
+ :data-source="record.rpms || []"
+ :pagination="false"
+ >
<div slot="status" slot-scope="status">
<span>
<a-badge :status="statusValueMap[status]" />
@@ -184,6 +189,14 @@
<a-icon v-if="statusValueMap[status] === 'processing'" type="loading" class="color-running-circle" />
</span>
</div>
+ <div slot="cves" slot-scope="cves" class="cve-text">
+ <a-popover placement="topLeft">
+ <template slot="content">
+ <p class="cve-text-pop">{{ cves }}</p>
+ </template>
+ {{ cves }}
+ </a-popover>
+ </div>
</a-table>
</div>
</a-table>
@@ -257,6 +270,12 @@ const rowKeyMap = {
'hotpatch remove': 'cve_id'
};
+// rpm类型与任务类型映射关系
+const rpmTypeMap = {
+ 'cve fix': 'available_rpm',
+ 'cve rollback': 'target_rpm'
+};
+
const cveStatusTextMap = {
succeed: '修复成功',
fail: '待修复',
@@ -345,10 +364,12 @@ export default {
taskTypeMap,
rowKeyMap,
statusValueMap,
+ rpmTypeMap,
// rpm列表是否为展开状态
isRpmTableExtend: false,
isRollbackModelvisible: false,
countDown: 0,
+ // 创建的回滚任务id
rollbackTaskId: '',
jumpModalInterval: null,
// 详情页面下要执行任务的所有主机
@@ -467,15 +488,16 @@ export default {
title: taskType === 'cve fix' ? '受影响rpm' : '已安装rpm'
},
{
- dataIndex: taskType === 'cve fix' ? 'available_rpm' : 'target_rpm',
- key: taskType === 'cve fix' ? 'available_rpm' : 'target_rpm',
+ dataIndex: rpmTypeMap[taskType],
+ key: rpmTypeMap[taskType],
title: taskType === 'cve fix' ? '待安装rpm' : '目标rpm',
scopedSlots: {customRender: 'rpm'}
},
{
dataIndex: 'cves',
key: 'cves',
- title: 'CVE'
+ title: 'CVE',
+ scopedSlots: {customRender: 'cves'}
},
{
dataIndex: 'status',
@@ -1166,4 +1188,18 @@ export default {
border-radius: 3px;
padding: 4px 6px 20px;
}
+.cve-text {
+ max-width: 300px;
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ &-pop {
+ max-width: 500px;
+ display: -webkit-box;
+ -webkit-line-clamp: 25;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+}
</style>
diff --git a/src/views/leaks/components/CreateRepairTaskDrawer.vue b/src/views/leaks/components/CreateRepairTaskDrawer.vue
index 30efbe5..b7e4424 100644
--- a/src/views/leaks/components/CreateRepairTaskDrawer.vue
+++ b/src/views/leaks/components/CreateRepairTaskDrawer.vue
@@ -207,7 +207,9 @@
>点击跳转到{{ item.fix_way }}{{ taskType === 'cve fix' ? '修复' : '移除' }}任务页面</a
>
</p>
- <p v-if="jumpTaskId.length > 1">只执行热补丁任务,冷补丁任务需手动执行</p>
+ <p v-if="jumpTaskId.length > 1">
+ {{ isExcuteASAP ? '已自动执行热补丁任务,冷补丁任务需手动执行' : '请优先执行热补丁任务' }}
+ </p>
<p>{{ countDown }}秒后回到原页面</p>
</a-col>
</a-row>
@@ -307,6 +309,8 @@ export default {
},
data() {
return {
+ // 是否立即执行
+ isExcuteASAP: false,
hostListparams: [],
fixParams: {},
// 修复任务入参
@@ -788,6 +792,7 @@ export default {
}
},
handleSubmit(excuteASAP = false) {
+ this.isExcuteASAP = excuteASAP;
const _this = this;
this.form.validateFields((err, values) => {
if (!err) {
--
2.33.0