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
|
||||
13
CHANGELOG.md
13
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/)
|
||||
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
|
||||
- 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)
|
||||
|
|
@ -3,8 +3,41 @@ package main
|
|||
import (
|
||||
"net/http"
|
||||
"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) {
|
||||
|
||||
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
|
||||
})
|
||||
case "ip-up":
|
||||
sort.SliceStable(AllHosts, func(i, j int) bool {
|
||||
return AllHosts[i].Ip < AllHosts[j].Ip
|
||||
})
|
||||
sort_by_ips("asc")
|
||||
case "ip-down":
|
||||
sort.SliceStable(AllHosts, func(i, j int) bool {
|
||||
return AllHosts[i].Ip > AllHosts[j].Ip
|
||||
})
|
||||
sort_by_ips("desc")
|
||||
case "date-up":
|
||||
sort.SliceStable(AllHosts, func(i, j int) bool {
|
||||
return AllHosts[i].Date < AllHosts[j].Date
|
||||
|
|
|
|||
Loading…
Reference in a new issue