diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/endpointTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/endpointTab.vue index b1a798a99..a0f00cef5 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/endpointTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/endpointTab.vue @@ -81,6 +81,12 @@ + + + +
  -
+
@@ -94,15 +94,27 @@
{{item.key}}={{item.value}}
- +
+ + +
+
{{item.key}}={{item.value}}
+
+ +
+
@@ -151,6 +163,26 @@ + + +
+
{{p.key}}={{p.value}}
+
+ + {{scope.row.labels.length > 8 ? scope.row.labels.substring(0, 8) + '...' : scope.row.labels}} + +
+ + + + + +
+ + +
+
+
+ + = + + +
+
+
+ +
+
+
+
@@ -262,10 +311,12 @@ currentModuleCopy: {}, currentProjectCopy: {id: ''}, tempParamObj: [], + tempLabelModule: [], tempEndpoint: {}, tempEndpoint2: {}, rightBox: {show: false, title: this.$t('project.endpoint.createEndpoint'),isEdit: false}, editParamBox: {show: false, top: 0, left: 0, type: 0}, //param编辑弹框 + editLabelsBox: {show: false, top: 0, left: 0, type: 0}, //param编辑弹框 moduleParamShow: false, //module默认参数param悬浮窗 assetSearch: {host: '', sn: '', text: '', label: 'IP', dropdownShow: false}, //侧滑框中asset的搜索相关 assetPageObj: {pageNo: 1, pageSize: -1}, @@ -278,18 +329,23 @@ { label: this.$t("project.endpoint.asset"), prop: 'asset', - width: 121, + width: 76, show: true, },{ label: this.$t("project.endpoint.host"), prop: 'host', - width: 121, + width: 76, show: true, },{ label: this.$t("project.endpoint.port"), prop: 'port', width: 54, show: true, + },{ + label: this.$t("project.endpoint.labels"), + prop: 'labels', + width: 90, + show: true, },{ label: this.$t("project.endpoint.param"), prop: 'param', @@ -350,6 +406,50 @@ this.editParamBox.show = show; }, + //子弹框控制 obj: module或endpoint对象 type:1module2endpoint + showEditLabelsBox(show, obj, type, e) { + //editLabelsBox tempLabelModule labelModule + console.log(123123123123,show, obj, type, e,this.tempLabelModule); + if (show) { + let position = e.target.getBoundingClientRect(); + this.editLabelsBox.type = type; + if (this.editLabelsBox.type == 2) { + this.tempEndpoint = obj; + } + this.editLabelsBox.top = position.top - 227; + this.editLabelsBox.left = position.left - 48; + if (!obj.labels) { + this.$set(obj, 'labelModule', []); + this.tempLabelModule = []; + } else { + this.tempLabelModule = JSON.parse(JSON.stringify(obj.labelModule)); + } + } else { + if (!this.editLabelsBox.show) { + return; + } + for (let i = 0; i < this.tempLabelModule.length; i++) { + if (!this.tempLabelModule[i].key || !this.tempLabelModule[i].value) { + this.tempLabelModule.splice(i, 1); + i--; + } + } + if (this.editLabelsBox.type == 1) { + this.currentModuleCopy.labelModule = this.tempLabelModule; + this.currentModuleCopy.labels = this.paramToJson(this.tempLabelModule); + } else if (this.editLabelsBox.type == 2) { + for (let i = 0; i < this.endpointList.length; i++) { + if (this.endpointList[i].asset.id == this.tempEndpoint.asset.id) { + this.endpointList[i].labels = this.paramToJson(this.tempLabelModule); + this.endpointList[i].labelModule = this.tempLabelModule; + break; + } + } + } + this.tempLabelModule = []; + } + this.editLabelsBox.show = show; + }, clickOutside() { this.esc(false); }, @@ -368,7 +468,15 @@ removeParam(index) { this.tempParamObj.splice(index, 1); }, + // 新增labels + addLabels() { + this.tempLabelModule.push({key: '', value: ''}); + }, + // 移除单个param + removeLabels(index) { + this.tempLabelModule.splice(index, 1); + }, //编辑endpoint toEditEndpoint(endpoint) { for (let i = 0; i < this.endpointList.length; i++) { @@ -462,6 +570,7 @@ this.endpoint.moduleId = ''; this.endpoint.projectId = project.id; this.editParamBox.show = false; + this.editLabelsBox.show = false; this.tempParamObj = []; this.endpointList = []; this.getAssetList(); @@ -471,6 +580,7 @@ changeModule(module) { this.endpoint.moduleId = module.id; this.editParamBox.show = false; + this.editLabelsBox.show = false; this.tempParamObj = []; }, @@ -525,6 +635,8 @@ host: item.host, param: this.currentModuleCopy.param ? this.currentModuleCopy.param : "", paramObj: this.currentModuleCopy.paramObj ? this.currentModuleCopy.paramObj : {}, + labels: this.currentModuleCopy.labels ? this.currentModuleCopy.labels : "", + labelModule: this.currentModuleCopy.labelModule ? this.currentModuleCopy.labelModule : {}, port: this.currentModuleCopy.port, path: this.currentModuleCopy.path, moduleId: this.currentModuleCopy.id @@ -576,10 +688,15 @@ for (let i = 0; i < response.data.list.length; i++) { try { let tempObj = JSON.parse(response.data.list[i].param); + let tempObj1 = JSON.parse(response.data.list[i].labels); response.data.list[i].paramObj = []; + response.data.list[i].labelsModule = []; for (let k in tempObj) { response.data.list[i].paramObj.push({key: k, value: tempObj[k]}) } + for (let k in tempObj1) { + response.data.list[i].labelsModule.push({key: k, value: tempObj1[k]}) + } } catch(err) { //console.info(response.data.list[i], err); } @@ -601,7 +718,7 @@ //对endpointList进行处理,避免携带过多无用数据 let endpointList = []; this.endpointList.forEach((item, index) => { - let endpoint = {moduleId: item.moduleId, assetId: item.assetId, port: item.port, param: item.param, path: item.path, host: item.host}; + let endpoint = {moduleId: item.moduleId, assetId: item.assetId, port: item.port, param: item.param, path: item.path, host: item.host,labels:item.labels}; endpointList.push(endpoint); }); this.$refs.addEndpoint.validate((valid) => { @@ -627,6 +744,8 @@ this.endpointList[i].port = this.currentModuleCopy.port; this.endpointList[i].param = this.currentModuleCopy.param; this.endpointList[i].paramObj = this.currentModuleCopy.paramObj; + this.endpointList[i].labels = this.currentModuleCopy.labels; + this.endpointList[i].labelModule = this.currentModuleCopy.labelModule; this.endpointList[i].path = this.currentModuleCopy.path; } this.$message({duration: 1000, type: 'success', message: this.$t("tip.coverSuccess")}); @@ -702,11 +821,11 @@ immediate: true, handler(n, o) { if (n.type && n.type.toLowerCase() == 'snmp') { - this.endpointTableTitle[3].show = false; this.endpointTableTitle[4].show = false; + this.endpointTableTitle[5].show = false; } else { - this.endpointTableTitle[3].show = true; this.endpointTableTitle[4].show = true; + this.endpointTableTitle[5].show = true; } } }, @@ -831,15 +950,22 @@ } .module-info-port { width: 53px; - right: 209px; + right: 309px; } .module-info-port-snmp { - right: 50px; + right: 142px; } .module-info-param { width: 89px; right: 116px; } + .module-info-labels { + width: 89px; + right: 216px; + } + .module-info-labels-snmp { + right: 50px; + } .module-info-path { width: 70px; right: 42px; diff --git a/nezha-fronted/src/components/common/rightBox/editEndpointBox.vue b/nezha-fronted/src/components/common/rightBox/editEndpointBox.vue index 1a9b3c9b1..9ed548a47 100644 --- a/nezha-fronted/src/components/common/rightBox/editEndpointBox.vue +++ b/nezha-fronted/src/components/common/rightBox/editEndpointBox.vue @@ -84,6 +84,34 @@
+ + + +
+ + + + + + + +
+ +
+ +
+ + + + = + + + + +
+
+
+
@@ -194,6 +222,35 @@ } }, + // 新增label + addLabel() { + console.log(123123); + this.endpoint.labelModule.push({key: '', value: ''}); + this.$nextTick(() => { + this.$refs.labelBoxScrollbar.update(); + }); + }, + // 移除单个Label + removeLabel(index) { + this.endpoint.labelModule.splice(index, 1); + this.$nextTick(() => { + this.$refs.labelBoxScrollbar.update(); + }); + }, + + //将labels转为json字符串格式 + labelsToJson(param) { + let tempParam = {}; + for (let i = 0; i < param.length; i++) { + eval('tempParam["' + param[i].key + '"]="' + param[i].value + '"'); + } + let jsonString = JSON.stringify(tempParam); + if (jsonString == '{}') { + return ""; + } else { + return jsonString; + } + }, /*获取project列表*/ getProjectList() { return new Promise(resolve => { @@ -296,12 +353,12 @@ } }); }, - //保存endpoint save() { this.$refs.endpointForm.validate((valide=>{ if(valide){ this.editEndpoint.param = this.paramToJson(this.editEndpoint.paramObj); + this.editEndpoint.labels = this.labelsToJson(this.editEndpoint.labelModule); let requestData = []; requestData.push(this.editEndpoint); this.$put('endpoint', requestData).then(response => { diff --git a/nezha-fronted/src/components/common/rightBox/moduleBox.vue b/nezha-fronted/src/components/common/rightBox/moduleBox.vue index 79f3b18ab..3cec6f3db 100644 --- a/nezha-fronted/src/components/common/rightBox/moduleBox.vue +++ b/nezha-fronted/src/components/common/rightBox/moduleBox.vue @@ -268,6 +268,34 @@ + + +
+ + + + + + + +
+ +
+ +
+ + + + = + + + + +
+
+
+
+ @@ -446,7 +474,7 @@ this.$nextTick(()=>{ this.$refs.selectWalk.show(); }) - this.editModule.port= 161 + this.editModule.port= 161; } this.updateScrollbar(); }, @@ -505,7 +533,11 @@ }, /*保存*/ save() { + if(this.editModule.type.toLowerCase() == 'snmp'){ + this.editModule.paramObj=[];//处理snmp可能会带有param的问题 + } this.editModule.param = this.paramToJson(this.editModule.paramObj); + this.editModule.labels = this.labelsToJson(this.editModule.labelModule); this.$refs.moduleForm.validate((valid) => { if (valid) { if (this.editModule.type.toLowerCase() == 'snmp') { @@ -585,7 +617,6 @@ this.$refs.paramBoxScrollbar.update(); }); }, - // 移除单个param removeParam(index) { this.editModule.paramObj.splice(index, 1); @@ -593,7 +624,21 @@ this.$refs.paramBoxScrollbar.update(); }); }, - + // 新增label + addLabel() { + console.log(123123); + this.editModule.labelModule.push({key: '', value: ''}); + this.$nextTick(() => { + this.$refs.labelBoxScrollbar.update(); + }); + }, + // 移除单个Label + removeLabel(index) { + this.editModule.labelModule.splice(index, 1); + this.$nextTick(() => { + this.$refs.labelBoxScrollbar.update(); + }); + }, //将param转为json字符串格式 paramToJson(param) { let tempParam = {}; @@ -607,6 +652,19 @@ return jsonString; } }, + //将labels转为json字符串格式 + labelsToJson(param) { + let tempParam = {}; + for (let i = 0; i < param.length; i++) { + eval('tempParam["' + param[i].key + '"]="' + param[i].value + '"'); + } + let jsonString = JSON.stringify(tempParam); + if (jsonString == '{}') { + return ""; + } else { + return jsonString; + } + }, updateScrollbar() { this.$refs.scrollbar.update(); } diff --git a/nezha-fronted/src/components/common/searchSelectInfo.vue b/nezha-fronted/src/components/common/searchSelectInfo.vue index 1b4d4f79a..f03597287 100644 --- a/nezha-fronted/src/components/common/searchSelectInfo.vue +++ b/nezha-fronted/src/components/common/searchSelectInfo.vue @@ -46,6 +46,9 @@ }, { value: 2, label: i18n.t('asset.notInStock') + }, { + value: 3, + label: i18n.t('asset.Suspended') } ], pingStatus:[ diff --git a/nezha-fronted/src/components/page/asset/asset.vue b/nezha-fronted/src/components/page/asset/asset.vue index a81753a0e..a5d7892f2 100644 --- a/nezha-fronted/src/components/page/asset/asset.vue +++ b/nezha-fronted/src/components/page/asset/asset.vue @@ -87,7 +87,7 @@
{{ $t('asset.inStock')}} {{ $t('asset.notInStock')}} - {{ $t('asset.offStreamUnit')}} + {{ $t('asset.Suspended')}}
@import '../../charts/chart'; + .project-calendar .el-input__inner { - height: 24px; + height: 24px; } + .change-time-height { height: 23px; } + .date-pick-group { display: flex; align-items: center; justify-content: space-between; } + .date-pick-group button:first-of-type { margin-right: 4px; } + .date-pick-group button:last-of-type { margin-left: 4px; } @@ -25,7 +30,9 @@
- + @@ -87,19 +95,28 @@ :prop="$tableSet.propTitle(item.prop,'project')" :sort-orders="['ascending', 'descending']" > - @@ -184,95 +216,113 @@ import bus from '../../../libs/bus' import facade from '@/components/common/project/projectFacade' import deleteButton from "../../common/deleteButton"; + export default { - name: "project2", - components: { + name:"project2", + components:{ 'export-excel':exportXLSX, - 'loading': loading, - 'panel-tab': panelTab, + 'loading':loading, + 'panel-tab':panelTab, facade, 'delete-button':deleteButton, }, - data() { + data(){ return { - rightBox: { - module: {show: false}, - addEndpoint: {show: false}, - editEndpoint: {show: false}, + rightBox:{ + module:{show:false}, + addEndpoint:{show:false}, + editEndpoint:{show:false}, }, /*二级页面相关*/ - bottomBox: { - endpoint: {}, //asset详情 - endpointDetail: null, - mainResizeShow: true, //dom高度改变时部分内容是否展示 - subResizeShow: true, - isFullScreen: false, //是否是全屏,用来控制拖动条是否展示, - showSubList: false, - targetTab: '', + bottomBox:{ + endpoint:{}, //asset详情 + endpointDetail:null, + mainResizeShow:true, //dom高度改变时部分内容是否展示 + subResizeShow:true, + isFullScreen:false, //是否是全屏,用来控制拖动条是否展示, + showSubList:false, + targetTab:'', }, - mainTableHeight: this.$tableHeight.normal, //主列表table高度 - ready: false, + mainTableHeight:this.$tableHeight.normal, //主列表table高度 + ready:false, /*工具参数*/ - tools: { - loading: false, //是否显示table加载动画 - toTopBtnTop: this.$tableHeight.toTopBtnTop, //to-top按钮的top属性 - tableHover: false, //控制滚动条和top按钮同时出现 - showTopBtn: false, //显示To top按钮 - showCustomTableTitle: false, //自定义列弹框是否显示 - customTableTitle: [], //自定义列工具的数据 + tools:{ + loading:false, //是否显示table加载动画 + toTopBtnTop:this.$tableHeight.toTopBtnTop, //to-top按钮的top属性 + tableHover:false, //控制滚动条和top按钮同时出现 + showTopBtn:false, //显示To top按钮 + showCustomTableTitle:false, //自定义列弹框是否显示 + customTableTitle:[], //自定义列工具的数据 }, batchDeleteObjs:[], - tableId: 'projectTable', //需要分页的table的id,用于记录每页数量 - userData: [], + tableId:'projectTable', //需要分页的table的id,用于记录每页数量 + userData:[], - endpoint: {id: '', host: '', port: '', param: '', path: '', asset: {}, project: {}, module: {}, moduleId: '', assetId: '', paramObj: []}, - tableTitle: [ + endpoint:{ + id:'', + host:'', + port:'', + param:'', + path:'', + asset:{}, + project:{}, + module:{}, + moduleId:'', + assetId:'', + paramObj:[] + }, + tableTitle:[ { - label: this.$t("project.endpoint.endpointId"), - prop: 'id', - show: true, - width: 150 + label:this.$t("project.endpoint.endpointId"), + prop:'id', + show:true, + width:150 },{ - label: this.$t("project.endpoint.asset"), - prop: 'asset', - show: true, + label:this.$t("project.endpoint.asset"), + prop:'asset', + show:true, },{ - label: this.$t("project.endpoint.host"), - prop: 'host', - show: true, + label:this.$t("project.endpoint.host"), + prop:'host', + show:true, width:200, },{ - label: this.$t("project.endpoint.port"), - prop: 'port', - show: true, + label:this.$t("project.endpoint.port"), + prop:'port', + show:true, width:100, },{ - label: this.$t("overall.type"), - prop: 'type', - show: false, + label:this.$t("overall.type"), + prop:'type', + show:false, width:200, },{ - label: this.$t("project.endpoint.param"), - prop: 'param', - show: true, + label:this.$t("project.endpoint.labels"), + prop:'labels', + show:true, width:200, },{ - label: this.$t("project.endpoint.path"), - prop: 'path', - show: true, + label:this.$t("project.endpoint.param"), + prop:'param', + show:true, width:200, },{ - label: this.$t("alert.list.state"), - prop: 'state', - show: true, + label:this.$t("project.endpoint.path"), + prop:'path', + show:true, + width:200, + },{ + label:this.$t("alert.list.state"), + prop:'state', + show:true, width:80, },{ - label: this.$t("project.endpoint.alerts"), - prop: 'alerts', - show: true, + label:this.$t("project.endpoint.alerts"), + prop:'alerts', + show:true, width:150, }, // { @@ -281,86 +331,91 @@ // show: true, // }, { - label: this.$t('config.account.option'), - prop: 'option', - show: true, - width: 120 + label:this.$t('config.account.option'), + prop:'option', + show:true, + width:120 } ], - endpointTableData: [], - endpointPageObj: { - pageNo: 1, - pageSize: 50, + endpointTableData:[], + endpointPageObj:{ + pageNo:1, + pageSize:50, total:0 }, currentProjectTitle:'', - moduleList: [], - projectList: [], - pageType: 'project', //project endpoint - currentProject: {id: '', name: '', remark: ''}, //endpoint弹框、module列表用来回显project - module: {}, //编辑的module - blankModule: {id: '', type: '', name: '', project: {}, port: '', path: '', param: '', paramObj: [], snmpParam: ''}, //空白module - currentModule: {id: '', type: '', name: '', project: {}, port: '', path: '', param: '', paramObj: [], snmpParam: ''}, //用来回显的module - endpointSearchLabel: {moduleId: ''}, //endpoint搜索参数 - endpointSearchMsg: { //给搜索框子组件传递的信息 - zheze_none: true, - searchLabelList: [{ - id: 1, - name: "ID", - type: 'input', - label: 'id', - disabled: false - }, { - id: 11, - name: this.$t('asset.asset'), + moduleList:[], + projectList:[], + pageType:'project', //project endpoint + currentProject:{id:'',name:'',remark:''}, //endpoint弹框、module列表用来回显project + module:{}, //编辑的module + blankModule:{id:'',type:'',name:'',project:{},port:'',path:'',param:'',paramObj:[],snmpParam:''}, //空白module + currentModule:{id:'',type:'',name:'',project:{},port:'',path:'',param:'',paramObj:[],snmpParam:''}, //用来回显的module + endpointSearchLabel:{moduleId:''}, //endpoint搜索参数 + endpointSearchMsg:{ //给搜索框子组件传递的信息 + zheze_none:true, + searchLabelList:[{ + id:1, + name:"ID", + type:'input', + label:'id', + disabled:false + },{ + id:11, + name:this.$t('asset.asset'), // name: this.$t('asset.asset'), - type: 'query', - label: 'query', - disabled: false + type:'query', + label:'query', + disabled:false }], }, } }, - methods: { + methods:{ // 全屏 - fullScreen() { - let vm = this; + fullScreen(){ + let vm=this; this.$bottomBoxWindow.fullScreen(vm); }, // 退出全屏 - exitFullScreen() { - let vm = this; + exitFullScreen(){ + let vm=this; this.$bottomBoxWindow.exitFullScreen(vm); }, // 鼠标拖动二级列表 - listResize(e) { - let vm = this; - this.$bottomBoxWindow.listResize(vm, e); + listResize(e){ + let vm=this; + this.$bottomBoxWindow.listResize(vm,e); }, - getEndpointTableData() { - if(this.currentModule && this.currentModule.id) { - this.pageType = 'endpoint'; - this.endpointSearchLabel.moduleId = this.currentModule.id; - this.$set(this.endpointSearchLabel, 'pageNo', this.endpointPageObj.pageNo); - this.$set(this.endpointSearchLabel, 'pageSize', this.endpointPageObj.pageSize); - this.tools.loading = true; - this.$get('endpoint', this.endpointSearchLabel).then(response => { - this.tools.loading = false; - if (response.code === 200) { - for (let i = 0; i < response.data.list.length; i++) { - try { - let tempObj = JSON.parse(response.data.list[i].param); - response.data.list[i].paramObj = []; - for (let k in tempObj) { - response.data.list[i].paramObj.push({key: k, value: tempObj[k]}) + getEndpointTableData(){ + if(this.currentModule&&this.currentModule.id){ + this.pageType='endpoint'; + this.endpointSearchLabel.moduleId=this.currentModule.id; + this.$set(this.endpointSearchLabel,'pageNo',this.endpointPageObj.pageNo); + this.$set(this.endpointSearchLabel,'pageSize',this.endpointPageObj.pageSize); + this.tools.loading=true; + this.$get('endpoint',this.endpointSearchLabel).then(response=>{ + this.tools.loading=false; + if(response.code===200){ + for(let i=0; i{ - if(response.code == 200){ - this.projectList = response.data.list; + getProjectList(){ + this.$get('project',{pageSize:-1}).then(response=>{ + if(response.code==200){ + this.projectList=response.data.list; } }) }, - getProjectModule(projectId) { - let moduleList = JSON.parse(JSON.stringify(this.moduleList)); - return moduleList.filter((item,index) => { - return item.project.id == projectId; + getProjectModule(projectId){ + let moduleList=JSON.parse(JSON.stringify(this.moduleList)); + return moduleList.filter((item,index)=>{ + return item.project.id==projectId; }) }, - detailProject(project) { - this.pageType = 'project'; - if(project) { - this.currentProject = project; - this.currentProjectTitle = project.id + ""; + detailProject(project){ + this.pageType='project'; + if(project){ + this.currentProject=project; + this.currentProjectTitle=project.id+""; } - this.currentModule = {}; + this.currentModule={}; }, - closeAddEndpointRightBox(refresh) { - this.rightBox.addEndpoint.show = false; - if (refresh) { + closeAddEndpointRightBox(refresh){ + this.rightBox.addEndpoint.show=false; + if(refresh){ this.getEndpointTableData(); } }, - closeEditEndpointRightBox(refresh) { - this.rightBox.editEndpoint.show = false; - if (refresh) { + closeEditEndpointRightBox(refresh){ + this.rightBox.editEndpoint.show=false; + if(refresh){ this.getEndpointTableData(); } }, - getModuleList() { - this.$get('module', { pageSize: -1, pageNo: 1}).then(response => { - if (response.code === 200) { - this.moduleList = response.data.list; - for (let i = 0; i < this.moduleList.length; i++) { - try { - let tempObj = JSON.parse(this.moduleList[i].param); - this.$set(this.moduleList[i], 'paramObj', []); - for (let k in tempObj) { - this.moduleList[i].paramObj.push({key: k, value: tempObj[k]}); + getModuleList(){ + this.$get('module',{pageSize:-1,pageNo:1}).then(response=>{ + if(response.code===200){ + this.moduleList=response.data.list; + for(let i=0; i { - this.$delete("endpoint?ids=" + endpoint.id).then(response => { - if (response.code === 200) { - this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")}); + delEndpoint(endpoint){ + this.$confirm(this.$t("tip.confirmDelete"),{ + confirmButtonText:this.$t("tip.yes"), + cancelButtonText:this.$t("tip.no"), + type:'warning' + }).then(()=>{ + this.$delete("endpoint?ids="+endpoint.id).then(response=>{ + if(response.code===200){ + this.$message({duration:1000,type:'success',message:this.$t("tip.deleteSuccess")}); this.getEndpointTableData(); - } else { + }else{ this.$message.error(response.msg); } }); }); }, - jumpToAlertMsg(endpoint) { - this.endpoint = Object.assign({}, endpoint); - this.bottomBox.targetTab = 'alertMessage'; - this.bottomBox.showSubList = true; + jumpToAlertMsg(endpoint){ + this.endpoint=Object.assign({},endpoint); + this.bottomBox.targetTab='alertMessage'; + this.bottomBox.showSubList=true; }, - addModule() { - this.module = this.newModule(); - this.rightBox.module.show = true; - this.$nextTick(() => { + addModule(){ + this.module=this.newModule(); + this.rightBox.module.show=true; + this.$nextTick(()=>{ this.$refs.moduleBox.initWalk(); }); }, - newModule() { + newModule(){ return JSON.parse(JSON.stringify(this.blankModule)); }, //搜索 - endpointSearch(searchObj) { + endpointSearch(searchObj){ let orderBy=''; if(this.endpointSearchLabel.orderBy){ orderBy=this.endpointSearchLabel.orderBy } - this.endpointSearchLabel = {}; - this.endpointPageObj.pageNo = 1; - for (let item in searchObj) { - if (searchObj[item]) { - this.$set(this.endpointSearchLabel, item, searchObj[item]); + this.endpointSearchLabel={}; + this.endpointPageObj.pageNo=1; + for(let item in searchObj){ + if(searchObj[item]){ + this.$set(this.endpointSearchLabel,item,searchObj[item]); } } if(orderBy){ - this.$set(this.endpointSearchLabel, 'orderBy', orderBy); + this.$set(this.endpointSearchLabel,'orderBy',orderBy); } this.getEndpointTableData(); }, - dateFormat(time) { - if (!time) { + dateFormat(time){ + if(!time){ return '-'; } - let date = new Date(time * 1000); - let year = date.getFullYear(); - let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; - let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); - let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(); - let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(); - let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); + let date=new Date(time*1000); + let year=date.getFullYear(); + let month=date.getMonth()+1<10?"0"+(date.getMonth()+1):date.getMonth()+1; + let day=date.getDate()<10?"0"+date.getDate():date.getDate(); + let hours=date.getHours()<10?"0"+date.getHours():date.getHours(); + let minutes=date.getMinutes()<10?"0"+date.getMinutes():date.getMinutes(); + let seconds=date.getSeconds()<10?"0"+date.getSeconds():date.getSeconds(); - return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds; + return year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds; }, - viewAsset(endpoint) { - this.endpoint = Object.assign({}, endpoint); - this.bottomBox.targetTab = 'assetDetail'; - this.bottomBox.showSubList = true; + viewAsset(endpoint){ + this.endpoint=Object.assign({},endpoint); + this.bottomBox.targetTab='assetDetail'; + this.bottomBox.showSubList=true; }, - query(endpoint) { - this.endpoint = Object.assign({}, endpoint); - this.bottomBox.targetTab = 'endpointQuery'; - this.bottomBox.showSubList = true; + query(endpoint){ + this.endpoint=Object.assign({},endpoint); + this.bottomBox.targetTab='endpointQuery'; + this.bottomBox.showSubList=true; }, getStateContent:function(row){ if(row){ - if(row.state == 1){ + if(row.state==1){ return 'up'; }else{ return `down:${this.getStateErrorMsg(row)}` } } }, - convertToDetail(obj) { - let detail = { - project: obj.project.name, - module: obj.module.name, - asset: obj.asset.host, - host: obj.host, - port: obj.port, - path: obj.path, - param: obj.param + convertToDetail(obj){ + let detail={ + project:obj.project.name, + module:obj.module.name, + asset:obj.asset.host, + host:obj.host, + port:obj.port, + path:obj.path, + param:obj.param }; return detail; }, @@ -565,11 +623,13 @@ return hours+':'+minutes; }, - getStateErrorMsg(row) { - let errCodes = [230009, 230010, 230011]; + getStateErrorMsg(row){ + let errCodes=[230009,230010,230011]; if(row){ - if(row.state == 0){ - if(errCodes.find((item)=>{return row.stateInfo.code == item})){ + if(row.state==0){ + if(errCodes.find((item)=>{ + return row.stateInfo.code==item + })){ return this.$t('project.endpoint.stateInfo_'+row.stateInfo.code) }else{ return row.stateInfo.msg; @@ -578,45 +638,45 @@ } } }, - assetConvertToDetail(obj) { - let detail = JSON.parse(JSON.stringify(obj)); - detail.state = obj.state == 1 ? this.$t('asset.inStock'): this.$t('asset.notInStock'); - detail.assetType = obj.model.type.value; - detail.vendorModel = obj.model.vendor.value + " " + obj.model.name; - detail.dataCenter = obj.idc ? obj.idc.name : ""; - detail.location = obj.idc ? obj.idc.location : ""; - detail.principal = obj.idc ? this.getPrincipalName(obj.idc.principal) : ""; - detail.tel = obj.idc ? obj.idc.tel : ""; - detail.cabinet = obj.cabinet ? obj.cabinet.name : ""; - detail.uSize = obj.cabinet ? obj.cabinet.uSize : ""; - detail.remark = obj.idc ? obj.idc.remark : ""; - !obj.accounts && (obj.accounts = []); - if (obj.accounts.length > 0) { - let account = obj.accounts[0]; - detail.protocol = account.protocol; - detail.account = account.user; - let loginType = ""; - if (account.authType == 1) { - loginType = this.$t('asset.password'); - } else if (account.authType == 2) { - loginType = this.$t('asset.ssh'); + assetConvertToDetail(obj){ + let detail=JSON.parse(JSON.stringify(obj)); + detail.state=obj.state==1?this.$t('asset.inStock'):this.$t('asset.notInStock'); + detail.assetType=obj.model.type.value; + detail.vendorModel=obj.model.vendor.value+" "+obj.model.name; + detail.dataCenter=obj.idc?obj.idc.name:""; + detail.location=obj.idc?obj.idc.location:""; + detail.principal=obj.idc?this.getPrincipalName(obj.idc.principal):""; + detail.tel=obj.idc?obj.idc.tel:""; + detail.cabinet=obj.cabinet?obj.cabinet.name:""; + detail.uSize=obj.cabinet?obj.cabinet.uSize:""; + detail.remark=obj.idc?obj.idc.remark:""; + !obj.accounts&&(obj.accounts=[]); + if(obj.accounts.length>0){ + let account=obj.accounts[0]; + detail.protocol=account.protocol; + detail.account=account.user; + let loginType=""; + if(account.authType==1){ + loginType=this.$t('asset.password'); + }else if(account.authType==2){ + loginType=this.$t('asset.ssh'); } - detail.loginType = loginType; - detail.port = account.port; + detail.loginType=loginType; + detail.port=account.port; } return detail; }, - getPrincipalName(data) { - for (let item in this.userData) { - if (this.userData[item].userId === data) { + getPrincipalName(data){ + for(let item in this.userData){ + if(this.userData[item].userId===data){ return this.userData[item].username } } }, - getUserData() { - this.$get('sys/user/list').then(response => { - if (response.code === 200) { - this.userData = response.data.list + getUserData(){ + this.$get('sys/user/list').then(response=>{ + if(response.code===200){ + this.userData=response.data.list } }) }, @@ -633,80 +693,80 @@ if(item.order==='descending'){ orderBy='-'+item.prop; } - this.$set(this.endpointSearchLabel, "orderBy", orderBy); + this.$set(this.endpointSearchLabel,"orderBy",orderBy); this.getEndpointTableData(); }, - initEvent() { - bus.$on("project-page-type", pageType => { - this.pageType = pageType; + initEvent(){ + bus.$on("project-page-type",pageType=>{ + this.pageType=pageType; }); - bus.$on("current-project-change", project => { - this.currentProject = project; + bus.$on("current-project-change",project=>{ + this.currentProject=project; }); - bus.$on("current-module-change", module => { - this.currentModule = module; + bus.$on("current-module-change",module=>{ + this.currentModule=module; this.bottomBox.showSubList=false; }); - bus.$on("project-list-change", () => { + bus.$on("project-list-change",()=>{ this.getProjectList(); }); - bus.$on("module-list-change", menu => { + bus.$on("module-list-change",menu=>{ this.getModuleList(); }); - bus.$on("endpoint-list-change", menu => { + bus.$on("endpoint-list-change",menu=>{ this.getEndpointTableData(); }); }, - messageStyle(e) { - if (e.column.label == 'Alerts' || e.column.label == this.$t("project.endpoint.alerts")) { - if (e.row.alertNum > 0) { + messageStyle(e){ + if(e.column.label=='Alerts'||e.column.label==this.$t("project.endpoint.alerts")){ + if(e.row.alertNum>0){ return 'danger'; - } else { + }else{ return 'success'; } } return ''; }, }, - created() { - this.currentProject = this.$store.state.currentProject; + created(){ + this.currentProject=this.$store.state.currentProject; this.getModuleList(); this.getUserData(); this.getProjectList(); }, - mounted() { + mounted(){ //初始化表头 - this.tools.customTableTitle = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path) - ? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path)) - : this.tableTitle; + this.tools.customTableTitle=localStorage.getItem("nz-tableTitle-"+localStorage.getItem("nz-username")+"-"+this.$route.path) + ?JSON.parse(localStorage.getItem("nz-tableTitle-"+localStorage.getItem("nz-username")+"-"+this.$route.path)) + :this.tableTitle; //是否存在分页缓存 - let pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId); - if (pageSize) { - this.endpointPageObj.pageSize = pageSize + let pageSize=localStorage.getItem('nz-pageSize-'+localStorage.getItem('nz-username')+'-'+this.tableId); + if(pageSize){ + this.endpointPageObj.pageSize=pageSize } - setTimeout(() => { - this.ready = true; - }, 300); + setTimeout(()=>{ + this.ready=true; + },300); this.initEvent(); //resize时刷新左侧列表滚动条 - let vm = this; - window.onresize = function() { + let vm=this; + window.onresize=function(){ // vm.$refs.leftScrollbar.update(); }; }, - computed: { - itemTip() { - return function(id, content, ready) { - let className = "item-tip-show"; - this.$nextTick(() => { - if (ready) { - let cellDom = document.querySelector(`#module-${id}`); - let spanDom = document.querySelector(`#module-${id}>span`); - if (cellDom.offsetWidth - 16 <= spanDom.offsetWidth) { + computed:{ + itemTip(){ + return function(id,content,ready){ + let className="item-tip-show"; + this.$nextTick(()=>{ + if(ready){ + let cellDom=document.querySelector(`#module-${id}`); + let spanDom=document.querySelector(`#module-${id}>span`); + if(cellDom.offsetWidth-16<=spanDom.offsetWidth){ document.querySelector(`#module-${id}>.el-popover`).classList.add(className); - } else { + }else{ document.querySelector(`#module-${id}>.el-popover`).classList.remove(className); } } @@ -718,103 +778,108 @@ return this.$store.getters.getReloadFacade }, }, - watch: { - pageType(n) { - if (n == 'endpoint') { - this.$nextTick(() => { + watch:{ + pageType(n){ + if(n=='endpoint'){ + this.$nextTick(()=>{ //绑定滚动条事件,控制top按钮 - let el = this.$refs.endpointTable.$el.querySelector(".el-table__body-wrapper"); - if (el._ps_) { - el.addEventListener("ps-scroll-y", () => { - if (el._ps_.scrollbarYTop > 50) { - this.tools.showTopBtn = true; - } else { - this.tools.showTopBtn = false; + let el=this.$refs.endpointTable.$el.querySelector(".el-table__body-wrapper"); + if(el._ps_){ + el.addEventListener("ps-scroll-y",()=>{ + if(el._ps_.scrollbarYTop>50){ + this.tools.showTopBtn=true; + }else{ + this.tools.showTopBtn=false; } }); - el.addEventListener("mouseenter", () => { - this.tools.tableHover = true; + el.addEventListener("mouseenter",()=>{ + this.tools.tableHover=true; }); - el.addEventListener("mouseleave", () => { - this.tools.tableHover = false; + el.addEventListener("mouseleave",()=>{ + this.tools.tableHover=false; }); } }); } }, - currentModule(n, o) { - this.endpointPageObj.pageNo = 1; - if (n && n.id) { + currentModule(n,o){ + this.endpointPageObj.pageNo=1; + if(n&&n.id){ this.getEndpointTableData(); - } else { - this.endpointTableData = []; + }else{ + this.endpointTableData=[]; } }, - "bottomBox.showSubList": function(n) { - let vm = this; - this.$bottomBoxWindow.showSubListWatch(vm, n); + "bottomBox.showSubList":function(n){ + let vm=this; + this.$bottomBoxWindow.showSubListWatch(vm,n); }, - endpoint: { - deep: true, - handler(n) { - this.bottomBox.endpointDetail = this.convertToDetail(n); - this.$get('asset', {id: n.assetId}).then(response => { - if (response.code === 200) { - this.bottomBox.assetDetail = this.assetConvertToDetail(response.data.list[0]); + endpoint:{ + deep:true, + handler(n){ + this.bottomBox.endpointDetail=this.convertToDetail(n); + this.$get('asset',{id:n.assetId}).then(response=>{ + if(response.code===200){ + this.bottomBox.assetDetail=this.assetConvertToDetail(response.data.list[0]); } }); } }, }, - destroyed() { - window.onresize = null; + destroyed(){ + window.onresize=null; } } - @@ -976,85 +1069,105 @@ margin: 0 3px; min-width: 25px; } + .right-sub-box .el-pagination button, .right-sub-box .el-pagination span:not([class*=suffix]) { margin: 0 3px; height: 25px; line-height: 25px; } + .right-sub-box .el-pager li { height: 25px; line-height: 25px; } + .right-sub-box .el-pagination.is-background .el-pager li:not(.disabled).active { background-color: #656565; border: 1px solid #656565; } + .right-sub-box .el-pagination.is-background .btn-next, .right-sub-box .el-pagination.is-background .btn-prev, .right-sub-box .el-pagination.is-background .el-pager li { background-color: white; } + .right-sub-box .el-pagination button, .right-sub-box .el-pager li { border: 1px solid #DADADA; } - .right-sub-box .el-pager li.active+li { + + .right-sub-box .el-pager li.active + li { border: 1px solid #DADADA; } + .right-sub-box .el-pagination.is-background .el-pager li:not(.disabled):hover { color: black; } + .right-sub-box .el-pagination.is-background .el-pager li.active:hover { color: white; } + .endpoint-sub-table-paginate .el-pagination { position: absolute; right: 10px; bottom: 13px; } - .el-input-group__append>i { + + .el-input-group__append > i { cursor: pointer; } - .el-table .disabledCheck .cell .el-checkbox__inner{ + + .el-table .disabledCheck .cell .el-checkbox__inner { display: none !important; } - .el-table .disabledCheck .cell::before{ + + .el-table .disabledCheck .cell::before { /*content: '\e627';*/ /*font-family: 'nz-icon';*/ text-align: center; line-height: 37px; } + /* end--覆盖分页组件样式*/ /* 列表搜索框 样式重写*/ - .relative-position{ + .relative-position { position: relative; } - .query-input-inactive{ - left:213px; + + .query-input-inactive { + left: 213px; width: 18%; } - .query-input-inactive .el-input__inner{ + + .query-input-inactive .el-input__inner { height: 26px; line-height: 26px; } - .metric-tip-icon{ + + .metric-tip-icon { vertical-align: middle; transform: scale(0.6); - display:inline-block; + display: inline-block; } - .metirc-tip-list{ + + .metirc-tip-list { line-height: 26px; font-weight: bold; } - .table-header-inner{ + + .table-header-inner { position: absolute; z-index: 1; top: 38px; left: 11px; cursor: pointer; } - .control-icon-unchecked{ + + .control-icon-unchecked { color: #d1d1d1; } - .control-icon-checked{ - color:#666; + + .control-icon-checked { + color: #666; } diff --git a/nezha-fronted/static/config.json b/nezha-fronted/static/config.json index 196875cc5..39df1b8fd 100644 --- a/nezha-fronted/static/config.json +++ b/nezha-fronted/static/config.json @@ -1 +1 @@ -{"baseUrl":"http://192.168.40.42:8080/nz-admin", "version": "1.2"} +{"baseUrl":"http://192.168.40.42:8080/nz-admin", "version": "1.2.2020.11.10.14.10"}