NEZ-704: 创建 endponit 添加 state参数

This commit is contained in:
zhangyu
2021-06-01 17:24:57 +08:00
parent 3a36dccf18
commit a6dfb7e510
6 changed files with 56 additions and 23 deletions

View File

@@ -133,7 +133,8 @@ const cn = {
batchDel: '批量删除', batchDel: '批量删除',
tempPrev: '模板预览', tempPrev: '模板预览',
silenceAlert: '告警静默', silenceAlert: '告警静默',
quickSilent: '快速静默' quickSilent: '快速静默',
configEndpoint: '配置'
}, },
setup: { setup: {
step0: '欢迎', step0: '欢迎',
@@ -1298,7 +1299,10 @@ const cn = {
name: '名称', name: '名称',
configs: '配置', configs: '配置',
state: '状态', state: '状态',
allselect: '当前页已全部选择' allselect: '当前页已全部选择',
enable: '开启',
disable: '关闭',
status: 'Endpoint 状态'
}, },
metrics: { metrics: {
metrics: '指标', metrics: '指标',

View File

@@ -138,7 +138,8 @@ const en = {
batchDel: 'Batches delete', batchDel: 'Batches delete',
tempPrev: 'Template preview', tempPrev: 'Template preview',
silenceAlert: 'silence alert', silenceAlert: 'silence alert',
quickSilent: 'Quick silent' quickSilent: 'Quick silent',
configEndpoint: 'Config'
}, },
pageSize: '/page', pageSize: '/page',
setup: { setup: {
@@ -1308,7 +1309,10 @@ const en = {
name: 'Name', name: 'Name',
configs: 'Config', configs: 'Config',
state: 'State', state: 'State',
allselect: 'The current page has all been selected' allselect: 'The current page has all been selected',
enable: 'Enable',
disable: 'Disable',
status: 'Endpoint status'
}, },
metrics: { metrics: {
metrics: 'Metrics', // "指标" metrics: 'Metrics', // "指标"

View File

@@ -249,6 +249,7 @@ export default {
endpointNameTmpl: '{{module.name}}-{{asset.name}}', endpointNameTmpl: '{{module.name}}-{{asset.name}}',
type: 'http', type: 'http',
port: '', port: '',
enabled: 1,
configs: { configs: {
walk: [], walk: [],
snmpCredentialsId: '', snmpCredentialsId: '',
@@ -672,6 +673,9 @@ export default {
this.object = JSON.parse(JSON.stringify(u)) this.object = JSON.parse(JSON.stringify(u))
this.object.walk = this.object.configs.walk ? JSON.parse(JSON.stringify(this.object.configs.walk)) : [] this.object.walk = this.object.configs.walk ? JSON.parse(JSON.stringify(this.object.configs.walk)) : []
this.object.configs.port && (this.object.port = this.object.configs.port) this.object.configs.port && (this.object.port = this.object.configs.port)
// if (!this.object.enabled && !isNaN(this.object.enabled)) {
// this.object.enabled = 1
// }
this.rightBox.show = true this.rightBox.show = true
}, },
showRightBox () { showRightBox () {
@@ -679,6 +683,9 @@ export default {
this.object = { ...JSON.parse(JSON.stringify(this.blankEndpoint)), projectId: this.currentModule.projectId, moduleId: this.currentModule.id, assetName: '', type: this.currentModule.type } this.object = { ...JSON.parse(JSON.stringify(this.blankEndpoint)), projectId: this.currentModule.projectId, moduleId: this.currentModule.id, assetName: '', type: this.currentModule.type }
this.object.walk = this.object.configs.walk ? JSON.parse(JSON.stringify(this.object.configs.walk)) : [] this.object.walk = this.object.configs.walk ? JSON.parse(JSON.stringify(this.object.configs.walk)) : []
this.object.configs.port && (this.object.port = this.object.configs.port) this.object.configs.port && (this.object.port = this.object.configs.port)
// if (!this.object.enabled && !isNaN(this.object.enabled)) {
// this.object.enabled = 1
// }
this.rightBox.show = true this.rightBox.show = true
}, },
editAllEndpoint () { editAllEndpoint () {

View File

@@ -91,17 +91,22 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</span> </span>
<!--module-->
<el-form-item :label='$t("project.endpoint.state")' prop="remark">
<el-select id="module-box-input-state" v-model="editEndpoint.enabled" class="right-box__select" placeholder="" popper-class="right-box-select-dropdown prevent-clickoutside" size="small">
<el-option v-for="item in endpointStateList" :id="'module-'+item.value" :key="item.value" :label="item.name" :value="item.value"></el-option>
</el-select>
</el-form-item>
<!--Enpoint template--> <!--Enpoint template-->
<div class="right-box-sub-title">{{ $t("overall.endpointTemplate") }} <div class="right-box-sub-title">{{ $t("overall.configEndpoint") }}
<el-tooltip effect="light" placement="top"> <!-- <el-tooltip effect="light" placement="top">-->
<div slot="content"> <!-- <div slot="content">-->
{{$t('project.module.tip.defaultEndpointSet')}} <!-- {{$t('project.module.tip.defaultEndpointSet')}}-->
<div></div> <!-- <div></div>-->
{{$t('project.module.tip.relation')}} <!-- {{$t('project.module.tip.relation')}}-->
</div> <!-- </div>-->
<i class="nz-icon nz-icon-info-normal"></i> <!-- <i class="nz-icon nz-icon-info-normal"></i>-->
</el-tooltip> <!-- </el-tooltip>-->
</div> </div>
<div class="right-box-line"></div> <div class="right-box-line"></div>
@@ -331,6 +336,10 @@ export default {
{ name: this.$t('project.endpoint.authTypeWord'), value: 1 }, { name: this.$t('project.endpoint.authTypeWord'), value: 1 },
{ name: this.$t('project.endpoint.authTypeToken'), value: 2 } { name: this.$t('project.endpoint.authTypeToken'), value: 2 }
], ],
endpointStateList: [
{ name: this.$t('project.endpoint.enable'), value: 1 },
{ name: this.$t('project.endpoint.disable'), value: 0 }
],
configsCopyValue: '' configsCopyValue: ''
} }
}, },
@@ -782,7 +791,7 @@ export default {
.half-form-item { .half-form-item {
width: calc(50% - 30px); width: calc(50% - 30px);
display: inline-block; display: inline-block;
padding: 0 18px 0 8px; padding: 0 0px 0 8px;
} }
.half-form-item:nth-child(even){ .half-form-item:nth-child(even){
padding-left: 0; padding-left: 0;

View File

@@ -787,7 +787,7 @@ export default {
.half-form-item { .half-form-item {
width: calc(50% - 21px); width: calc(50% - 21px);
display: inline-block; display: inline-block;
padding: 0 18px 0 0px; padding: 0 0px 0 0px;
} }
.half-form-item:nth-child(even){ .half-form-item:nth-child(even){
padding-left: 0; padding-left: 0;

View File

@@ -86,6 +86,10 @@
</div> </div>
</el-popover> </el-popover>
</template> </template>
<template v-else-if="item.prop === 'enabled'">
<span v-if="scope.row[item.prop] === 1">{{$t('project.endpoint.enable')}}</span>
<span v-else>{{$t('project.endpoint.disable')}}</span>
</template>
<span v-else>{{scope.row[item.prop] ? scope.row[item.prop] : ''}}</span> <span v-else>{{scope.row[item.prop] ? scope.row[item.prop] : ''}}</span>
</template> </template>
</el-table-column> </el-table-column>
@@ -176,6 +180,11 @@ export default {
show: true, show: true,
sortable: 'custom' sortable: 'custom'
} }
// {
// label: this.$t('project.endpoint.status'),
// prop: 'enabled',
// show: false
// }
] ]
} }
}, },
@@ -194,24 +203,24 @@ export default {
suspendedStr (status) { // 10进制转为2进制 分别给对应的状态 suspendedStr (status) { // 10进制转为2进制 分别给对应的状态
if (!status || status === 1 || status == 0) { return '' } if (!status || status === 1 || status == 0) { return '' }
const arr = status.toString(2).split('') const arr = status.toString(2).split('')
while (arr.length < 5) { while (arr.length < 4) {
arr.unshift('0') arr.unshift('0')
} }
arr.pop() arr.pop()
let str = '' let str = ''
arr.forEach((item, index) => { arr.forEach((item, index) => {
if (index === 0) { if (index === 0) {
str += `<div>DC <div class="active-icon inline-block ${item == '0' ? 'red-bg' : 'green-bg'}"></div></div>` str += `<div>DC <div class="active-icon inline-block ${item == '0' ? 'red-bg' : 'gray-bg'}"></div></div>`
} }
if (index === 1) { if (index === 1) {
str += `<div>ASSET <div class="active-icon inline-block ${item == '0' ? 'red-bg' : 'green-bg'}"></div></div>` str += `<div>ASSET <div class="active-icon inline-block ${item == '0' ? 'red-bg' : 'gray-bg'}"></div></div>`
} }
if (index === 2) { if (index === 2) {
str += `<div>ENDPOINT <div class="active-icon inline-block ${item == '0' ? 'red-bg' : 'green-bg'}"></div></div>` str += `<div>ENDPOINT <div class="active-icon inline-block ${item == '0' ? 'red-bg' : 'gray-bg'}"></div></div>`
}
if (index === 3) {
str += `<div>PROMETHEUS <div class="active-icon inline-block ${item == '0' ? 'red-bg' : 'green-bg'}"></div></div>`
} }
// if (index === 3) {
// str += `<div>PROMETHEUS <div class="active-icon inline-block ${item == '0' ? 'red-bg' : 'green-bg'}"></div></div>`
// }
}) })
return str return str
} }