diff --git a/src/components/OverviewState/index.vue b/src/components/OverviewState/index.vue index 4aaa58a..14ecd99 100644 --- a/src/components/OverviewState/index.vue +++ b/src/components/OverviewState/index.vue @@ -1,28 +1,28 @@ @@ -97,7 +97,7 @@ export default { font-size: 28px; margin-right: 5px; } - span{ + span { max-width: 90px; } } diff --git a/src/services/screen/resource.js b/src/services/screen/resource.js index 3db5436..96dee05 100644 --- a/src/services/screen/resource.js +++ b/src/services/screen/resource.js @@ -1,22 +1,22 @@ import request from 'utils/request' import { wrapperParams } from 'utils' -export function getOverview (type) { +export function getOverview(type) { return request.get('/cos/v1/cloud/resource/overview', { params: { type } }) } -export function getPlatformOverview (type) { +export function getPlatformOverview(type) { return request.get('/cos/v1/cloud/resource', { params: { type } }) } -export function getUsed (type) { +export function getUsed(type) { return request.get('/cos/v1/cloud/resource/used', { params: { type } }) } -export function getVendors () { +export function getVendors() { return request.get('/cos/v1/cloud/resource/type') } -export function getPlatforms (type) { +export function getPlatforms(type) { return request.get('/cos/v1/cloud/resource/platform', { params: wrapperParams({ type }) }) } @@ -26,11 +26,11 @@ export function getAlarmPieChart() { }) } -export function getResourceApply (type) { +export function getResourceApply(type) { return request.get('/cos/v1/cloud/resource/apply', { params: { type } }) } -export function getResourceTrend (type) { +export function getResourceTrend(type) { return request.get('/cos/v1/cloud/resource/trend', { params: { type } }) } @@ -54,3 +54,8 @@ export function getResourceCount(type) { params: { type } }) } +export function getCapacityCountNew(params) { + return request.get('/ims/v1/cloudResource/vendors/resource/capacity', { + params: params + }) +} diff --git a/src/views/resource_screen/data.js b/src/views/resource_screen/data.js index 93def59..9e3ebd5 100644 --- a/src/views/resource_screen/data.js +++ b/src/views/resource_screen/data.js @@ -42,36 +42,36 @@ export const overviewConfigs = [ // value: 0, // }, ] + }, + { + title: '私有云使用情况', + icon: 'el-icon-data-line', + type: 'PROGRESS', + titleStyle: { + fontSize: '14px' + }, + data: [ + { + title: 'CPU总量/剩余量', + unit: '核', + color: '#3AE13A', + used: 0, + total: 0 + }, + { + title: '内存总量/剩余量', + unit: 'G', + color: '#FFC400', + used: 0, + total: 0 + }, + { + title: '存储总量/剩余量', + unit: 'T', + color: '#33A1FF', + used: 0, + total: 0 + } + ] } - // { - // title: "私有云使用情况", - // icon: "el-icon-data-line", - // type: "PROGRESS", - // titleStyle: { - // fontSize: "14px", - // }, - // data: [ - // { - // title: "CPU总量/剩余量", - // unit: "核", - // color: "#3AE13A", - // used: 0, - // total: 0, - // }, - // { - // title: "内存总量/剩余量", - // unit: "G", - // color: "#FFC400", - // used: 0, - // total: 0, - // }, - // { - // title: "存储总量/剩余量", - // unit: "T", - // color: "#33A1FF", - // used: 0, - // total: 0, - // }, - // ], - // }, ] diff --git a/src/views/resource_screen/index.vue b/src/views/resource_screen/index.vue index d4e65fd..7d94a66 100644 --- a/src/views/resource_screen/index.vue +++ b/src/views/resource_screen/index.vue @@ -8,16 +8,16 @@
- + - + - + - +
@@ -31,7 +31,7 @@
告警统计
- +
@@ -75,18 +75,7 @@ import OverviewState from 'components/OverviewState' import PlatformCard from './PlatformCard' import ResourceCount from '../count_screen/ResourceCount' import { overviewConfigs } from './data' -import { - getOverview, - getPlatformOverview, - getUsed, - getPlatforms, - getAlarmPieChart, - getResourceApply, - getResourceTrend, - getResTops, - getHostStatus, - getResourceCount -} from 'services/screen/resource' +import { getOverview, getPlatformOverview, getUsed, getPlatforms, getAlarmPieChart, getResourceApply, getResourceTrend, getResTops, getHostStatus, getResourceCount, getCapacityCountNew } from 'services/screen/resource' export default { components: { ScreenWrapper, @@ -114,6 +103,7 @@ export default { // 处理数据对configs赋值 const { hosts, servers, running } = res.data const unit = state.overviewConfigs[0] + console.log(unit, '....') ;[hosts, servers, running].forEach((item, index) => { unit.data[index].value = item }) @@ -131,30 +121,6 @@ export default { }) } } - // 使用情况 - const getUsedState = async () => { - const res = await getUsed() - if (res.success) { - // 处理数据对configs赋值 - const { - menUnused, - memTotal, - cpuUnused, - cpuTotal, - diskTotal, - diskUnused - } = res.data - const unit = state.overviewConfigs[2] - ;[ - { used: cpuUnused, total: cpuTotal }, - { used: menUnused, total: memTotal }, - { used: diskUnused, total: diskTotal } - ].forEach((item, index) => { - unit.data[index].used = item.used - unit.data[index].total = item.total - }) - } - } // 公有私有统计 const getPlatformCount = async () => { const colors = ['#1890FF', '#19BE6B', '#4144E3', '#ecbc1e'] @@ -181,9 +147,25 @@ export default { } // 云资源统计 const getResource = async () => { - const res = await getResourceCount(state.vendorType) + const params = { + vendorTypes: 'VMWARE,INSPURRAIL,USPHERE', + realTime: false + } + const res = await getCapacityCountNew(params) if (res.success) { state.resourceCount = res.data + // 2 + const { hostLastMemory, hostTotalMemory, hostTotalCpuHz, hostLastCpuHz, hostTotalDisk, hostLastDisk } = res.data + + const unit2 = state.overviewConfigs[2] + ;[ + { used: hostLastCpuHz, total: hostTotalCpuHz }, + { used: hostLastMemory, total: hostTotalMemory }, + { used: hostLastDisk, total: hostTotalDisk } + ].forEach((item, index) => { + unit2.data[index].used = item.used + unit2.data[index].total = item.total + }) } } // 云主机状态 @@ -237,27 +219,14 @@ export default { } } // 切换平台 - const change = async (type) => { + const change = async type => { state.vendorType = type - const proArr = [ - getApplyCount(), - getUsedCount(), - getCpuTop5(), - getMemTop5(), - getHostCount(), - getResource() - ] + const proArr = [getApplyCount(), getUsedCount(), getCpuTop5(), getMemTop5(), getHostCount(), getResource()] await Promise.all(proArr) } const init = async () => { try { - await Promise.all([ - getOverviewState(), - getUsedState(), - getPlatformState(), - getAlarmCount(), - change() - ]) + await Promise.all([getOverviewState(), getPlatformState(), getAlarmCount(), change()]) } catch (error) {} state.loading = false } @@ -296,7 +265,7 @@ export default { height: calc(100% - 30px); } } -.resource-count ::v-deep .cell{ +.resource-count ::v-deep .cell { height: 85px; }