From 925f5cf937276a2167fb49fe2f4aeccf34aabb55 Mon Sep 17 00:00:00 2001 From: renpy Date: Fri, 18 Aug 2023 16:05:45 +0800 Subject: [PATCH] =?UTF-8?q?server=20=E6=A8=A1=E5=9D=97=20=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E7=BB=84=E4=BB=B6=E4=B8=8E=E6=97=B6=E9=97=B4=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=8E=A7=E4=BB=B6=E6=B7=BB=E5=8A=A0=E8=81=94=E5=8A=A8?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serverMonitor/instances/cpu.vue | 23 +++++++++++----- .../serverMonitor/instances/monitor.vue | 26 ++++++++++++++----- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/views/abnormalAlarm/serverMonitor/instances/cpu.vue b/src/views/abnormalAlarm/serverMonitor/instances/cpu.vue index d427ff0..f3ef1bd 100644 --- a/src/views/abnormalAlarm/serverMonitor/instances/cpu.vue +++ b/src/views/abnormalAlarm/serverMonitor/instances/cpu.vue @@ -31,7 +31,7 @@ @@ -152,15 +152,16 @@ export default { currLabel:"", queryParams: { server: undefined, - timer: "1h", + timer: 1, startDate: dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss'), endDate: dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss') }, serverOptions: [], timerOptions: [ - {label: "1Hours",value: "1h"}, - {label: "2Hours",value: "2h"}, - {label: "3Hours",value: "3h"}, + {label: "1Hours",value: 1}, + {label: "2Hours",value: 2}, + {label: "3Hours",value: 3}, + {label: "user-defined",value: 0}, ], option1:{}, option2:{}, @@ -179,6 +180,9 @@ export default { modalTitle: "", } }, + created() { + this.getBeforeHours(1) + }, mounted() { this.getServerList() this.$nextTick(() => { @@ -191,6 +195,12 @@ export default { }) }, methods: { + getBeforeHours(num) { + let currentTime = moment() + let oneHourAgo = moment().subtract(num, 'hours'); + this.queryParams.startDate = oneHourAgo.format('YYYY-MM-DD HH:mm:ss') + this.queryParams.endDate = currentTime.format('YYYY-MM-DD HH:mm:ss') + }, createAlertRules() { this.visible_rule = true }, @@ -249,9 +259,10 @@ export default { this.currLabel = val.label }, onTimeChange(val) { - console.log(val); + this.getBeforeHours(val) }, onRangeDateChange(date, dateString) { + this.queryParams.timer = 0 this.queryParams.startDate = dateString[0] this.queryParams.endDate = dateString[1] }, diff --git a/src/views/abnormalAlarm/serverMonitor/instances/monitor.vue b/src/views/abnormalAlarm/serverMonitor/instances/monitor.vue index 6ba8047..4e6e641 100644 --- a/src/views/abnormalAlarm/serverMonitor/instances/monitor.vue +++ b/src/views/abnormalAlarm/serverMonitor/instances/monitor.vue @@ -31,7 +31,7 @@ @@ -183,15 +183,16 @@ export default { currLabel:"", queryParams: { server: undefined, - timer: "1h", - startDate: dateFormat(new Date(), 'yyyy-MM-dd'), - endDate: dateFormat(new Date(), 'yyyy-MM-dd') + timer: 1, + startDate: dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss'), + endDate: dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss') }, serverOptions: [], timerOptions: [ - {label: "1Hours",value: "1h"}, - {label: "2Hours",value: "2h"}, - {label: "3Hours",value: "3h"}, + {label: "1Hours",value: 1}, + {label: "2Hours",value: 2}, + {label: "3Hours",value: 3}, + {label: "user-defined",value: 0}, ], data1: [ { @@ -280,10 +281,19 @@ export default { myLine: null } }, + created() { + this.getBeforeHours(1) + }, mounted() { this.getServerList() }, methods: { + getBeforeHours(num) { + let currentTime = moment() + let oneHourAgo = moment().subtract(num, 'hours'); + this.queryParams.startDate = oneHourAgo.format('YYYY-MM-DD HH:mm:ss') + this.queryParams.endDate = currentTime.format('YYYY-MM-DD HH:mm:ss') + }, createAlertRules() { this.visible_rule = true }, @@ -343,8 +353,10 @@ export default { }, onTimeChange(val) { console.log(val); + this.getBeforeHours(val) }, onRangeDateChange(date, dateString) { + this.queryParams.timer = 0 this.queryParams.startDate = dateString[0] this.queryParams.endDate = dateString[1] },