Edit names}
+ fallback={Edit names }
>
Edit names
diff --git a/frontend/src/components/Body/TableHead.tsx b/frontend/src/components/Body/TableHead.tsx
index 384a66e..7b4955f 100644
--- a/frontend/src/components/Body/TableHead.tsx
+++ b/frontend/src/components/Body/TableHead.tsx
@@ -1,24 +1,26 @@
+import { For } from "solid-js";
import { Host } from "../../functions/exports";
import { sortByAnyField } from "../../functions/sort";
function TableHead() {
- const handleSort = (sortBy: keyof Host) => {
- sortByAnyField(sortBy);
+ const handleSort = (sortBy: string) => {
+ sortBy === "MAC" ? sortBy = "Mac" : '';
+ sortBy === "Hardware" ? sortBy = "Hw" : '';
+ sortBy === "Online" ? sortBy = "Now" : '';
+ sortByAnyField(sortBy as keyof Host);
};
return (
- Name
- Iface
- IP
- MAC
- Hardware
- Date
- Known
- Online
+ {(key) =>
+ {key}
+ }
diff --git a/frontend/src/components/Body/TableRow.tsx b/frontend/src/components/Body/TableRow.tsx
index 64aba53..8da5d40 100644
--- a/frontend/src/components/Body/TableRow.tsx
+++ b/frontend/src/components/Body/TableRow.tsx
@@ -1,31 +1,28 @@
import { createSignal, Show } from "solid-js";
import { editNames } from "../../functions/exports";
import { apiEditHost } from "../../functions/api";
+import { getHosts } from "../../functions/atstart";
function TableRow(_props: any) {
const [name, setName] = createSignal(_props.host.Name);
-
- const link = "http://" + _props.host.IP;
- const edit = "/host/" + _props.host.ID;
let now =
;
if (_props.host.Now == 1) {
now =
;
};
- let known = false;
- if (_props.host.Known == 1) {
- known = true;
- }
+ let known:boolean;
+ _props.host.Known === 1 ? known = true : known = false;
const handleInput = async (n: string) => {
- // console.log('Edit:', n);
setName(n);
await apiEditHost(_props.host.ID, name(), '');
+ getHosts();
};
const handleToggle = async () => {
await apiEditHost(_props.host.ID, name(), 'toggle');
+ getHosts();
};
return (
@@ -41,7 +38,7 @@ function TableRow(_props: any) {
{_props.host.Iface}
-
{_props.host.IP}
+
{_props.host.IP}
{_props.host.Mac}
{_props.host.Hw}
{_props.host.Date}
@@ -53,7 +50,9 @@ function TableRow(_props: any) {
{now}
-
+
+
+
)
diff --git a/frontend/src/components/Config/Prometheus.tsx b/frontend/src/components/Config/Prometheus.tsx
index dfb4102..a7000cf 100644
--- a/frontend/src/components/Config/Prometheus.tsx
+++ b/frontend/src/components/Config/Prometheus.tsx
@@ -23,7 +23,7 @@ function Prometheus() {
Save
- /metrics
+ /metrics
diff --git a/frontend/src/components/Filter.tsx b/frontend/src/components/Filter.tsx
index 6039d8c..55a7a26 100644
--- a/frontend/src/components/Filter.tsx
+++ b/frontend/src/components/Filter.tsx
@@ -12,23 +12,23 @@ function Filter() {
return (
-
+
Iface
{(iface) =>
{handleFilter("Iface", iface)}}>{iface}
}
-
+
Known
{handleFilter("Known", 1)}}>Known
{handleFilter("Known", 0)}}>Unknown
-
+
Online
{handleFilter("Now", 1)}}>Online
{handleFilter("Now", 0)}}>Offline
- {handleFilter("ID", 0)}} class="btn btn-outline-primary">Reset filter
+ {handleFilter("ID", 0)}} class="btn btn-outline-primary" title="Reset filter">Reset filter
)
diff --git a/frontend/src/components/Header.tsx b/frontend/src/components/Header.tsx
index a2a71a9..4560ccb 100644
--- a/frontend/src/components/Header.tsx
+++ b/frontend/src/components/Header.tsx
@@ -33,36 +33,27 @@ function Header() {
{/* icons */}
{/* theme */}
-
+
>
)
diff --git a/frontend/src/components/HistShow.tsx b/frontend/src/components/HistShow.tsx
new file mode 100644
index 0000000..4a25e71
--- /dev/null
+++ b/frontend/src/components/HistShow.tsx
@@ -0,0 +1,17 @@
+import { setShow, show } from "../functions/exports";
+
+function HistShow(_props: any) {
+
+ const handleSaveShow = (showStr: string) => {
+ localStorage.setItem(_props.name, showStr);
+
+ setShow(+showStr);
+ show() == 0 ? setShow(198) : '';
+ };
+
+ return (
+
handleSaveShow(e.target.value)} placeholder="Show elements" title="Nomber of elements to show" style="max-width: 10em;">
+ )
+}
+
+export default HistShow
diff --git a/frontend/src/components/HostPage/HistCard.tsx b/frontend/src/components/HostPage/HistCard.tsx
index 3f0553f..6ef9c7c 100644
--- a/frontend/src/components/HostPage/HistCard.tsx
+++ b/frontend/src/components/HostPage/HistCard.tsx
@@ -1,10 +1,19 @@
+import { setShow, show } from "../../functions/exports";
+import HistShow from "../HistShow"
import MacHistory from "../MacHistory"
function HistCard(_props: any) {
+ const showStr = localStorage.getItem("hostShow") as string;
+ setShow(+showStr);
+ (show() === 0 || isNaN(show())) ? setShow(570) : '';
+
return (
-
+
{_props.mac !== ""
?
diff --git a/frontend/src/components/MacHistory.tsx b/frontend/src/components/MacHistory.tsx
index 206a3cb..451aef2 100644
--- a/frontend/src/components/MacHistory.tsx
+++ b/frontend/src/components/MacHistory.tsx
@@ -1,6 +1,6 @@
-import { createSignal, For, onMount } from "solid-js";
+import { createSignal, For, onMount, Show } from "solid-js";
import { apiGetHistory } from "../functions/api";
-import { Host } from "../functions/exports";
+import { Host, show } from "../functions/exports";
function MacHistory(_props: any) {
@@ -11,17 +11,18 @@ function MacHistory(_props: any) {
h = await apiGetHistory(_props.mac);
if (h != null) {
h.sort((a:Host, b:Host) => (a.Date < b.Date ? 1 : -1));
- if (_props.show > 0) {
- h = h.slice(0, _props.show);
- }
setHist(h);
}
});
return (
-
{h =>
-
+ {(h, index) =>
+
+
+
}
)
}
diff --git a/frontend/src/components/Search.tsx b/frontend/src/components/Search.tsx
index 8b462e0..dbe55bb 100644
--- a/frontend/src/components/Search.tsx
+++ b/frontend/src/components/Search.tsx
@@ -7,7 +7,7 @@ function Search() {
};
return (
- handleSearch(e.target.value)} class="form-control" placeholder="Search" style="max-width: 10em;">
+ handleSearch(e.target.value)} class="form-control" placeholder="Search" style="max-width: 10em;" title="Search">
)
}
diff --git a/frontend/src/functions/atstart.ts b/frontend/src/functions/atstart.ts
index 2e9eefa..7d5b6ee 100644
--- a/frontend/src/functions/atstart.ts
+++ b/frontend/src/functions/atstart.ts
@@ -12,15 +12,17 @@ export function runAtStart() {
}, 60000); // 60000 ms = 1 minute
}
-async function getHosts() {
+export async function getHosts() {
const hosts = await apiGetAllHosts();
- setAllHosts(hosts);
- setBkpHosts(hosts);
- sortAtStart();
- filterAtStart();
- listIfaces();
- // console.log("UPD");
+ if (hosts !== null && hosts.length > 0) {
+ setAllHosts(hosts);
+ setBkpHosts(hosts);
+
+ listIfaces();
+ sortAtStart();
+ filterAtStart();
+ }
}
function listIfaces() {
diff --git a/frontend/src/functions/exports.ts b/frontend/src/functions/exports.ts
index 4d105db..fcef127 100644
--- a/frontend/src/functions/exports.ts
+++ b/frontend/src/functions/exports.ts
@@ -88,4 +88,6 @@ export const [ifaces, setIfaces] = createSignal([]);
export const [appConfig, setAppConfig] = createSignal(emptyConf);
-export const [editNames, setEditNames] = createSignal(false);
\ No newline at end of file
+export const [editNames, setEditNames] = createSignal(false);
+
+export const [show, setShow] = createSignal(198);
\ No newline at end of file
diff --git a/frontend/src/pages/History.tsx b/frontend/src/pages/History.tsx
index b494630..2d6390a 100644
--- a/frontend/src/pages/History.tsx
+++ b/frontend/src/pages/History.tsx
@@ -1,14 +1,20 @@
import { For } from "solid-js"
import Filter from "../components/Filter"
-import { allHosts } from "../functions/exports"
+import { allHosts, setShow, show } from "../functions/exports"
import MacHistory from "../components/MacHistory"
+import HistShow from "../components/HistShow"
function History() {
+ const showStr = localStorage.getItem("histShow") as string;
+ setShow(+showStr);
+ (show() === 0 || isNaN(show())) ? setShow(198) : '';
+
return (
-