fix:explore 去除时间锁定 以及 dashboard 时间锁定优化

This commit is contained in:
zhangyu
2023-07-20 17:03:55 +08:00
parent cf53f4f7d3
commit 7ebddf4905
4 changed files with 57 additions and 13 deletions

View File

@@ -868,7 +868,7 @@ export default {
})
},
setTimePickerRange () {
if (!this.timePickerRange.nowTimeType) {
if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) {
this.setDefaultTimeRange()
}
const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType

View File

@@ -30,7 +30,7 @@
</el-select>
<button slot="suffix" class="search-icon-btn"><i class="el-icon-search" @click="dateChange()"></i></button>
</el-input>
<pick-time id="explore" ref="pickTime" v-model="filterTime" :refresh-data-func="getData" :sign="sign" :use-chart-unit="false" :use-refresh="false">
<pick-time id="explore" ref="pickTime" v-model="filterTime" :refresh-data-func="getData" :show-locked="true" :sign="sign" :use-chart-unit="false" :use-refresh="false">
<template slot="added-text">{{$t('overall.query')}}</template>
</pick-time>
</template>
@@ -73,7 +73,16 @@ export default {
matchContent: '',
loading: true,
endpointLoading: false,
limit: 100
limit: 100,
nowTimeType: {}
}
},
computed: {
timePickerLocked () {
return this.$store.getters.getTimePickerLocked
},
timePickerRange () {
return this.$store.getters.getTimePickerRange
}
},
methods: {
@@ -119,8 +128,45 @@ export default {
this.$refs.pickTime && this.$refs.pickTime.$refs.timePicker.refresh()
},
getData () {
const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
this.setSearchTime(nowTimeType.type, nowTimeType.value)
this.$store.dispatch('dispatchTimePickerRange', {
time: this.searchTime,
nowTimeType: this.nowTimeType
})
this.queryLogData()
},
setTimePickerRange () {
if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) {
return
}
const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType
this.filterTime = this.timePickerRange.time
this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.filterTime)
this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType)
},
setSearchTime (type, val) { // 设置searchTime
if (type === 'minute') {
const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val))
const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
this.$set(this.filterTime, 0, startTime)
this.$set(this.filterTime, 1, endTime)
this.$set(this.filterTime, 2, val + 'm')
} else if (type === 'hour') {
const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val))
const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
this.$set(this.filterTime, 0, startTime)
this.$set(this.filterTime, 1, endTime)
this.$set(this.filterTime, 2, val + 'h')
} else if (type === 'date') {
const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val))
const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
this.$set(this.filterTime, 0, startTime)
this.$set(this.filterTime, 1, endTime)
this.$set(this.filterTime, 2, val + 'd')
}
this.$refs.pickTime.$refs.timePicker.searchTime = this.filterTime
},
queryLogData (limit) { // log的chart和table是一个请求
this.loading = true
if (limit) {
@@ -162,6 +208,7 @@ export default {
} else if (this.from === fromRoute.asset) {
this.expressions = [`{asset="${this.obj.name}"}`]
}
this.setTimePickerRange()
this.$nextTick(() => {
this.queryLogData()
})

View File

@@ -1157,7 +1157,8 @@ export default {
})
},
setTimePickerRange () {
if (!this.timePickerRange.nowTimeType) {
if (this.$route.query.searchTime) return
if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) {
this.setDefaultTimeRange()
}
const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType
@@ -1188,6 +1189,10 @@ export default {
mode: { target: this, propertyName: 'mode', type: 'string' }
}
this.initQueryFromPath(searchKeys)
this.$store.dispatch('dispatchTimePickerRange', {
time: this.searchTime,
nowTimeType: this.nowTimeType
})
this.showPanel.id = this.dashboardId
this.filter.dashboardId = this.dashboardId
// 设置查看模式

View File

@@ -28,7 +28,7 @@
<div class="top-tool-right">
<button v-if="!closable" class="top-tool-btn top-tool-btn--text margin-r-10" style="cursor: pointer;" type="button" @click="split">
{{$t('overall.split')}}</button>
<pick-time id="explore" ref="pickTime" :show-locked="true" v-model="filterTime" :class="{'margin-r-10': showMetrics}" :refresh-data-func="expressionChange" @unitChange="chartUnitChange">
<pick-time id="explore" ref="pickTime" v-model="filterTime" :class="{'margin-r-10': showMetrics}" :refresh-data-func="expressionChange" @unitChange="chartUnitChange">
<!-- <template slot="added-text">{{$t('dashboard.metricPreview.runQuery')}}</template> -->
<template slot="added-text">{{$t('overall.query')}}</template>
</pick-time>
@@ -3563,7 +3563,6 @@ export default {
mounted () {
this.scrollbarWrap = this.$refs.exploreScrollbar
this.scrollbarWrap.addEventListener('scroll', this.onScroll)
this.setTimePickerRange()
this.initQueryFromPath()
},
beforeDestroy () {
@@ -3987,13 +3986,6 @@ export default {
}
},
expressionChange () {
const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
this.pageObj.pageNo = 1
this.setSearchTime(nowTimeType.type, nowTimeType.value)
this.$store.dispatch('dispatchTimePickerRange', {
time: this.searchTime,
nowTimeType: this.nowTimeType
})
if (this.expressions && this.expressions.length >= 1) {
if (this.showMetrics) {
this.queryTableData()