fix:修复 projectTopo metrics 删除会删除节点的问题

This commit is contained in:
zhangyu
2022-06-21 10:46:59 +08:00
parent 6919205fd4
commit 2b92eb3d01
9 changed files with 15 additions and 48 deletions

View File

@@ -195,7 +195,7 @@ export default {
<div class="partition"></div>
<div class="legend-value legend-value-agent">
<div class="map-asset">
<div class="progress-title">${self.$t('config.agent.agent.agent')} ${self.$t('overall.normal')}</div>
<div class="progress-title">${self.$t('guide.agent')} ${self.$t('overall.normal')}</div>
<div class="success-progress progress-box">
<div class="top-progress" style="width: ${(dcStat.agent.up / (dcStat.agent.up + dcStat.agent.down)) * 100}%"></div>
<div style="width: 100%" class="bottom-progress"></div>
@@ -203,7 +203,7 @@ export default {
<div class="success-progress progress-content">${dcStat.agent.up}</div>
</div>
<div class="map-asset">
<div class="progress-title">${self.$t('config.agent.agent.agent')} ${self.$t('overall.unusual')}</div>
<div class="progress-title">${self.$t('guide.agent')} ${self.$t('overall.unusual')}</div>
<div class="error-progress progress-box">
<div class="top-progress" style="width: ${(dcStat.agent.down / (dcStat.agent.up + dcStat.agent.down)) * 100}%"></div>
<div style="width: 100%" class="bottom-progress"></div>

View File

@@ -63,7 +63,7 @@
</div>
</template>
</div>
<div class="tag-search__add cursor-pointer" @click="addCondition()">{{$t('project.topology.add')}}</div>
<div class="tag-search__add cursor-pointer" @click="addCondition()">{{$t('buttons.add')}}</div>
</div>
</template>

View File

@@ -87,7 +87,7 @@ export default {
},
{
route: '/agent',
title: this.$t('config.agent.agent.agent'),
title: this.$t('guide.agent'),
icon: 'nz-icon nz-icon-agent',
tip: this.$t('guide.agentTip'),
permissionCode: 'agent_view'

View File

@@ -53,6 +53,7 @@
:ref="'promql-'+'-1'"
:expression-list="selection.pen.data.expressArr"
:index="index"
type="metric"
:plugins="['metric-selector', 'metric-input', 'remove']"
:showRemove="false"
:styleType="2"
@@ -1500,43 +1501,6 @@ export default {
}
},
methods: {
queryMetrics () {
this.metricOptions = []
this.$get('prom/api/v1/label/__name__/values').then(response => {
if (response.status == 'success') {
const metrics = response.data.sort()
const metricMap = new Map()
metrics.forEach((item) => {
let key = ''
if (/^[a-zA-Z]+?_[a-zA-Z]*/.test(item)) {
key = item.split('_')[0]
} else if (/^_\w*/.test(item)) {
key = ' '
} else {
key = item
}
if (metricMap.get(key)) {
const values = metricMap.get(key)
values.push({ label: item, value: item })
} else {
const values = [{ label: item, value: item }]
metricMap.set(key, values)
}
// this.metricStore.push({label:item,value:item,insertText:item})
})
for (const key of metricMap.keys()) {
const option = {
label: key,
value: key
}
if (metricMap.get(key) && metricMap.get(key).length > 1) {
option.children = metricMap.get(key)
}
this.metricOptions.push(option)
}
}
})
},
tabClick (n) {
},
moduleIdChange (n) {

View File

@@ -373,7 +373,10 @@ const canvasOptions = {
disableEmptyLine: true,
autoExpandDistance: 0,
minScale: 0.2,
scaleKey: -1
scaleKey: -1,
keyCode: {
}
}
export default {
name: 'topologyL5',

View File

@@ -10,7 +10,7 @@
<el-input :disabled="true" v-model="dc.name" id="traffic-setting-name"></el-input>
</el-form-item>
<traffic-setting-tab ref="trafficSetting" :post-asset-list="assetList" v-for="(item,index) in traffic.setting" :index="index" :asset-setting="item" :key="uuids[index]" :id="uuids[index]" @delSelf="delAssetSetting" :validate-repeat-func="valiateRepeatFunc"></traffic-setting-tab>
<button @click="addAssetSetting" class="nz-btn nz-btn-size-normal nz-btn-style-light" id="traffic-setting-add" style="margin:15px 1px 15px 15px" type="button">{{$t('project.topology.add')}}</button>
<button @click="addAssetSetting" class="nz-btn nz-btn-size-normal nz-btn-style-light" id="traffic-setting-add" style="margin:15px 1px 15px 15px" type="button">{{$t('buttons.add')}}</button>
</el-form>
</div>

View File

@@ -94,7 +94,7 @@ const searchSelectInfo = { // value: 传给后台的值label显示给用
operation: [
{
value: 'add',
label: i18n.t('config.operationlog.operations.add')
label: i18n.t('buttons.add')
},
{
value: 'update',

View File

@@ -887,7 +887,7 @@ export default {
}
})
}
} else if (data.children && !data.children.length && this.type !== 'log') {
} else if (data.children && (!data.children.length || data.children.length > 100) && this.type !== 'log') {
this.metricOptions.forEach(item => {
if (!item.temp && item.children && item.value != data.value) {
item.children = []
@@ -898,7 +898,7 @@ export default {
const children = this.$store.state.metricsList.find(item => item.value === data.value).children
resolve(children)
}).then((children) => {
let childrenCopy = JSON.parse(JSON.stringify(children))
const childrenCopy = JSON.parse(JSON.stringify(children))
const findChild = this.metricOptions.find(item => item.label === data.label)
if (childrenCopy.length > 100) {
@@ -927,7 +927,7 @@ export default {
childrenCopy = childrenCopy.splice(findChild.children.length, findChild.children.length + 101)
findChild.children.splice(findChild.children.length - 1, 1)
findChild.children.push(...childrenCopy)
if (findChild.children.length < children.length) {
if (findChild.children.length < children.length - 1) {
findChild.children.push({
label: 'More',
value: false,

View File

@@ -652,7 +652,7 @@ export default {
{ name: vm.$t('config.agent.up'), value: data.agent.up ? data.agent.up : 0 },
{ name: vm.$t('asset.down'), value: data.agent.down ? data.agent.down : 0 }
]
prometheusOption.title.text = vm.$t('config.agent.agent.agent')
prometheusOption.title.text = vm.$t('guide.agent')
prometheusOption.legend.data = [vm.$t('config.agent.up'), vm.$t('asset.down')]
tooltipEndpointChart && tooltipEndpointChart.setOption(endpointOption, true)
tooltipPrometheusChart && tooltipPrometheusChart.setOption(prometheusOption, true)