mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 02:48:21 +00:00
Add Apply Interfaces
This commit is contained in:
parent
80f255fe86
commit
e72c2c4f2e
2 changed files with 33 additions and 1 deletions
|
@ -40,6 +40,15 @@ async function load(){
|
|||
loading = false
|
||||
}
|
||||
|
||||
async function apply(){
|
||||
let res = await apiCall("Network.ApplyInterfaces", {});
|
||||
if (res.Error === null) {
|
||||
console.debug("apply log", res.Data.Log);
|
||||
} else {
|
||||
console.debug("error", res);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async() => {
|
||||
load();
|
||||
});
|
||||
|
@ -48,7 +57,7 @@ onMounted(async() => {
|
|||
|
||||
<template>
|
||||
<TableView title="Interfaces" :columns="columns" :loading="loading" v-model:selection="selection" v-model:data="displayData" :table-props="{sort:true, sortSelf: true}">
|
||||
<button @click="load">Apply</button>
|
||||
<button @click="apply">Apply</button>
|
||||
<button @click="load">Refresh</button>
|
||||
<button @click="load">Create</button>
|
||||
<button @click="load" :disabled="selection.length != 1">Edit</button>
|
||||
|
|
|
@ -2,8 +2,10 @@ package network
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"nfsense.net/nfsense/internal/definitions"
|
||||
"nfsense.net/nfsense/internal/interfaces"
|
||||
)
|
||||
|
||||
type GetInterfacesParameters struct {
|
||||
|
@ -18,3 +20,24 @@ func (f *Network) GetInterfaces(ctx context.Context, params GetInterfacesParamet
|
|||
Interfaces: f.Conf.Network.Interfaces,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type ApplyInterfacesParameters struct {
|
||||
}
|
||||
|
||||
type ApplyInterfacesResult struct {
|
||||
Log string
|
||||
}
|
||||
|
||||
func (f *Network) ApplyInterfaces(ctx context.Context, params ApplyInterfacesParameters) (ApplyInterfacesResult, error) {
|
||||
data, err := interfaces.GenerateInterfacesFile(*f.Conf)
|
||||
if err != nil {
|
||||
return ApplyInterfacesResult{}, fmt.Errorf("Generating Interfaces File: %w", err)
|
||||
}
|
||||
log, err := interfaces.ApplyInterfacesFile(data)
|
||||
if err != nil {
|
||||
return ApplyInterfacesResult{}, fmt.Errorf("Applying Interfaces File: %w", err)
|
||||
}
|
||||
return ApplyInterfacesResult{
|
||||
Log: log,
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue