CN-1461 提取界面各功能的默认时间条件至config.js

This commit is contained in:
hyx
2023-11-13 17:23:32 +08:00
parent 051aeadbca
commit 38368a6cb8
24 changed files with 291 additions and 139 deletions

View File

@@ -216,7 +216,7 @@ import Chart from '@/views/charts/Chart'
import _ from 'lodash'
import axios from 'axios'
import relatedServer from '@/mixins/relatedServer'
import { dateFormatByAppearance, getMillisecond, getSecond } from '@/utils/date-util'
import { dateFormatByAppearance, getMillisecond, getSecond, getNowTime } from '@/utils/date-util'
import Loading from '@/components/common/Loading'
import { ref } from 'vue'
@@ -320,11 +320,21 @@ export default {
methods: {
getMillisecond,
dateFormatByAppearance,
getQueryParams () {
return {
startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime),
resource: this.entity.entityValue
getQueryParams (dateRangeValue) {
if (dateRangeValue) {
// range取 config.js 中配置的值
const { startTime, endTime } = getNowTime(dateRangeValue)
return {
startTime: getSecond(startTime),
endTime: getSecond(endTime),
resource: this.entity.entityValue
}
} else {
return {
startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime),
resource: this.entity.entityValue
}
}
},
getPerformanceQueryParams () {

View File

@@ -219,7 +219,7 @@ import Chart from '@/views/charts/Chart'
import _ from 'lodash'
import axios from 'axios'
import relatedServer from '@/mixins/relatedServer'
import { dateFormatByAppearance, getMillisecond, getSecond } from '@/utils/date-util'
import { dateFormatByAppearance, getMillisecond, getSecond, getNowTime } from '@/utils/date-util'
import Loading from '@/components/common/Loading'
import { ref } from 'vue'
@@ -324,11 +324,21 @@ export default {
methods: {
getMillisecond,
dateFormatByAppearance,
getQueryParams () {
return {
startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime),
resource: this.entity.entityValue
getQueryParams (dateRangeValue) {
if (dateRangeValue) {
// range取 config.js 中配置的值
const { startTime, endTime } = getNowTime(dateRangeValue)
return {
startTime: getSecond(startTime),
endTime: getSecond(endTime),
resource: this.entity.entityValue
}
} else {
return {
startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime),
resource: this.entity.entityValue
}
}
},
getPerformanceQueryParams () {

View File

@@ -251,7 +251,7 @@ import { valueToRangeValue } from '@/utils/unit-convert'
import Chart from '@/views/charts/Chart'
import _ from 'lodash'
import relatedServer from '@/mixins/relatedServer'
import { dateFormatByAppearance, getMillisecond, getSecond } from '@/utils/date-util'
import { dateFormatByAppearance, getMillisecond, getSecond, getNowTime } from '@/utils/date-util'
import Loading from '@/components/common/Loading'
import axios from 'axios'
@@ -404,11 +404,21 @@ export default {
methods: {
getMillisecond,
dateFormatByAppearance,
getQueryParams () {
return {
startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime),
resource: this.entity.entityValue
getQueryParams (dateRangeValue) {
if (dateRangeValue) {
// range取 config.js 中配置的值
const { startTime, endTime } = getNowTime(dateRangeValue)
return {
startTime: getSecond(startTime),
endTime: getSecond(endTime),
resource: this.entity.entityValue
}
} else {
return {
startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime),
resource: this.entity.entityValue
}
}
},
getPerformanceQueryParams () {

View File

@@ -121,7 +121,7 @@ export default {
this.sentChart = echarts.init(document.getElementById(`entityDetailSend${this.entityName}`))
this.receivedChart = echarts.init(document.getElementById(`entityDetailReceived${this.entityName}`))
this.loadingTraffic = true
axios.get(this.trafficUrl, { params: this.getQueryParams() }).then(response => {
axios.get(this.trafficUrl, { params: this.getQueryParams(DEFAULT_TIME_FILTER_RANGE.entity.trafficLine) }).then(response => {
if (response.status === 200 && response.data.data.result && response.data.data.result.length > 0) {
response.data.data.result.forEach(t => {
if (t.legend === 'rate') {
@@ -278,7 +278,7 @@ export default {
this.performanceScoreData = {}
this.scoreDataState = false
if (this.networkQuantityUrl) {
axios.get(this.networkQuantityUrl, { params: this.getQueryParams() }).then(response => {
axios.get(this.networkQuantityUrl, { params: this.getQueryParams(DEFAULT_TIME_FILTER_RANGE.entity.trafficLine) }).then(response => {
if (response.status === 200) {
this.performanceScoreData = {
establishLatencyMs: response.data.data.result.establishLatencyMsAvg || null,
@@ -347,7 +347,7 @@ export default {
queryEntityDetailPerformance () {
this.loadingAlert = true
axios.get(this.performanceUrl, { params: this.getQueryParams() }).then(response => {
axios.get(this.performanceUrl, { params: this.getQueryParams(DEFAULT_TIME_FILTER_RANGE.entity.performanceEvent) }).then(response => {
if (response.status === 200) {
this.entityData.performanceNum = response.data.data.result.length
this.performanceData = response.data.data.result
@@ -359,7 +359,7 @@ export default {
queryEntityDetailSecurity () {
this.loadingSecurityEvents = true
axios.get(this.securityUrl, { params: this.getQueryParams() }).then(response => {
axios.get(this.securityUrl, { params: this.getQueryParams(DEFAULT_TIME_FILTER_RANGE.entity.securityEvent) }).then(response => {
if (response.status === 200) {
this.entityData.securityNum = response.data.data.result.length
this.securityData = response.data.data.result
@@ -436,9 +436,9 @@ export default {
queryEntityDetail () {
this.queryEntityDetailTraffic()
// this.queryEntityDetailPerformance()
// this.queryEntityDetailSecurity()
this.queryEntityDetailSecurity()
this.queryEntityDetailNetworkQuantity()
/*if (this.entity.entityType === 'ip') {
/* if (this.entity.entityType === 'ip') {
if (!this.entityData.dnsServerRole) {
this.loadingDns = true
}
@@ -449,7 +449,7 @@ export default {
this.queryDnsServerInfoRate()
}, 200)
})
}*/
} */
},
resize () {

View File

@@ -124,7 +124,8 @@ export default {
path: '/entity/detail',
query: {
entityType: this.entityData.entityType,
entityName: this.entityData.entityValue
entityName: this.entityData.entityValue,
range: this.timeFilter.dateRangeValue
}
})
window.open(href, '_blank')
@@ -139,16 +140,27 @@ export default {
})
window.open(href, '_blank')
},
getQueryParams () {
return {
startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime),
resource: this.entityType
getQueryParams (dateRangeValue) {
if (dateRangeValue) {
// range取 config.js 中配置的值
const endTime = window.$dayJs.tz().valueOf()
const startTime = endTime - dateRangeValue * 60 * 1000
return {
startTime: getSecond(startTime),
endTime: getSecond(endTime),
resource: this.entityType
}
} else {
return {
startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime),
resource: this.entityType
}
}
},
queryEntityDetailTraffic () {
this.loading = true
axios.get(this.trafficUrl, { params: this.getQueryParams() }).then(response => {
axios.get(this.trafficUrl, { params: this.getQueryParams(DEFAULT_TIME_FILTER_RANGE.entity.trafficLine) }).then(response => {
if (response.status === 200 && response.data.data.result && response.data.data.result.length > 0) {
let sentSeries
let receivedSeries
@@ -262,7 +274,7 @@ export default {
this.loadingNetworkQuality = true
this.performanceScoreData = {}
this.scoreDataState = false
axios.get(this.scoreUrl, { params: this.getQueryParams() }).then(response => {
axios.get(this.scoreUrl, { params: this.getQueryParams(DEFAULT_TIME_FILTER_RANGE.entity.trafficLine) }).then(response => {
if (response.status === 200) {
this.performanceScoreData = {
establishLatencyMs: _.get(response, 'data.data.result.establishLatencyMsAvg', null),