mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 10:38:20 +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;
|
||||
let res: any;
|
||||
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 {
|
||||
res = await apiCall(`${subsystem }.${entity}.get`, {id: id});
|
||||
res = await apiCall(`${subsystem}.${entity}.get`, {id: id});
|
||||
}
|
||||
|
||||
if (res.Error === null) {
|
||||
|
@ -30,7 +30,16 @@ async function load(){
|
|||
|
||||
async function update(value: any) {
|
||||
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) {
|
||||
p.toast.success(`Updated ${ editTypes[subsystem][entity].name}`);
|
||||
p.router.go(-1);
|
||||
|
|
|
@ -9,7 +9,16 @@ const { subsystem, entity } = $(props);
|
|||
|
||||
async function create(value: any) {
|
||||
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) {
|
||||
p.toast.success(`Created ${ editTypes[subsystem][entity].name}`);
|
||||
p.router.go(-1);
|
||||
|
|
Loading…
Add table
Reference in a new issue