CN-56 perf: entity详情布局

This commit is contained in:
chenjinsong
2021-08-02 13:22:15 +08:00
parent 6e780dd447
commit 6e07d7b269
7 changed files with 53 additions and 13 deletions

View File

@@ -29,7 +29,7 @@ npm run lint
### 3.图表组件库 ### 3.图表组件库
图表echarts5.0 图表echarts5.0
地图(支持下钻)(待定)echarts+自定义事件 | amCharts 地图amCharts
拖拽 & ResizeVue-grid-layout  https://jbaysolutions.github.io/vue-grid-layout/guide/ 拖拽 & ResizeVue-grid-layout  https://jbaysolutions.github.io/vue-grid-layout/guide/
### 4.响应式方案 ### 4.响应式方案
@@ -37,7 +37,7 @@ lib-flexible + postcss-px2rem-exclude + 媒体查询
lib-flexible 将px自动转为rempostcss-px2rem-exclude 避免将ui库的css转换媒体查询根据不同屏幕大小使用不同的root font size lib-flexible 将px自动转为rempostcss-px2rem-exclude 避免将ui库的css转换媒体查询根据不同屏幕大小使用不同的root font size
### 5.工具 ### 5.工具
使用lodash库该库包含大部分常用工具方法包括数组操作、函数功能扩展、对象操作等且高性能、一致。开发中应该优先使用该库的方法 lodash库该库包含大部分常用工具方法包括数组操作、函数功能扩展、对象操作等且高性能、一致。开发中应该优先使用该库的方法
https://www.lodashjs.com/ https://www.lodashjs.com/
## 开发规范 & 要求 ## 开发规范 & 要求

View File

@@ -36,7 +36,7 @@
<span class="body__row-label">{{$t('entities.asn')}}:</span> <span class="body__row-label">{{$t('entities.asn')}}:</span>
<div class="body__row-value" :title="d.asn">{{d.asn || '-'}}</div> <div class="body__row-value" :title="d.asn">{{d.asn || '-'}}</div>
</div> </div>
<div class="body__detail">{{$t('overall.detail')}}</div> <div class="body__detail" @click="entityDetail">{{$t('overall.detail')}}</div>
</template> </template>
<template v-else-if="entityType === 'domain'"> <template v-else-if="entityType === 'domain'">
<div class="body__row"> <div class="body__row">
@@ -51,7 +51,7 @@
<span class="body__row-label">{{$t('entities.creditScore')}}:</span> <span class="body__row-label">{{$t('entities.creditScore')}}:</span>
<div class="body__row-value" :title="d.reputationScore">{{d.reputationScore || '-'}}</div> <div class="body__row-value" :title="d.reputationScore">{{d.reputationScore || '-'}}</div>
</div> </div>
<div class="body__detail">{{$t('overall.detail')}}</div> <div class="body__detail" @click="entityDetail({domain: d.domainName})">{{$t('overall.detail')}}</div>
</template> </template>
<template v-else-if="entityType === 'app'"> <template v-else-if="entityType === 'app'">
<div class="body__row"> <div class="body__row">
@@ -66,7 +66,7 @@
<span class="body__row-label">{{$t('entities.subcategory')}}:</span> <span class="body__row-label">{{$t('entities.subcategory')}}:</span>
<div class="body__row-value" :title="d.appSubategory">{{d.appSubategory || '-'}}</div> <div class="body__row-value" :title="d.appSubategory">{{d.appSubategory || '-'}}</div>
</div> </div>
<div class="body__detail">{{$t('overall.detail')}}</div> <div class="body__detail" @click="entityDetail({appId: d.appId})">{{$t('overall.detail')}}</div>
</template> </template>
</div> </div>
</div> </div>
@@ -95,6 +95,12 @@ export default {
entityType: String, entityType: String,
pageObj: Object pageObj: Object
}, },
data () {
return {
showDetail: false,
typeName: ''
}
},
computed: { computed: {
circleColor () { circleColor () {
let color let color
@@ -161,6 +167,9 @@ export default {
} }
}) })
}) })
},
entityDetail (params) {
this.$emit('showDetail', params)
} }
} }
} }

View File

