diff --git a/nezha-fronted/src/components/charts/chart-alert-list.vue b/nezha-fronted/src/components/charts/chart-alert-list.vue index 696c5c51a..a4a740890 100644 --- a/nezha-fronted/src/components/charts/chart-alert-list.vue +++ b/nezha-fronted/src/components/charts/chart-alert-list.vue @@ -99,6 +99,7 @@ :fromPath="'/alertList'" style="height: calc(100% - 50px)" :showOption="false" + :chart-alert-list="true" > @@ -459,6 +460,9 @@ export default { }) }, messageDetail (row) { + if (row.alertRule.type == 3) { + return + } this.$get('/alert/rule/' + row.alertRule.id).then(res => { this.currentMsg = { ...row, alertRule: { ...res.data } } this.graphShow = true diff --git a/nezha-fronted/src/components/common/alert/alertLabel.vue b/nezha-fronted/src/components/common/alert/alertLabel.vue index 72e969a91..cfa858c73 100644 --- a/nezha-fronted/src/components/common/alert/alertLabel.vue +++ b/nezha-fronted/src/components/common/alert/alertLabel.vue @@ -257,12 +257,14 @@ export default { type: {}, // labelLoading:{}, that: {}, - detailList: Boolean + detailList: Boolean, + alertTableDialog: Boolean }, data () { return { alertLabelData: null, - loading: true + loading: true, + heightList: 0 } }, components: { @@ -292,30 +294,29 @@ export default { }, computed: { calcPosition () { - const self = this return function (position) { const clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight - const dialog = document.querySelector('#dialog-alert-massage .el-dialog') - const dialogHeight = dialog.getBoundingClientRect() const leftOffSetView = this.detailList ? -80 : 10 - const topOffSetView = this.detailList ? 0 : 0 const leftOffSet = this.detailList ? -80 : 10 - const topOffSet = this.detailList ? 70 : 0 - const elHeight = self.type === 'asset' ? 318 : (self.type === 'project' ? 70 : 70) - if (position.top + elHeight > clientHeight) { + const topOffSet = this.detailList ? 60 : 22 + if (position.top + this.heightList > clientHeight) { return { left: `${position.left + position.width + leftOffSet}px`, - top: `${position.top - elHeight + topOffSet}px` + top: `${position.top - this.heightList + topOffSet}px` } - } else if (dialogHeight) { - return { - left: `${position.left + position.width + 10 - dialogHeight.x}px`, - top: `${position.top - dialogHeight.y}px` + } else if (this.alertTableDialog) { + const dialog = document.querySelector('#dialog-alert-massage .el-dialog') + const dialogHeight = dialog.getBoundingClientRect() + if (dialogHeight) { + return { + left: `${position.left + position.width + 10 - dialogHeight.x}px`, + top: `${position.top - dialogHeight.y}px` + } } } else { return { left: `${position.left + position.width + leftOffSetView}px`, - top: `${position.top + topOffSetView}px` + top: `${position.top}px` } } } @@ -397,6 +398,12 @@ export default { return this.$t('asset.notInStock') } } + }, + mounted () { + this.heightList = this.$refs.alertLabels.getBoundingClientRect().height + }, + beforeDestroy () { + } } diff --git a/nezha-fronted/src/components/common/alert/alertRuleInfo.vue b/nezha-fronted/src/components/common/alert/alertRuleInfo.vue index d418ceb99..ebb61d9dd 100644 --- a/nezha-fronted/src/components/common/alert/alertRuleInfo.vue +++ b/nezha-fronted/src/components/common/alert/alertRuleInfo.vue @@ -11,7 +11,16 @@
{{$t('alert.type')}}
-
{{alertRuleData.type ? alertRuleData.type : '--'}}
+
+ + {{$t('project.metrics.metrics')}} + + + {{$t('overall.logs')}} + + SNMP trap + -- +
{{$t('alert.severity')}}
diff --git a/nezha-fronted/src/components/common/bottomBox/bottomBox.vue b/nezha-fronted/src/components/common/bottomBox/bottomBox.vue index de5fb5d7e..f5625acbf 100644 --- a/nezha-fronted/src/components/common/bottomBox/bottomBox.vue +++ b/nezha-fronted/src/components/common/bottomBox/bottomBox.vue @@ -50,11 +50,12 @@ - + - + +
@@ -66,6 +67,7 @@ import cabinetTab from './tabs/cabinetTab' import alertMessageTab from './tabs/alertMessageTab' import alertMessageTabNew from './tabs/alertMessageTabNew' +import alertRuleEvalLog from './tabs/alertRuleEvalLog' import assetSubTab from './tabs/assetSubTab' import endpointQuery from './tabs/endpointQuery' import endpointTab from './tabs/endpointTab' @@ -97,7 +99,8 @@ export default { endpointQuery, panelTabNew, assetTab, - assetSubTab + assetSubTab, + alertRuleEvalLog }, props: { isFullScreen: Boolean, // 是否全屏 @@ -203,7 +206,7 @@ export default { { prop: 'panelTab', name: this.$t('overall.detail') }, { prop: 'endpointAlertMessage', name: this.$t('overall.alert') }, { prop: 'endpointQuery', name: 'Metrics' }, - { prop: 'log', name: 'Log' }, + { prop: 'log', name: 'Log' } ] }, chartTemp: { @@ -213,7 +216,8 @@ export default { }, alertRule: { alertRule: [ - { prop: 'alertRuleAlertMessage', name: this.$t('overall.alert') } + { prop: 'alertRuleAlertMessage', name: this.$t('overall.alert') }, + { prop: 'evalLog', name: this.$t('overall.alertRuleEvalLog') } ] }, model: [ diff --git a/nezha-fronted/src/components/common/bottomBox/nzBottomDataList.vue b/nezha-fronted/src/components/common/bottomBox/nzBottomDataList.vue index fbbcbef1d..523346a9c 100644 --- a/nezha-fronted/src/components/common/bottomBox/nzBottomDataList.vue +++ b/nezha-fronted/src/components/common/bottomBox/nzBottomDataList.vue @@ -4,7 +4,7 @@
{{bottomHeaderTitle}}:
-
{{tab.name}}
+
{{tab.name}}
diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/alertRuleEvalLog.vue b/nezha-fronted/src/components/common/bottomBox/tabs/alertRuleEvalLog.vue new file mode 100644 index 000000000..6a1b3ba95 --- /dev/null +++ b/nezha-fronted/src/components/common/bottomBox/tabs/alertRuleEvalLog.vue @@ -0,0 +1,117 @@ + + + diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/cabinetTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/cabinetTab.vue index 6967ce888..0e70baaf7 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/cabinetTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/cabinetTab.vue @@ -34,7 +34,8 @@ - - -
- + {{item3.name}} + {{item3.num || 0}} @@ -56,9 +57,12 @@
- + - {{item3.name+'/'+item4.name}} +
+ {{item3.name+'/'+item4.name}} + {{item4.num || 0}} +
@@ -88,9 +92,12 @@
- + {{item3.name}} - {{item4.name}} +
+ {{item4.name}} + {{item4.num || 0}} +
diff --git a/nezha-fronted/src/components/common/i18n.js b/nezha-fronted/src/components/common/i18n.js index 7ed9d7088..c018835e2 100644 --- a/nezha-fronted/src/components/common/i18n.js +++ b/nezha-fronted/src/components/common/i18n.js @@ -1,8 +1,6 @@ import Vue from 'vue' import locale from 'element-ui/lib/locale' import VueI18n from 'vue-i18n' -import { get } from '@/http' -// import messages from './language' Vue.use(VueI18n) // 从localStorage获取语言选择。 const i18n = new VueI18n({ @@ -16,15 +14,6 @@ export function loadI18n (i18nData) { Object.keys(i18nData).forEach(lang => { i18n.setLocaleMessage(lang, i18nData[lang]) }) - } else { - get('/sys/i18n/lang').then(response => { - if (response.code === 200) { - i18nData = response.data - Object.keys(i18nData).forEach(lang => { - i18n.setLocaleMessage(lang, i18nData[lang]) - }) - } - }) } } export default i18n diff --git a/nezha-fronted/src/components/common/js/tools.js b/nezha-fronted/src/components/common/js/tools.js index 6e464c329..4bc8a57cf 100644 --- a/nezha-fronted/src/components/common/js/tools.js +++ b/nezha-fronted/src/components/common/js/tools.js @@ -294,6 +294,15 @@ export function stringTimeParseToUnix (stringTime) { time = time + localOffset - offset * 60 * 60 * 1000 return parseInt(time / 1000) } +export function stringTimeParseToUnixMs (stringTime) { + let time = new Date(stringTime).getTime() + let offset = localStorage.getItem('nz-sys-timezone') + offset = moment.tz(offset).format('Z') + offset = Number.parseInt(offset) + const localOffset = new Date().getTimezoneOffset() * 60 * 1000 * -1 // 默认 一分钟显示时区偏移的结果 + time = time + localOffset - offset * 60 * 60 * 1000 + return parseInt(time) +} export function getTime (size, unit) { // 计算时间 const now = new Date(bus.computeTimezone(new Date().getTime())) if (unit) { @@ -361,6 +370,28 @@ export function calcDurationByStringTimeB (startTime, endTime) { return result } +export function calcDurationByStringTimeMs (startTime, endTime) { + let durationSecond = stringTimeParseToUnixMs(endTime) - stringTimeParseToUnixMs(startTime) + let result = '' + if (durationSecond < 1000) { + result = `${durationSecond % 1000}ms` + return result + } else { + durationSecond = durationSecond / 1000 + } + result = `${durationSecond % 60}s` + if (durationSecond >= 60 * 60 * 24) { + result = `${(Math.floor(durationSecond / 3600)) % 24}h` + result = `${Math.floor(durationSecond / (60 * 60 * 24))}d ${result}` + } else if (durationSecond >= 60 * 60) { + result = `${(Math.floor(durationSecond / 60)) % 60}m` + result = `${Math.floor(durationSecond / (60 * 60))}h ${result}` + } else if (durationSecond >= 60) { + result = `${(Math.floor(durationSecond / 60)) % 60}m ${result}` + } + + return result +} export function unixTimeParseToString (unixTime, fmt = 'yyyy-MM-dd hh:mm:ss') { const date = new Date(unixTime * 1000) const o = { diff --git a/nezha-fronted/src/components/common/js/validate.js b/nezha-fronted/src/components/common/js/validate.js index 438ae997b..c58066919 100644 --- a/nezha-fronted/src/components/common/js/validate.js +++ b/nezha-fronted/src/components/common/js/validate.js @@ -76,7 +76,7 @@ export function nzNumber (rule, value, callback) { } export function noSpecialChar (rule, value, callback) { - const charReg = /^[\u4e00-\u9fa5a-z0-9A-Z-_.]+$/ + const charReg = /[\u0000-\uFFFF]/ setTimeout(() => { if (charReg.test(value)) { callback() @@ -170,7 +170,7 @@ export function checkExprTempAge (rule, value, callback) { }, 100) } -export function arrLength (rule, value, callback) { // 校验经纬度 +export function arrLength (rule, value, callback) { // 校验数组 if (value.length > 0) { callback() } else { diff --git a/nezha-fronted/src/components/common/labelFilter/clickSearch.vue b/nezha-fronted/src/components/common/labelFilter/clickSearch.vue index 5a2ef69aa..6c619e0d8 100644 --- a/nezha-fronted/src/components/common/labelFilter/clickSearch.vue +++ b/nezha-fronted/src/components/common/labelFilter/clickSearch.vue @@ -6,7 +6,7 @@ @@ -306,7 +306,7 @@ export default { this.$set(c, 'labelWidth', labelWidth) // label区域宽 this.$set(c, 'inputWidth', this.widthConstant.dropdownCheckBox.inputOriginalWidth) // 内容区域宽 } else if (this.titleSearchListCopy[type].type === 'checkBox') { - const width = this.computeDistance(c.name) + this.widthConstant.checkBox.tagBlankTotal + this.widthConstant.checkBox.boxMargin + const width = this.computeDistance(c.name + ' (' + c.num + ')') + this.widthConstant.checkBox.tagBlankTotal + this.widthConstant.checkBox.boxMargin this.$set(c, 'width', width) // 总宽 } }) diff --git a/nezha-fronted/src/components/common/labelFilter/dropdown.vue b/nezha-fronted/src/components/common/labelFilter/dropdown.vue index e83c789fb..673174c3f 100644 --- a/nezha-fronted/src/components/common/labelFilter/dropdown.vue +++ b/nezha-fronted/src/components/common/labelFilter/dropdown.vue @@ -17,7 +17,12 @@ @blur="$emit('blur', item, false, $event)" @change="change" @focus="$emit('focus', item, true, $event)" - > + > + +
diff --git a/nezha-fronted/src/components/common/language/cn.js b/nezha-fronted/src/components/common/language/cn.js index d7b8c5c52..00fd8d4ed 100644 --- a/nezha-fronted/src/components/common/language/cn.js +++ b/nezha-fronted/src/components/common/language/cn.js @@ -36,6 +36,7 @@ const cn = { project: '系统', monitor: '监控', alert: '告警', + alertRuleEvalLog: 'Eval log', asset: '资产', config: '设置', administration: '系统管理', @@ -172,7 +173,12 @@ const cn = { clearAllSelect: '清除选择的内容', disabled: '已禁用', enabled: '启用', - close: '关闭' + close: '关闭', + records: '导出形式', + fileFormat: '文件格式', + allData: '全部数据', + selectRecords: '选中的数据', + current: '当前页' }, setup: { step0: '欢迎', @@ -1260,6 +1266,7 @@ const cn = { alertMessage: '告警信息', rule: '告警规则', alertRule: '告警规则', + alertRuleMessage: 'Message', alertList: '告警信息', alertConfig: '告警规则', alertName: '告警名称', @@ -1355,7 +1362,7 @@ const cn = { }, P1Rule: 'P1: 万分紧急,可导致业务瘫痪的告警', P2Rule: 'P2: 重要,需要紧急关注的警报,但还没有影响业务', - P3Rule: 'P3: 轻微警报,需要处理,但不紧急' + P3Rule: 'P3: 轻微警报,需要处理,但不紧急', }, project: { chart: { diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js index 11da5136b..55f9f9965 100644 --- a/nezha-fronted/src/components/common/language/en.js +++ b/nezha-fronted/src/components/common/language/en.js @@ -35,6 +35,7 @@ const en = { project: 'Project', // '系统' monitor: 'Monitor', // 监控 alert: 'Alert', // "告警" + alertRuleEvalLog: 'Eval log', asset: 'Asset', // '资产' config: 'Setting', // '设置' administration: 'Administration', @@ -177,7 +178,12 @@ const en = { clearAllSelect: 'Clear the selection', disabled: 'Disabled', enabled: 'Enabled', - close: 'Close' + close: 'Close', + records: 'Records', + fileFormat: 'File format', + allData: 'All data', + selectRecords: 'Select records', + current: 'Current page' }, pageSize: '/page', setup: { @@ -1264,6 +1270,7 @@ const en = { rule: 'Rule', // '规则' alertMessage: 'Alert message', // "告警信息" alertRule: 'Alert rule', // "告警规则" + alertRuleMessage: 'Message', alertName: 'Name', // "告警名称" method: 'Method', // "告警名称" severity: 'Priority', // "等级" diff --git a/nezha-fronted/src/components/common/login.vue b/nezha-fronted/src/components/common/login.vue index 942039211..20d57784f 100644 --- a/nezha-fronted/src/components/common/login.vue +++ b/nezha-fronted/src/components/common/login.vue @@ -7,12 +7,12 @@
- +
- +
{{$t('login.verifyTitle')}}
@@ -23,7 +23,7 @@ {{$t('login.verifyContent')}}
- +
@@ -151,7 +151,6 @@ export default { if (this.loading || !this.license.valid) { return } - // if (this.license.valid && this.validateLogin() && (this.$route.path == '/' || this.$route.path == '/login')) { if (this.validateLogin() && (this.$route.path == '/' || this.$route.path == '/login')) { this.loading = true this.$post('/sys/login', this.loginData).then(res => { @@ -160,27 +159,13 @@ export default { this.authToken = res.data.authToken this.lang = res.data.user.lang this.$i18n.locale = this.lang - // 获取国际化内容 - const getI18nData = new Promise(resolve => get('/sys/i18n/lang').then(response => { - if (response.code === 200) { - const i18nData = response.data - resolve(i18nData) - } else { - resolve() - } - })) // 获取可选语言 - const getLangList = new Promise(resolve => get('/sys/dict/all?type=lang').then(response => { + get('/sys/dict/all?type=lang').then(response => { if (response.code === 200) { const langList = response.data.map(lang => ({ name: lang.name, value: lang.value })) this.$store.commit('setLangList', langList) localStorage.setItem('nz-language-list', JSON.stringify(langList)) } - resolve() - })) - Promise.all([getI18nData, getLangList]).then(response => { - response[0] && loadI18n(response[0]) - this.$store.commit('i18nReady', true) }) sessionStorage.setItem('nz-token', res.data.authToken) if (res.data.authFlag === 1) { diff --git a/nezha-fronted/src/components/common/popBox/topToolMoreOptions.vue b/nezha-fronted/src/components/common/popBox/topToolMoreOptions.vue index ffbfddbd2..b9359cfcb 100644 --- a/nezha-fronted/src/components/common/popBox/topToolMoreOptions.vue +++ b/nezha-fronted/src/components/common/popBox/topToolMoreOptions.vue @@ -43,15 +43,29 @@
-
- - +
+
+ Records + + {{item.name}} + +
+
+ File format + + {{item.name}} + +
@@ -138,17 +152,29 @@ export default { paramsType: { type: String, default: '' - } + }, + deleteObjs: Array }, data () { return { - importBox: { show: false, title: this.$t('overall.importExcel'), type: 1 }, + importBox: { show: false, title: this.$t('overall.importExcel'), type: 1, record: 'all', format: 1 }, importFile: null, importFileList: [], importResult: null, exportShow: false, panelLock: true, - language: localStorage.getItem('nz-language') + language: localStorage.getItem('nz-language'), + recordArr: [ + { name: this.$t('overall.allData'), value: 'all' }, + { name: this.$t('overall.selectRecords'), value: 'records' }, + { name: this.$t('overall.current'), value: 'current' } + ], + formatArr: [ + { name: 'XLSX', value: 1 }, + { name: 'CSV', value: 2 }, + { name: 'JSON', value: 3 } + ] + } }, mounted () { @@ -244,6 +270,8 @@ export default { this.importResult = null this.importFileList = [] this.importFile = null + this.importBox.value = 1 + this.importBox.record = 'all' }) }, downloadTemplate () { @@ -309,6 +337,7 @@ export default { delete params.searchName } params.language = localStorage.getItem('nz-language') || 'en' + params.format = this.importBox.format this.exportExcel(this.exportUrl, params, this.exportFileName + '-' + this.getTimeString() + '.xlsx') this.closeDialog() }, @@ -341,10 +370,53 @@ export default { // delete params.moduleId // } params.language = localStorage.getItem('nz-language') || 'en' - + params.format = this.importBox.format this.exportExcel(this.exportUrl, params, this.exportFileName + '-' + this.getTimeString() + '.xlsx') this.closeDialog() }, + exportRecords() { + const params = JSON.parse(JSON.stringify(this.params)) + if (this.params2) { + Object.keys(this.params2).forEach(key => { + if (params[key]) { + if (params[key].prototype.toString.call(val) === '[object Object]') { + Object.assign(params[key], this.params2[key]) + } else if (params[key].prototype.toString.call(val) === '[object Array]') { + params[key].concat(this.params2[key]) + } + } else { + params[key] = this.params2[key] + } + }) + } + params.pageSize = -1 + if (this.exportUrl.indexOf('panel') > -1) { + delete params.start_time + delete params.end_time + delete params.id + delete params.searchName + } + if (this.importUrl.indexOf('panel') > -1) { + delete params.panelId + } + // if (this.importUrl.indexOf('endpoint') > -1){ + // delete params.moduleId + // } + params.language = localStorage.getItem('nz-language') || 'en' + params.format = this.importBox.format + params.ids = this.deleteObjs.map(item => item.id).join(',') + this.exportExcel(this.exportUrl, params, this.exportFileName + '-' + this.getTimeString() + '.xlsx') + this.closeDialog() + }, + exportData () { + if (this.importBox.record === 'all') { + this.exportAll() + } else if (this.importBox.record === 'current') { + this.exportCur() + } else if (this.importBox.record === 'records') { + this.exportRecords() + } + }, exportExcel (url, params, fileName) { if (this.paramsType) { params.type = this.paramsType @@ -395,7 +467,7 @@ export default { this.importBox.width = '600px' } else if (type == 2) { // export this.importBox.title = this.$t('overall.exportExcel') - this.importBox.width = '300px' + this.importBox.width = '580px' } }, getTimeString () { diff --git a/nezha-fronted/src/components/common/rightBox/administration/roleBox.vue b/nezha-fronted/src/components/common/rightBox/administration/roleBox.vue index 5bd6e5553..d6d21bded 100644 --- a/nezha-fronted/src/components/common/rightBox/administration/roleBox.vue +++ b/nezha-fronted/src/components/common/rightBox/administration/roleBox.vue @@ -6,9 +6,9 @@
-
+
- + @@ -160,7 +160,8 @@ export default { default: true }, alertMessageTabNew: Boolean, - loading: Boolean + loading: Boolean, + chartAlertList: Boolean }, mixins: [table, bus], data () { diff --git a/nezha-fronted/src/components/common/table/alert/alertRuleEvalLogTable.vue b/nezha-fronted/src/components/common/table/alert/alertRuleEvalLogTable.vue new file mode 100644 index 000000000..f45bcb526 --- /dev/null +++ b/nezha-fronted/src/components/common/table/alert/alertRuleEvalLogTable.vue @@ -0,0 +1,187 @@ + + + + + diff --git a/nezha-fronted/src/components/common/table/alert/alertSilenceTable.vue b/nezha-fronted/src/components/common/table/alert/alertSilenceTable.vue index 8afd2d7ee..39006fd4d 100644 --- a/nezha-fronted/src/components/common/table/alert/alertSilenceTable.vue +++ b/nezha-fronted/src/components/common/table/alert/alertSilenceTable.vue @@ -116,7 +116,8 @@ export default { }, mixins: [table], props: { - loading: Boolean + loading: Boolean, + nowTime: {} }, data () { return { diff --git a/nezha-fronted/src/components/common/table/settings/globalizationTable.vue b/nezha-fronted/src/components/common/table/settings/globalizationTable.vue new file mode 100644 index 000000000..8abf4f98c --- /dev/null +++ b/nezha-fronted/src/components/common/table/settings/globalizationTable.vue @@ -0,0 +1,128 @@ + + + + diff --git a/nezha-fronted/src/components/layout/header.vue b/nezha-fronted/src/components/layout/header.vue index 906407154..aca88eff4 100644 --- a/nezha-fronted/src/components/layout/header.vue +++ b/nezha-fronted/src/components/layout/header.vue @@ -38,11 +38,8 @@
- -
English
-
- -
简体中文
+ +
{{lang.name}}
@@ -62,7 +59,6 @@
-
@@ -138,7 +134,6 @@ export default { getLinkData () { this.$get('link').then(response => { this.$store.commit('setLinkData', response.data.list) - // this.linkData = response.data.list }) }, changeLocal (lang) { @@ -154,13 +149,6 @@ export default { document.location.href = '/' }) }, - // refreshLang () { - // this.language = localStorage.getItem('nz-language') - // this.$i18n.locale = this.language - // this.$nextTick(() => { - // // window.location.reload() - // }) - // }, showPinDialog () { this.$router.push({ path: '/profile', @@ -207,6 +195,9 @@ export default { route () { return this.$route.path }, + langList () { + return this.$store.getters.getLangList + }, breadcrumb () { if (this.$route.path === '/profile') { return [ diff --git a/nezha-fronted/src/components/page/alert/alertRule.vue b/nezha-fronted/src/components/page/alert/alertRule.vue index d0fcb7e03..6d374bbba 100644 --- a/nezha-fronted/src/components/page/alert/alertRule.vue +++ b/nezha-fronted/src/components/page/alert/alertRule.vue @@ -21,7 +21,8 @@ - - { this.tools.loading = false + this.nowTime = this.utcTimeToTimezoneStr(response.time) if (response.code === 200) { for (let i = 0; i < response.data.list.length; i++) { response.data.list[i].status = response.data.list[i].status + '' diff --git a/nezha-fronted/src/components/page/asset/asset.vue b/nezha-fronted/src/components/page/asset/asset.vue index 610f6e526..169568089 100644 --- a/nezha-fronted/src/components/page/asset/asset.vue +++ b/nezha-fronted/src/components/page/asset/asset.vue @@ -21,7 +21,8 @@ - -
-
{{$t('overall.batchEdit')}}
+
{{$t('overall.batchEdit')}}
@@ -556,7 +558,7 @@ export default { }) }) }, - getSearchableMetaData () { + getSearchableMetaData (metaData) { return new Promise(resolve => { this.$get('asset/field/meta', { pageSize: -1 }).then(response => { if (response.code === 200) { @@ -569,7 +571,20 @@ export default { if (m.param) { const param = JSON.parse(m.param) if (param.items) { - data.push({ ...m, children: param.items.map(p => { return { ...p, id: p.name, metaId: m.id } }) }) + // param.items.map(p => { return { ...p, id: p.name, metaId: m.id, num: metaData.find(meta => meta.id === m.id && meta.option === p.name).num } }) + data.push({ + ...m, + children: param.items.map(p => { + const metaFind = metaData.find(meta => meta.id === m.id && meta.option === p.name) + return { + ...p, + id: p.name, + name: p.name, + metaId: m.id, + num: metaFind ? metaFind.num : 0 + } + }) + }) } } }) @@ -602,7 +617,7 @@ export default { // const titleSearchData = {} this.modelData.forEach(m => { m.value = [] - arr.push({ ...m, name: m.brand.name + '/' + m.name, value: m.id }) + arr.push({ ...m, name: m.brand.name + '/' + m.name, value: m.id, num: m.num }) // if (titleSearchData[m.brand.name]) { // titleSearchData[m.brand.name].children.push(m) // } else { diff --git a/nezha-fronted/src/components/page/config/dc.vue b/nezha-fronted/src/components/page/config/dc.vue index d99b58293..3880e6412 100644 --- a/nezha-fronted/src/components/page/config/dc.vue +++ b/nezha-fronted/src/components/page/config/dc.vue @@ -21,7 +21,8 @@ - - @@ -228,17 +229,6 @@ export default { } }, methods: { - statusChange (dc) { - this.$put(this.url, dc).then(response => { - if (response.code === 200) { - this.rightBox.show = false - this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') }) - } else { - this.$message.error(response.msg) - } - this.getTableData() - }) - }, getUserData () { return new Promise(resolve => { this.$get('sys/user', { pageSize: -1, pageNo: 1 }).then(response => { diff --git a/nezha-fronted/src/components/page/config/globalization.vue b/nezha-fronted/src/components/page/config/globalization.vue new file mode 100644 index 000000000..772205bc8 --- /dev/null +++ b/nezha-fronted/src/components/page/config/globalization.vue @@ -0,0 +1,155 @@ + + + diff --git a/nezha-fronted/src/components/page/config/model.vue b/nezha-fronted/src/components/page/config/model.vue index 8100895be..b7288b273 100644 --- a/nezha-fronted/src/components/page/config/model.vue +++ b/nezha-fronted/src/components/page/config/model.vue @@ -14,7 +14,8 @@ type="button" @click="add"> - { + window.location.reload() + }, 500) + } }, closeDialog () { this.authBindShow = false diff --git a/nezha-fronted/src/components/page/config/template/chartTemp.vue b/nezha-fronted/src/components/page/config/template/chartTemp.vue index 67705c48b..3a391c9a8 100644 --- a/nezha-fronted/src/components/page/config/template/chartTemp.vue +++ b/nezha-fronted/src/components/page/config/template/chartTemp.vue @@ -37,7 +37,8 @@ type="button" @click="add"> - - t.id) - } - this.$put('sys/user', user).then(response => { - if (response.code === 200) { - this.rightBox.show = false - this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') }) - } else { - this.$message.error(response.msg) - } - this.getTableData() - }) - }, edit (u, copyFlag) { this.$get(`${this.url}/${u.id}`).then(response => { const user = response.user diff --git a/nezha-fronted/src/components/page/config/util.vue b/nezha-fronted/src/components/page/config/util.vue deleted file mode 100644 index 6aa53f5f7..000000000 --- a/nezha-fronted/src/components/page/config/util.vue +++ /dev/null @@ -1,60 +0,0 @@ - - diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 4a74c794a..6d8e63f47 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -47,7 +47,8 @@ - - - - - { + const configUrl = 'static/config.json?Timestamp=' + new Date().getTime() if (to.path === '/login') { // 拦截登录页面,系统初始化检查 - const configUrl = 'static/config.json?Timestamp=' + new Date().getTime() Vue.http.get(configUrl).then(config => { get(config.body.baseUrl + 'setup/inited').then(res => { if (res.code === 200) { @@ -24,11 +24,33 @@ router.beforeEach((to, from, next) => { } } }) + if (!store.getters.i18nIsReady) { + get(config.body.baseUrl + 'sys/i18n/lang').then(res => { + if (res.code === 200) { + loadI18n(res.data) + store.commit('i18nReady', true) + } + }) + } }) } else if (sessionStorage.getItem('nz-token')) { + // 从localStorage加载i18n + if (!store.getters.i18nIsReady) { + Vue.http.get(configUrl).then(config => { + get(config.body.baseUrl + 'sys/i18n/lang').then(response => { + if (response.code === 200) { + loadI18n(response.data) + store.commit('i18nReady', true) + } + }) + }) + const langList = localStorage.getItem('nz-language-list') + if (langList) { + store.commit('setLangList', JSON.parse(langList)) + } + } new Promise(resolve => { if (store.getters.menuList.length === 0) { - const configUrl = 'static/config.json?Timestamp=' + new Date().getTime() 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)) diff --git a/nezha-fronted/src/router/index.js b/nezha-fronted/src/router/index.js index 3e4970a02..684737135 100644 --- a/nezha-fronted/src/router/index.js +++ b/nezha-fronted/src/router/index.js @@ -114,6 +114,10 @@ export default new Router({ path: '/system', component: resolve => require(['../components/page/config/system.vue'], resolve) }, + { + path: '/i18n', + component: resolve => require(['@/components/page/config/globalization.vue'], resolve) + }, { path: '/alertMessage', component: resolve => require(['../components/page/alert/alertMessage.vue'], resolve) diff --git a/nezha-fronted/src/store/index.js b/nezha-fronted/src/store/index.js index f399e6ee3..6094b6df7 100644 --- a/nezha-fronted/src/store/index.js +++ b/nezha-fronted/src/store/index.js @@ -35,7 +35,9 @@ const store = new Vuex.Store({ showTopoScreen: false, logo: '', isShrink: localStorage.getItem('nz-left-menu-shrink') == 'true', - metricsList: [] + metricsList: [], + langList: [], + i18nReady: false }, getters: { getLinkData (state) { @@ -71,6 +73,12 @@ const store = new Vuex.Store({ getMetricsList (state) { return state.metricsList }, + getLangList (state) { + return state.langList + }, + i18nIsReady (state) { + return state.i18nReady + } }, mutations: { /* 监听对象变化,用于顶部菜单与底部内容的同步 */ @@ -153,6 +161,12 @@ const store = new Vuex.Store({ }, setMetricsList (state, metricsList) { state.metricsList = [...metricsList] + }, + setLangList (state, langList) { + state.langList = langList + }, + i18nReady (state, ready) { + state.i18nReady = ready } }, actions: { diff --git a/nezha-fronted/src/store/user.js b/nezha-fronted/src/store/user.js index 932dde238..6d6f84845 100644 --- a/nezha-fronted/src/store/user.js +++ b/nezha-fronted/src/store/user.js @@ -1,7 +1,7 @@ -import { post, get } from '../http' +import { post, get } from '@/http' import router from '../router' import bus from '../libs/bus' -import { sortByOrderNum } from '../permission' +import { sortByOrderNum } from '@/permission' import moment from 'moment-timezone' import { theme } from '@/components/common/js/constants'