diff --git a/src/views/abnormalAlarm/serverMonitor/instances/cpu.vue b/src/views/abnormalAlarm/serverMonitor/instances/cpu.vue index 7773848..d427ff0 100644 --- a/src/views/abnormalAlarm/serverMonitor/instances/cpu.vue +++ b/src/views/abnormalAlarm/serverMonitor/instances/cpu.vue @@ -9,6 +9,7 @@ placeholder="select..." :filter-option="filterOption" show-arrow + labelInValue :options="serverOptions" @change="onServerChange" > @@ -36,7 +37,7 @@
- Create Alert Rules + Create Alert Rules
@@ -115,12 +116,20 @@
+ @@ -129,18 +138,23 @@ import moment from 'moment'; import * as echarts from 'echarts' import dateFormat from '@/components/jeecg/JEasyCron/format-date' import BoxTitle from '../../components/boxTitle.vue'; +import CreateRules from './createRules.vue'; import { getAction, postAction, httpAction, deleteAction } from '@/api/manage' export default { components: { BoxTitle, + CreateRules }, data() { return { + currId:"", + visible_rule: false, + currLabel:"", queryParams: { server: undefined, timer: "1h", - startDate: dateFormat(new Date(), 'yyyy-MM-dd'), - endDate: dateFormat(new Date(), 'yyyy-MM-dd') + startDate: dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss'), + endDate: dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss') }, serverOptions: [], timerOptions: [ @@ -165,7 +179,8 @@ export default { modalTitle: "", } }, - mounted () { + mounted() { + this.getServerList() this.$nextTick(() => { setTimeout(() => { this.drawChart1() @@ -176,6 +191,22 @@ export default { }) }, methods: { + createAlertRules() { + this.visible_rule = true + }, + handleCancel() { + this.visible_rule = false + }, + handleOk(params) { + postAction("/alarmRule/create", params).then(res => { + if (res.success) { + this.visible_rule = false + this.$message.success("success") + } else { + this.$message.warning("This operation fails. Contact your system administrator") + } + }) + }, moment, filterOption(input, option) { return ( @@ -191,14 +222,31 @@ export default { value: item.sourceId } }) - this.queryParams.server = this.$route.query.serverId || res.result[0].sourceId + this.currId = this.$route.query.serverId || res.result[0].sourceId + if (this.$route.query.serverId) { + let currOption = this.serverOptions.find(item => { + return item.value === this.$route.query.serverId + }) + this.currLabel = currOption.label + this.queryParams.server = { + key: this.$route.query.serverId, + label:this.currLabel + } + } else { + this.currLabel = res.result[0].sourceName + this.queryParams.server = { + key: res.result[0].sourceId, + label:this.currLabel + } + } } else { this.$message.warning("This operation fails. Contact your system administrator") } }) }, onServerChange(val) { - console.log(val); + this.currId = val.key + this.currLabel = val.label }, onTimeChange(val) { console.log(val); diff --git a/src/views/abnormalAlarm/serverMonitor/instances/createRules.vue b/src/views/abnormalAlarm/serverMonitor/instances/createRules.vue new file mode 100644 index 0000000..9feda96 --- /dev/null +++ b/src/views/abnormalAlarm/serverMonitor/instances/createRules.vue @@ -0,0 +1,351 @@ + + + + + \ No newline at end of file diff --git a/src/views/abnormalAlarm/serverMonitor/instances/monitor.vue b/src/views/abnormalAlarm/serverMonitor/instances/monitor.vue index ca2485c..6ba8047 100644 --- a/src/views/abnormalAlarm/serverMonitor/instances/monitor.vue +++ b/src/views/abnormalAlarm/serverMonitor/instances/monitor.vue @@ -9,6 +9,7 @@ placeholder="select..." :filter-option="filterOption" show-arrow + labelInValue :options="serverOptions" @change="onServerChange" > @@ -36,7 +37,7 @@
- Create Alert Rules + Create Alert Rules
@@ -144,12 +145,20 @@
+ @@ -160,13 +169,18 @@ import dateFormat from '@/components/jeecg/JEasyCron/format-date' import BoxTitle from '../../components/boxTitle.vue'; import { getAction, postAction, httpAction, deleteAction } from '@/api/manage' import LineChart from './lineChart.vue'; +import CreateRules from './createRules.vue'; export default { components: { BoxTitle, - LineChart + LineChart, + CreateRules }, data() { return { + currId:"", + visible_rule: false, + currLabel:"", queryParams: { server: undefined, timer: "1h", @@ -266,14 +280,26 @@ export default { myLine: null } }, - mounted () { - this.$nextTick(() => { - setTimeout(() => { - // this.drawLine() - },0) - }) + mounted() { + this.getServerList() }, methods: { + createAlertRules() { + this.visible_rule = true + }, + handleCancel() { + this.visible_rule = false + }, + handleOk(params) { + postAction("/alarmRule/create", params).then(res => { + if (res.success) { + this.visible_rule = false + this.$message.success("success") + } else { + this.$message.warning("This operation fails. Contact your system administrator") + } + }) + }, moment, filterOption(input, option) { return ( @@ -289,14 +315,31 @@ export default { value: item.sourceId } }) - this.queryParams.server = this.$route.query.serverId || res.result[0].sourceId + this.currId = this.$route.query.serverId || res.result[0].sourceId + if (this.$route.query.serverId) { + let currOption = this.serverOptions.find(item => { + return item.value === this.$route.query.serverId + }) + this.currLabel = currOption.label + this.queryParams.server = { + key: this.$route.query.serverId, + label:this.currLabel + } + } else { + this.currLabel = res.result[0].sourceName + this.queryParams.server = { + key: res.result[0].sourceId, + label:this.currLabel + } + } } else { this.$message.warning("This operation fails. Contact your system administrator") } }) }, onServerChange(val) { - console.log(val); + this.currId = val.key + this.currLabel = val.label }, onTimeChange(val) { console.log(val);