fix: panel请求保存的问题

This commit is contained in:
zhangyu
2021-11-25 13:51:06 +08:00
parent 857392eef3
commit 1fb059926a
20 changed files with 44 additions and 44 deletions

View File

@@ -497,7 +497,7 @@ export default {
const axiosArr = [] const axiosArr = []
const paramStr = this.currentMsg ? JSON.stringify(this.promQueryParamConvert(this.currentMsg)) : null const paramStr = this.currentMsg ? JSON.stringify(this.promQueryParamConvert(this.currentMsg)) : null
if (paramStr && paramStr.trim() != '""') { if (paramStr && paramStr.trim() != '""') {
axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels))))) axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels)))))
this.legend = [] this.legend = []
this.chartDatas = [] this.chartDatas = []
axios.all(axiosArr).then(res => { axios.all(axiosArr).then(res => {
@@ -991,7 +991,7 @@ export default {
const start = this.searchTimeDialog[0] ? this.searchTimeDialog[0] : bus.computeTimezoneTime(new Date().getTime() - 1 * 60 * 60 * 1000) 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()) const end = this.searchTimeDialog[1] ? this.searchTimeDialog[1] : bus.computeTimezoneTime(new Date().getTime())
this.expressions = [this.currentMsg.alertRule.expr] this.expressions = [this.currentMsg.alertRule.expr]
this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels)))).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 this.chartLoading = false
const logData = [res.data] const logData = [res.data]
this.resultType = res.data.resultType this.resultType = res.data.resultType

View File

