NEZ-3248 fix:Explore Logs 数据源模式下点击 分屏,请求异常

This commit is contained in:
zhangyu
2023-10-23 16:35:13 +08:00
parent 0c6448eba5
commit b7d44f5c78
5 changed files with 19 additions and 10 deletions

View File

@@ -83,6 +83,7 @@ export default {
momentTz (timestamp, fmt) { // moment 转化时间戳为str
const offset = localStorage.getItem('nz-sys-timezone')
const format = fmt || localStorage.getItem('nz-default-dateFormat')
console.log(timestamp, fmt, offset, localStorage.getItem('nz-default-dateFormat'), format)
return moment.tz(timestamp, offset).format(format)
},
momentStrToTimestamp (str, fmt) {

View File

@@ -60,7 +60,7 @@
{{scope.row.type ? scope.row.type.category : '-'}}
</div>
</template>
<span v-else-if="item.prop === 'production_date' || item.prop === 'expiration_date'">{{ scope.row[item.prop] ? momentTz(scope.row[item.prop]) : '-'}}</span>
<span v-else-if="item.prop === 'production_date' || item.prop === 'expiration_date'">{{ scope.row[item.prop] ? momentTz(scope.row[item.prop] * 1000) : '-'}}</span>
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
<span v-else>-</span>
</template>

View File

@@ -3887,7 +3887,7 @@ export default {
const requestArr = []
// 过滤掉state为0的元素
this.expressions.forEach((item, index) => {
if (item != '' && this.promqlKeys[index].state) {
if (item != '' && this.promqlKeys[index].state && item) {
requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(item) + '&start=' + this.$stringTimeParseToUnix(bus.formateTimeToTime(this.filterTime[0])) + '&end=' + this.$stringTimeParseToUnix(bus.formateTimeToTime(this.filterTime[1])) + '&limit=' + limit))
}
})
@@ -4369,7 +4369,8 @@ export default {
} else {
const promiseArr = []
this.expressions.forEach((item, index) => {
if (item != '' && this.promqlKeys[index].state) {
console.log(item)
if (item != '' && this.promqlKeys[index].state && item) {
promiseArr.push(this.$get('logs/loki/api/v1/format_query', { query: item }))
} else {
promiseArr.push('')
@@ -4384,6 +4385,7 @@ export default {
this.updatePath()
},
initQueryFromPath () {
console.log('initQueryFromPath')
const param = this.$route.query[this.position]
if (param) {
const data = JSON.parse(param)
@@ -4409,6 +4411,7 @@ export default {
this.promqlCount = data.queries.length
data.queries.forEach((item, index) => {
this.$set(this.expressions, index, item.expr)
console.log(item)
this.promqlKeys[index] = {
...item,
id: getUUID(),
@@ -4426,7 +4429,11 @@ export default {
const queries = this.expressions.map((item, index) => {
return {
expr: item,
state: this.promqlKeys[index].state
state: this.promqlKeys[index].state,
oldName: this.promqlKeys[index].oldName,
legend: this.promqlKeys[index].legend,
step: this.promqlKeys[index].step,
queryType: this.promqlKeys[index].queryType
}
})
const q = {

View File

@@ -421,13 +421,14 @@ export default {
})
this.expressionChange()
} else {
this.expressions.push(item.expression)
this.expressionName.push(item.name)
const expressionName = this.getExpressionName()
this.expressions.push(item.expression || item.expr || '')
this.expressionName.push(item.name || expressionName)
this.expressionsShow.push({
id: getUUID(),
show: true,
hideInput: true,
oldName: item.name,
oldName: item.name || expressionName,
error: '',
elementId: item.id,
legend: item.legend,

View File

@@ -380,7 +380,7 @@ export default {
this.myChart.clear()
this.myChart.setOption(option)
this.$nextTick(() => {
this.myChart.resize()
this.myChart?.resize()
})
/* 点击legend
* 1.当前如果是全高亮状态则全部置灰只留被点击的legend高亮
@@ -424,7 +424,7 @@ export default {
this.myChart.clear()
this.myChart.setOption(option)
this.$nextTick(() => {
this.myChart.resize()
this.myChart?.resize()
})
}
},
@@ -531,7 +531,7 @@ export default {
},
resizeChart () {
setTimeout(() => {
this.myChart.resize()
this.myChart?.resize()
})
},
aliasLegend (row) {