feat:全屏图表添加手动刷新按钮

This commit is contained in:
zhangyu
2020-12-01 10:55:39 +08:00
parent e18da8390d
commit 6d72516a44
9 changed files with 172 additions and 34 deletions

View File

@@ -52,6 +52,7 @@
ref="alertListTable" ref="alertListTable"
:form="'chartList'" :form="'chartList'"
:fromPath="'/alertList'" :fromPath="'/alertList'"
:showTopBtn="false"
></alertMessageTable> ></alertMessageTable>
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination" :append-to-body="false" pop-class="out-popper-fix"></Pagination> <Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination" :append-to-body="false" pop-class="out-popper-fix"></Pagination>
</div> </div>
@@ -61,6 +62,7 @@
<span class="nz-dialog-title">{{data.title}}</span> <span class="nz-dialog-title">{{data.title}}</span>
<div class="float-right panel-calendar dialog-tool"> <div class="float-right panel-calendar dialog-tool">
</div> </div>
<span class="float-right dialog-tool" @click="screenRefreshChart"><i class="global-active-color nz-icon nz-icon-refresh"/></span>
</div> </div>
<alertMessageTable <alertMessageTable
:tableData="storedScreanTableData" :tableData="storedScreanTableData"
@@ -71,6 +73,7 @@
@tableDataSort="tableDataSort" @tableDataSort="tableDataSort"
@deleteMessage="deleteMessage" @deleteMessage="deleteMessage"
ref="alertListScreenTable" ref="alertListScreenTable"
:showTopBtn="false"
></alertMessageTable> ></alertMessageTable>
<Pagination :pageObj="screenPageObj" @pageNo='screenPageNo' @pageSize='screenPageSize' ref="Pagination" ></Pagination> <Pagination :pageObj="screenPageObj" @pageNo='screenPageNo' @pageSize='screenPageSize' ref="Pagination" ></Pagination>
<loading :ref="'localLoadingScreen'+chartIndex"></loading> <loading :ref="'localLoadingScreen'+chartIndex"></loading>
@@ -550,30 +553,37 @@ export default {
if (response.code == 200) { if (response.code == 200) {
this.storedTableData = response.data.list; this.storedTableData = response.data.list;
this.storedScreanTableData=response.data.list; this.storedScreanTableData=response.data.list;
this.storedTableData.forEach((item) => { let axiosAll=[]
item.labels = JSON.parse(item.labels); this.$nextTick(() => {
let paramStr = JSON.stringify(this.promQueryParamConvert(item)); this.storedTableData.forEach((item) => {
if(paramStr&& paramStr !='""'){ item.labels = JSON.parse(item.labels);
this.$get('/prom/api/v1/query?query=' + paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")).then(response2 => { if(item.alertRule.buildIn != 1){
let current = []; let paramStr = JSON.stringify(this.promQueryParamConvert(item));
if (response2.data && response2.data.result && response2.data.result.length > 0) { axiosAll.push(axios.get('/prom/api/v1/query?query=' + paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")))
current = response2.data.result[0].value.map((item, i) => { }else{
if (i == 0) { axiosAll.push('')
return bus.computeTimezone(item); }
} else { });
return parseFloat(item).toFixed(2); axios.all(axiosAll).then(res=>{
} res.forEach((item,index)=>{
}); let current = [];
} let response2 = item.data;
this.requestIndex+=1; if (response2.data && response2.data.result && response2.data.result.length > 0) {
item.current=current; current = response2.data.result[0].value.map((item, i) => {
if(this.requestIndex===this.storedTableData.length){ if (i == 0) {
this.$set(item, "current", current); return bus.computeTimezone(item);
this.requestIndex=0; } else {
} return parseFloat(item).toFixed(2);
}); }
} });
}); }else{
current=[null,null]
}
this.storedTableData[index].current=current;
});
this.$set( this.storedTableData,[...this.storedTableData]);
})
});
this.pageObj.total = response.data.total; this.pageObj.total = response.data.total;
this.isError = false; this.isError = false;
this.errorContent = ''; this.errorContent = '';
@@ -588,6 +598,100 @@ export default {
} }
}); });
}, },
getAlerScreetList: function (filterType,isPreview=false,chartInfo) {
this.resize();
this.loadingTable=true;
this.isPreview = isPreview;
let queryParam={
pageSize:this.screenPageObj.pageSize,
pageNo:this.screenPageObj.pageNo,
}
let chart;
if(chartInfo){
chart=Object.assign({},chartInfo)
}else{
chart=Object.assign({},this.chartInfo)
}
if(chart && chart.param){ //按照粒度project>module>endpoint 查询只传最细粒度
let param=chart.param;
if(param.endpointId&&param.endpointId != ''){
queryParam.endpointId=param.endpointId;
}else{
if(param.moduleId&&param.moduleId!=''){
queryParam.moduleId=param.moduleId;
}else{
if(param.projectId&&param.projectId!=''){
queryParam.projectId=param.projectId;
}
}
}
if(param.ruleId&&param.ruleId!=''){
queryParam.ruleId=param.ruleId;
}
if(param.severity&&param.severity!=''){
queryParam.severity=param.severity;
}
if(param.state&&param.state!=''){
queryParam.state=param.state;
}
}
if(this.searchLabel.orderBy){
queryParam.orderBy=this.searchLabel.orderBy;
}
this.startLoading(filterType);
this.$get('/alert/message', queryParam).then(response => {
if (response.code == 200) {
this.storedTableData = response.data.list;
this.storedScreanTableData=response.data.list;
let axiosAll=[]
this.$nextTick(() => {
this.storedScreanTableData.forEach((item) => {
item.labels = JSON.parse(item.labels);
if(item.alertRule.buildIn != 1){
let paramStr = JSON.stringify(this.promQueryParamConvert(item));
axiosAll.push(axios.get('/prom/api/v1/query?query=' + paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")))
}else{
axiosAll.push('')
}
});
axios.all(axiosAll).then(res=>{
res.forEach((item,index)=>{
let current = [];
let response2 = item.data;
if (response2.data && response2.data.result && response2.data.result.length > 0) {
current = response2.data.result[0].value.map((item, i) => {
if (i == 0) {
return bus.computeTimezone(item);
} else {
return parseFloat(item).toFixed(2);
}
});
}else{
current=[null,null]
}
this.storedScreanTableData[index].current=current;
})
this.$set(this.storedScreanTableData,[...this.storedScreanTableData])
})
})
this.screenPageObj.total = response.data.total;
this.isError = false;
this.errorContent = '';
this.divFirstShow = true;
this.firstShow = true; // 展示操作按键
this.loadingTable=false;
this.endLoading(filterType);
}else{
this.isError = true;
this.errorContent = response.msg;
}
});
},
screenRefreshChart(){
this.getAlerScreetList();
},
promQueryParamConvert(obj) { promQueryParamConvert(obj) {
if(obj){ if(obj){
return "(" + obj.alertRule.expr + ") and (" + function(){ return "(" + obj.alertRule.expr + ") and (" + function(){
@@ -649,11 +753,11 @@ export default {
screenPageNo(val) { screenPageNo(val) {
this.screenPageObj.pageNo = val; this.screenPageObj.pageNo = val;
this.getAlertList(); this.getAlerScreetList();
}, },
screenPageSize(val) { screenPageSize(val) {
this.screenPageObj.pageSize = val; this.screenPageObj.pageSize = val;
this.getAlertList(); this.getAlerScreetList();
}, },
startLoading(area){ startLoading(area){
if(area==='showFullScreen'){ if(area==='showFullScreen'){
@@ -764,6 +868,7 @@ export default {
this.screenModal = true; this.screenModal = true;
this.deleteBox.ids=[]; this.deleteBox.ids=[];
this.$refs.alertListTable.$refs.alertListTable.clearSelection(); this.$refs.alertListTable.$refs.alertListTable.clearSelection();
this.screenPageObj={...this.pageObj}
}, },
// 设置数据, filter区分 // 设置数据, filter区分
setData(chartItem, seriesItem, panelId, filter,area,errorMsg) { setData(chartItem, seriesItem, panelId, filter,area,errorMsg) {

View File

@@ -55,6 +55,7 @@
<div class="float-right panel-calendar dialog-tool"> <div class="float-right panel-calendar dialog-tool">
<time-picker ref="calendarPanel" class="nz-dashboard-picker" style="margin-top: -12px;" @change="dateChange"></time-picker> <time-picker ref="calendarPanel" class="nz-dashboard-picker" style="margin-top: -12px;" @change="dateChange"></time-picker>
</div> </div>
<span class="float-right dialog-tool" @click="screenRefreshChart" style="margin-right: 15px"><i class="global-active-color nz-icon nz-icon-refresh"/></span>
</div> </div>
<div class="single-stat-screen-container" > <div class="single-stat-screen-container" >
<div id="chartScreenContainer" ref="chartScreenContainer" class="single-stat-content" > <div id="chartScreenContainer" ref="chartScreenContainer" class="single-stat-content" >
@@ -319,6 +320,9 @@ export default {
this.startLoading(); this.startLoading();
this.divFirstShow = true; this.divFirstShow = true;
}, },
screenRefreshChart(){
this.$refs['calendarPanel'].timeChange(this.$refs['calendarPanel'].nowTimeType,'chart')
},
// 重新请求数据 刷新操作-local // 重新请求数据 刷新操作-local
refreshChart() { refreshChart() {
this.dropdownMenuShow=false; this.dropdownMenuShow=false;

View File

@@ -81,6 +81,7 @@
<time-picker ref="calendarPanel" class="nz-dashboard-picker" style="margin-top: -12px;" <time-picker ref="calendarPanel" class="nz-dashboard-picker" style="margin-top: -12px;"
@change="dateChange"></time-picker> @change="dateChange"></time-picker>
</div> </div>
<span class="float-right dialog-tool" @click="screenRefreshChart" style="margin-right: 15px"><i class="global-active-color nz-icon nz-icon-refresh"/></span>
</div> </div>
<el-table style="margin-top: 10px;" class="nz-table" height="95%" :data="seriesItemScreen" border <el-table style="margin-top: 10px;" class="nz-table" height="95%" :data="seriesItemScreen" border
tooltip-effect="light" v-scrollBar:el-table @sort-change="tableDataSortScreen"> tooltip-effect="light" v-scrollBar:el-table @sort-change="tableDataSortScreen">
@@ -297,6 +298,9 @@
this.startLoading(); this.startLoading();
this.divFirstShow = true; this.divFirstShow = true;
}, },
screenRefreshChart(){
this.$refs['calendarPanel'].timeChange(this.$refs['calendarPanel'].nowTimeType,'chart')
},
// 重新请求数据 刷新操作-local // 重新请求数据 刷新操作-local
refreshChart() { refreshChart() {
this.dropdownMenuShow = false; this.dropdownMenuShow = false;

View File

@@ -41,6 +41,7 @@
<el-dialog class="nz-dialog table-chart-dialog" :title="$t('dashboard.panel.view')" :visible.sync="screenModal" width="96%" @opened="initDialog" @close="screenModal = false" > <el-dialog class="nz-dialog table-chart-dialog" :title="$t('dashboard.panel.view')" :visible.sync="screenModal" width="96%" @opened="initDialog" @close="screenModal = false" >
<div slot="title"> <div slot="title">
<span class="nz-dialog-title">{{chartData.title}}</span> <span class="nz-dialog-title">{{chartData.title}}</span>
<!--<span class="float-right dialog-tool" @click="screenRefreshChart" style="margin-right: 15px"><i class="global-active-color nz-icon nz-icon-refresh"/></span>-->
</div> </div>
<iframe :id="'urlContainerFull'+chartIndex" frameborder="0" width="100%" height="100%" name="showHereFull" scrolling=auto v-if="!showStatic" <iframe :id="'urlContainerFull'+chartIndex" frameborder="0" width="100%" height="100%" name="showHereFull" scrolling=auto v-if="!showStatic"
style="z-index:5000;padding-bottom:6px;" style="z-index:5000;padding-bottom:6px;"
@@ -197,6 +198,9 @@ export default {
clearChart(){ clearChart(){
this.data = {}; this.data = {};
}, },
screenRefreshChart(){
('urlContainerFull'+this.chartIndex).window.location.reload()
},
// 重新请求数据 刷新操作-local // 重新请求数据 刷新操作-local
refreshChart() { refreshChart() {
this.dropdownMenuShow=false; this.dropdownMenuShow=false;

View File

@@ -132,7 +132,9 @@
<div class="float-right panel-calendar dialog-tool"> <div class="float-right panel-calendar dialog-tool">
<time-picker ref="calendarPanel" class="nz-dashboard-picker" style="margin-top: -12px;" @change="dateChange"></time-picker> <time-picker ref="calendarPanel" class="nz-dashboard-picker" style="margin-top: -12px;" @change="dateChange"></time-picker>
<!--<pick-time :refresh-data-func="dateChange" v-model="searchTime" :use-chart-unit="false" ref="pickTime"></pick-time>-->
</div> </div>
<span class="float-right dialog-tool" @click="screenRefreshChart" style="margin-right: 15px"><i class="global-active-color nz-icon nz-icon-refresh"/></span>
</div> </div>
<div class="line-area" ref="screenShowArea" id="screenShowArea" style="margin-top:0px;" @mouseenter="mouseEnterFullChart" @mouseleave="mouseLeaveFullChart"></div> <div class="line-area" ref="screenShowArea" id="screenShowArea" style="margin-top:0px;" @mouseenter="mouseEnterFullChart" @mouseleave="mouseLeaveFullChart"></div>
<div class="chart-no-data" v-show="noData">No Data</div> <div class="chart-no-data" v-show="noData">No Data</div>
@@ -1148,6 +1150,9 @@
this.firstShow = false; this.firstShow = false;
this.$emit('on-refresh-data', id); this.$emit('on-refresh-data', id);
}, },
screenRefreshChart(){
this.$refs['calendarPanel'].timeChange(this.$refs['calendarPanel'].nowTimeType,'chart')
},
initDialog(){ initDialog(){
//此时初始化才能获得screenShowArea对象否则此对象为undefined无法初始化图表 //此时初始化才能获得screenShowArea对象否则此对象为undefined无法初始化图表
this.initChart(this.data, this.seriesItem, this.$refs.screenShowArea, 'screen',this.legend); this.initChart(this.data, this.seriesItem, this.$refs.screenShowArea, 'screen',this.legend);

View File

@@ -162,7 +162,7 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<button class="to-top" :style="{top: tools.toTopBtnTop}" :class="{'to-top-is-hover': tools.tableHover}" v-show="tools.showTopBtn && bottomBox.mainResizeShow" @click="$toTop('ps', 0)"><i class="nz-icon nz-icon-top"></i></button> <button class="to-top" :style="{top: tools.toTopBtnTop}" :class="{'to-top-is-hover': tools.tableHover}" v-show="tools.showTopBtn && bottomBox.mainResizeShow &&showTopBtn" @click="$toTop('ps', 0)"><i class="nz-icon nz-icon-top"></i></button>
<!--<弹窗>--> <!--<弹窗>-->
<!--导出--> <!--导出-->
<div class="export-xlsx"> <div class="export-xlsx">
@@ -238,6 +238,10 @@
tableHeight:{}, tableHeight:{},
tableId:{}, tableId:{},
projectAlertId:{}, projectAlertId:{},
showTopBtn:{
type:Boolean,
default:true,
},
}, },
data() { data() {
vm = this; vm = this;

View File

@@ -33,6 +33,7 @@
@tableDataSort="tableDataSort" @tableDataSort="tableDataSort"
@deleteMessage="deleteMessage" @deleteMessage="deleteMessage"
@select-change="(selection)=>{this.batchDeleteObjs=selection}" @select-change="(selection)=>{this.batchDeleteObjs=selection}"
:showTopBtn="false"
></alertMessageTable> ></alertMessageTable>
<Pagination :tableId="tableId" :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination> <Pagination :tableId="tableId" :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
<!--导出--> <!--导出-->
@@ -552,7 +553,7 @@
} }
this.tableData[index].current=current; this.tableData[index].current=current;
}) })
this.tableData=[...this.tableData]; this.$set(this.tableData,[...this.tableData])
}) })
}); });
this.pageObj.total = response.data.total; this.pageObj.total = response.data.total;

View File

@@ -259,13 +259,19 @@ export default {
this.$set(this.searchTime, 0, timeGroup[0]); this.$set(this.searchTime, 0, timeGroup[0]);
this.$set(this.searchTime, 1, timeGroup[1]); this.$set(this.searchTime, 1, timeGroup[1]);
this.$set(this.showTime, 'id', 0); this.nowTimeType={
this.$set(this.showTime, 'text', this.searchTime[0]+" "+this.$t("dashboard.panel.to")+" "+this.searchTime[1]); id:4,
text:this.$t("dashboard.panel.lastOneHour"),
type:'hour',
value:1,
};
this.$set(this.showTime, 'id', this.nowTimeType.id);
this.$set(this.showTime, 'text', this.nowTimeType.text);
} }
}, },
//left(){}, //left(){},
//right(){}, //right(){},
timeChange(val) { timeChange(val,from) {
this.nowTimeType=val; this.nowTimeType=val;
this.$set(this.showTime, 'id', val.id); this.$set(this.showTime, 'id', val.id);
this.$set(this.showTime, 'text', val.text); this.$set(this.showTime, 'text', val.text);
@@ -286,8 +292,13 @@ export default {
let id = val.id; let id = val.id;
if(id===0){//custom if(id===0){//custom
this.isCustom = true; if(from==='chart'){
this.$refs.calendar.focus(); this.isCustom = false;
this.$emit('change', this.searchTime);
} else{
this.isCustom = true;
this.$refs.calendar.focus();
}
}else { }else {
this.isCustom = false; this.isCustom = false;
if(this.showEmpty&& id === 12){ if(this.showEmpty&& id === 12){

View File

@@ -392,7 +392,7 @@
} }
this.tableData[index].current=current; this.tableData[index].current=current;
}) })
this.tableData=[...this.tableData]; this.$set(this.tableData,[...this.tableData])
}) })
}); });
this.deleteBox.ids=''; this.deleteBox.ids='';