端口映射的安全组解绑设置值为0

This commit is contained in:
=
2023-12-07 09:21:17 +08:00
parent 6cbf2ecac4
commit 9f2198e32e
6 changed files with 35 additions and 22 deletions
@@ -8,7 +8,7 @@
<el-button size="mini" @click="handleCancelClick">{{cancelText}}</el-button>
<el-button type="primary" size="mini" @click="handleCommitClick">{{okText}}</el-button>
</div>
<el-link slot="reference" :underline="false" :type="type" :size="size" :icon="icon" :disabled="disabled" style="width: 100%;text-align: left;">{{buttonText}}</el-link>
<el-link slot="reference" :underline="false" :type="type" :size="size" :icon="icon" :disabled="disabled" style="text-align: left; font-size: 12px">{{buttonText}}</el-link>
</el-popover>
</template>
@@ -500,6 +500,9 @@ export default {
},
handleUpdate(row) {
this.temp = Object.assign({}, row) // copy obj
if (row.securityGroupId === 0) {
this.temp.securityGroupId = null
}
this.temp.timestamp = new Date(this.temp.timestamp)
this.dialogStatus = 'update'
this.dialogFormVisible = true
@@ -24,7 +24,8 @@
</el-table-column>
<el-table-column align="center" :label="$t('table.defaultPassType')">
<template slot-scope="scope">
<span>{{scope.row.defaultPassType}}</span>
<el-tag type="success" v-if="scope.row.defaultPassType == 'allow'">允许</el-tag>
<el-tag type="info" v-if="scope.row.defaultPassType == 'deny'">拒绝</el-tag>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('table.createTime')">
@@ -45,14 +46,14 @@
</el-table-column>
<el-table-column align="center" :label="$t('table.actions')" class-name="small-padding fixed-width" style="display:flex;justify-content:center">
<template slot-scope="scope">
<div>
<el-link :underline="false" type="primary" size="mini" @click="handleUpdate(scope.row)">{{$t('table.edit')}}</el-link>
<el-link :underline="false" v-if="scope.row.enable =='启用'" size="mini" type="warning" @click="handleDisableStatus(scope.row)">{{$t('table.disable')}}</el-link>
<el-link :underline="false" v-if="scope.row.enable =='禁用'" size="mini" type="success" @click="handleEnableStatus(scope.row)">{{$t('table.enable')}}</el-link>
<el-link :underline="false" type="primary" size="mini" @click="handleGoRulePage(scope.row)">{{$t('table.ruleConfig')}}</el-link>
<div >
<el-link :underline="false" type="primary" size="mini" @click="handleUpdate(scope.row)" style="font-size: 12px">{{$t('table.edit')}}</el-link>
<el-link :underline="false" v-if="scope.row.enable =='启用'" size="mini" type="warning" @click="handleDisableStatus(scope.row)" style="font-size: 12px">{{$t('table.disable')}}</el-link>
<el-link :underline="false" v-if="scope.row.enable =='禁用'" size="mini" type="success" @click="handleEnableStatus(scope.row)" style="font-size: 12px">{{$t('table.enable')}}</el-link>
<el-link :underline="false" type="primary" size="mini" @click="handleGoRulePage(scope.row)" style="font-size: 12px">{{$t('table.ruleConfig')}}</el-link>
</div>
<el-dropdown>
<span class="el-dropdown-link">
<span class="el-dropdown-link" style="font-size: 12px">
更多操作<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
@@ -60,7 +61,7 @@
<LinkPopover @handleCommitClick="handleDelete(scope.row)" style="width: 100%"/>
</el-dropdown-item>
<el-dropdown-item>
<el-link :underline="false" type="primary" size="mini" @click="handlePortMapping(scope.row)">{{$t('table.securityGroupBindPortMapping')}}</el-link>
<el-link :underline="false" type="primary" size="mini" @click="handlePortMapping(scope.row)" style="font-size: 12px">{{$t('table.securityGroupBindPortMapping')}}</el-link>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
@@ -198,7 +199,7 @@ import LinkPopover from '../../components/Link/linkPopover'
update: '编辑',
create: '新建'
},
passTypeList: [{key: 'allow', value: 1}, {key: 'deny', value: -1}],
passTypeList: [{key: '允许', value: 1}, {key: '拒绝', value: 0}],
dialogPvVisible: false,
pvData: [],
rules: {
@@ -326,6 +327,7 @@ import LinkPopover from '../../components/Link/linkPopover'
},
handleUpdate(row) {
this.temp = Object.assign({}, row) // copy obj
this.temp.defaultPassType = row.defaultPassType == 'allow' ? 1 : 0
this.temp.timestamp = new Date(this.temp.timestamp)
this.dialogStatus = 'update'
this.dialogFormVisible = true
@@ -409,3 +411,8 @@ import LinkPopover from '../../components/Link/linkPopover'
}
}
</script>
<style>
.filter-container {
text-align: right;
}
</style>
@@ -35,8 +35,8 @@
</el-table-column>
<el-table-column align="center" :label="$t('table.passType')">
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.passType == 'allow'" effect="dark">{{scope.row.passType}}</el-tag>
<el-tag type="info" v-if="scope.row.passType == 'deny'" effect="dark">{{scope.row.passType}}</el-tag>
<el-tag type="success" v-if="scope.row.passType == 'allow'" effect="dark">允许</el-tag>
<el-tag type="info" v-if="scope.row.passType == 'deny'" effect="dark">拒绝</el-tag>
</template>
</el-table-column>
<el-table-column align="center" :label="$t('table.priority')">
@@ -62,11 +62,10 @@
</el-table-column>
<el-table-column align="center" :label="$t('table.actions')" width="250" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">{{$t('table.edit')}}</el-button>
<el-button v-if="scope.row.enable =='启用'" size="mini" type="warning" @click="handleDisableStatus(scope.row)">{{$t('table.disable')}}</el-button>
<el-button v-if="scope.row.enable =='禁用'" size="mini" type="success" @click="handleEnableStatus(scope.row)">{{$t('table.enable')}}</el-button>
<!-- <el-button v-if="scope.row.status!='deleted'" size="mini" type="danger" @click="handleDelete(scope.row,'deleted')">{{$t('table.delete')}}</el-button>-->
<ButtonPopover @handleCommitClick="handleDelete(scope.row)" style="margin-left: 10px"/>
<el-link type="primary" :underline="false" size="mini" @click="handleUpdate(scope.row)" style="font-size:12px">{{$t('table.edit')}}</el-link>
<el-link :underline="false" v-if="scope.row.enable =='启用'" size="mini" type="warning" @click="handleDisableStatus(scope.row)" style="font-size:12px">{{$t('table.disable')}}</el-link>
<el-link :underline="false" v-if="scope.row.enable =='禁用'" size="mini" type="success" @click="handleEnableStatus(scope.row)" style="font-size:12px">{{$t('table.enable')}}</el-link>
<LinkPopover @handleCommitClick="handleDelete(scope.row)"/>
</template>
</el-table-column>
</el-table>
@@ -132,7 +131,7 @@
import {fetchGroupOne, fetchRuleList, createRule, updateRule, deleteRule, enableRule, disableRule} from '@/api/securityGroup'
import waves from '@/directive/waves' // 水波纹指令
import { parseTime } from '@/utils'
import ButtonPopover from '../../components/Button/buttonPopover'
import LinkPopover from '../../components/Link/linkPopover'
export default {
name: 'complexTable',
@@ -140,7 +139,7 @@ import ButtonPopover from '../../components/Button/buttonPopover'
waves
},
components: {
ButtonPopover
LinkPopover
},
data() {
return {
@@ -164,7 +163,7 @@ import ButtonPopover from '../../components/Button/buttonPopover'
update: '编辑',
create: '新建'
},
passTypeList: [{key: 'allow', value: 1}, {key: 'deny', value: 0}],
passTypeList: [{key: '允许', value: 1}, {key: '拒绝', value: 0}],
dialogPvVisible: false,
pvData: [],
rules: {
@@ -304,6 +303,7 @@ import ButtonPopover from '../../components/Button/buttonPopover'
},
handleUpdate(row) {
this.temp = Object.assign({}, row) // copy obj
this.temp.passType = row.passType == 'allow' ? 1 : 0
this.temp.timestamp = new Date(this.temp.timestamp)
this.dialogStatus = 'update'
this.dialogFormVisible = true
@@ -97,7 +97,7 @@ public class PortMappingDO {
/**
* 安全组Id
*/
private Integer securityGroupId;
private Integer securityGroupId = 0; // 设置为null不生效,不知道为啥
/**
* 创建时间
@@ -187,6 +187,9 @@ public class PortMappingService implements LifecycleBean {
PortMappingDO portMappingDO = new PortMappingDO();
BeanUtil.copyProperties(req, portMappingDO);
if (req.getSecurityGroupId() == null) {
portMappingDO.setSecurityGroupId(0);
}
portMappingDO.setUpdateTime(new Date());
portMappingDO.setEnable(EnableStatusEnum.ENABLE.getStatus());
portMappingMapper.updateById(portMappingDO);
@@ -292,7 +295,7 @@ public class PortMappingService implements LifecycleBean {
if (mappingDO == null) {
throw new RuntimeException("指定的端口映射不存在");
}
mappingDO.setSecurityGroupId(null);
mappingDO.setSecurityGroupId(0);
mappingDO.setUpdateTime(new Date());
portMappingMapper.updateById(mappingDO);
portToSecurityGroupMap.remove(mappingDO.getServerPort());