Skip to content

Commit

Permalink
Merge pull request #5554 from GuoLiBin6/feat/glb-to-3.11/secgroup
Browse files Browse the repository at this point in the history
feat(4592): secgroup reconfiguration
  • Loading branch information
easy-mj authored Oct 20, 2023
2 parents 59a6669 + 78d7546 commit 4320d10
Show file tree
Hide file tree
Showing 20 changed files with 800 additions and 288 deletions.
3 changes: 2 additions & 1 deletion containers/Compute/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1725,5 +1725,6 @@
"compute.bios": "Boot Mode",
"compute.not_limited": "0 means no limit",
"compute.iops": "IOPS",
"compute.bps": "Throughput"
"compute.bps": "Throughput",
"compute.idc_secgroup_support_add_rules": "Only the security group of the local IDC supports this operation"
}
3 changes: 2 additions & 1 deletion containers/Compute/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1728,5 +1728,6 @@
"compute.bios": "引导模式",
"compute.not_limited": "0代表不限制",
"compute.iops": "IOPS",
"compute.bps": "吞吐量"
"compute.bps": "吞吐量",
"compute.idc_secgroup_support_add_rules": "只有本地IDC的安全组支持此操作"
}
6 changes: 6 additions & 0 deletions containers/Compute/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Disk = () => import(/* webpackChunkName: "compute" */ /* webpackPrefetch:
const DiskBackup = () => import(/* webpackChunkName: "compute" */ /* webpackPrefetch: true */ '@Compute/views/disk-backup')
const GPU = () => import(/* webpackChunkName: "compute" */ /* webpackPrefetch: true */ '@Compute/views/gpu')
const Secgroup = () => import(/* webpackChunkName: "compute" */ /* webpackPrefetch: true */ '@Compute/views/secgroup')
const SecgroupCreate = () => import(/* webpackChunkName: "compute" */ /* webpackPrefetch: true */ '@Compute/views/secgroup/Create')
const Servertemplate = () => import(/* webpackChunkName: "compute" */ /* webpackPrefetch: true */ '@Compute/views/servertemplate')
const ServertemplateCreateServer = () => import(/* webpackChunkName: "compute" */ /* webpackPrefetch: true */ '@Compute/views/servertemplate/CreateServer')
const DiskSnapshot = () => import(/* webpackChunkName: "compute" */ /* webpackPrefetch: true */ '@Compute/views/snapshot')
Expand Down Expand Up @@ -451,6 +452,11 @@ export default {
path: '',
component: Secgroup,
},
{
name: 'SecgroupCreate',
path: 'create',
component: SecgroupCreate,
},
],
},
{
Expand Down
3 changes: 2 additions & 1 deletion containers/Compute/sections/ServerNetwork/NetworkConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export default {
item.vpc = curObjArr[0]
this.$nextTick(() => {
if (this.form.fi) {
const networkVpcObj = item.vpc
const networkVpcObj = item.vpc || {}
if (R.is(Object, networkVpcObj)) {
this.$set(this.form.fi, 'networkVpcObj', networkVpcObj)
}
Expand All @@ -366,6 +366,7 @@ export default {
this.$nextTick(() => {
this.form.fc.setFieldsValue({ [`vpcs[${item.key}]`]: data?.[0]?.key, vpcs: { [item.key]: data?.[0]?.key } })
})
this.vpcSelectChange([data[0]], 0, item)
// this.fetchNetworkOpts(this.networkParamsC, item)
},
fetchNetworkSuccessHandle (data, item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
<script>
import ListMixin from '@/mixins/list'
import WindowsMixin from '@/mixins/windows'
import { getStatusTableColumn, getNameDescriptionTableColumn } from '@/utils/common/tableColumn'
import i18n from '@/locales'
import regexp from '@/utils/regexp'
import expectStatus from '@/constants/expectStatus'
import SingleActionsMixin from '../mixins/singleActions'
const PROTOCOL = {
any: 'ANY',
Expand All @@ -27,7 +30,7 @@ const ACTIONS = {
export default {
name: 'DirectionList',
mixins: [WindowsMixin, ListMixin],
mixins: [WindowsMixin, ListMixin, SingleActionsMixin],
props: {
type: {
type: String,
Expand All @@ -44,19 +47,23 @@ export default {
listId: {
type: String,
},
data: Object,
},
data () {
const title = this.type === 'out' ? this.$t('compute.text_978') : this.$t('compute.text_979')
const getParams = {
direction: this.type,
order: 'desc',
order_by: 'priority',
secgroup: this.id,
}
return {
getParams,
list: this.$list.createList(this, {
id: this.listId,
resource: 'secgrouprules',
getParams: {
direction: this.type,
order: 'desc',
order_by: 'priority',
secgroup: this.id,
},
steadyStatus: Object.values(expectStatus.common).flat(),
getParams,
filterOptions: {
cidr: {
label: title,
Expand All @@ -78,18 +85,18 @@ export default {
},
}),
columns: [
{
getNameDescriptionTableColumn({
field: 'cidr',
title: title,
minWidth: 70,
showOverflow: 'ellipsis',
formatter: ({ cellValue, row }) => {
if (row.cidr) {
return `${row.cidr} (IP)`
}
return '-'
},
},
edit: false,
showDesc: false,
hideField: true,
slotCallback: row => {
const name = row.cidr ? `${row.cidr} (IP)` : '-'
return (
<side-page-trigger onTrigger={() => this.handleOpenSidepage(row)}>{ name }</side-page-trigger>
)
},
}),
{
field: 'protocol',
title: this.$t('compute.text_980'),
Expand All @@ -104,6 +111,7 @@ export default {
return cellValue === 'any' ? 'ALL' : !row.ports ? 'ALL' : row.ports
},
},
getStatusTableColumn({ statusModule: 'common' }),
{
field: 'action',
title: this.$t('compute.text_694'),
Expand All @@ -114,6 +122,12 @@ export default {
{
field: 'priority',
title: this.$t('compute.text_981'),
formatter: ({ row }) => {
if (this.data.brand === 'Aws') {
return '-'
}
return row.priority
},
},
{
field: 'description',
Expand All @@ -136,70 +150,6 @@ export default {
},
},
],
singleActions: [
{
label: this.$t('compute.text_982'),
permission: 'secgrouprules_update',
action: obj => {
this.createDialog('EditRulesDialog', {
data: [obj],
title: 'edit',
columns: this.columns,
onManager: this.onManager,
refresh: this.refresh,
type: this.type,
})
},
meta: () => {
return {
validate: !this.isRead,
tooltip: this.isRead ? i18n.t('compute.secgroup.shared') : '',
}
},
},
{
label: this.$t('compute.text_983'),
permission: 'secgrouprules_create',
action: obj => {
this.createDialog('EditRulesDialog', {
data: [obj],
title: 'clone',
columns: this.columns,
onManager: this.onManager,
refresh: this.refresh,
type: this.type,
secgroup: this.id,
})
},
meta: () => {
return {
validate: !this.isRead,
tooltip: this.isRead ? i18n.t('compute.secgroup.shared') : '',
}
},
},
{
label: this.$t('compute.perform_delete'),
permission: 'secgrouprules_delete',
action: obj => {
this.createDialog('DeleteResDialog', {
vm: this,
data: [obj],
columns: this.columns,
title: this.$t('compute.perform_delete'),
name: this.$t('compute.text_984'),
onManager: this.onManager,
refresh: this.refresh,
})
},
meta: () => {
return {
validate: !this.isRead,
tooltip: this.isRead ? i18n.t('compute.secgroup.shared') : '',
}
},
},
],
groupActions: [
{
label: this.$t('compute.perform_create'),
Expand All @@ -212,6 +162,7 @@ export default {
refresh: this.refresh,
type: this.type,
secgroup: this.id,
brand: this.data.brand,
})
},
meta: () => {
Expand Down Expand Up @@ -260,6 +211,15 @@ export default {
return 'ports'
}
},
handleOpenSidepage (row) {
this.sidePageTriggerHandle(this, 'SecgroupRuleSidePage', {
id: row.id,
resource: 'secgrouprules',
getParams: this.getParams,
}, {
list: this.list,
})
},
},
}
</script>
69 changes: 69 additions & 0 deletions containers/Compute/views/secgroup-rule/mixins/singleActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
export default {
created () {
this.singleActions = [
{
label: this.$t('compute.text_982'),
permission: 'secgrouprules_update',
action: obj => {
this.createDialog('EditRulesDialog', {
data: [obj],
title: 'edit',
columns: this.columns,
onManager: this.onManager,
refresh: this.refresh,
type: this.type,
brand: this.data.brand,
})
},
meta: () => {
return {
validate: !this.isRead,
tooltip: this.isRead ? this.$t('compute.secgroup.shared') : '',
}
},
},
// {
// label: this.$t('compute.text_983'),
// permission: 'secgrouprules_create',
// action: obj => {
// this.createDialog('EditRulesDialog', {
// data: [obj],
// title: 'clone',
// columns: this.columns,
// onManager: this.onManager,
// refresh: this.refresh,
// type: this.type,
// secgroup: this.id,
// })
// },
// meta: () => {
// return {
// validate: !this.isRead,
// tooltip: this.isRead ? i18n.t('compute.secgroup.shared') : '',
// }
// },
// },
{
label: this.$t('compute.perform_delete'),
permission: 'secgrouprules_delete',
action: obj => {
this.createDialog('DeleteResDialog', {
vm: this,
data: [obj],
columns: this.columns,
title: this.$t('compute.perform_delete'),
name: this.$t('compute.text_984'),
onManager: this.onManager,
refresh: this.refresh,
})
},
meta: () => {
return {
validate: !this.isRead,
tooltip: this.isRead ? this.$t('compute.secgroup.shared') : '',
}
},
},
]
},
}
63 changes: 63 additions & 0 deletions containers/Compute/views/secgroup-rule/sidepage/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<template>
<base-side-page
@cancel="cancelSidePage"
:title="$t('dictionary.secgrouprule')"
icon="res-secgroup"
:res-name="name"
:current-tab="params.windowData.currentTab"
:tabs="detailTabs"
:loaded="loaded"
@tab-change="handleTabChange">
<template v-slot:actions>
<actions :options="singleActions" :row="detailData" button-type="link" button-size="small" />
</template>
<component
:is="params.windowData.currentTab"
:res-id="data.id"
:data="detailData"
:getParams="getParams"
res-type="secgrouprule" />
</base-side-page>
</template>

<script>
import SidePageMixin from '@/mixins/sidePage'
import WindowsMixin from '@/mixins/windows'
import Actions from '@/components/PageList/Actions'
import SingleActionsMixin from '../mixins/singleActions'
export default {
name: 'SecgroupRuleSidePage',
components: { Actions },
mixins: [SidePageMixin, WindowsMixin, SingleActionsMixin],
data () {
const detailTabs = [
{ label: this.$t('compute.text_240'), key: 'event-drawer' },
]
return {
detailTabs,
t: null,
}
},
computed: {
getParams () {
return {
t: this.t,
}
},
name () {
return this.detailData.cidr ? `${this.detailData.cidr} (IP)` : '-'
},
},
created () {
if (this.params.tab) this.handleTabChange(this.params.tab)
},
methods: {
refresh () {
this.t = new Date().getTime()
if (this.isList) return this.params.list.refresh(...arguments)
return this.fetchData()
},
},
}
</script>
Loading

0 comments on commit 4320d10

Please sign in to comment.