@@ -111,7 +111,7 @@ export default {
methods: { methods: {
jump (route) { jump (route) {
if (route === this.route) { if (route === this.route) {
// this.refresh() this.refresh()
return return
} }
this.$router.push({ this.$router.push({

View File

@@ -36,7 +36,10 @@ export const fromRoute = {
export const panelTypeAndRouteMapping = { export const panelTypeAndRouteMapping = {
trafficSummary: 1, trafficSummary: 1,
networkAppPerformance: 2, networkAppPerformance: 2,
dnsServiceInsights: 3 dnsServiceInsights: 3,
ipEntityDetail: 4,
domainEntityDetail: 5,
appEntityDetail: 6
} }
export const position = { export const position = {

View File

@@ -632,7 +632,7 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler (n, o) { handler (n, o) {
if (n) { if (n && o) {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart() this.initChart()
}) })
@@ -643,7 +643,6 @@ export default {
setup (props) { setup (props) {
const chartInfo = JSON.parse(JSON.stringify(props.chart)) const chartInfo = JSON.parse(JSON.stringify(props.chart))
chartInfo.category = getTypeCategory(props.chart.type) chartInfo.category = getTypeCategory(props.chart.type)
chartInfo.params = chartInfo.params ? JSON.parse(chartInfo.params) : null
return { return {
chartInfo, chartInfo,
layoutConstant, layoutConstant,

View File

@@ -40,6 +40,10 @@ import TimeRefresh from '@/components/common/TimeRange/TimeRefresh'
export default { export default {
name: 'Panel', name: 'Panel',
props: {
typeName: String,
entity: Object
},
components: { components: {
Chart, Chart,
DateTimeRange, DateTimeRange,
@@ -61,7 +65,7 @@ export default {
const panel = ref({}) const panel = ref({})
let panelType = 1 // 取得panel的type let panelType = 1 // 取得panel的type
const { params } = useRoute() const { params } = useRoute()
panelTypeAndRouteMapping[params.typeName] && (panelType = panelTypeAndRouteMapping[params.typeName]) panelType = props.typeName ? panelTypeAndRouteMapping[props.typeName] : panelTypeAndRouteMapping[params.typeName]
return { return {
panelType, panelType,
panel, panel,
@@ -78,10 +82,23 @@ export default {
if (this.panel.id) { if (this.panel.id) {
this.chartList = (await getChartList({ panelId: this.panel.id, pageSize: -1 })).map(chart => { this.chartList = (await getChartList({ panelId: this.panel.id, pageSize: -1 })).map(chart => {
chart.i = chart.id chart.i = chart.id
this.recursionParamsConvert(chart)
return chart return chart
}) })
} }
}, },
recursionParamsConvert (chart) {
console.info(chart)
chart.params = chart.params ? JSON.parse(chart.params) : null
if (this.entity) {
chart.params = { ...chart.params, ...this.entity }
}
if (!this.$_.isEmpty(chart.children)) {
chart.children.forEach(c => {
this.recursionParamsConvert(c)
})
}
},
timeRefreshChange () { timeRefreshChange () {
if (!this.$refs.dateTimeRange.isCustom) { if (!this.$refs.dateTimeRange.isCustom) {
const value = this.timeFilter.dateRangeValue const value = this.timeFilter.dateRangeValue

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="outer-box"> <div class="outer-box" v-if="!showDetail">
<div class="cn-entities"> <div class="cn-entities">
<el-select <el-select
size="small" size="small"
@@ -30,11 +30,13 @@
:list-data="listData" :list-data="listData"
:entity-type="filterType" :entity-type="filterType"
:page-obj="pageObjRight" :page-obj="pageObjRight"
@showDetail="entityDetail"
@pageSize="pageSizeRight" @pageSize="pageSizeRight"
@pageNo="pageNoRight" @pageNo="pageNoRight"
></entity-list> ></entity-list>
</div> </div>
</div> </div>
<cn-panel v-else :entity="currentEntity" :type-name="typeName"></cn-panel>
</template> </template>
<script> <script>
@@ -43,6 +45,7 @@ import { ref } from 'vue'
import LeftFilter from '@/components/entities/LeftFilter' import LeftFilter from '@/components/entities/LeftFilter'
import EntityList from '@/components/entities/EntityList' import EntityList from '@/components/entities/EntityList'
import { getEntityIpFilterList, getEntityDomainFilterList, getEntityAppFilterList, getEntityIpList, getEntityDomainList, getEntityAppList } from '@/utils/api' import { getEntityIpFilterList, getEntityDomainFilterList, getEntityAppFilterList, getEntityIpList, getEntityDomainList, getEntityAppList } from '@/utils/api'
import Panel from '@/views/charts/Panel'
export default { export default {
name: 'EntityExplorer', name: 'EntityExplorer',
data () { data () {
@@ -64,12 +67,16 @@ export default {
pageSize: 50, pageSize: 50,
total: 0 total: 0
}, },
listData: [] listData: [],
showDetail: false,
typeName: '',
currentEntity: {}
} }
}, },
components: { components: {
LeftFilter, LeftFilter,
EntityList EntityList,
'cn-panel': Panel
}, },
methods: { methods: {
async showMore (key) { async showMore (key) {
@@ -231,6 +238,11 @@ export default {
}) })
} }
} }
},
entityDetail (entity) {
this.typeName = `${this.filterType.toLowerCase()}EntityDetail`
this.currentEntity = entity
this.showDetail = true
} }
}, },
watch: { watch: {