NEZ-917 fix: 解决时区、log-chart有时不能显示的问题

This commit is contained in:
chenjinsong
2021-08-24 18:33:32 +08:00
parent d54d2abe03
commit c0728a5f5a
3 changed files with 8 additions and 90 deletions

View File

@@ -63,7 +63,7 @@
</div>
<div class="profile-left__bottom-title">
<div>{{$t('profile.lastLoginTime')}}</div>
<div>{{userList.lastLoginTime}}</div>
<div>{{utcTimeToTimezoneStr(userList.lastLoginTime)}}</div>
</div>
</div>
</div>

View File

@@ -373,89 +373,6 @@ export default {
collapseValue: ['1', '2'],
showTab: ['1', '2'],
logData: []
/*logData: [JSON.parse(`{
"result": [{
"labels": {
"asset": "44.53",
"endpoint": "192.168.44.53",
"filename": "/opt/cn/cn-web/logs/cn-web.log",
"job": "cn-log",
"project": "cn"
},
"level": "debug",
"message": "2021-07-23 03:39:01.842 [quartzScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers",
"timestamp": 1627545412000000000,
"uuid": "1jqsjdjdf"
}, {
"labels": {
"asset": "44.53",
"endpoint": "192.168.44.53",
"filename": "/opt/cn/cn-web/logs/cn-web.log",
"job": "cn-log",
"project": "cn"
},
"level": "debug",
"message": "2021-07-23 03:39:01.842 [quartzScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers",
"timestamp": 1627545412000000000,
"uuid": "1jqsjdjdf"
}, {
"labels": {
"asset": "44.53",
"endpoint": "192.168.44.53",
"filename": "/opt/cn/cn-web/logs/cn-web.log",
"job": "cn-log",
"project": "cn"
},
"level": "debug",
"message": "2021-07-22 03:39:01.842 [quartzScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggersDEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggersDEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggersDEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggersDEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers",
"timestamp": 1627543512000000000,
"uuid": "1jqsjdjdg"
}, {
"labels": {
"asset": "44.53",
"endpoint": "192.168.44.53",
"filename": "/opt/cn/cn-web/logs/cn-web.log",
"job": "cn-log",
"project": "cn"
},
"level": "debug",
"message": "2021-07-21 03:39:01.842 [quartzScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers",
"timestamp": 1627542512000000000,
"uuid": "1jqsjdjdh"
}, {
"labels": {
"asset": "44.53",
"endpoint": "192.168.44.53",
"filename": "/opt/cn/cn-web/logs/cn-web.log",
"job": "cn-log",
"project": "cn"
},
"level": "debug",
"message": "2021-07-20 03:39:01.842 [quartzScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers",
"timestamp": 1627502512000000000,
"uuid": "1jqsjdjdi"
}
],
"resultType": "streamsFormat",
"series": [
{
"name": "debug",
"data": [[1588889221, 123], [1588889222, 10]]
}, {
"name": "info",
"data": [[1588889221, 123], [1588889222, 10]]
}, {
"name": "warn",
"data": [[1588889221, 123], [1588889222, 10]]
}, {
"name": "error",
"data": [[1588889221, 123], [1588889222, 10]]
}, {
"name": "unknown",
"data": [[1588889221, 123], [1588889222, 10]]
}
]
}`)]*/ // 日志数据
}
},
created () {
@@ -555,9 +472,9 @@ export default {
res = res.filter((r, i) => errorRowIndex.indexOf(i) === -1)
}
if (res.length > 0) {
this.logData = res.map(r => r.data)
const hasGraph = this.logData.some(d => d.resultType === 'matrix')
const hasLog = this.logData.some(d => d.resultType === 'streamsFormat')
const logData = res.map(r => r.data)
const hasGraph = logData.some(d => d.resultType === 'matrix')
const hasLog = logData.some(d => d.resultType === 'streamsFormat')
const graphTabIndex = this.showTab.indexOf('1')
if (hasGraph) {
if (graphTabIndex === -1) {
@@ -571,7 +488,7 @@ export default {
const logTabIndex = this.showTab.indexOf('2')
if (hasLog) {
if (logTabIndex === -1) {
this.showTab.push('1')
this.showTab.push('2')
}
} else {
if (logTabIndex > -1) {
@@ -580,6 +497,7 @@ export default {
}
this.$nextTick(() => {
hasGraph && this.loadLogGraph()
this.logData = logData
})
}
}).catch(e => {

View File

@@ -61,7 +61,7 @@
prop="date"
width="140"
>
<template slot-scope="{ row }">{{row.date}}</template>
<template slot-scope="{ row }">{{utcTimeToTimezoneStr(row.date)}}</template>
</el-table-column>
<el-table-column
prop="message"
@@ -225,7 +225,7 @@ export default {
rotate: 0,
fontSize: 13 * window.devicePixelRatio,
formatter (value) {
return vm.$unixTimeParseToString(vm.toMillisecondTime(value) / 1000, 'hh:mm')
return vm.utcTimeToTimezoneStr(vm.$unixTimeParseToString(vm.toMillisecondTime(value) / 1000), 'hh:mm')
}
},
boundaryGap: [0, '1%']