Merge branch 'codeCheck' of https://git.mesalab.cn/nezha/nezha-fronted into codeCheck

This commit is contained in:
zhangyu
2020-10-14 17:04:18 +08:00
10 changed files with 61 additions and 24 deletions

View File

@@ -842,6 +842,9 @@
chartInfo.param.nullType=chartInfo.param.nullType||'connected';
query+='&nullType='+chartInfo.param.nullType;
}
if(chartInfo.type === 'table'&&chartInfo.param&&chartInfo.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(startTime) + "&end=" + this.$stringTimeParseToUnix(endTime) + '&step=' + step);
});
// 一个图表的所有element单独获取数据

View File

@@ -86,7 +86,7 @@
</div>
<button class="to-top" :class="{'to-top-is-hover': tableHover}" v-show="showTopBtn" @click="$toTop('el', $refs.dashboardScrollbar.wrap)" style="bottom: 0;"><i class="nz-icon nz-icon-top"></i></button>
<transition name="right-box">
<chart-box @close="closeRightBox" :chart="chart" v-if="rightBox.show" ref="addChartModal" :show-panel="showPanel" :panel-data="panelData" @on-create-success="createSuccess" @on-delete-success="delChartOk"></chart-box>
<chart-box @close="closeRightBox" @delete-chart="delChart" :chart="chart" v-if="rightBox.show" ref="addChartModal" :show-panel="showPanel" :panel-data="panelData" @on-create-success="createSuccess" @on-delete-success="delChartOk"></chart-box>
</transition>
</div>
</template>
@@ -249,12 +249,30 @@
type: 'success',
message: this.$t("tip.deleteSuccess")
});
this.rightBox.show = false;
let chartList=this.$refs.chartList.dataList;
let nextChart=null,prevChart=null
for (let i =0;i< chartList.length;i++){
if(chartList[i].id === data.id){
chartList.splice(i,1);
break;
}
if(data.next != -1){
if(chartList[i].id === data.next){
nextChart = chartList[i]
}
}
if(data.prev != 0){
if(chartList[i].id === data.prev){
prevChart = chartList[i]
}
}
}
if(nextChart&&prevChart){ //删除图表为中间位置
prevChart.next = nextChart.id;
nextChart.prev = prevChart.id;
}else{
if(!nextChart) prevChart.next = -1;
if(!prevChart) nextChart.prev = 0;
}
// this.getTableData(this.obj.id); //删除相关图表后,刷新面板数据
} else {

View File

@@ -159,6 +159,7 @@
if(this.paramsType){
form.append('type',this.paramsType);
}
form.append('language',localStorage.getItem("nz-language") ? localStorage.getItem("nz-language") : 'en')
this.$post(this.importUrl,form,{'Content-Type': 'multipart/form-data'}).then(response=>{
if(response.code==200 && response.msg=='success'){
this.importResult=response.data;

View File

@@ -724,7 +724,6 @@
width: 100%;
height: 50px;
background-color: #232f3e;
z-index: 1;
}

View File

@@ -129,6 +129,7 @@ const cn = {
url: "URL",
statistics:'Statistics',
sync: '同步到设备',
last:'Last',
threshold:'阈值',
typeVal: {
line: {

View File

@@ -138,6 +138,7 @@ const en = {
statistics:'Statistics',
legendTip:'Controls the name of the time series, using name or pattern. For example {{hostname}} will be replaced with label value for the label hostname.',
sync: 'Sync to assets',
last:'Last',
threshold:'Threshold',
typeVal:{
line:{

View File

@@ -443,12 +443,15 @@
this.deleteBox.show = false;
},
exportCur:function(){
this.exportExcel(this.searchLabel);
let searchLabel=Object.assign({},this.searchLabel)
this.$set(searchLabel,'language',localStorage.getItem("nz-language") ? localStorage.getItem("nz-language") : 'en')
this.exportExcel(searchLabel);
this.closeDialog();
},
exportAll:function(){
let temp = JSON.parse(JSON.stringify(this.searchLabel));
temp.pageSize = -1;
this.$set(temp,'language',localStorage.getItem("nz-language") ? localStorage.getItem("nz-language") : 'en')
this.exportExcel(temp);
this.closeDialog();
},

View File

@@ -143,6 +143,9 @@
<span class="nz-input-append">px</span>
</el-form-item>
<el-form-item :label="$t('dashboard.panel.chartForm.last')" v-if="editChart.type == 'table'">
<el-switch class="exporter-switch" v-model="editChart.param.last" active-color="#ee9d3f" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
<el-form-item :label="$t('dashboard.panel.chartForm.sync')" v-if="showPanel.type && showPanel.type == 'model'">
<el-switch class="exporter-switch" v-model="editChart.sync" active-color="#ee9d3f" :active-value="1" :inactive-value="0"></el-switch>
@@ -535,24 +538,8 @@
}
});
},
del(u) {
this.$confirm(this.$t("tip.confirmDelete"), {
confirmButtonText: this.$t("tip.yes"),
cancelButtonText: this.$t("tip.no"),
type: 'warning'
}).then(() => {
this.$delete("panel/" + this.panelId + "/charts?ids=" + u.id).then(response => {
if (response.code === 200) {
if(this.$refs.chartForm){
this.$refs.chartForm.resetFields();//清空表单
}
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
this.esc(true);
} else {
this.$message.error(response.msg);
}
})
});
del() {
this.$emit('delete-chart',this.editChart)
},
//----------------------------------
@@ -1056,6 +1043,7 @@
this.editChart.height = 400+'';
this.editChart.unit=2;
let param = {};
param.last=0;
param.url='';
param.threshold='';
param.valueMapping={type:'text',mapping:[{value:'',text:''}]};
@@ -1122,6 +1110,8 @@
this.setIsOtherChart();
if(chartType === 'bar'||chartType === 'line'||chartType === 'stackArea'){
this.editChart.param={nullType:this.editChart.param.nullType,threshold:'',legendValue:{min:'off',max:'off',avg:'off',last:'off',total:'off'}}
}else if(chartType == 'table'){
this.editChart.param.last= 0;
}
/*if(this.$refs.chartTag){
this.$refs.chartTag.forEach((item, index) => {
@@ -1296,7 +1286,9 @@
} else if(n.type === 'singleStat'){
n.param&&!n.param.valueMapping&&this.$set(this.editChart.param,'valueMapping',{type:'value',mapping:[{text:'',value:''}]})
this.setIsSingleStat();
} else {
} else if(n.type === 'table'){
n.param.last?this.$set(this.editChart.param,'last',n.param.last):this.$set(this.editChart.param,'last',0)
}else {
this.setIsOtherChart();
n.param&&!n.param.legendValue&&this.$set(this.editChart.param,'legendValue',{min:'off',max:'off',avg:'off',last:'off',total:'off'})
}

View File

@@ -84,7 +84,7 @@
<button class="to-top" :class="{'to-top-is-hover': tableHover}" v-show="showTopBtn" @click="$toTop('el', $refs.dashboardScrollbar.wrap)" style="bottom: 0;"><i class="nz-icon nz-icon-top"></i></button>
<transition name="right-box">
<chart-box @close="closeChartBox" :chart="chart" v-if="rightBox.chart.show" ref="addChartModal" :show-panel="showPanel" :panel-data="panelData" @reload="panelReload" @on-create-success="createSuccess" @on-delete-success="delChartOk" @reloadOnlyPanel="panelReloadOnlyPanel"></chart-box>
<chart-box @close="closeChartBox" @delete-chart="delChart" :chart="chart" v-if="rightBox.chart.show" ref="addChartModal" :show-panel="showPanel" :panel-data="panelData" @reload="panelReload" @on-create-success="createSuccess" @on-delete-success="delChartOk" @reloadOnlyPanel="panelReloadOnlyPanel"></chart-box>
</transition>
<transition name="right-box">
<panel-box v-if="closePanelBox" :panel="panel" @reload="panelReload" @reloadForDel="panelReloadForDel" ref="panelBox"></panel-box>
@@ -321,6 +321,7 @@
type: 'success',
message: this.$t("tip.deleteSuccess")
});
this.rightBox.chart.show = false;
let chartList=this.$refs.chartList.dataList;
let nextChart=null,prevChart=null
for (let i =0;i< chartList.length;i++){

View File

@@ -103,6 +103,8 @@
<span :title="$t('overall.query')" @click="query(scope.row)" class="content-right-option" :id="'edp-query-'+scope.row.id"><i class="nz-icon nz-icon-search"></i></span>
&nbsp;
<span :title="$t('overall.edit')" @click="editEndpoint(scope.row)" class="content-right-option" :id="'edp-edit-'+scope.row.id"><i class="nz-icon nz-icon-edit"></i></span>
<span :title="$t('overall.delete')" @click.stop="delEndpoint(scope.row)" class="content-right-option" :id="'asset-del-'+scope.row.id"><i class="nz-icon nz-icon-delete"></i></span>
</div>
<span v-else-if="item.prop == 'state'" >
<el-popover placement="right" width="50" trigger="hover" :popper-class="scope.row.state == '1'?'small-pop':''">
@@ -439,6 +441,22 @@
this.bottomBox.targetTab = "panel";
this.bottomBox.showSubList = true;
},
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 {
this.$message.error(response.msg);
}
});
});
},
jumpToAlertMsg(endpoint) {
this.endpoint = Object.assign({}, endpoint);
this.bottomBox.targetTab = 'alertMessage';