mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 19:08:20 +00:00
Added Actions
This commit is contained in:
parent
161949395a
commit
02016cbbf3
2 changed files with 42 additions and 7 deletions
|
@ -2,6 +2,9 @@
|
||||||
import { apiCall } from "../../api";
|
import { apiCall } from "../../api";
|
||||||
|
|
||||||
let addresses = $ref([]);
|
let addresses = $ref([]);
|
||||||
|
let loading = $ref(false);
|
||||||
|
let selection = $ref([] as number[]);
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{heading: 'Name', path: 'name'},
|
{heading: 'Name', path: 'name'},
|
||||||
{heading: 'Type', path: 'type'},
|
{heading: 'Type', path: 'type'},
|
||||||
|
@ -10,6 +13,7 @@ const columns = [
|
||||||
];
|
];
|
||||||
|
|
||||||
async function load(){
|
async function load(){
|
||||||
|
loading = true
|
||||||
let res = await apiCall("Object.GetAddresses", {});
|
let res = await apiCall("Object.GetAddresses", {});
|
||||||
if (res.Error === null) {
|
if (res.Error === null) {
|
||||||
addresses = res.Data.Addresses;
|
addresses = res.Data.Addresses;
|
||||||
|
@ -17,6 +21,7 @@ async function load(){
|
||||||
} else {
|
} else {
|
||||||
console.debug("error", res);
|
console.debug("error", res);
|
||||||
}
|
}
|
||||||
|
loading = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const displayData = $computed(() => {
|
const displayData = $computed(() => {
|
||||||
|
@ -54,6 +59,16 @@ function getAddressValue(s: any): string {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteAddress(){
|
||||||
|
let res = await apiCall("Object.DeleteAddress", {name: displayData[selection[0]].name});
|
||||||
|
if (res.Error === null) {
|
||||||
|
console.debug("deleted address");
|
||||||
|
} else {
|
||||||
|
console.debug("error", res);
|
||||||
|
}
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async() => {
|
onMounted(async() => {
|
||||||
load();
|
load();
|
||||||
});
|
});
|
||||||
|
@ -61,10 +76,10 @@ onMounted(async() => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<TableView title="Addresses" :columns="columns" :loading="loading" v-model:selection="selection" v-model:data="displayData" :table-props="{sort:true, sortSelf: true}">
|
||||||
<PageHeader title="Addresses">
|
<button @click="load">Refresh</button>
|
||||||
<button @click="load">Load Addresses</button>
|
<button @click="load">Create</button>
|
||||||
</PageHeader>
|
<button @click="load" :disabled="selection.length != 1">Edit</button>
|
||||||
<NiceTable :columns="columns" v-model:data="displayData"/>
|
<button @click="deleteAddress" :disabled="selection.length != 1">Delete</button>
|
||||||
</div>
|
</TableView>
|
||||||
</template>
|
</template>
|
|
@ -2,6 +2,9 @@
|
||||||
import { apiCall } from "../../api";
|
import { apiCall } from "../../api";
|
||||||
|
|
||||||
let services = $ref({});
|
let services = $ref({});
|
||||||
|
let loading = $ref(false);
|
||||||
|
let selection = $ref([] as number[]);
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{heading: 'Name', path: 'name'},
|
{heading: 'Name', path: 'name'},
|
||||||
{heading: 'Type', path: 'type'},
|
{heading: 'Type', path: 'type'},
|
||||||
|
@ -50,6 +53,7 @@ function getServicePortRange(s:any): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function load(){
|
async function load(){
|
||||||
|
loading = true
|
||||||
let res = await apiCall("Object.GetServices", {});
|
let res = await apiCall("Object.GetServices", {});
|
||||||
if (res.Error === null) {
|
if (res.Error === null) {
|
||||||
console.debug("services", res.Data.Services);
|
console.debug("services", res.Data.Services);
|
||||||
|
@ -57,6 +61,17 @@ async function load(){
|
||||||
} else {
|
} else {
|
||||||
console.debug("error", res);
|
console.debug("error", res);
|
||||||
}
|
}
|
||||||
|
loading = false
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteService(){
|
||||||
|
let res = await apiCall("Object.DeleteService", {name: displayData[selection[0]].name});
|
||||||
|
if (res.Error === null) {
|
||||||
|
console.debug("deleted service");
|
||||||
|
} else {
|
||||||
|
console.debug("error", res);
|
||||||
|
}
|
||||||
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async() => {
|
onMounted(async() => {
|
||||||
|
@ -66,5 +81,10 @@ onMounted(async() => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<TableView title="Services" :columns="columns" :load-data="load" v-model:data="displayData" :table-props="{sort:true, sortSelf: true}"/>
|
<TableView title="Services" :columns="columns" :loading="loading" v-model:selection="selection" v-model:data="displayData" :table-props="{sort:true, sortSelf: true}">
|
||||||
|
<button @click="load">Refresh</button>
|
||||||
|
<button @click="load">Create</button>
|
||||||
|
<button @click="load" :disabled="selection.length != 1">Edit</button>
|
||||||
|
<button @click="deleteService" :disabled="selection.length != 1">Delete</button>
|
||||||
|
</TableView>
|
||||||
</template>
|
</template>
|
Loading…
Add table
Reference in a new issue