commit
78e1302832
3 changed files with 41 additions and 15 deletions
2
.version
2
.version
|
|
@ -1 +1 @@
|
||||||
VERSION=0.7.4
|
VERSION=0.7.5
|
||||||
11
CHANGELOG.md
11
CHANGELOG.md
|
|
@ -5,24 +5,21 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
## [v0.7.3] - 2022-08-30
|
## [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
|
### Added
|
||||||
- Workflow to build ARM images
|
- Workflow to build ARM images
|
||||||
|
|
||||||
|
|
||||||
## [v0.7.2] - 2022-08-26
|
## [v0.7.2] - 2022-08-26
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Theme support in config
|
- Theme support in config
|
||||||
|
|
||||||
|
|
||||||
## [v0.7.1] - 2022-08-26
|
## [v0.7.1] - 2022-08-26
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Workaround for correct display of strings with apostrophes
|
- Workaround for correct display of strings with apostrophes
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- [Issue #2](https://github.com/aceberg/WatchYourLAN/issues/2)
|
- [Issue #2](https://github.com/aceberg/WatchYourLAN/issues/2)
|
||||||
- [Issue #5](https://github.com/aceberg/WatchYourLAN/issues/5)
|
- [Issue #5](https://github.com/aceberg/WatchYourLAN/issues/5)
|
||||||
|
|
@ -3,8 +3,41 @@ package main
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
|
"bytes"
|
||||||
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func sort_by_ips(method string) {
|
||||||
|
type ipHost struct {
|
||||||
|
Host Host
|
||||||
|
Ip net.IP
|
||||||
|
}
|
||||||
|
toSort := []ipHost{}
|
||||||
|
var oneSort ipHost
|
||||||
|
|
||||||
|
for _, oneHost := range AllHosts {
|
||||||
|
oneSort.Host = oneHost
|
||||||
|
oneSort.Ip = net.ParseIP(oneHost.Ip)
|
||||||
|
toSort = append(toSort, oneSort)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch method {
|
||||||
|
case "asc":
|
||||||
|
sort.Slice(toSort, func(i, j int) bool {
|
||||||
|
return bytes.Compare(toSort[i].Ip, toSort[j].Ip) < 0
|
||||||
|
})
|
||||||
|
case "desc":
|
||||||
|
sort.Slice(toSort, func(i, j int) bool {
|
||||||
|
return bytes.Compare(toSort[i].Ip, toSort[j].Ip) > 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
AllHosts = []Host{}
|
||||||
|
for _, oneSort := range toSort {
|
||||||
|
AllHosts = append(AllHosts, oneSort.Host)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func sort_hosts(w http.ResponseWriter, r *http.Request) {
|
func sort_hosts(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
sort_method := r.FormValue("sort_method")
|
sort_method := r.FormValue("sort_method")
|
||||||
|
|
@ -19,13 +52,9 @@ func sort_hosts(w http.ResponseWriter, r *http.Request) {
|
||||||
return AllHosts[i].Name > AllHosts[j].Name
|
return AllHosts[i].Name > AllHosts[j].Name
|
||||||
})
|
})
|
||||||
case "ip-up":
|
case "ip-up":
|
||||||
sort.SliceStable(AllHosts, func(i, j int) bool {
|
sort_by_ips("asc")
|
||||||
return AllHosts[i].Ip < AllHosts[j].Ip
|
|
||||||
})
|
|
||||||
case "ip-down":
|
case "ip-down":
|
||||||
sort.SliceStable(AllHosts, func(i, j int) bool {
|
sort_by_ips("desc")
|
||||||
return AllHosts[i].Ip > AllHosts[j].Ip
|
|
||||||
})
|
|
||||||
case "date-up":
|
case "date-up":
|
||||||
sort.SliceStable(AllHosts, func(i, j int) bool {
|
sort.SliceStable(AllHosts, func(i, j int) bool {
|
||||||
return AllHosts[i].Date < AllHosts[j].Date
|
return AllHosts[i].Date < AllHosts[j].Date
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue