mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 18:38:22 +00:00
wip, adjust create and update to rust backend
This commit is contained in:
parent
8945fdeda3
commit
cdfa7efd2d
2 changed files with 22 additions and 4 deletions
|
@ -14,9 +14,9 @@ async function load(){
|
||||||
loading = true;
|
loading = true;
|
||||||
let res: any;
|
let res: any;
|
||||||
if (editTypes[subsystem][entity].idType == 'Number') {
|
if (editTypes[subsystem][entity].idType == 'Number') {
|
||||||
res = await apiCall(`${subsystem }.${entity}.get`, {id: id as number - 0});
|
res = await apiCall(`${subsystem}.${entity}.get`, {id: id as number - 0});
|
||||||
} else {
|
} else {
|
||||||
res = await apiCall(`${subsystem }.${entity}.get`, {id: id});
|
res = await apiCall(`${subsystem}.${entity}.get`, {id: id});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.Error === null) {
|
if (res.Error === null) {
|
||||||
|
@ -30,7 +30,16 @@ async function load(){
|
||||||
|
|
||||||
async function update(value: any) {
|
async function update(value: any) {
|
||||||
console.debug('value', value);
|
console.debug('value', value);
|
||||||
let res = await apiCall(`${subsystem}.${entity}.update`, value);
|
let res: any;
|
||||||
|
|
||||||
|
if (editTypes[subsystem][entity].idType == 'Number') {
|
||||||
|
res = await apiCall(`${subsystem}.${entity}.update`, {id: id as number - 0, thing: value});
|
||||||
|
} else {
|
||||||
|
// TODO dont have name in value at all, see create (index.vue)
|
||||||
|
delete value.name;
|
||||||
|
res = await apiCall(`${subsystem}.${entity}.update`, {id: id, thing: value});
|
||||||
|
}
|
||||||
|
|
||||||
if (res.Error === null) {
|
if (res.Error === null) {
|
||||||
p.toast.success(`Updated ${ editTypes[subsystem][entity].name}`);
|
p.toast.success(`Updated ${ editTypes[subsystem][entity].name}`);
|
||||||
p.router.go(-1);
|
p.router.go(-1);
|
||||||
|
|
|
@ -9,7 +9,16 @@ const { subsystem, entity } = $(props);
|
||||||
|
|
||||||
async function create(value: any) {
|
async function create(value: any) {
|
||||||
console.debug('value', value);
|
console.debug('value', value);
|
||||||
let res = await apiCall(`${subsystem}.${entity}.create`, value);
|
let res: any;
|
||||||
|
if (editTypes[subsystem][entity].idType == 'Number') {
|
||||||
|
res = await apiCall(`${subsystem }.${entity}.create`, value);
|
||||||
|
} else {
|
||||||
|
// TODO find way to only have a name/id field in the form on create and not put it into the value
|
||||||
|
let id = value.name;
|
||||||
|
delete value.name;
|
||||||
|
res = await apiCall(`${subsystem }.${entity}.create`, {id: id, thing: value});
|
||||||
|
}
|
||||||
|
|
||||||
if (res.Error === null) {
|
if (res.Error === null) {
|
||||||
p.toast.success(`Created ${ editTypes[subsystem][entity].name}`);
|
p.toast.success(`Created ${ editTypes[subsystem][entity].name}`);
|
||||||
p.router.go(-1);
|
p.router.go(-1);
|
||||||
|
|
Loading…
Add table
Reference in a new issue