mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-13 11:38:21 +00:00
Fix Edit form for Number Type ID's
This commit is contained in:
parent
4ab4ab37d5
commit
64a449e9b4
2 changed files with 18 additions and 5 deletions
|
@ -87,6 +87,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
name: "Firewall",
|
name: "Firewall",
|
||||||
"forwardrules": {
|
"forwardrules": {
|
||||||
name: "ForwardRule",
|
name: "ForwardRule",
|
||||||
|
idType: "Number",
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
name: zod.string(),
|
name: zod.string(),
|
||||||
|
@ -111,6 +112,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
"destinationnatrules": {
|
"destinationnatrules": {
|
||||||
name: "DestinationNATRule",
|
name: "DestinationNATRule",
|
||||||
|
idType: "Number",
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
name: zod.string(),
|
name: zod.string(),
|
||||||
|
@ -141,6 +143,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
"sourcenatrules": {
|
"sourcenatrules": {
|
||||||
name: "SourceNATRule",
|
name: "SourceNATRule",
|
||||||
|
idType: "Number",
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
name: zod.string(),
|
name: zod.string(),
|
||||||
|
@ -208,6 +211,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
"staticroutes": {
|
"staticroutes": {
|
||||||
name: "StaticRoute",
|
name: "StaticRoute",
|
||||||
|
idType: "Number",
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
name: zod.string(),
|
name: zod.string(),
|
||||||
|
@ -275,6 +279,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
name: "Service",
|
name: "Service",
|
||||||
"dhcpv4servers": {
|
"dhcpv4servers": {
|
||||||
name: "DHCPv4Server",
|
name: "DHCPv4Server",
|
||||||
|
idType: "Number",
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
}),
|
}),
|
||||||
|
@ -299,6 +304,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
"ntpservers": {
|
"ntpservers": {
|
||||||
name: "NTPServer",
|
name: "NTPServer",
|
||||||
|
idType: "Number",
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
}),
|
}),
|
||||||
|
@ -314,6 +320,7 @@ export const editTypes: { [key: string]: { [key: string]: any } } = {
|
||||||
},
|
},
|
||||||
"dnsservers": {
|
"dnsservers": {
|
||||||
name: "DNSServer",
|
name: "DNSServer",
|
||||||
|
idType: "Number",
|
||||||
validationSchema: toFormValidator(
|
validationSchema: toFormValidator(
|
||||||
zod.object({
|
zod.object({
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -4,22 +4,28 @@ import { apiCall } from "../../../../api";
|
||||||
import getPlugins from '../../../../plugins';
|
import getPlugins from '../../../../plugins';
|
||||||
const p = getPlugins();
|
const p = getPlugins();
|
||||||
|
|
||||||
const props = $defineProps<{subsystem: string, entity: string, id: string}>();
|
const props = $defineProps<{subsystem: string, entity: string, id: string | number}>();
|
||||||
const { subsystem, entity, id } = $(props);
|
const { subsystem, entity, id } = $(props);
|
||||||
|
|
||||||
let initialValues = $ref({} as {});
|
let initialValues = $ref({} as {});
|
||||||
let loading = $ref(true);
|
let loading = $ref(true);
|
||||||
|
|
||||||
async function load(){
|
async function load(){
|
||||||
loading = true
|
loading = true;
|
||||||
let res = await apiCall(editTypes[subsystem].name +".Get"+ editTypes[subsystem][entity].name, {id: id});
|
let res: any;
|
||||||
|
if (editTypes[subsystem][entity].idType == "Number") {
|
||||||
|
res = await apiCall(editTypes[subsystem].name +".Get"+ editTypes[subsystem][entity].name, {id: id as number - 0});
|
||||||
|
} else {
|
||||||
|
res = await apiCall(editTypes[subsystem].name +".Get"+ editTypes[subsystem][entity].name, {id: id});
|
||||||
|
}
|
||||||
|
|
||||||
if (res.Error === null) {
|
if (res.Error === null) {
|
||||||
console.debug("update data", res.Data);
|
console.debug("update data", res.Data);
|
||||||
initialValues = res.Data;
|
initialValues = res.Data;
|
||||||
} else {
|
} else {
|
||||||
console.debug("error", res);
|
console.debug("error", res);
|
||||||
}
|
}
|
||||||
loading = false
|
loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update(value: any) {
|
async function update(value: any) {
|
||||||
|
@ -44,7 +50,7 @@ onMounted(async() => {
|
||||||
<div v-if="editTypes[subsystem][entity]">
|
<div v-if="editTypes[subsystem][entity]">
|
||||||
<PageHeader :title="'Update ' + editTypes[subsystem][entity].name">
|
<PageHeader :title="'Update ' + editTypes[subsystem][entity].name">
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<NiceForm v-if="!loading" class="scroll cl-secondary" :submit="update" :discard="() => $router.go(-1)" :sections="editTypes[subsystem][entity].sections" :initialValues="initialValues"/>
|
<NiceForm v-if="!loading" class="scroll cl-secondary" :submit="update" :discard="() => $router.go(-1)" :sections="editTypes[subsystem][entity].sections" :initial-values="initialValues"/>
|
||||||
<p v-else>Loading...</p>
|
<p v-else>Loading...</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
|
|
Loading…
Add table
Reference in a new issue