@@ -176,7 +188,7 @@ export default {
dialogText: '',
url: 'alert/message',
// 导出相关
- importBox: { show: false, title: this.$t('overall.importExcel'), type: 1, record: 'all', format: 1 },
+ importBox: { show: false, title: this.$t('overall.exportExcel'), type: 1, record: 'all', format: 1 },
deleteBox: { show: false, ids: '', remark: '', state: 2 },
// 详情相关
graphShow: false,
@@ -347,7 +359,9 @@ export default {
{ name: 'XLSX', value: 1 },
{ name: 'CSV', value: 2 },
{ name: 'JSON', value: 3 }
- ]
+ ],
+ errorContent: '',
+ isError: false
}
},
computed: {
@@ -445,16 +459,13 @@ export default {
})
},
messageDetail (row) {
+ console.log(row)
if (row.alertRule.type == 3) {
return
}
this.$get('/alert/rule/' + row.alertRule.id).then(res => {
this.currentMsg = { ...row, alertRule: { ...res.data } }
- if (row.alertRule.type !== 1) {
- this.graphShow = false
- } else {
- this.graphShow = true
- }
+ this.graphShow = true
this.$nextTick(() => {
this.searchTimeDialog = [bus.computeTimezoneTime(new Date().getTime() - 1 * 60 * 60 * 1000), bus.computeTimezoneTime(new Date().getTime())]
this.queryDate()
@@ -475,7 +486,7 @@ export default {
this.queryChartDate()
})
} else if (this.currentMsg.alertRule.type === 2) {
- this.queryLogData(1000)
+ this.queryLogData(100)
}
},
queryChartDate () {
@@ -497,8 +508,7 @@ export default {
if (this.$refs.messageChart) {
this.$refs.messageChart.startLoading()
const axiosArr = []
- const paramStr = JSON.stringify(this.promQueryParamConvert(this.currentMsg))
- axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + paramStr.substring(1, paramStr.length - 1) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step))
+ axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels)))))
this.legend = []
this.chartDatas = []
axios.all(axiosArr).then(res => {
@@ -571,6 +581,17 @@ export default {
} else {
this.$message.error(response.data.error)
}
+ } else {
+ this.$refs.messageChart.endLoading()
+ this.chartLoading = false
+ this.isError = true
+ if (response.msg) {
+ this.errorContent = response.msg
+ } else if (response.error) {
+ this.errorContent = response.error
+ } else {
+ this.errorContent = response
+ }
}
})
this.$nextTick(() => {
@@ -630,12 +651,12 @@ export default {
},
queryLogData (limit) { // log的chart和table是一个请求
if (!limit) {
- limit = 1000
+ limit = 100
}
const start = this.searchTimeDialog[0] ? this.searchTimeDialog[0] : bus.computeTimezoneTime(new Date().getTime() - 1 * 60 * 60 * 1000)
const end = this.searchTimeDialog[1] ? this.searchTimeDialog[1] : bus.computeTimezoneTime(new Date().getTime())
this.expressions = [this.currentMsg.alertRule.expr]
- this.$get('/logs/loki/api/v1/query_range?format=1&query=' + this.currentMsg.alertRule.expr + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit).then(res => {
+ this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels)))).then(res => {
this.chartLoading = false
const logData = [res.data]
this.resultType = res.data.resultType
@@ -855,6 +876,7 @@ export default {
this.getTableData()
clearTimeout(this.timer)
this.timer = ''
+ this.scrollbarToTop()
}, 1000)
} else {
clearTimeout(this.timer)
@@ -862,12 +884,24 @@ export default {
this.getTableData()
clearTimeout(this.timer)
this.timer = ''
+ this.scrollbarToTop()
}, 1000)
}
},
+ scrollbarToTop () {
+ this.$nextTick(() => {
+ const wraps = document.querySelectorAll('.el-table__body-wrapper')
+ wraps.forEach(wrap => {
+ if (wrap) {
+ wrap.scrollTop = 0
+ wrap.scrollLeft = 0
+ }
+ })
+ })
+ },
promQueryParamConvert (alert) {
const obj = { ...alert }
- let r = '(' + obj.alertRule.expr.replace(/\"/g, '\'') + ')'
+ let r = '(' + obj.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, '') + ')'
let intoLabels = false
obj.labels = JSON.parse(obj.labels)
if (Object.keys(obj.labels).length > 0) {
@@ -898,6 +932,14 @@ export default {
}
return r
},
+ promQueryParamLabels (labels) {
+ const obj = JSON.parse(labels)
+ const filterArr = ['alertname', 'severity_id', 'severity', 'rule_type']
+ filterArr.forEach(key => {
+ delete obj[key]
+ })
+ return JSON.stringify(obj)
+ },
// asset弹框控制
tabControl (data) {
if (data === 'close') {
@@ -929,8 +971,21 @@ export default {
const searchLabel = Object.assign({}, this.searchLabel)
searchLabel.format = this.importBox.format
delete searchLabel.statistics
+ if (this.searchCheckBox) {
+ Object.keys(this.searchCheckBox).forEach(key => {
+ if (searchLabel[key]) {
+ if (searchLabel[key].prototype.toString.call(val) === '[object Object]') {
+ Object.assign(searchLabel[key], this.searchCheckBox[key])
+ } else if (searchLabel[key].prototype.toString.call(val) === '[object Array]') {
+ searchLabel[key].concat(this.searchCheckBox[key])
+ }
+ } else {
+ searchLabel[key] = this.searchCheckBox[key]
+ }
+ })
+ }
this.$set(searchLabel, 'language', localStorage.getItem('nz-language') ? localStorage.getItem('nz-language') : 'en')
- this.exportExcel({ ...searchLabel, state: this.state })
+ this.exportExcel('alert/message/export', { ...searchLabel, state: this.state })
this.closeDialog()
},
exportAll () {
@@ -938,8 +993,21 @@ export default {
temp.pageSize = -1
delete temp.statistics
temp.format = this.importBox.format
+ if (this.searchCheckBox) {
+ Object.keys(this.searchCheckBox).forEach(key => {
+ if (temp[key]) {
+ if (temp[key].prototype.toString.call(val) === '[object Object]') {
+ Object.assign(temp[key], this.searchCheckBox[key])
+ } else if (temp[key].prototype.toString.call(val) === '[object Array]') {
+ temp[key].concat(this.searchCheckBox[key])
+ }
+ } else {
+ temp[key] = this.searchCheckBox[key]
+ }
+ })
+ }
this.$set(temp, 'language', localStorage.getItem('nz-language') ? localStorage.getItem('nz-language') : 'en')
- this.exportExcel({ ...temp, state: this.state })
+ this.exportExcel('alert/message/export', { ...temp, state: this.state })
this.closeDialog()
},
getTimeString () {
@@ -956,7 +1024,7 @@ export default {
formatNum (num) {
return num > 9 ? num : '0' + num
},
- exportExcel (params) {
+ exportExcel (url, params, fileName) {
for (const item in params) {
if (params[item]) {
if (item === 'alertMessageState') {
@@ -1058,16 +1126,16 @@ export default {
const params = JSON.parse(JSON.stringify(this.searchLabel))
params.format = this.importBox.format
delete params.statistics
- if (this.params2) {
- Object.keys(this.params2).forEach(key => {
+ if (this.searchCheckBox) {
+ Object.keys(this.searchCheckBox).forEach(key => {
if (params[key]) {
if (params[key].prototype.toString.call(val) === '[object Object]') {
- Object.assign(params[key], this.params2[key])
+ Object.assign(params[key], this.searchCheckBox[key])
} else if (params[key].prototype.toString.call(val) === '[object Array]') {
- params[key].concat(this.params2[key])
+ params[key].concat(this.searchCheckBox[key])
}
} else {
- params[key] = this.params2[key]
+ params[key] = this.searchCheckBox[key]
}
})
}
diff --git a/nezha-fronted/src/components/page/alert/alertRule.vue b/nezha-fronted/src/components/page/alert/alertRule.vue
index 8804ddbdc..46be3b49d 100644
--- a/nezha-fronted/src/components/page/alert/alertRule.vue
+++ b/nezha-fronted/src/components/page/alert/alertRule.vue
@@ -308,6 +308,9 @@ export default {
schedDays: response.data.schedDays ? response.data.schedDays.split(',').map(item => Number(item)) : [],
receiverShow: response.data.receiver ? response.data.receiver.split(',').map(item => Number(item)) : []
}
+ if (this.object.inr == 0) {
+ this.object.inr = undefined
+ }
if (copyFlag) {
this.object.id = ''
this.object.name = this.object.name + '-copy'
diff --git a/nezha-fronted/src/components/page/asset/asset.vue b/nezha-fronted/src/components/page/asset/asset.vue
index 6429abadc..8c14c05bf 100644
--- a/nezha-fronted/src/components/page/asset/asset.vue
+++ b/nezha-fronted/src/components/page/asset/asset.vue
@@ -517,6 +517,7 @@ export default {
this.getTableData()
clearTimeout(this.timer)
this.timer = ''
+ this.scrollbarToTop()
}, 1000)
} else {
clearTimeout(this.timer)
@@ -524,9 +525,21 @@ export default {
this.getTableData()
clearTimeout(this.timer)
this.timer = ''
+ this.scrollbarToTop()
}, 1000)
}
},
+ scrollbarToTop () {
+ this.$nextTick(() => {
+ const wraps = document.querySelectorAll('.el-table__body-wrapper')
+ wraps.forEach(wrap => {
+ if (wrap) {
+ wrap.scrollTop = 0
+ wrap.scrollLeft = 0
+ }
+ })
+ })
+ },
getDcData () {
return new Promise(resolve => {
this.$get('dc', { pageSize: -1 }).then(response => {
@@ -673,7 +686,7 @@ export default {
}
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)
- if (this.$route.path === '/asset' && !this.titleSearchList.model.children.length) {
+ if (this.$route.path === '/asset' && this.titleSearchList) {
this.$set(this.searchLabel, 'statistics', 1)
}/* else {
delete this.searchLabel.statistics
diff --git a/nezha-fronted/src/components/page/config/agent.vue b/nezha-fronted/src/components/page/config/agent.vue
index 12646c90e..8a2979200 100644
--- a/nezha-fronted/src/components/page/config/agent.vue
+++ b/nezha-fronted/src/components/page/config/agent.vue
@@ -190,7 +190,7 @@ export default {
toDownloadAgent: function () {
this.getAllDc()
this.showAgentDownload = true
- this.token = sessionStorage.getItem('nz-token')
+ this.token = localStorage.getItem('nz-token')
axios.get('/healthy').then(response => {
const url = response.request.responseURL
this.ipAddr = url.split('/healthy')[0]
diff --git a/nezha-fronted/src/components/page/config/changePin.vue b/nezha-fronted/src/components/page/config/changePin.vue
new file mode 100644
index 000000000..a7694c6d8
--- /dev/null
+++ b/nezha-fronted/src/components/page/config/changePin.vue
@@ -0,0 +1,125 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nezha-fronted/src/components/page/config/operationRecord.vue b/nezha-fronted/src/components/page/config/operationRecord.vue
index 19e3672ef..e7773b73a 100644
--- a/nezha-fronted/src/components/page/config/operationRecord.vue
+++ b/nezha-fronted/src/components/page/config/operationRecord.vue
@@ -60,7 +60,7 @@ export default {
url: 'sys/log',
tableId: 'operationLogTable', // 需要分页的table的id,用于记录每页数量,
mainTableHeight: this.$tableHeight.profile,
- username: sessionStorage.getItem('nz-username'),
+ username: localStorage.getItem('nz-username'),
layout: [],
searchMsg: { // 给搜索框子组件传递的信息
searchLabelList: [
diff --git a/nezha-fronted/src/components/page/config/profile.vue b/nezha-fronted/src/components/page/config/profile.vue
index c59324b47..b4ea20a31 100644
--- a/nezha-fronted/src/components/page/config/profile.vue
+++ b/nezha-fronted/src/components/page/config/profile.vue
@@ -151,7 +151,7 @@ export default {
},
data () {
return {
- username: sessionStorage.getItem('nz-username'),
+ username: localStorage.getItem('nz-username'),
mfaEnable: localStorage.getItem('nz-mfa-enable'),
authBindShow: false,
fileShow: false,
@@ -369,7 +369,7 @@ export default {
},
downloadTxt () {
const element = document.createElement('a')
- element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(this.fileContent))
+ element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponentComponent(this.fileContent))
element.setAttribute('download', 'Nezha recovery codes')
element.style.display = 'none'
element.click()
diff --git a/nezha-fronted/src/components/page/dashboard/chartBox.vue b/nezha-fronted/src/components/page/dashboard/chartBox.vue
index 48b16ee39..1dcb3e250 100644
--- a/nezha-fronted/src/components/page/dashboard/chartBox.vue
+++ b/nezha-fronted/src/components/page/dashboard/chartBox.vue
@@ -224,6 +224,7 @@
:expression-list="expressions"
:id="promqlKeys[index-1]"
:index="index-1"
+ :required = 'true'
:type="promqlType"
:key="promqlKeys[index-1]"
:plugins="['metric-selector', 'metric-input', 'remove']"
@@ -500,6 +501,9 @@ export default {
spanList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
limitOptions: [100, 200, 500, 1000, 2000],
nullTypeList: [{
+ label: 'connected',
+ value: 'connected'
+ }, {
label: 'null',
value: 'null'
}, {
@@ -618,7 +622,14 @@ export default {
this.$set(this.editChart, 'unit', Number.parseInt(unit))
},
expressionChange: function () {
-
+ if (this.expressions[0]) {
+ this.editChart.elements = []
+ this.expressions.forEach((expr, i) => {
+ this.editChart.elements.push({ id: this.elementIds[i], expression: expr, type: 'expert', legend: this.legends[i] })
+ })
+ } else {
+ this.editChart.elements = []
+ }
},
addExpression () {
this.expressions.push('')
diff --git a/nezha-fronted/src/components/page/dashboard/explore/editor.vue b/nezha-fronted/src/components/page/dashboard/explore/editor.vue
new file mode 100644
index 000000000..c74fea88e
--- /dev/null
+++ b/nezha-fronted/src/components/page/dashboard/explore/editor.vue
@@ -0,0 +1,975 @@
+
+
+
+
+
+
+
+
{{detailItem.insertText}}
+
+
{{detailItem.documentation}}
+
+
+
+
+
+
+
+
+
diff --git a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue
index f78b52bc4..212feadbb 100644
--- a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue
+++ b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue
@@ -464,11 +464,12 @@ export default {
if (!limit) {
limit = this.$refs.logDetail ? this.$refs.logDetail.getLimit() : 100
}
+ this.$refs.logDetail && this.$refs.logDetail.resetOperation()
if (this.expressions.length > 0) {
const requestArr = []
this.expressions.forEach((item, index) => {
if (item != '') {
- requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + item + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&limit=' + limit))
+ requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(item) + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&limit=' + limit))
}
})
if (requestArr.length > 0) {
@@ -611,7 +612,7 @@ export default {
const step = bus.getStep(this.filterTime[0], this.filterTime[1])
promqlInputIndexs.push(index)
queryExpression.push(item)
- requestArr.push(this.$get('/prom/api/v1/query_range?query=' + item + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&step=' + step + '&nullType=null'))
+ requestArr.push(this.$get('/prom/api/v1/query_range?query=' + encodeURIComponent(item) + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&step=' + step + '&nullType=null'))
}
})
if (requestArr.length > 0) {
@@ -668,8 +669,11 @@ export default {
this.$refs['promql-' + promqlIndex][0].setError('')
} else {
- // console.log(response)
- this.$refs['promql-' + promqlIndex][0].setError(response.error)
+ if (response.error) {
+ this.$refs['promql-' + promqlIndex][0].setError(response.error)
+ } else {
+ this.$refs['promql-' + promqlIndex][0].setError(response)
+ }
}
})
@@ -693,7 +697,7 @@ export default {
const requestArr = []
this.expressions.forEach((item, index) => {
if (item !== '') {
- requestArr.push(this.$get('/prom/api/v1/query?query=' + item))
+ requestArr.push(this.$get('/prom/api/v1/query?query=' + encodeURIComponent(item)))
}
})
if (requestArr.length > 0) {
@@ -759,6 +763,7 @@ export default {
},
expressionChange () {
const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
+ this.pageObj.pageNo = 1
// console.log(this.filterTime,nowTimeType);
this.setSearchTime(nowTimeType.type, nowTimeType.value)
if (this.showMetrics) {
@@ -801,7 +806,7 @@ export default {
const expressions = this.expressions.filter(item => {
return item && item != ''
})
- const username = sessionStorage.getItem('nz-username')
+ const username = localStorage.getItem('nz-username')
if (historyJson && historyJson != 'undefined' && historyJson != '') {
const historyObj = JSON.parse(historyJson)
let history = historyObj[username]
diff --git a/nezha-fronted/src/components/page/dashboard/explore/logTab.vue b/nezha-fronted/src/components/page/dashboard/explore/logTab.vue
index 695a78d38..33118f3df 100644
--- a/nezha-fronted/src/components/page/dashboard/explore/logTab.vue
+++ b/nezha-fronted/src/components/page/dashboard/explore/logTab.vue
@@ -104,6 +104,7 @@
diff --git a/nezha-fronted/src/components/page/dashboard/overview/chart.vue b/nezha-fronted/src/components/page/dashboard/overview/chart.vue
index eef3889e2..25fe099df 100644
--- a/nezha-fronted/src/components/page/dashboard/overview/chart.vue
+++ b/nezha-fronted/src/components/page/dashboard/overview/chart.vue
@@ -397,11 +397,12 @@ export default {
return params.title
},
defaultTooltipFormatter: function (params) {
+ let showFlag = false
let minusFlag = true
let str = '
'
params instanceof Array || (params = [params])
params.forEach((item, i) => {
- const alias = this.queryAlias(i)
+ const alias = this.queryAlias(item.seriesIndex)
if (i === 0 && alias.indexOf('Previous ') === -1) {
const value = item.data[0]
const tData = new Date(value)
@@ -420,43 +421,50 @@ export default {
str += '
'
minusFlag = false
}
- const val = Number(item.data[1])
- str += '
'
- str += `
${alias || item.seriesName}:
`
- str += '
'
- let dot = bus.countDecimals(val)
- // console.log(dot,val)
- if (dot < this.chartDot) {
- dot = this.chartDot
- } else if (dot > 6) {
- dot = 6
- }
- str += chartDataFormat.getUnit(this.unit).compute(val, null, -1, dot)
- const previousItem = params.find((series) => ('Previous ' + item.seriesName) === series.seriesName)
- if (previousItem) {
- str += '
'
- const previousval = formatScientificNotation(previousItem.data[1], dot)
- let minusVal = 0
- if (previousval <= val) {
- minusVal = val - previousval
- str += '+'
- } else {
- minusVal = previousval - val
- str += '-'
+ showFlag = showFlag || item.data[1]
+ if (!isNaN(item.data[1] + '')) {
+ const val = Number(item.data[1])
+ str += ''
+ str += `
${alias || item.seriesName}:
`
+ str += '
'
+ let dot = bus.countDecimals(val)
+ // console.log(dot,val)
+ if (dot < this.chartDot) {
+ dot = this.chartDot
+ } else if (dot > 6) {
+ dot = 6
}
+ str += chartDataFormat.getUnit(this.unit).compute(val, null, -1, dot)
+ const previousItem = params.find((series) => ('Previous ' + item.seriesName) === series.seriesName)
+ if (previousItem) {
+ str += ''
+ const previousval = formatScientificNotation(previousItem.data[1], dot)
+ let minusVal = 0
+ if (previousval <= val) {
+ minusVal = val - previousval
+ str += '+'
+ } else {
+ minusVal = previousval - val
+ str += '-'
+ }
- str += chartDataFormat.getUnit(this.unit).compute(minusVal, null, -1, dot)
- str += ''
- } else if (alias.indexOf('Previous ') !== -1) {
- str += ''
- str += ''
+ str += chartDataFormat.getUnit(this.unit).compute(minusVal, null, -1, dot)
+ str += ''
+ } else if (alias.indexOf('Previous ') !== -1) {
+ str += ''
+ str += ''
+ }
+ str += '
'
+
+ str += '
'
}
- str += ''
-
- str += '
'
})
str += '
'
- return str
+ if (!showFlag) {
+ return ''
+ } else {
+ return str
+ }
},
queryAlias: function (i) {
let alias = null
diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue
index 509fbfe3d..21d9c3d3d 100644
--- a/nezha-fronted/src/components/page/dashboard/panel.vue
+++ b/nezha-fronted/src/components/page/dashboard/panel.vue
@@ -1,5 +1,5 @@
-
+
@@ -86,6 +86,7 @@
ref="chartList"
:class="{'show-top':showTopBtn}"
:data-list="dataList"
+ :nowTimeType="nowTimeType"
:from="fromRoute.panel"
:panel-lock="panelLock"
:time-range="searchTime"
@@ -94,6 +95,7 @@
@on-remove-chart="delChart"
@on-add-group-item-chart="addGroupItem"
>
+
@@ -131,6 +133,7 @@ export default {
data () {
return {
fromRoute,
+ panelTabLoading: false,
overScroll10: false,
isLoading: true,
panelLock: false,
@@ -225,7 +228,8 @@ export default {
filterPanel: '',
// ---图表相关参数--end
scrollbarWrap: null,
- batchDeleteObjs: []
+ batchDeleteObjs: [],
+ nowTimeType: {}
}
},
components: {
@@ -255,13 +259,8 @@ export default {
this.showPanel = val
this.showPanel.type = 'dashboard'
this.filter.panelId = this.showPanel.id
- // let curTime = this.$refs.calendarPanel.getCurrentTime();
- const curTime = this.searchTime
- this.filter.start_time = bus.timeFormate(curTime[0], 'yyyy-MM-dd hh:mm:ss')
- this.filter.end_time = bus.timeFormate(curTime[1], 'yyyy-MM-dd hh:mm:ss')
- // this.$refs.chartList.initCurrentRecordNum();
- // this.$refs.chartList.cleanData()
- this.getData(this.filter)
+ this.dateChange()
+ this.$refs.chartList.cleanData()
},
del (u) {
@@ -327,7 +326,9 @@ export default {
this.rightBox.chartTemp.show = true
},
chartBySync () {
+ this.panelTabLoading = true
this.$post('visual/panel/chart/syncTmpl', { panelId: this.showPanel.id }).then(res => {
+ this.panelTabLoading = false
if (res.code === 200) {
this.getData(this.filter)
this.$message.success(this.$t('tip.syncSuccess'))
@@ -486,6 +487,7 @@ export default {
// 选择日期变化
dateChange (val) {
const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
+ this.nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType)
this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss')
this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss')
diff --git a/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue b/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue
index 05dff1223..f0524227a 100644
--- a/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue
+++ b/nezha-fronted/src/components/page/monitor/endpoint/endpointList.vue
@@ -590,7 +590,7 @@ export default {
}
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)
this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize)
- if (this.$route.path === '/monitor/endpoint' && !this.titleSearchList.project.children.length) {
+ if (this.$route.path === '/monitor/endpoint') {
this.$set(this.searchLabel, 'statistics', 1)
}
const params = {
@@ -664,6 +664,7 @@ export default {
this.getTableData()
clearTimeout(this.timer)
this.timer = ''
+ this.scrollbarToTop()
}, 1000)
} else {
clearTimeout(this.timer)
@@ -671,9 +672,21 @@ export default {
this.getTableData()
clearTimeout(this.timer)
this.timer = ''
+ this.scrollbarToTop()
}, 1000)
}
},
+ scrollbarToTop () {
+ this.$nextTick(() => {
+ const wraps = document.querySelectorAll('.el-table__body-wrapper')
+ wraps.forEach(wrap => {
+ if (wrap) {
+ wrap.scrollTop = 0
+ wrap.scrollLeft = 0
+ }
+ })
+ })
+ },
getSearchableStateData (data) {
return new Promise(resolve => {
// this.$get('asset/model?pageSize=-1').then(response => {
diff --git a/nezha-fronted/src/http.js b/nezha-fronted/src/http.js
index d4ef80fbb..b9bf40742 100644
--- a/nezha-fronted/src/http.js
+++ b/nezha-fronted/src/http.js
@@ -1,7 +1,7 @@
import axios from 'axios'
axios.interceptors.request.use(config => {
- const token = sessionStorage.getItem('nz-token')
+ const token = localStorage.getItem('nz-token')
if (token) {
config.headers.Authorization = token // 请求头token
}
@@ -58,6 +58,8 @@ axios.interceptors.response.use(
if (accountErrorCode.indexOf(response.data.code) !== -1 && noJumpPath.indexOf(window.location.hash) == -1) {
window.location.href = '/'
}
+ } else {
+ return response
}
return response
},
@@ -76,6 +78,8 @@ export function get (url, params) {
resolve(err.response.data)
} else if (err.message) {
resolve(err.message)
+ } else {
+ resolve(err)
}
})
})
@@ -90,6 +94,8 @@ export function post (url, params, headers) {
resolve(err.response.data)
} else if (err.message) {
resolve(err.message)
+ } else {
+ resolve(err)
}
})
})
@@ -104,6 +110,8 @@ export function put (url, params, headers) {
resolve(err.response.data)
} else if (err.message) {
resolve(err.message)
+ } else {
+ resolve(err)
}
})
})
@@ -118,6 +126,8 @@ export function del (url, params) {
resolve(err.response.data)
} else if (err.message) {
resolve(err.message)
+ } else {
+ resolve(err)
}
})
})
diff --git a/nezha-fronted/src/permission.js b/nezha-fronted/src/permission.js
index 36d277982..e0965e5a5 100644
--- a/nezha-fronted/src/permission.js
+++ b/nezha-fronted/src/permission.js
@@ -38,7 +38,16 @@ router.beforeEach((to, from, next) => {
if (res.inited === 0) {
next({ path: '/setup' })
} else {
- next()
+ if (localStorage.getItem('nz-token')) {
+ next({
+ path: 'overview',
+ query: {
+ t: +new Date()
+ }
+ })
+ } else {
+ next()
+ }
}
}
})
@@ -52,7 +61,7 @@ router.beforeEach((to, from, next) => {
}
})
})
- } else if (sessionStorage.getItem('nz-token')) {
+ } else if (localStorage.getItem('nz-token')) {
const i18nRequest = new Promise(resolve => {
// 从localStorage加载i18n
if (!store.getters.i18nIsReady) {
@@ -76,12 +85,17 @@ router.beforeEach((to, from, next) => {
const permissionRequest = new Promise(resolve => {
if (store.getters.menuList.length === 0) {
Vue.http.get(configUrl).then(config => {
- post(config.body.baseUrl + 'sys/user/permissions', { token: sessionStorage.getItem('nz-token') }).then(res => {
- store.commit('setMenuList', sortByOrderNum(res.data.menus))
- store.commit('setButtonList', res.data.buttons)
- store.commit('setRoleList', res.data.roles)
- document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`))
- resolve()
+ post(config.body.baseUrl + 'sys/user/permissions', { token: localStorage.getItem('nz-token') }).then(res => {
+ if (res.code === 200) {
+ store.commit('setMenuList', sortByOrderNum(res.data.menus))
+ store.commit('setButtonList', res.data.buttons)
+ store.commit('setRoleList', res.data.roles)
+ document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`))
+ resolve()
+ } else {
+ localStorage.removeItem('nz-token')
+ next({ path: '/login' })
+ }
})
})
} else {
diff --git a/nezha-fronted/src/store/user.js b/nezha-fronted/src/store/user.js
index 646f06f20..db6f19345 100644
--- a/nezha-fronted/src/store/user.js
+++ b/nezha-fronted/src/store/user.js
@@ -57,7 +57,7 @@ const user = {
system_bgImg: localStorage.getItem('nz-sys-bgImg'),
dateFormat: localStorage.getItem('nz-default-dateFormat')
}
- sessionStorage.setItem('nz-token', res.data.token)
+ localStorage.setItem('nz-token', res.data.token)
localStorage.setItem('nz-sys-name', res.data.systemName || defaultAppearance.system_name)
if (res.systemLogo || defaultAppearance.system_logo) {
localStorage.setItem('nz-sys-logo', res.data.systemLogo || defaultAppearance.system_logo)
@@ -100,9 +100,9 @@ const user = {
})
},
logoutSuccess (store, res) {
- sessionStorage.removeItem('nz-username')
localStorage.removeItem('nz-username')
- sessionStorage.removeItem('nz-token')
+ localStorage.removeItem('nz-username')
+ localStorage.removeItem('nz-token')
}
}
}