mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 02:48:21 +00:00
Add Delete Interface
This commit is contained in:
parent
7121c46a74
commit
61ae805305
2 changed files with 25 additions and 7 deletions
|
@ -49,6 +49,16 @@ async function apply(){
|
|||
}
|
||||
}
|
||||
|
||||
async function deleteInterface(){
|
||||
let res = await apiCall("Network.DeleteInterface", {Interface: displayData[selection[0]].name});
|
||||
if (res.Error === null) {
|
||||
console.debug("deleted interface");
|
||||
} else {
|
||||
console.debug("error", res);
|
||||
}
|
||||
load();
|
||||
}
|
||||
|
||||
onMounted(async() => {
|
||||
load();
|
||||
});
|
||||
|
@ -61,6 +71,6 @@ onMounted(async() => {
|
|||
<button @click="load">Refresh</button>
|
||||
<button @click="load">Create</button>
|
||||
<button @click="load" :disabled="selection.length != 1">Edit</button>
|
||||
<button @click="load" :disabled="selection.length == 0">Delete</button>
|
||||
<button @click="deleteInterface" :disabled="selection.length == 0">Delete</button>
|
||||
</TableView>
|
||||
</template>
|
|
@ -8,27 +8,35 @@ import (
|
|||
"nfsense.net/nfsense/internal/interfaces"
|
||||
)
|
||||
|
||||
type GetInterfacesParameters struct {
|
||||
}
|
||||
|
||||
type GetInterfacesResult struct {
|
||||
Interfaces map[string]definitions.Interface
|
||||
}
|
||||
|
||||
func (f *Network) GetInterfaces(ctx context.Context, params GetInterfacesParameters) (GetInterfacesResult, error) {
|
||||
func (f *Network) GetInterfaces(ctx context.Context, params struct{}) (GetInterfacesResult, error) {
|
||||
return GetInterfacesResult{
|
||||
Interfaces: f.Conf.Network.Interfaces,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type ApplyInterfacesParameters struct {
|
||||
type DeleteInterfaceParameters struct {
|
||||
Interface string
|
||||
}
|
||||
|
||||
func (f *Network) DeleteInterface(ctx context.Context, params DeleteInterfaceParameters) (struct{}, error) {
|
||||
_, ok := f.Conf.Network.Interfaces[params.Interface]
|
||||
if !ok {
|
||||
return struct{}{}, fmt.Errorf("Interface does not Exist")
|
||||
}
|
||||
|
||||
delete(f.Conf.Network.Interfaces, params.Interface)
|
||||
return struct{}{}, nil
|
||||
}
|
||||
|
||||
type ApplyInterfacesResult struct {
|
||||
Log string
|
||||
}
|
||||
|
||||
func (f *Network) ApplyInterfaces(ctx context.Context, params ApplyInterfacesParameters) (ApplyInterfacesResult, error) {
|
||||
func (f *Network) ApplyInterfaces(ctx context.Context, params struct{}) (ApplyInterfacesResult, error) {
|
||||
data, err := interfaces.GenerateInterfacesFile(*f.Conf)
|
||||
if err != nil {
|
||||
return ApplyInterfacesResult{}, fmt.Errorf("Generating Interfaces File: %w", err)
|
||||
|
|
Loading…
Add table
Reference in a new issue