@@ -734,7 +734,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
const axiosArr = chartItem.elements.map((ele) => { const axiosArr = chartItem.elements.map((ele) => {
const filterItem = ele const filterItem = ele
let query = escape(filterItem.expression) let query = encodeURIComponent(filterItem.expression)
if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null
chartInfo.param.nullType = chartInfo.param.nullType || 'null' chartInfo.param.nullType = chartInfo.param.nullType || 'null'
query += '&nullType=' + chartInfo.param.nullType query += '&nullType=' + chartInfo.param.nullType
@@ -1227,7 +1227,7 @@ export default {
const endTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss') const endTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss')
// const step = bus.getStep(startTime, endTime) // const step = bus.getStep(startTime, endTime)
this.$nextTick(() => { this.$nextTick(() => {
let query = escape(chartInfo.elements[0].expression) let query = encodeURIComponent(chartInfo.elements[0].expression)
if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea') && chartInfo.param) { if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea') && chartInfo.param) {
chartInfo.param.nullType = chartInfo.param.nullType || 'null' chartInfo.param.nullType = chartInfo.param.nullType || 'null'
query += '&nullType=' + chartInfo.param.nullType query += '&nullType=' + chartInfo.param.nullType

View File

@@ -1004,7 +1004,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
const axiosArr = chartItem.elements.map((ele) => { const axiosArr = chartItem.elements.map((ele) => {
const filterItem = ele const filterItem = ele
let query = escape(filterItem.expression) let query = encodeURIComponent(filterItem.expression)
if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null
chartInfo.param.nullType = chartInfo.param.nullType || 'null' chartInfo.param.nullType = chartInfo.param.nullType || 'null'
query += '&nullType=' + chartInfo.param.nullType query += '&nullType=' + chartInfo.param.nullType

View File

@@ -418,7 +418,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
const axiosArr = chartItem.elements.map((ele) => { const axiosArr = chartItem.elements.map((ele) => {
const filterItem = ele const filterItem = ele
const query = escape(filterItem.expression) const query = encodeURIComponent(filterItem.expression)
// if(chartItem.type === 'table'&&chartItem.param&&chartItem.param.last == 1){ // if(chartItem.type === 'table'&&chartItem.param&&chartItem.param.last == 1){
// return this.$get('/prom/api/v1/query_range?query=' + query + "&start=" + this.$stringTimeParseToUnix(endTime) + "&end=" + this.$stringTimeParseToUnix(endTime) + '&step=' + step); // return this.$get('/prom/api/v1/query_range?query=' + query + "&start=" + this.$stringTimeParseToUnix(endTime) + "&end=" + this.$stringTimeParseToUnix(endTime) + '&step=' + step);
// } // }
@@ -1662,7 +1662,7 @@ export default {
const step = bus.getStep(startTime, endTime) const step = bus.getStep(startTime, endTime)
axiosArr = this.chart.elements.map((ele) => { axiosArr = this.chart.elements.map((ele) => {
const filterItem = ele const filterItem = ele
const query = escape(filterItem.expression) const query = encodeURIComponent(filterItem.expression)
let str = '' let str = ''
if ((chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 'table') && chartItem.param) { // 如果是这三个 默认给null if ((chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 'table') && chartItem.param) { // 如果是这三个 默认给null
chartItem.param.nullType = chartItem.param.nullType || 'null' chartItem.param.nullType = chartItem.param.nullType || 'null'

View File

@@ -1645,7 +1645,7 @@ export default {
if (type === 'list') { // 普通模式,主控台使用 if (type === 'list') { // 普通模式,主控台使用
axiosArr = this.data.elements.map((ele) => { axiosArr = this.data.elements.map((ele) => {
const filterItem = ele const filterItem = ele
let query = escape(filterItem.expression) let query = encodeURIComponent(filterItem.expression)
if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null
!this.chartInfo.param && (this.chartInfo.param = {}) !this.chartInfo.param && (this.chartInfo.param = {})
this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null'
@@ -1658,7 +1658,7 @@ export default {
endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss') endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss')
this.data.elements.forEach((ele) => { this.data.elements.forEach((ele) => {
const filterItem = ele const filterItem = ele
let query = escape(filterItem.expression) let query = encodeURIComponent(filterItem.expression)
if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null
!this.chartInfo.param && (this.chartInfo.param = {}) !this.chartInfo.param && (this.chartInfo.param = {})
this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null'
@@ -1670,14 +1670,14 @@ export default {
} else if (type === 'dashboard') { // 概览模式,指标概览中使用 } else if (type === 'dashboard') { // 概览模式,指标概览中使用
// 概览模式,需要区分单独一个和多个 // 概览模式,需要区分单独一个和多个
if (this.stableFilter.chartCount === 'multiple') { if (this.stableFilter.chartCount === 'multiple') {
let query = escape(this.data.name) let query = encodeURIComponent(this.data.name)
if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null
this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null'
query += '&nullType=' + this.chartInfo.param.nullType query += '&nullType=' + this.chartInfo.param.nullType
} }
axiosArr = [this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)] axiosArr = [this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)]
} else { } else {
let query = escape(this.data.elements[0].expression) let query = encodeURIComponent(this.data.elements[0].expression)
if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null
this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null'
query += '&nullType=' + this.chartInfo.param.nullType query += '&nullType=' + this.chartInfo.param.nullType

View File

@@ -333,7 +333,7 @@ export default {
const requestArr = [] const requestArr = []
this.expressions.forEach((item, index) => { this.expressions.forEach((item, index) => {
if (item != '' && this.from.trim() != fromRoute.chartTemp) { if (item != '' && this.from.trim() != fromRoute.chartTemp) {
requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(item) + '&start=' + this.$stringTimeParseToUnix(this.startTime) + '&end=' + this.$stringTimeParseToUnix(this.endTime) + '&limit=' + limit)) requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(item) + '&start=' + this.$stringTimeParseToUnix(this.startTime) + '&end=' + this.$stringTimeParseToUnix(this.endTime) + '&limit=' + limit))
} else if (item != '' && this.from.trim() == fromRoute.chartTemp) { } else if (item != '' && this.from.trim() == fromRoute.chartTemp) {
requestArr.push(logsTempData[index % 2]) requestArr.push(logsTempData[index % 2])
} }
@@ -416,7 +416,7 @@ export default {
const requestArr = [] const requestArr = []
this.expressions.forEach((item, index) => { this.expressions.forEach((item, index) => {
if (item != '' && this.from.trim() != fromRoute.chartTemp) { if (item != '' && this.from.trim() != fromRoute.chartTemp) {
requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(item) + '&start=' + this.$stringTimeParseToUnix(this.searchTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.searchTime[1]) + '&limit=' + limit)) requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(item) + '&start=' + this.$stringTimeParseToUnix(this.searchTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.searchTime[1]) + '&limit=' + limit))
} else if (item != '' && this.from.trim() == fromRoute.chartTemp) { } else if (item != '' && this.from.trim() == fromRoute.chartTemp) {
requestArr.push(logsTempData[index % 2]) requestArr.push(logsTempData[index % 2])
} }

View File

@@ -555,13 +555,13 @@ export default {
host: this.customConnect.host, host: this.customConnect.host,
port: this.customConnect.port, port: this.customConnect.port,
authType: this.customConnect.authType, authType: this.customConnect.authType,
authUsername: encodeURIComponent(this.customConnect.authUsername), authUsername: encodeURIComponentComponent(this.customConnect.authUsername),
authPin: this.encode(this.customConnect.authPin), authPin: this.encode(this.customConnect.authPin),
authPriKey: encodeURIComponent(this.customConnect.authPriKey), authPriKey: encodeURIComponentComponent(this.customConnect.authPriKey),
authUserTip: encodeURIComponent(this.customConnect.authUserTip), authUserTip: encodeURIComponentComponent(this.customConnect.authUserTip),
authPinTip: encodeURIComponent(this.customConnect.authPinTip), authPinTip: encodeURIComponentComponent(this.customConnect.authPinTip),
authProtocolPort: encodeURIComponent(this.customConnect.authProtocolPort), authProtocolPort: encodeURIComponentComponent(this.customConnect.authProtocolPort),
authProtocol: encodeURIComponent(this.customConnect.authProtocol) authProtocol: encodeURIComponentComponent(this.customConnect.authProtocol)
} }
} }
this.editableTabsValue = newTabName this.editableTabsValue = newTabName
@@ -995,7 +995,7 @@ export default {
}, },
encode (str) { encode (str) {
// 对编码的字符串转化base64 // 对编码的字符串转化base64
const base64 = encodeURIComponent(btoa(str)) const base64 = encodeURIComponentComponent(btoa(str))
return base64 return base64
}, },
closeAssetCustom () { closeAssetCustom () {

View File

@@ -681,7 +681,7 @@ export default {
resolve({ data: '', status: 'no query' }) resolve({ data: '', status: 'no query' })
}) })
} }
query = escape(query) query = encodeURIComponent(query)
query += '&nullType=' + 'null' query += '&nullType=' + 'null'
return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)
}) })

View File

@@ -264,7 +264,7 @@ export default {
if (this.$refs.messageChart) { if (this.$refs.messageChart) {
this.$refs.messageChart.startLoading() this.$refs.messageChart.startLoading()
const axiosArr = [] const axiosArr = []
axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(this.currentMsg.alertRule.expr.replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels))))) axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels)))))
this.legend = [] this.legend = []
this.chartDatas = [] this.chartDatas = []
axios.all(axiosArr).then(res => { axios.all(axiosArr).then(res => {
@@ -738,7 +738,7 @@ export default {
const start = this.searchTime[0] ? this.searchTime[0] : getTime(-1, 'h') const start = this.searchTime[0] ? this.searchTime[0] : getTime(-1, 'h')
const end = this.searchTime[1] ? this.searchTime[1] : getTime(0, 'h') const end = this.searchTime[1] ? this.searchTime[1] : getTime(0, 'h')
this.expressions = [this.currentMsg.alertRule.expr] this.expressions = [this.currentMsg.alertRule.expr]
this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels)))).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 this.chartLoading = false
const logData = [res.data] const logData = [res.data]
this.resultType = res.data.resultType this.resultType = res.data.resultType

View File

@@ -250,7 +250,7 @@ export default {
this.tableData = [] this.tableData = []
this.tableDataCopy = '' this.tableDataCopy = ''
setTimeout(() => { setTimeout(() => {
this.$get('/prom/api/v1/query?query=' + escape("{endpoint='" + this.currentEndpoint.id + "'}") + '&time=' + this.formatTime).then(response => { this.$get('/prom/api/v1/query?query=' + encodeURIComponent("{endpoint='" + this.currentEndpoint.id + "'}") + '&time=' + this.formatTime).then(response => {
this.loading = false this.loading = false
if (response.status === 'success') { if (response.status === 'success') {
const results = response.data.result const results = response.data.result
@@ -452,13 +452,13 @@ export default {
} }
const axiosArr = [] const axiosArr = []
for (const endpoint of this.selectedEndpoints) { for (const endpoint of this.selectedEndpoints) {
axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step)) axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step))
} }
if (this.$refs.pickTime && this.$refs.pickTime.$refs.multipleTime && this.$refs.pickTime.$refs.multipleTime.searchTime.length) { // 判断是否需要添加比较 if (this.$refs.pickTime && this.$refs.pickTime.$refs.multipleTime && this.$refs.pickTime.$refs.multipleTime.searchTime.length) { // 判断是否需要添加比较
const startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'yyyy-MM-dd hh:mm:ss') const startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'yyyy-MM-dd hh:mm:ss')
const endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss') const endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss')
for (const endpoint of this.selectedEndpoints) { for (const endpoint of this.selectedEndpoints) {
axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)) axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step))
} }
} }
this.legend = [] this.legend = []

View File

@@ -115,7 +115,7 @@ export default {
if (item != '') { if (item != '') {
let expr = item let expr = item
this.matchContent && (expr = `${item} ${this.matchSymbol} "${this.matchContent}"`) this.matchContent && (expr = `${item} ${this.matchSymbol} "${this.matchContent}"`)
requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(expr) + '&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(expr) + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&limit=' + limit))
} }
}) })
axios.all(requestArr).then(res => { axios.all(requestArr).then(res => {

View File

@@ -311,7 +311,7 @@ export default {
}, },
downloadTxt () { downloadTxt () {
const element = document.createElement('a') 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.setAttribute('download', 'Nezha recovery codes')
element.style.display = 'none' element.style.display = 'none'
element.click() element.click()

View File

@@ -137,7 +137,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
const axiosArr = chartItem.elements.map((ele) => { const axiosArr = chartItem.elements.map((ele) => {
const filterItem = ele const filterItem = ele
let query = escape(filterItem.expression) let query = encodeURIComponent(filterItem.expression)
if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null
chartInfo.param.nullType = chartInfo.param.nullType || 'null' chartInfo.param.nullType = chartInfo.param.nullType || 'null'
query += '&nullType=' + chartInfo.param.nullType query += '&nullType=' + chartInfo.param.nullType

View File

@@ -686,7 +686,7 @@ export default {
resolve({ data: '', status: 'no query' }) resolve({ data: '', status: 'no query' })
}) })
} }
query = escape(query) query = encodeURIComponent(query)
query += '&nullType=' + 'null' query += '&nullType=' + 'null'
return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)
}) })

View File

@@ -168,7 +168,7 @@ export default {
this.tableData = [] this.tableData = []
this.tableDataCopy = '' this.tableDataCopy = ''
setTimeout(() => { setTimeout(() => {
this.$get('/prom/api/v1/query?query=' + escape("{endpoint='" + this.currentEndpoint.id + "'}") + '&time=' + this.$stringTimeParseToUnix(new Date(this.formatTime).getTime())).then(response => { this.$get('/prom/api/v1/query?query=' + encodeURIComponent("{endpoint='" + this.currentEndpoint.id + "'}") + '&time=' + this.$stringTimeParseToUnix(new Date(this.formatTime).getTime())).then(response => {
this.loading = false this.loading = false
if (response.status === 'success') { if (response.status === 'success') {
const results = response.data.result const results = response.data.result
@@ -378,13 +378,13 @@ export default {
} }
const axiosArr = [] const axiosArr = []
for (const endpoint of this.batchDeleteObjs) { for (const endpoint of this.batchDeleteObjs) {
axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step)) axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step))
} }
if (this.$refs.pickTime && this.$refs.pickTime.$refs.multipleTime && this.$refs.pickTime.$refs.multipleTime.searchTime.length) { // 判断是否需要添加比较 if (this.$refs.pickTime && this.$refs.pickTime.$refs.multipleTime && this.$refs.pickTime.$refs.multipleTime.searchTime.length) { // 判断是否需要添加比较
const startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'yyyy-MM-dd hh:mm:ss') const startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'yyyy-MM-dd hh:mm:ss')
const endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss') const endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss')
for (const endpoint of this.batchDeleteObjs) { for (const endpoint of this.batchDeleteObjs) {
axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)) axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step))
} }
} }
this.legend = [] this.legend = []

View File

@@ -4,7 +4,7 @@ const RIGHT = 39
const DOWN = 40 const DOWN = 40
const TAB = 9 const TAB = 9
const ENTER = 13 const ENTER = 13
const ESCAPE = 27 const encodeURIComponent = 27
export default { export default {
methods: { methods: {
@@ -82,10 +82,10 @@ export default {
} }
}, },
processKey (e) { processKey (e) {
if (![LEFT, UP, RIGHT, DOWN, ESCAPE, ENTER, TAB].includes(e.keyCode)) this.populate() if (![LEFT, UP, RIGHT, DOWN, encodeURIComponent, ENTER, TAB].includes(e.keyCode)) this.populate()
}, },
processControl (e) { processControl (e) {
if ([LEFT, UP, RIGHT, DOWN, ESCAPE, ENTER, TAB].includes(e.keyCode)) { if ([LEFT, UP, RIGHT, DOWN, encodeURIComponent, ENTER, TAB].includes(e.keyCode)) {
switch (e.keyCode) { switch (e.keyCode) {
case LEFT: case LEFT:
if (this.pagination) this.$refs.page.switchPage('previous') if (this.pagination) this.$refs.page.switchPage('previous')
@@ -103,7 +103,7 @@ export default {
case ENTER: case ENTER:
if (this.highlight !== -1) this.selectItem(this.list[this.highlight]) if (this.highlight !== -1) this.selectItem(this.list[this.highlight])
break break
case ESCAPE: case encodeURIComponent:
this.close() this.close()
break break
} }

View File

@@ -511,7 +511,7 @@ export default {
if (this.$refs.messageChart) { if (this.$refs.messageChart) {
this.$refs.messageChart.startLoading() this.$refs.messageChart.startLoading()
const axiosArr = [] const axiosArr = []
axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels))))) axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels)))))
this.legend = [] this.legend = []
this.chartDatas = [] this.chartDatas = []
axios.all(axiosArr).then(res => { axios.all(axiosArr).then(res => {
@@ -659,7 +659,7 @@ export default {
const start = this.searchTimeDialog[0] ? this.searchTimeDialog[0] : bus.computeTimezoneTime(new Date().getTime() - 1 * 60 * 60 * 1000) 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()) const end = this.searchTimeDialog[1] ? this.searchTimeDialog[1] : bus.computeTimezoneTime(new Date().getTime())
this.expressions = [this.currentMsg.alertRule.expr] this.expressions = [this.currentMsg.alertRule.expr]
this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels)))).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 this.chartLoading = false
const logData = [res.data] const logData = [res.data]
this.resultType = res.data.resultType this.resultType = res.data.resultType

View File

@@ -368,7 +368,7 @@ export default {
}, },
downloadTxt () { downloadTxt () {
const element = document.createElement('a') 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.setAttribute('download', 'Nezha recovery codes')
element.style.display = 'none' element.style.display = 'none'
element.click() element.click()

View File

@@ -472,7 +472,7 @@ export default {
const requestArr = [] const requestArr = []
this.expressions.forEach((item, index) => { this.expressions.forEach((item, index) => {
if (item != '') { if (item != '') {
requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(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) { if (requestArr.length > 0) {
@@ -615,7 +615,7 @@ export default {
const step = bus.getStep(this.filterTime[0], this.filterTime[1]) const step = bus.getStep(this.filterTime[0], this.filterTime[1])
promqlInputIndexs.push(index) promqlInputIndexs.push(index)
queryExpression.push(item) queryExpression.push(item)
requestArr.push(this.$get('/prom/api/v1/query_range?query=' + escape(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) { if (requestArr.length > 0) {
@@ -700,7 +700,7 @@ export default {
const requestArr = [] const requestArr = []
this.expressions.forEach((item, index) => { this.expressions.forEach((item, index) => {
if (item !== '') { if (item !== '') {
requestArr.push(this.$get('/prom/api/v1/query?query=' + escape(item))) requestArr.push(this.$get('/prom/api/v1/query?query=' + encodeURIComponent(item)))
} }
}) })
if (requestArr.length > 0) { if (requestArr.length > 0) {

View File

@@ -261,7 +261,7 @@ export default {
this.filter.end_time = endTime this.filter.end_time = endTime
const step = bus.getStep(startTime, endTime) const step = bus.getStep(startTime, endTime)
const query = params.elements[0].expression const query = params.elements[0].expression
this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step).then(response => { this.$get('/prom/api/v1/query_range?query=' + encodeURIComponent(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step).then(response => {
this.$refs.metricSet.loading = false this.$refs.metricSet.loading = false
if (response.status === 'success') { if (response.status === 'success') {
if (response.data.result) { if (response.data.result) {