diff --git a/src/components/echarts/Line.vue b/src/components/echarts/Line.vue index a309ffc101bb413a35bc599e45a316bdf268aedc..a142d3efa7a3e916ee6b5a92da139321beef6e72 100644 --- a/src/components/echarts/Line.vue +++ b/src/components/echarts/Line.vue @@ -49,7 +49,7 @@ const initChart = () => { let yUnit = props.yUnit value = item.value if (value === undefined) return - if (props.yUnit === '%' && value <= 1) { + if (props.yUnit === '%') { value = (value * 100).toFixed(2) } if (props.yUnit === 'KB/s') { @@ -63,6 +63,17 @@ const initChart = () => { value = (value / 1024).toFixed(2) } } + if (props.yUnit === 'KB') { + if (value >= 1024 * 1024 * 1024) { + value = (value / 1024 / 1024 / 1024).toFixed(2); + yUnit = 'GB' + } else if (value >= 1024 * 1024) { + value = (value / 1024 / 1024).toFixed(2); + yUnit = 'MB' + } else { + value = (value / 1024).toFixed(2) + } + } str += `

@@ -110,7 +121,7 @@ const initChart = () => { axisLabel: { formatter: function (value: any) { let yUnit = props.yUnit; - if (props.yUnit === '%' && value <= 1) { + if (props.yUnit === '%') { value = (value * 100).toFixed(1) } if (props.yUnit === 'KB/s') { @@ -124,6 +135,17 @@ const initChart = () => { value = (value / 1024).toFixed(2) } } + if (props.yUnit === 'KB') { + if (value >= 1024 * 1024 * 1024) { + value = (value / 1024 / 1024 / 1024).toFixed(2); + yUnit = 'GB' + } else if (value >= 1024 * 1024) { + value = (value / 1024 / 1024).toFixed(2); + yUnit = 'MB' + } else { + value = (value / 1024).toFixed(2) + } + } return value + yUnit } } diff --git a/src/views/monitor-warn/cluster-status/components/container-health.vue b/src/views/monitor-warn/cluster-status/components/container-health.vue index a5f1d5ca7ef7ee15dbf8ef3bef9c0b44df63ce93..a54b85a2451d23dc7f68644a5a61ef1cf9b6bc55 100644 --- a/src/views/monitor-warn/cluster-status/components/container-health.vue +++ b/src/views/monitor-warn/cluster-status/components/container-health.vue @@ -17,25 +17,25 @@
- + - + - + - + - + - + - - + +
diff --git a/src/views/monitor-warn/cluster-status/components/physical-resources.vue b/src/views/monitor-warn/cluster-status/components/physical-resources.vue index 1a2d2c3b32edfe217612dec37f78ef9fff1bfe35..4e9730175648139f019867f0420f223f04a3bdeb 100644 --- a/src/views/monitor-warn/cluster-status/components/physical-resources.vue +++ b/src/views/monitor-warn/cluster-status/components/physical-resources.vue @@ -24,7 +24,7 @@ - + diff --git a/src/views/monitor-warn/node-health/components/container-health.vue b/src/views/monitor-warn/node-health/components/container-health.vue index 50e81072c6ec9a788cf48226a7f7ba71f66d835c..1cfa759cd67e0e40a51a89ef87797b6726158f19 100644 --- a/src/views/monitor-warn/node-health/components/container-health.vue +++ b/src/views/monitor-warn/node-health/components/container-health.vue @@ -139,7 +139,14 @@ const getContainerList = () => { res.data.forEach(({ metric_name, data }: any) => { if (metric_name === 'node_container_status') { for (let i = 0; i < data.result.length; i++) { - const container = {} + const container = { + name: '', + status: '', + cpuUsage: 0, + memoryUsage: 0, + outbound: 0, + inbound: 0, + } const containerID = data.result[i].metric.container res.data.forEach(({ metric_name, data }: any) => { const resultArray = data.result @@ -150,7 +157,7 @@ const getContainerList = () => { } }) } - if (metric_name === 'node_container_outbound_traffic') { + if (resultArray && metric_name === 'node_container_outbound_traffic') { resultArray.forEach(({ metric, value }: any) => { if (metric.container === containerID) { container.outbound = value[1] @@ -160,7 +167,7 @@ const getContainerList = () => { container.outbound = 0 } } - if (metric_name === 'node_container_inbound_traffic') { + if (resultArray && metric_name === 'node_container_inbound_traffic') { resultArray.forEach(({ metric, value }: any) => { if (metric.container === containerID) { container.inbound = value[1] @@ -207,14 +214,14 @@ const getUsed = computed(() => (type: string, used: any) => { return (used / Math.pow(1024, 1)).toFixed(1) + ' KB'; } if (type === 'inbound') { - if (used > 1024 * 1024) return (used / Math.pow(1024, 2)).toFixed(1) + ' MB/s'; - if (used > 1024 * 1024 * 1024) return (used / Math.pow(1024, 3)).toFixed(1) + ' GB/s'; - return (used / Math.pow(1024, 1)).toFixed(1) + ' KB/s'; + if (used > 1024 * 1024) return (used / Math.pow(1024, 2)).toFixed(1) + ' MB'; + if (used > 1024 * 1024 * 1024) return (used / Math.pow(1024, 3)).toFixed(1) + ' GB'; + return (used / Math.pow(1024, 1)).toFixed(1) + ' KB'; } if (type === 'outbound') { - if (used > 1024 * 1024) return (used / Math.pow(1024, 2)).toFixed(1) + ' MB/s'; - if (used > 1024 * 1024 * 1024) return (used / Math.pow(1024, 3)).toFixed(1) + ' GB/s'; - return (used / Math.pow(1024, 1)).toFixed(1) + ' KB/s'; + if (used > 1024 * 1024) return (used / Math.pow(1024, 2)).toFixed(1) + ' MB'; + if (used > 1024 * 1024 * 1024) return (used / Math.pow(1024, 3)).toFixed(1) + ' GB'; + return (used / Math.pow(1024, 1)).toFixed(1) + ' KB'; } }) diff --git a/src/views/monitor-warn/node-health/components/physical-resources.vue b/src/views/monitor-warn/node-health/components/physical-resources.vue index 60a017b62b7b85d7ac97e9e58cdb3da1fd765bee..da18fdbe52e451c3cb1f5502d3cbb97dc49b8bb3 100644 --- a/src/views/monitor-warn/node-health/components/physical-resources.vue +++ b/src/views/monitor-warn/node-health/components/physical-resources.vue @@ -21,7 +21,7 @@ - + diff --git a/src/views/rule-management/rule-view/components/ruleDialog.vue b/src/views/rule-management/rule-view/components/ruleDialog.vue index e5cbfae8de67f8a10055e11a50f12089604f0101..33ecba050c97cb10440d5a2ad49743af1607563f 100644 --- a/src/views/rule-management/rule-view/components/ruleDialog.vue +++ b/src/views/rule-management/rule-view/components/ruleDialog.vue @@ -185,7 +185,7 @@ const validateExpression = (rule: any, value: any, callback: any) => { if (value === '' || value === null) { return callback(new Error('请输入规则表达式')); } - var reg = /^[^`@#$%^&*?]+$/; + var reg = /^[^`@#$%&?]+$/; if (!reg.test(value)) { return callback(new Error('规则表达式中不可包含特殊字符')); }