mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 19:08:20 +00:00
Move types to definitions.ts, minor improvements
This commit is contained in:
parent
f91132f200
commit
ffe2bf1880
3 changed files with 38 additions and 62 deletions
27
client/src/definitions.ts
Normal file
27
client/src/definitions.ts
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import PillBar from "./components/inputs/PillBar.vue";
|
||||||
|
import TextBox from "./components/inputs/TextBox.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 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"network": {
|
||||||
|
"interfaces": {
|
||||||
|
title: "Interfaces",
|
||||||
|
fields: [
|
||||||
|
{key: "name", label: "Name", component: () => TextBox },
|
||||||
|
{key: "comment", label: "Comment", component: () => MultilineTextBox },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
|
@ -1,35 +1,10 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import PillBar from "../../../../components/inputs/PillBar.vue";
|
|
||||||
import TextBox from "../../../../components/inputs/TextBox.vue";
|
import { editTypes } from "../../../../definitions";
|
||||||
import MultilineTextBox from "../../../../components/inputs/MultilineTextBox.vue";
|
|
||||||
import CheckBox from "../../../../components/inputs/CheckBox.vue";
|
|
||||||
|
|
||||||
const props = $defineProps<{subsystem: string, entity: string, id: string}>();
|
const props = $defineProps<{subsystem: string, entity: string, id: string}>();
|
||||||
const { subsystem, entity, id } = $(props);
|
const { subsystem, entity, id } = $(props);
|
||||||
|
|
||||||
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 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"network": {
|
|
||||||
"interfaces": {
|
|
||||||
title: "Interfaces",
|
|
||||||
fields: [
|
|
||||||
{key: "name", label: "Name", component: () => TextBox },
|
|
||||||
{key: "comment", label: "Comment", component: () => MultilineTextBox },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
async function update() {
|
async function update() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,10 +16,10 @@ async function update() {
|
||||||
<button @click="update">Update</button>
|
<button @click="update">Update</button>
|
||||||
<button @click="$router.go(-1)">Discard</button>
|
<button @click="$router.go(-1)">Discard</button>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
{{ subsystem }} {{ entity }} {{ id }}
|
<NiceForm class="scroll cl-secondary" :title="editTypes[subsystem][entity].title" :fields="editTypes[subsystem][entity].fields"/>
|
||||||
<NiceForm class="scroll cl-secondary" title="Test" :fields="editTypes[subsystem][entity].fields"/>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
No edit for this Entity
|
<PageHeader title="Error"/>
|
||||||
|
No editType for this Entity
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,50 +1,24 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import PillBar from "../../../../components/inputs/PillBar.vue";
|
import { editTypes } from "../../../../definitions";
|
||||||
import TextBox from "../../../../components/inputs/TextBox.vue";
|
|
||||||
import MultilineTextBox from "../../../../components/inputs/MultilineTextBox.vue";
|
|
||||||
import CheckBox from "../../../../components/inputs/CheckBox.vue";
|
|
||||||
|
|
||||||
const props = $defineProps<{subsystem: string, entity: string}>();
|
const props = $defineProps<{subsystem: string, entity: string}>();
|
||||||
const { subsystem, entity } = $(props);
|
const { subsystem, entity } = $(props);
|
||||||
|
|
||||||
const createTypes: { [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 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"network": {
|
|
||||||
"interfaces": {
|
|
||||||
title: "Interfaces",
|
|
||||||
fields: [
|
|
||||||
{key: "name", label: "Name", component: () => TextBox },
|
|
||||||
{key: "comment", label: "Comment", component: () => MultilineTextBox },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
async function create() {
|
async function create() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div v-if="createTypes[subsystem][entity]">
|
<div v-if="editTypes[subsystem][entity]">
|
||||||
<PageHeader :title="'Edit ' + createTypes[subsystem][entity].title">
|
<PageHeader :title="'Edit ' + editTypes[subsystem][entity].title">
|
||||||
<button @click="create">Create</button>
|
<button @click="create">Create</button>
|
||||||
<button @click="$router.go(-1)">Discard</button>
|
<button @click="$router.go(-1)">Discard</button>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
{{ subsystem }} {{ entity }}
|
<NiceForm class="scroll cl-secondary" :title="editTypes[subsystem][entity].title" :fields="editTypes[subsystem][entity].fields"/>
|
||||||
<NiceForm class="scroll cl-secondary" title="Test" :fields="createTypes[subsystem][entity].fields"/>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
No create for this Entity
|
<PageHeader title="Error"/>
|
||||||
|
No editType for this Entity
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Add table
Reference in a new issue