mirror of
https://github.com/speatzle/nfsense.git
synced 2025-06-28 07:19:37 +00:00
wip convert definitions for NicerForm
This commit is contained in:
parent
302790edc6
commit
7d4049c90a
1 changed files with 160 additions and 109 deletions
|
@ -4,7 +4,7 @@ import { SearchProvider, Options } from '~/components/inputs/DropdownInput.vue';
|
||||||
import { apiCall } from './api';
|
import { apiCall } from './api';
|
||||||
|
|
||||||
const GetHardwareInterfaces: SearchProvider = async (o) => {
|
const GetHardwareInterfaces: SearchProvider = async (o) => {
|
||||||
let res = await apiCall('network.get_links', {});
|
let res = await apiCall('network.links.list', {});
|
||||||
if (res.Error === null) {
|
if (res.Error === null) {
|
||||||
console.debug('links', res.Data);
|
console.debug('links', res.Data);
|
||||||
return Object.fromEntries(res.Data.map(r => [r.name, { display: r.name }]));
|
return Object.fromEntries(res.Data.map(r => [r.name, { display: r.name }]));
|
||||||
|
@ -15,7 +15,7 @@ const GetHardwareInterfaces: SearchProvider = async (o) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const GetInterfaces: SearchProvider = async (o) => {
|
const GetInterfaces: SearchProvider = async (o) => {
|
||||||
let res = await apiCall('network.get_interfaces', {});
|
let res = await apiCall('network.interfaces.list', {});
|
||||||
if (res.Error === null) {
|
if (res.Error === null) {
|
||||||
console.debug('interfaces', res.Data);
|
console.debug('interfaces', res.Data);
|
||||||
let obj = {} as Options;
|
let obj = {} as Options;
|
||||||
|
@ -32,7 +32,7 @@ const GetInterfaces: SearchProvider = async (o) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const GetAddresses: SearchProvider = async (o) => {
|
const GetAddresses: SearchProvider = async (o) => {
|
||||||
let res = await apiCall('object.get_addresses', {});
|
let res = await apiCall('object.addresses.list', {});
|
||||||
if (res.Error === null) {
|
if (res.Error === null) {
|
||||||
console.debug('addresses', res.Data);
|
console.debug('addresses', res.Data);
|
||||||
let obj = {} as Options;
|
let obj = {} as Options;
|
||||||
|
@ -49,7 +49,7 @@ const GetAddresses: SearchProvider = async (o) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const GetServices: SearchProvider = async (o) => {
|
const GetServices: SearchProvider = async (o) => {
|
||||||
let res = await apiCall('Object.get_services', {});
|
let res = await apiCall('Object.services.list', {});
|
||||||
if (res.Error === null) {
|
if (res.Error === null) {
|
||||||
console.debug('services', res.Data);
|
console.debug('services', res.Data);
|
||||||
let obj = {} as Options;
|
let obj = {} as Options;
|
||||||
|
@ -66,7 +66,7 @@ const GetServices: SearchProvider = async (o) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const GetPeers: SearchProvider = async (o) => {
|
const GetPeers: SearchProvider = async (o) => {
|
||||||
let res = await apiCall('VPN.get_wireguard_peers', {});
|
let res = await apiCall('VPN.wireguard.peers.list', {});
|
||||||
if (res.Error === null) {
|
if (res.Error === null) {
|
||||||
console.debug('peers', res.Data);
|
console.debug('peers', res.Data);
|
||||||
let obj = {} as Options;
|
let obj = {} as Options;
|
||||||
|
@ -82,11 +82,28 @@ const GetPeers: SearchProvider = async (o) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const PortDefinition: Object = {
|
||||||
|
'any': { display: 'Any'},
|
||||||
|
'single': {
|
||||||
|
display: 'Single',
|
||||||
|
fields: {
|
||||||
|
port: { is: 'NumberBox', label: 'Port'},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'range': {
|
||||||
|
display: 'Range',
|
||||||
|
fields: {
|
||||||
|
start_port: { is: 'NumberBox', label: 'Start Port'},
|
||||||
|
end_port: { is: 'NumberBox', label: 'End Port'},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const editTypes: { [key: string]: { [key: string]: any } } = {
|
export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
'firewall': {
|
'firewall': {
|
||||||
name: 'firewall',
|
name: 'Firewall',
|
||||||
'forwardrules': {
|
'forward_rules': {
|
||||||
name: 'forward_rule',
|
name: 'Forward Rule',
|
||||||
idType: 'Number',
|
idType: 'Number',
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
|
@ -110,8 +127,8 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'destinationnatrules': {
|
'destination_nat_rules': {
|
||||||
name: 'destination_nat_rule',
|
name: 'Destination NAT Rule',
|
||||||
idType: 'Number',
|
idType: 'Number',
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
|
@ -141,8 +158,8 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'sourcenatrules': {
|
'source_nat_rules': {
|
||||||
name: 'source_nat_rule',
|
name: 'Source NAT Rule',
|
||||||
idType: 'Number',
|
idType: 'Number',
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
|
@ -175,110 +192,144 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'network': {
|
'network': {
|
||||||
name: 'network',
|
name: 'Network',
|
||||||
'interfaces': {
|
'interfaces': {
|
||||||
name: 'interface',
|
name: 'Interface',
|
||||||
validationSchema: toFormValidator(
|
fields: {
|
||||||
zod.object({
|
name: { is: 'TextBox', label: 'Name'},
|
||||||
name: zod.string(),
|
alias: { is: 'TextBox', label: 'Alias'},
|
||||||
type: zod.string(),
|
interface_type: { is: 'EnumInput', label: 'Type', props: { variants: {
|
||||||
hardware_interface: zod.string().optional(),
|
'hardware': {
|
||||||
vlan_id: zod.number().optional(),
|
display: 'Hardware',
|
||||||
comment: zod.string().optional(),
|
fields: {
|
||||||
}),
|
device: { is: 'SingleSelect', label: 'Device', props: { searchProvider: GetHardwareInterfaces }},
|
||||||
),
|
},
|
||||||
sections: [
|
},
|
||||||
{
|
'vlan': {
|
||||||
fields: [
|
display: 'VLAN',
|
||||||
{ key: 'name', label: 'Name', as: 'TextBox', default: 'placeholder' },
|
fields: {
|
||||||
{ key: 'type', label: 'Type', as: 'PillBar', props: { options: { hardware: { display: 'Hardware' }, vlan: { display: 'VLAN' }, bond: { display: 'Bond' }, bridge: { display: 'Bridge' } } } },
|
vlan_parent: { is: 'SingleSelect', label: 'VLAN Parent', props: { searchProvider: GetInterfaces}},
|
||||||
{ key: 'hardware_device', label: 'Hardware Device', as: 'SingleSelect', enabled: (values: any) => (values['type'] == 'hardware'), props: { searchProvider: GetHardwareInterfaces } },
|
vlan_id: { is: 'NumberBox', label: 'VLAN ID', props: { min: 1, max: 4094 }},
|
||||||
{ key: 'vlan_parent', label: 'VLAN Parent', as: 'SingleSelect', enabled: (values: any) => (values['type'] == 'vlan'), props: { searchProvider: GetInterfaces } },
|
},
|
||||||
{ key: 'vlan_id', label: 'VLAN ID', as: 'NumberBox', props: { min: 1, max: 4094 }, enabled: (values: any) => (values['type'] == 'vlan') },
|
},
|
||||||
{ key: 'bond_members', label: 'Bond Members', as: 'MultiSelect', enabled: (values: any) => (values['type'] == 'bond'), props: { searchProvider: GetHardwareInterfaces } },
|
'bond': {
|
||||||
{ key: 'bridge_members', label: 'Bridge Members', as: 'MultiSelect', enabled: (values: any) => (values['type'] == 'bridge'), props: { searchProvider: GetHardwareInterfaces } },
|
display: 'Bond',
|
||||||
],
|
fields: {
|
||||||
},
|
members: { is: 'MultiSelect', label: 'Members', props: { searchProvider: GetInterfaces}},
|
||||||
{
|
},
|
||||||
title: 'Addressing',
|
},
|
||||||
fields: [
|
'bridge': {
|
||||||
{ key: 'addressing_mode', label: 'Addressing Mode', as: 'PillBar', props: { options: { none: { display: 'None' }, static: { display: 'Static' }, dhcp: { display: 'DHCP' } } } },
|
display: 'Bridge',
|
||||||
{ key: 'address', label: 'Address', as: 'TextBox', enabled: (values: any) => (values['addressing_mode'] == 'static') },
|
fields: {
|
||||||
{ key: 'comment', label: 'Comment', as: 'MultilineTextBox' },
|
members: { is: 'MultiSelect', label: 'Members', props: { searchProvider: GetInterfaces}},
|
||||||
],
|
},
|
||||||
},
|
},
|
||||||
],
|
}}},
|
||||||
|
addressing_mode: { is: 'EnumInput', label: 'Addressing Mode', props: { variants: {
|
||||||
|
'none': { display: 'None' },
|
||||||
|
'static': {
|
||||||
|
display: 'Static',
|
||||||
|
fields: {
|
||||||
|
address: { is: 'TextBox', label: 'Address'},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'dhcp': { display: 'DHCP' },
|
||||||
|
}}},
|
||||||
|
comment: { is: 'TextBox', label: 'Comment'},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'staticroutes': {
|
'static_routes': {
|
||||||
name: 'static_route',
|
name: 'Static Route',
|
||||||
idType: 'Number',
|
idType: 'Number',
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
name: zod.string(),
|
name: zod.string(),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
sections: [
|
fields: {
|
||||||
{
|
name: { is: 'TextBox', label: 'Name'},
|
||||||
fields: [
|
interface: { is: 'SingleSelect', label: 'Interface', props: { searchProvider: GetInterfaces} },
|
||||||
{ key: 'name', label: 'Name', as: 'TextBox' },
|
gatway: { is: 'TextBox', label: 'Gateway'},
|
||||||
{ key: 'interface', label: 'Interface', as: 'SingleSelect', props: { searchProvider: GetInterfaces } },
|
destination: { is: 'TextBox', label: 'Destination'},
|
||||||
{ key: 'gateway', label: 'Gateway', as: 'TextBox' },
|
metric: { is: 'NumberBox', label: 'Metric'},
|
||||||
{ key: 'destination', label: 'Destination', as: 'TextBox' },
|
},
|
||||||
{ key: 'metric', label: 'Metric', as: 'NumberBox' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'object': {
|
'object': {
|
||||||
name: 'object',
|
name: 'object',
|
||||||
'addresses': {
|
'addresses': {
|
||||||
name: 'address',
|
name: 'Address',
|
||||||
validationSchema: toFormValidator(
|
fields: {
|
||||||
zod.object({
|
name: { is: 'TextBox', label: 'Name'},
|
||||||
}),
|
address_type: { is: 'EnumInput', label: 'Type', props: { variants: {
|
||||||
),
|
'host': {
|
||||||
sections: [
|
display: 'Host',
|
||||||
{
|
fields: {
|
||||||
fields: [
|
address: { is: 'TextBox', label: 'Address'},
|
||||||
{ key: 'name', label: 'Name', as: 'TextBox', default: 'placeholder' },
|
},
|
||||||
{ key: 'type', label: 'Type', as: 'PillBar', props: { options: { host: { display: 'Host' }, range: { display: 'Range' }, network: { display: 'Network' }, group: { display: 'Group' } } } },
|
},
|
||||||
{ key: 'host', label: 'Host', as: 'TextBox', default: 'placeholder', enabled: (values: any) => (values['type'] == 'host') },
|
'range': {
|
||||||
{ key: 'range', label: 'Range', as: 'TextBox', default: 'placeholder', enabled: (values: any) => (values['type'] == 'range') },
|
display: 'Range',
|
||||||
{ key: 'network', label: 'Network', as: 'TextBox', default: 'placeholder', enabled: (values: any) => (values['type'] == 'network') },
|
fields: {
|
||||||
{ key: 'children', label: 'Children', as: 'MultiSelect', enabled: (values: any) => (values['type'] == 'group'), props: { searchProvider: GetAddresses } },
|
range: { is: 'TextBox', label: 'Range'},
|
||||||
{ key: 'comment', label: 'Comment', as: 'MultilineTextBox' },
|
},
|
||||||
],
|
},
|
||||||
},
|
'network': {
|
||||||
],
|
display: 'Network',
|
||||||
|
fields: {
|
||||||
|
network: { is: 'TextBox', label: 'Network'},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'group': {
|
||||||
|
display: 'Group',
|
||||||
|
fields: {
|
||||||
|
members: { is: 'MultiSelect', label: 'Members', props: { searchProvider: GetAddresses}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}},
|
||||||
|
comment: { is: 'TextBox', label: 'Comment'},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'services': {
|
'services': {
|
||||||
name: 'service',
|
name: 'Service',
|
||||||
validationSchema: toFormValidator(
|
fields: {
|
||||||
zod.object({
|
name: { is: 'TextBox', label: 'Name'},
|
||||||
}),
|
service_type: { is: 'EnumInput', label: 'Type', props: { variants: {
|
||||||
),
|
'tcp': {
|
||||||
sections: [
|
display: 'TCP',
|
||||||
{
|
fields: {
|
||||||
fields: [
|
source: { is: 'EnumInput', label: 'Source', props: { variants: PortDefinition }},
|
||||||
{ key: 'name', label: 'Name', as: 'TextBox', default: 'placeholder' },
|
destination: { is: 'EnumInput', label: 'Destination', props: { variants: PortDefinition }},
|
||||||
{ key: 'type', label: 'Type', as: 'PillBar', props: { options: { tcp: { display: 'TCP' }, udp: { display: 'UDP' }, icmp: { display: 'ICMP' }, group: { display: 'Group' } } } },
|
},
|
||||||
{ key: 'sport_start', label: 'Source Port Start', as: 'NumberBox', enabled: (values: any) => (values['type'] == 'tcp' || values['type'] == 'udp') },
|
},
|
||||||
{ key: 'sport_end', label: 'Source Port End', as: 'NumberBox', enabled: (values: any) => (values['type'] == 'tcp' || values['type'] == 'udp') },
|
'udp': {
|
||||||
{ key: 'dport_start', label: 'Destination Port Start', as: 'NumberBox', enabled: (values: any) => (values['type'] == 'tcp' || values['type'] == 'udp') },
|
display: 'UDP',
|
||||||
{ key: 'dport_end', label: 'Destination Port End', as: 'NumberBox', enabled: (values: any) => (values['type'] == 'tcp' || values['type'] == 'udp') },
|
fields: {
|
||||||
{ key: 'icmp_code', label: 'ICMP Code', as: 'NumberBox', enabled: (values: any) => (values['type'] == 'icmp') },
|
source: { is: 'EnumInput', label: 'Source', props: { variants: PortDefinition }},
|
||||||
{ key: 'children', label: 'Children', as: 'MultiSelect', enabled: (values: any) => (values['type'] == 'group'), props: { searchProvider: GetServices } },
|
destination: { is: 'EnumInput', label: 'Destination', props: { variants: PortDefinition }},
|
||||||
{ key: 'comment', label: 'Comment', as: 'MultilineTextBox' },
|
},
|
||||||
],
|
},
|
||||||
},
|
'icmp': {
|
||||||
],
|
display: 'ICMP',
|
||||||
|
fields: {
|
||||||
|
icmp_code: { is: 'NumberBox', label: 'ICMP Code'},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'group': {
|
||||||
|
display: 'Group',
|
||||||
|
fields: {
|
||||||
|
members: { is: 'MultiSelect', label: 'Members', props: { searchProvider: GetServices}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}},
|
||||||
|
comment: { is: 'TextBox', label: 'Comment'},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'service': {
|
'service': {
|
||||||
name: 'service',
|
name: 'Service',
|
||||||
'dhcpservers': {
|
'dhcp_servers': {
|
||||||
name: 'dhcp_server',
|
name: 'DHCP Server',
|
||||||
idType: 'Number',
|
idType: 'Number',
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
|
@ -302,8 +353,8 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'ntpservers': {
|
'ntp_servers': {
|
||||||
name: 'ntp_server',
|
name: 'NTP Server',
|
||||||
idType: 'Number',
|
idType: 'Number',
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
|
@ -318,8 +369,8 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'dnsservers': {
|
'dns_servers': {
|
||||||
name: 'dns_server',
|
name: 'DNS Server',
|
||||||
idType: 'Number',
|
idType: 'Number',
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
|
@ -336,9 +387,9 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'vpn': {
|
'vpn': {
|
||||||
name: 'vpn',
|
name: 'VPN',
|
||||||
'wireguardinterfaces': {
|
'wireguard_interfaces': {
|
||||||
name: 'wireguard_interface',
|
name: 'Wireguard Interface',
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
}),
|
}),
|
||||||
|
@ -356,8 +407,8 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'wireguardpeers': {
|
'wireguard_peers': {
|
||||||
name: 'wireguard_peer',
|
name: 'Wireguard Peer',
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
}),
|
}),
|
||||||
|
@ -378,9 +429,9 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'system': {
|
'system': {
|
||||||
name: 'system',
|
name: 'System',
|
||||||
'users': {
|
'users': {
|
||||||
name: 'user',
|
name: 'User',
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Add table
Reference in a new issue