diff --git a/CHANGELOG.md b/CHANGELOG.md index 8353854..976b8f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,102 +1,6 @@ - # Change Log All notable changes to this project will be documented in this file. -## [v1.0.6] - 2024-01-06 -### Fixed -- Sort by `Known` field bug [#70](https://github.com/aceberg/WatchYourLAN/issues/70) - -## [v1.0.5] - 2024-01-05 -### Added -- Goreleaser for binaries [#66](https://github.com/aceberg/WatchYourLAN/issues/66) -- Better Mobile view [#51](https://github.com/aceberg/WatchYourLAN/issues/51) -- [More themes](https://github.com/aceberg/aceberg-bootswatch-fork) (emerald, grass, sand) - -## [v1.0.4] - 2023-10-12 -### Added -- Configurable `timeout` for `arp-scan` [#65](https://github.com/aceberg/WatchYourLAN/issues/65) - -## [v1.0.3] - 2023-10-08 -### Fixed -- Github Action workflow for binary release -- History bugs - -## [v1.0.2] - 2023-10-07 -### Fixed -- UI update bug [#61](https://github.com/aceberg/WatchYourLAN/issues/61) -### Added -- Device online/offline history [#60](https://github.com/aceberg/WatchYourLAN/issues/60) - -## [v1.0.1] - 2023-08-18 -### Added -- User Authentification - -## [v1.0.0] - 2023-08-03 +## [v2.0.0] - 2024-08- ### Changed -- Migrated to YAML config file format -## [v0.9.4] - 2023-06-26 -### Added -- Local node modules option - -## [v0.9.3] - 2023-06-04 -### Added -- Background color: light or dark - -## [v0.9.2] - 2023-05-05 -### Added -- Choose log level in config - -### Changed -- Move to go-1.20 - -## [v0.9.1] - 2023-01-16 -### Added -- Scan host for open ports -- App version on config page -- Check if update is available -- Button to test notifications - -### Changed -- Small fixes - -## [v0.8.3] - 2023-01-03 -### Added -- Clear table button (Config page) -- Delete host button -- Host name from DNS (Click on MAC to see host page) -- Sort buttons for all fields - - -## [v0.8.2] - 2023-01-02 -### Added -- Option to ignore IP change [Issue #25](https://github.com/aceberg/WatchYourLAN/issues/25) - - -## [v0.8.1] - 2022-12-29 -### Changed -- Full code refactoring - -### Added -- Embed templates -- GUI config page -- Binary and Dep package - -## [v0.7.5] - 2022-09-14 -### Fixed -- Sort by IP [Issue #4](https://github.com/aceberg/WatchYourLAN/issues/4), [Issue #14](https://github.com/aceberg/WatchYourLAN/issues/14) - -## [v0.7.3] - 2022-08-30 -### Added -- Workflow to build ARM images - -## [v0.7.2] - 2022-08-26 -### Added -- Theme support in config - -## [v0.7.1] - 2022-08-26 -### Added -- Workaround for correct display of strings with apostrophes -### Fixed -- [Issue #2](https://github.com/aceberg/WatchYourLAN/issues/2) -- [Issue #5](https://github.com/aceberg/WatchYourLAN/issues/5) \ No newline at end of file diff --git a/go.mod b/go.mod index 985c59c..3a14f1b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/aceberg/WatchYourLAN -go 1.22.4 +go 1.22.6 require ( github.com/gin-gonic/gin v1.10.0 diff --git a/internal/models/models.go b/internal/models/models.go index a0f3d7b..38e04bf 100644 --- a/internal/models/models.go +++ b/internal/models/models.go @@ -11,6 +11,8 @@ type Conf struct { DBPath string NodePath string Ifaces []string + ScanMethod string + ArpArgs string } // Host - one host diff --git a/internal/web/api.go b/internal/web/api.go new file mode 100644 index 0000000..ff7b0df --- /dev/null +++ b/internal/web/api.go @@ -0,0 +1,12 @@ +package web + +import ( + "net/http" + + "github.com/gin-gonic/gin" +) + +func apiAll(c *gin.Context) { + + c.IndentedJSON(http.StatusOK, allHosts) +} \ No newline at end of file diff --git a/internal/web/const-var.go b/internal/web/const-var.go index 2c3c8e5..c175c77 100644 --- a/internal/web/const-var.go +++ b/internal/web/const-var.go @@ -9,6 +9,8 @@ import ( var ( // appConfig - config for Web Gui appConfig models.Conf + + allHosts []models.Host ) // templFS - html templates diff --git a/internal/web/index.go b/internal/web/index.go index 93bdc8b..f1cd842 100644 --- a/internal/web/index.go +++ b/internal/web/index.go @@ -14,8 +14,8 @@ func indexHandler(c *gin.Context) { var guiData models.GuiData guiData.Config = appConfig - res := arp.Scan(appConfig.Ifaces) - log.Println("ARPSCAN:", res) + allHosts = arp.Scan(appConfig.Ifaces) + log.Println("ARPSCAN:", allHosts) go arp.GoScan() diff --git a/internal/web/public/js/index.js b/internal/web/public/js/index.js index 34e29ed..c51ab35 100644 --- a/internal/web/public/js/index.js +++ b/internal/web/public/js/index.js @@ -3,27 +3,26 @@ var addrsArray = {}; loadAddrs(); function createHTML(addr, i) { - let off = ''; + let now = ''; - if (addr.Offline == 0) { - off = `0`; + if (addr.Now == 0) { + now = ``; } else { - off = `${addr.Offline}`; + now = ``; } let html = ` ${i}. + ${addr.Name} - ${addr.Name} + ${addr.IP} - - ${addr.Addr} - - ${addr.Total} - ${addr.Watching} - ${addr.Online} - ${off} + ${addr.Mac} + ${addr.Hw} + ${addr.Date} + ${addr.Known} + ${now} `; diff --git a/internal/web/public/version b/internal/web/public/version index cd3d0a4..de0e66e 100644 --- a/internal/web/public/version +++ b/internal/web/public/version @@ -1 +1 @@ -VERSION=0.1.2 \ No newline at end of file +VERSION=2.0.0 \ No newline at end of file diff --git a/internal/web/templates/index.html b/internal/web/templates/index.html index f57cbd8..adc464b 100644 --- a/internal/web/templates/index.html +++ b/internal/web/templates/index.html @@ -4,15 +4,6 @@
-
-
-
- - - -
-
-
@@ -21,11 +12,12 @@ Name - Addr - Total - Watching - Online - Offline + IP + MAC + Hardware + Date + Known + Online diff --git a/internal/web/webgui.go b/internal/web/webgui.go index 3017000..9276a3a 100644 --- a/internal/web/webgui.go +++ b/internal/web/webgui.go @@ -42,6 +42,8 @@ func Gui(dirPath, nodePath string) { router.StaticFS("/fs/", http.FS(pubFS)) // public + router.GET("/api/all", apiAll) // api.go + router.GET("/", indexHandler) // index.go router.GET("/config/", configHandler) // config.go