You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
420 lines
10 KiB
420 lines
10 KiB
import acl from '/@/api/acl';
|
|
import { http } from '/nerv-lib/util/http';
|
|
import { dateUtil } from '/nerv-lib/util/date-util';
|
|
import { get } from 'lodash-es';
|
|
import { useRouter } from 'vue-router';
|
|
export const aclTableConfig = {
|
|
api: acl.LIST,
|
|
title: '防火墙',
|
|
showAction: ['remove'],
|
|
columns: [
|
|
{
|
|
title: '项目',
|
|
name: 'viewInfo',
|
|
textEllipsis: true,
|
|
width: '15%',
|
|
customRender: (text: any) => {
|
|
return get(text.record, 'viewInfo.project[0]');
|
|
},
|
|
},
|
|
{
|
|
title: '防火墙ID',
|
|
textEllipsis: true,
|
|
width: '20%',
|
|
dataIndex: 'metadata',
|
|
customRender: (text: any) => {
|
|
return get(text.record, 'metadata.name');
|
|
},
|
|
},
|
|
{
|
|
title: '名称',
|
|
textEllipsis: true,
|
|
width: '20%',
|
|
dataIndex: 'spec',
|
|
customRender: (text: any) => {
|
|
return get(text.record, 'spec.display_name');
|
|
},
|
|
},
|
|
{
|
|
title: '描述',
|
|
textEllipsis: true,
|
|
dataIndex: 'spec',
|
|
customRender: (text: any) => {
|
|
return get(text.record, 'spec.display_description');
|
|
},
|
|
width: '15%',
|
|
},
|
|
{
|
|
title: '租户',
|
|
textEllipsis: true,
|
|
dataIndex: 'spec',
|
|
width: '10%',
|
|
customRender: (text: any) => {
|
|
return get(text.record, 'spec.tenant');
|
|
},
|
|
},
|
|
{
|
|
title: '创建时间',
|
|
dataIndex: 'metadata',
|
|
width: '20%',
|
|
customRender: (text: any) => {
|
|
return dateUtil(text.text?.creationTimestamp).format('YYYY-MM-DD HH:mm:ss');
|
|
},
|
|
},
|
|
],
|
|
actions: [
|
|
{
|
|
label: '查看',
|
|
name: 'NoeaclDetail',
|
|
openPermission: true,
|
|
handle: (record, e, { router }) => {
|
|
router.push({
|
|
name: 'NoeaclDetail',
|
|
params: {
|
|
id: record.metadata?.name,
|
|
},
|
|
});
|
|
},
|
|
},
|
|
|
|
{
|
|
label: '修改入站规则',
|
|
name: 'NoeaclUpdateIngressRule',
|
|
openPermission: true,
|
|
handle: (record, e, { router }) => {
|
|
router.push({
|
|
name: 'NoeaclUpdateIngressRule',
|
|
params: {
|
|
id: record.metadata?.name,
|
|
},
|
|
});
|
|
},
|
|
},
|
|
{
|
|
label: '修改出站规则',
|
|
name: 'NoeaclUpdateEgressRule',
|
|
openPermission: true,
|
|
handle: (record, e, { router }) => {
|
|
router.push({
|
|
name: 'NoeaclUpdateEgressRule',
|
|
params: {
|
|
id: record.metadata?.name,
|
|
},
|
|
});
|
|
},
|
|
},
|
|
],
|
|
headerActions: [
|
|
{
|
|
label: '添加',
|
|
name: 'NoeaclAdd',
|
|
type: 'primary',
|
|
handle: (record, e, { router }) => {
|
|
router.push({ name: 'NoeaclAdd' });
|
|
},
|
|
},
|
|
],
|
|
|
|
};
|
|
export const aclAddConfig = {
|
|
title: '添加',
|
|
formLayout: '修改',
|
|
api: acl.ADD,
|
|
schemas: [
|
|
// {
|
|
// label: '项目',
|
|
// field: 'project_id',
|
|
// component: 'NsSelectApi' /* todo 需要根据权限过滤 */,
|
|
// componentProps: {
|
|
// api: {
|
|
// url: '/api/passport/passport/objs/Authorization/CheckAuthorization',
|
|
// method: 'POST',
|
|
// },
|
|
// showSearch: true,
|
|
// filterOption: (input: string, option: any) => {
|
|
// return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
// },
|
|
// // filterData: (item) => {
|
|
// // return authorizationService().checkPermission('vdisk', 'Volume', 'add', item.projectname);
|
|
// // },
|
|
// resultField: 'projects',
|
|
// labelField: 'projectname',
|
|
// valueField: 'projectid',
|
|
// immediate: true,
|
|
// placeholder: '请选择项目',
|
|
// },
|
|
// rules: [
|
|
// {
|
|
// type: 'number',
|
|
// required: true,
|
|
// message: '项目必填',
|
|
// trigger: 'blur',
|
|
// },
|
|
// ],
|
|
// },
|
|
{
|
|
label: '租户',
|
|
field: 'tenant',
|
|
component: 'NsSelectApi' /* todo 需要根据权限过滤 */,
|
|
componentProps: {
|
|
api: {
|
|
url: '/api/passport/passport/objs/Tenant?where=tenant_status=?&values=1',
|
|
method: 'GET',
|
|
},
|
|
autoSelectFirst: true,
|
|
showSearch: true,
|
|
filterOption: (input: string, option: any) => {
|
|
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
},
|
|
resultField: 'data',
|
|
labelField: 'tenant',
|
|
valueField: 'tenant',
|
|
immediate: true,
|
|
placeholder: '请选择租户',
|
|
},
|
|
rules: [
|
|
{
|
|
required: true,
|
|
message: '租户必填',
|
|
trigger: 'blur',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: '项目',
|
|
field: 'project_id',
|
|
component: 'NsSelectApi' /* todo 需要根据权限过滤 */,
|
|
dynamicParams: {
|
|
tenant: 'tenant',
|
|
},
|
|
componentProps: {
|
|
api: {
|
|
url: '/api/passport/passport/objs/Tenant/Projects',
|
|
method: 'GET',
|
|
},
|
|
autoSelectFirst: true,
|
|
showSearch: true,
|
|
filterOption: (input: string, option: any) => {
|
|
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
},
|
|
resultField: 'projects',
|
|
labelField: 'projectName',
|
|
valueField: 'projectID',
|
|
immediate: true,
|
|
placeholder: '请选择项目',
|
|
},
|
|
rules: [
|
|
{
|
|
type: 'number',
|
|
required: true,
|
|
message: '项目必填',
|
|
trigger: 'blur',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
field: 'name',
|
|
label: '防火墙名称',
|
|
component: 'NsInput',
|
|
componentProps: {
|
|
placeholder: '请输入',
|
|
},
|
|
rules: [
|
|
{
|
|
required: true,
|
|
message: '防火墙名称必填',
|
|
trigger: 'blur',
|
|
},
|
|
{
|
|
pattern: '^[a-zA-Z][a-zA-Z0-9_-]{5,31}$',
|
|
message: '以字母开头输入6-32个字符,只能包含字母,数字,短横线(-)和下划线(_)',
|
|
trigger: 'blur',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: '描述',
|
|
field: 'description',
|
|
component: 'NsTextarea',
|
|
componentProps: {
|
|
showCount: true,
|
|
maxlength: 255,
|
|
},
|
|
},
|
|
],
|
|
};
|
|
export const aclEditConfig = {
|
|
title: '编辑',
|
|
formLayout: '修改',
|
|
getApi: () => {
|
|
const router = useRouter();
|
|
|
|
return http.get(`${acl.DETAIL}/${router.currentRoute.value.params?.uid}`);
|
|
},
|
|
api: (record) => {
|
|
return http.put(`${acl.EDIT}/${record.uuid}`, record);
|
|
},
|
|
schemas: [
|
|
{
|
|
field: 'uuid',
|
|
component: 'NsInputText',
|
|
show: false,
|
|
},
|
|
{
|
|
field: 'name',
|
|
label: '网络名称',
|
|
component: 'NsInput',
|
|
componentProps: {
|
|
placeholder: '请输入',
|
|
},
|
|
rules: [
|
|
{
|
|
required: true,
|
|
message: '网络名称必填',
|
|
trigger: 'blur',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: '描述',
|
|
field: 'description',
|
|
component: 'NsTextarea',
|
|
componentProps: {
|
|
showCount: true,
|
|
maxlength: 255,
|
|
},
|
|
},
|
|
],
|
|
};
|
|
export const aclDetailConfig = {
|
|
title: '详情',
|
|
showBack: true,
|
|
api: () => {
|
|
const router = useRouter();
|
|
return http.get(`${acl.DETAIL}/${router.currentRoute.value.params?.id}`);
|
|
},
|
|
dataHandle: (val) => {
|
|
return val;
|
|
},
|
|
detail: [
|
|
{
|
|
title: '',
|
|
items: [
|
|
{
|
|
label: '名称',
|
|
name: 'name',
|
|
},
|
|
{
|
|
label: '描述',
|
|
name: 'description',
|
|
},
|
|
{
|
|
label: '状态',
|
|
name: 'status',
|
|
},
|
|
{
|
|
label: '租户',
|
|
name: 'tenant',
|
|
},
|
|
{
|
|
label: '创建时间',
|
|
name: 'created_at',
|
|
format: (value) => {
|
|
return dateUtil(value).format('YYYY-MM-DD HH:mm:ss');
|
|
},
|
|
},
|
|
{
|
|
label: '修改时间',
|
|
name: 'updated_at',
|
|
format: (value) => {
|
|
return dateUtil(value).format('YYYY-MM-DD HH:mm:ss');
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: '',
|
|
items: [
|
|
{
|
|
label: '入站规则',
|
|
name: 'ingress_rules',
|
|
type: 'table',
|
|
props: {
|
|
listField: 'ingress_rules',
|
|
columns: [
|
|
{
|
|
title: '协议',
|
|
dataIndex: 'protocol',
|
|
},
|
|
{
|
|
title: '名称',
|
|
dataIndex: 'name',
|
|
},
|
|
{
|
|
title: 'IP协议',
|
|
dataIndex: 'ether_type',
|
|
},
|
|
{
|
|
title: '端口范围',
|
|
dataIndex: 'ether_type',
|
|
customRender: (text: any) => {
|
|
if (text.record['port_range_min'] && text.record['port_range_max']) {
|
|
return `${text.record['port_range_min']}-${text.record['port_range_max']}`;
|
|
} else {
|
|
return 'any';
|
|
}
|
|
},
|
|
},
|
|
{
|
|
title: '远端IP前缀',
|
|
dataIndex: 'remote_ip_prefix',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: '',
|
|
items: [
|
|
{
|
|
label: '出站规则',
|
|
name: 'egress_rules',
|
|
type: 'table',
|
|
props: {
|
|
listField: 'egress_rules',
|
|
columns: [
|
|
{
|
|
title: '协议',
|
|
dataIndex: 'protocol',
|
|
},
|
|
{
|
|
title: '名称',
|
|
dataIndex: 'name',
|
|
},
|
|
{
|
|
title: 'IP协议',
|
|
dataIndex: 'ether_type',
|
|
},
|
|
{
|
|
title: '端口范围',
|
|
dataIndex: 'ether_type',
|
|
customRender: (text: any) => {
|
|
if (text.record['port_range_min'] && text.record['port_range_max']) {
|
|
return `${text.record['port_range_min']}-${text.record['port_range_max']}`;
|
|
} else {
|
|
return 'any';
|
|
}
|
|
},
|
|
},
|
|
{
|
|
title: '远端IP前缀',
|
|
dataIndex: 'remote_ip_prefix',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|