mirror of
https://github.com/speatzle/nfsense.git
synced 2025-09-13 15:19:08 +00:00
Add Static Route Frontend
This commit is contained in:
parent
3197f291fa
commit
ff28b30d93
3 changed files with 72 additions and 0 deletions
51
client/src/pages/network/StaticRoutes.vue
Normal file
51
client/src/pages/network/StaticRoutes.vue
Normal file
|
@ -0,0 +1,51 @@
|
|||
<script setup lang="ts">
|
||||
import { apiCall } from "../../api";
|
||||
|
||||
let staticRoutes = $ref([]);
|
||||
let loading = $ref(false);
|
||||
let selection = $ref([] as number[]);
|
||||
|
||||
const columns = [
|
||||
{heading: 'Name', path: 'name'},
|
||||
{heading: 'Interface', path: 'interface'},
|
||||
{heading: 'Gateway', path: 'gateway'},
|
||||
{heading: 'Destination', path: 'destination'},
|
||||
{heading: 'Metric', path: 'metric'},
|
||||
];
|
||||
|
||||
async function load(){
|
||||
loading = true
|
||||
let res = await apiCall("Network.GetStaticRoutes", {});
|
||||
if (res.Error === null) {
|
||||
console.debug("staticRoutes", res.Data.StaticRoutes);
|
||||
staticRoutes = res.Data.StaticRoutes;
|
||||
} else {
|
||||
console.debug("error", res);
|
||||
}
|
||||
loading = false
|
||||
}
|
||||
|
||||
async function deleteStaticRoutes(){
|
||||
let res = await apiCall("Network.DeleteStaticRoute", {index: selection[0]});
|
||||
if (res.Error === null) {
|
||||
console.debug("deleted static routes");
|
||||
} else {
|
||||
console.debug("error", res);
|
||||
}
|
||||
load();
|
||||
}
|
||||
|
||||
onMounted(async() => {
|
||||
load();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TableView title="Static Routes" :columns="columns" :loading="loading" v-model:selection="selection" v-model:data="staticRoutes" :table-props="{sort:true, sortSelf: true}">
|
||||
<button @click="load">Refresh</button>
|
||||
<router-link class="button" to="/network/staticroutes/edit">Create</router-link>
|
||||
<router-link class="button" :class="{ disabled: selection.length != 1 }" :to="'/network/staticroutes/edit/' + selection[0]">Edit</router-link>
|
||||
<button @click="deleteStaticRoutes" :disabled="selection.length != 1">Delete</button>
|
||||
</TableView>
|
||||
</template>
|
Loading…
Add table
Add a link
Reference in a new issue