From b96d4f49555a971cf02a04e582a35a313ecd4fcd Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Mon, 3 Apr 2023 22:45:49 +0200 Subject: [PATCH] Rework Definitions for new Form --- client/src/definitions.ts | 71 +++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/client/src/definitions.ts b/client/src/definitions.ts index d486a78..4ffa32b 100644 --- a/client/src/definitions.ts +++ b/client/src/definitions.ts @@ -1,35 +1,42 @@ -import PillBar from "./components/inputs/PillBar.vue"; -import TextBox from "./components/inputs/TextBox.vue"; -import NumberBox from "./components/inputs/NumberBox.vue"; -import MultilineTextBox from "./components/inputs/MultilineTextBox.vue"; -import CheckBox from "./components/inputs/CheckBox.vue"; - -export const editTypes: { [key: string]: {[key: string]: any} } = { - "firewall": { - "forwardrules": { - title: "Forward Rule", - fields: [ - {key: "name", label: "Name", component: () => TextBox }, - {key: "verdict", label: "Verdict", component: () => PillBar, props: {options: [{name: 'Accept'}, {name: 'Drop'}, {name: 'Continue'}]}}, - {key: "counter", label: "Counter", component: () => CheckBox }, - {key: "comment", label: "Comment", component: () => MultilineTextBox }, +export const editTypes: { [key: string]: { [key: string]: any } } = { + "firewall": { + "forwardrules": { + title: "Forward Rule", + sections: [ + { + fields: [ + { key: "name", label: "Name", as: "TextBox" }, + { key: "verdict", label: "Verdict", as: "PillBar", props: { options: [{ name: 'Accept' }, { name: 'Drop' }, { name: 'Continue' }] } }, + { key: "counter", label: "Counter", as: "CheckBox", }, + { key: "comment", label: "Comment", as: "MultilineTextBox", }, ], - } + }, + ], }, - "network": { - "interfaces": { - title: "Interfaces", - fields: [ - {key: "name", label: "Name", component: () => TextBox, default: "placeholder"}, - {key: "type", label: "Type", component: () => PillBar, props: {options: [{name: 'Hardware', selected: true}, {name: 'VLAN'}, {name: 'Bond'}, {name: 'Brdige'}]}}, - {key: "hardware_interface", label: "Hardware Interface", component: () => TextBox }, - {key: "vlan_id", label: "VLAN ID", component: () => NumberBox, props: {min: 1, max: 4094} }, - {key: "bond_members", label: "Bond Members", component: () => TextBox, if: () => true }, - {key: "bridge_members", label: "Bridge Memebers", component: () => TextBox }, - {key: "addressing_mode", label: "Addressing Mode", component: () => PillBar, props: {options: [{name: 'None', selected: true}, {name: 'Static'}, {name: 'DHCP'}]}}, - {key: "address", label: "Address", component: () => TextBox }, - {key: "comment", label: "Comment", component: () => MultilineTextBox }, - ], - } + }, + "network": { + "interfaces": { + title: "Interfaces", + sections: [ + { + fields: [ + { key: "name", label: "Name", as: "TextBox", default: "placeholder" }, + { key: "type", label: "Type", as: "PillBar", props: { options: [{ name: 'Hardware' }, { name: 'VLAN' }, { name: 'Bond' }, { name: 'Bridge' }] } }, + { key: "hardware_interface", label: "Hardware Interface", as: "TextBox", enabled: (values: any) => (values["type"] == 0) }, + { key: "vlan_id", label: "VLAN ID", as: "NumberBox", props: { min: 1, max: 4094 }, enabled: (values: any) => (values["type"] == 1) }, + { key: "bond_members", label: "Bond Members", as: "TextBox", enabled: (values: any) => (values["type"] == 2) }, + { key: "bridge_members", label: "Bridge Members", as: "TextBox", enabled: (values: any) => (values["type"] == 3) }, + ], + }, + { + title: "Addressing", + fields: [ + { key: "addressing_mode", label: "Addressing Mode", as: "PillBar", props: { options: [{ name: 'None', selected: true }, { name: 'Static' }, { name: 'DHCP' }] } }, + { key: "address", label: "Address", as: "TextBox", enabled: (values: any) => (values["addressing_mode"] == 1) }, + { key: "comment", label: "Comment", as: "MultilineTextBox" }, + ], + } + ], }, - }; \ No newline at end of file + }, +}; \ No newline at end of file