feat:修改endpoint query为本地分页 修改 endpointquery chart的样式问题

This commit is contained in:
zhangyu
2021-05-10 16:36:06 +08:00
parent f56ca0fac5
commit 30b47d63c7
6 changed files with 117 additions and 55 deletions

View File

@@ -6,6 +6,7 @@
:search-msg="searchMsg"
:tabs="tabs"
:targetTab="targetTab"
:showPagination="false"
@changeTab="changeTab"
:customTool="true"
class="full-width-height"
@@ -221,4 +222,10 @@ export default {
width: 100%;
height: 100%;
}
/deep/ .nz-table2{
padding: 0 !important;
}
/deep/ .sub-container {
box-sizing: border-box;
}
</style>

View File

@@ -215,7 +215,8 @@ export const terminalLog = {
dangerCmd: ['chmod', 'chown', 'kill', 'rm', 'su', 'sudo'],
infoCmd: ['exit']
}
// 需要隐藏的内置label
export const sameLabels = ['instance', 'module', 'project', 'asset', 'endpoint', 'datacenter', 'datacenter_id', 'endpoint_id', 'module_id', 'nz_agent_id', 'project_id']
// 公共组件的跳转来源
export const fromRoute = {
panel: 'panel',

View File

@@ -15,7 +15,7 @@
line-height:28px;
padding-left:5px;
margin-left:0px;
margin-top: 0px !important;
margin-top: -3px !important;
text-align:left;
border-radius:2px;
min-width:80px;
@@ -57,6 +57,7 @@
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 4px;
}
.compare-box{
/*line-height: 50px;*/

View File

@@ -2,7 +2,7 @@
<div class="interval-refresh">
<time-picker v-if="showTimePicker" ref="timePicker" v-model="searchTime" :default-pick="defaultPick" :show-empty="showEmpty" class="time-picker margin-r-10" size="small" @change="dateChange"></time-picker>
<multipleTime ref="multipleTime" v-if="showMultiple" :stepSearchTime="searchTime" @change="dateChange(searchTime)" class="multiple-time"/>
<chart-unit v-model="unit" v-if="useChartUnit"></chart-unit>
<chart-unit v-model="unit" v-if="useChartUnit" style="margin-left: 10px"></chart-unit>
<div v-show="useRefresh" class="top-tool-btn-group margin-r-10">
<button :id="id+'-refresh'" class="top-tool-btn top-tool-btn--text" @click="refreshDataFunc">
<i class="global-active-color nz-icon nz-icon-refresh" style="font-size: 14px"></i>&nbsp;

View File

@@ -3,7 +3,7 @@
<el-table
id="endpointTable"
ref="dataTable"
:data="tableData"
:data="currentTableData"
v-loading="loading"
:height="'100%'"
border
@@ -46,6 +46,9 @@
min-width="180">
</el-table-column>
</el-table>
<div class="query-page-option">
<Pagination ref="Pagination" :pageObj="pageObj" :tableId="tableId" @pageNo='pageNo' @pageSize='pageSize'></Pagination>
</div>
<el-dialog class="line-chart-block-modal nz-dialog endpoint-dialog"
:title="$t('project.endpoint.dialogTitle')"
:visible.sync="graphShow"
@@ -56,7 +59,7 @@
@close="dialogClose">
<div slot="title">
{{$t("project.endpoint.dialogTitle")}}
<div class="float-right panel-calendar dialog-tool" style="display: flex">
<div class="float-right panel-calendar dialog-tool" style="display: flex;margin-right: 30px">
<pick-time :refresh-data-func="queryChartDate" :use-refresh="false" v-model="searchTime" style="height: 28px;" @unitChange="chartUnitChange" id="endpoint-query-full-chart" :show-multiple="true" ref="pickTime"></pick-time>
<button @click="saveChart" class="nz-btn nz-btn-size-large nz-btn-style-normal-new" v-has="'panel_chart_add'" id="endpoint-query-full-chart-save">{{$t('dashboard.metric.saveChart')}}</button>
</div>
@@ -74,6 +77,7 @@ import chartBox from '@/components/page/dashboard/chartBox'
import axios from 'axios'
import bus from '../../../../libs/bus'
import chart from '@/components/page/dashboard/overview/chart'
import { sameLabels } from '@/components/common/js/constants'
export default {
name: 'endpointTable',
@@ -115,16 +119,23 @@ export default {
data () {
return {
tableData: [],
currentTableData: [],
batchDeleteObjs: [],
currentEndpoint: {},
sameLabels: ['instance', 'module', 'project', 'asset', 'endpoint', 'datacenter'],
sameLabels: sameLabels,
loading: false,
panelData: {},
graphShow: false,
chartUnit: 5,
rightBox: { show: false },
minusTime: 0,
searchTime: [new Date().setHours(new Date().getHours() - 1), new Date()]
searchTime: [new Date().setHours(new Date().getHours() - 1), new Date()],
tableId: 'alertSilenceTable',
pageObj: {
pageSize: 10,
pageNo: 1,
total: 0
}
}
},
methods: {
@@ -139,16 +150,18 @@ export default {
this.tableData = []
this.tableDataCopy = ''
setTimeout(() => {
this.$get("/prom/api/v1/query?query={endpoint='" + this.currentEndpoint.id + "'}&time=" + new Date(this.formatTime).getTime()).then(response => {
this.$get("/prom/api/v1/query?query={endpoint_id='" + this.currentEndpoint.id + "'}&time=" + this.$stringTimeParseToUnix(new Date(this.formatTime).getTime())).then(response => {
this.loading = false
if (response.status === 'success') {
const results = response.data.result
this.queryData = JSON.parse(JSON.stringify(results))
this.tableData = this.handlerTableData(results)
this.tableDataCopy = JSON.stringify(this.tableData)
this.pageObj.total = this.tableData.length
this.$nextTick(this.$refs.dataTable.doLayout())
if (!this.scrollbarWrap) {
this.$nextTick(() => {
this.handleCurrentChange()
// this.scrollbarWrap = this.$refs.dataTable.$refs.singleTable.bodyWrapper
// this.toTopBtnHandler(this.scrollbarWrap)
})
@@ -253,6 +266,8 @@ export default {
const element = temp.hideSameLabels ? item.simpleElement : item.element
return element.indexOf(this.queryExpression) !== -1
})
this.pageObj.pageNo = 1
this.handleCurrentChange()
},
dragend () {
this.$nextTick(() => {
@@ -504,12 +519,29 @@ export default {
}
})
})
},
pageNo (val) {
this.pageObj.pageNo = val
this.handleCurrentChange()
},
pageSize (val) {
this.pageObj.pageSize = val
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val)
this.handleCurrentChange()
},
handleCurrentChange () {
this.pageObj.total = this.tableData.length
this.currentTableData = this.tableData.slice(
(this.pageObj.pageNo - 1) * this.pageObj.pageSize,
this.pageObj.pageNo * this.pageObj.pageSize
)
}
},
computed: {
},
created () {
// this.getPanelData()
this.pageObj.pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId)
}
}
</script>
@@ -523,4 +555,24 @@ export default {
padding-bottom: 0!important;
width: calc(100% - 40px)!important;
}
.query-page-option{
width: 100%;
position: absolute;
background: #fff;
bottom: -34px;
}
/deep/ .pagination{
padding-top: 0;
}
/deep/ .top-tool-btn--text{
background: #fff;
border-radius: 2px 0 0 2px;
outline: none;
height: 32px;
border: 1px solid #d8dce1;
border-right: none;
line-height: 30px;
margin-right: -5px;
padding: 0 5px;
}
</style>

View File

@@ -177,6 +177,7 @@
</transition>
<!--web-->
<el-dropdown>
<el-dropdown-menu></el-dropdown-menu>
<div id="header-open-cli" @click="cli">
</div>
</el-dropdown>
@@ -208,11 +209,11 @@
</div>
</template>
<script>
import DcBox from "@/components/common/rightBox/dcBox";
import AgentBox from '../../common/rightBox/agentBox';
import AssetBox from '../../common/rightBox/asset/assetBox';
import dataListMixin from '@/components/common/mixin/dataList';
import projectBox from '@/components/common/rightBox/projectBox';
import DcBox from '@/components/common/rightBox/dcBox'
import AgentBox from '../../common/rightBox/agentBox'
import AssetBox from '../../common/rightBox/asset/assetBox'
import dataListMixin from '@/components/common/mixin/dataList'
import projectBox from '@/components/common/rightBox/projectBox'
import moduleBox from '@/components/common/rightBox/moduleBox'
import addEndpointBox from '@/components/common/rightBox/addEndpointBox'
import alertRuleBox from '@/components/common/rightBox/alertRuleBox'
@@ -244,7 +245,7 @@ export default {
addEndpointBox,
alertRuleBox,
cabinetBox,
'export-excel': exportXLSX,
'export-excel': exportXLSX
},
mixins: [dataListMixin, table],
computed: {
@@ -453,9 +454,9 @@ export default {
param: {
url: '',
threshold: ''
},
}
};
}
}
},
mounted () {
this.getStateData()
@@ -468,65 +469,65 @@ export default {
// Datacenter
addDatacenter () {
this.rightBox.dc.show = true
this.$emit("update:show", false);
this.$emit('update:show', false)
},
addCabinet () {
this.rightBox.cabinet.show = true
this.$emit("update:show", false);
this.$emit('update:show', false)
},
// Angebt
addAgent () {
this.rightBox.agents.show = true
this.$emit("update:show", false);
this.$emit('update:show', false)
},
DownloadAgent () {
this.$emit("update:show", false);
this.$emit('update:show', false)
this.toDownloadAgent()
},
// Asset
addAsset () {
this.rightBox.asset.show = true
this.$emit("update:show", false);
this.$emit('update:show', false)
},
importAsset () {
this.showImportBox(1)
this.$emit("update:show", false);
this.$emit('update:show', false)
},
webTerminal () {
this.cli()
this.$emit("update:show", false);
this.$emit('update:show', false)
},
// Monitor
addPeoject () {
this.rightBox.project.show = true
this.$emit("update:show", false);
this.$emit('update:show', false)
},
addModule () {
this.rightBox.module.show = true
this.$emit("update:show", false);
this.$emit('update:show', false)
},
addEndpoint () {
this.rightBox.endpoint.show = true
this.$emit("update:show", false);
this.$emit('update:show', false)
},
importEndpoint () {
this.showImportBox(1)
this.$emit("update:show", false);
this.$emit('update:show', false)
},
// Visualization
addPanel () {
// this.rightBox.panel.show = true
this.rightBox.charts.show = true
this.$emit("update:show", false);
this.$emit('update:show', false)
},
addCharts () {
this.rightBox.charts.show = true
this.$emit("update:show", false);
this.$emit('update:show', false)
},
// Alert
addAlertRule () {
this.rightBox.alert.show = true
this.$emit("update:show", false);
this.$emit('update:show', false)
},
cli () {
this.$store.commit('openConsole')
@@ -1069,7 +1070,7 @@ export default {
watch: {
}
};
}
</script>
<style lang="scss">
.el-dialog__body {