From 47aaab21d6606f27d6117eb53034f6c2c5f3edf3 Mon Sep 17 00:00:00 2001 From: Hu gang <18768366022@163.com> Date: Wed, 20 Dec 2023 19:26:33 +0800 Subject: [PATCH] fix: host status adaptation --- src/api/leaks.js | 3 +- src/vendor/ant-design-pro/utils/request.js | 6 ++++ src/views/assests/HostDetail.vue | 34 +++++++------------ .../assests/components/HostBasicInfo.vue | 4 +-- .../assests/components/HostChartInfo.vue | 33 +++++++----------- src/views/leaks/CVEsDetail.vue | 21 +++++------- src/views/leaks/LeakTaskDetail.vue | 3 +- src/views/leaks/components/HostTable.vue | 12 +++---- 8 files changed, 49 insertions(+), 67 deletions(-) diff --git a/src/api/leaks.js b/src/api/leaks.js index c6f704b..da3fbf8 100644 --- a/src/api/leaks.js +++ b/src/api/leaks.js @@ -347,6 +347,7 @@ export function setCveStatus({cveList, status}) { } export function getHostUnderCVE({tableInfo, ...parameter}) { + const repoList = tableInfo.filters.repo ? tableInfo.filters.repo.map((v) => (v === '' ? null : v)) : null; return request({ url: api.getHostUnderCVE, method: 'post', @@ -358,7 +359,7 @@ export function getHostUnderCVE({tableInfo, ...parameter}) { fixed: tableInfo.fixed, host_name: tableInfo.filters.host_name === null ? undefined : tableInfo.filters.host_name, host_group: tableInfo.filters.host_group === null ? undefined : tableInfo.filters.host_group, - repo: tableInfo.filters.repo === null ? undefined : tableInfo.filters.repo, + repo: repoList === null ? undefined : repoList, last_scan: tableInfo.filters.last_scan }, page: tableInfo.pagination.current, diff --git a/src/vendor/ant-design-pro/utils/request.js b/src/vendor/ant-design-pro/utils/request.js index 11be85a..36615ad 100644 --- a/src/vendor/ant-design-pro/utils/request.js +++ b/src/vendor/ant-design-pro/utils/request.js @@ -165,6 +165,12 @@ request.interceptors.response.use((response) => { }); }); return retryRequest; + case '1108': + notification.error({ + message: '暂无指标数据!', + description: response.data.message + }); + break; default: notification.error({ message: response.data.label, diff --git a/src/views/assests/HostDetail.vue b/src/views/assests/HostDetail.vue index 6eadb05..ea08cfa 100644 --- a/src/views/assests/HostDetail.vue +++ b/src/views/assests/HostDetail.vue @@ -49,30 +49,20 @@ export default { }; }, methods: { - fetchHostInfo() { + async fetchHostInfo() { this.basicHostInfoIsLoading = true; - getHostDetail(Number(this.hostId), true) - .then((res) => { - this.basicHostInfo = res.data.host_infos[0]; - this.scene = this.basicHostInfo.scene; - }) - .catch((err) => { - this.$message.error(err.response.message); - }) - .finally(() => { - this.basicHostInfoIsLoading = false; - }); this.basicInfoIsLoading = true; - getHostDetail(Number(this.hostId), false) - .then((res) => { - this.basicInfo = res.data.host_infos[0]; - }) - .catch((err) => { - this.$message.error(err.response.message); - }) - .finally(() => { - this.basicInfoIsLoading = false; - }); + const basicHostRes = await getHostDetail(Number(this.hostId), true); + if (basicHostRes) { + this.basicHostInfo = basicHostRes.data.host_infos[0]; + this.scene = this.basicHostInfo.scene; + } + const basicRes = await getHostDetail(Number(this.hostId), false); + if (basicRes) { + this.basicInfo = basicRes.data.host_infos[0]; + } + this.basicInfoIsLoading = false; + this.basicHostInfoIsLoading = false; }, reFetchHostInfo() { this.fetchHostInfo(); diff --git a/src/views/assests/components/HostBasicInfo.vue b/src/views/assests/components/HostBasicInfo.vue index bab1074..9909e44 100644 --- a/src/views/assests/components/HostBasicInfo.vue +++ b/src/views/assests/components/HostBasicInfo.vue @@ -235,6 +235,7 @@ export default { getDetail() { let data = this.basicInfo; data = data.host_info; + this.basicInfo.status !== null && (this.status = this.basicInfo.status); for (const member in data.os) { this.os[member] = data.os[member] || '暂无'; } @@ -257,8 +258,7 @@ export default { this.detailIcon = 'up'; } } - }, - mounted() {} + } };