DB: sort by date
This commit is contained in:
parent
177ba13497
commit
58ab0291b1
6 changed files with 22 additions and 14 deletions
12
.github/workflows/docker-publish.yml
vendored
12
.github/workflows/docker-publish.yml
vendored
|
|
@ -3,14 +3,14 @@ name: Docker
|
|||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'Makefile'
|
||||
paths:
|
||||
- 'Dockerfile'
|
||||
- 'scr/**'
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- 'Makefile'
|
||||
paths:
|
||||
- 'Dockerfile'
|
||||
- 'scr/**'
|
||||
|
||||
env:
|
||||
IMAGE_NAME: watchyourlan
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ RUN cd /src && go build .
|
|||
|
||||
FROM alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apk add --no-cache tzdata arp-scan \
|
||||
&& mkdir /data
|
||||
|
||||
COPY src/templates /app/templates
|
||||
COPY --from=builder /src/watchyourlan /app/
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENTRYPOINT ["./watchyourlan"]
|
||||
|
|
@ -21,7 +21,7 @@ func db_select() (dbHosts []Host) {
|
|||
db, _ := sql.Open("sqlite3", AppConfig.DbPath)
|
||||
defer db.Close()
|
||||
|
||||
sqlStatement := `SELECT * FROM "now"`
|
||||
sqlStatement := `SELECT * FROM "now" ORDER BY DATE DESC`
|
||||
|
||||
res, err := db.Query(sqlStatement)
|
||||
if err != nil {
|
||||
|
|
|
|||
11
src/index.go
11
src/index.go
|
|
@ -8,9 +8,16 @@ import (
|
|||
)
|
||||
|
||||
func index(w http.ResponseWriter, r *http.Request) {
|
||||
//fmt.Println(AllHosts)
|
||||
type allData struct {
|
||||
Config Conf
|
||||
Hosts []Host
|
||||
}
|
||||
var guiData allData
|
||||
guiData.Config = AppConfig
|
||||
guiData.Hosts = AllHosts
|
||||
|
||||
tmpl, _ := template.ParseFiles("templates/index.html", "templates/header.html")
|
||||
tmpl.ExecuteTemplate(w, "index", AllHosts)
|
||||
tmpl.ExecuteTemplate(w, "index", guiData)
|
||||
}
|
||||
|
||||
func update_host(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<title>Watch Your LAN</title>
|
||||
<meta charset="utf-8">
|
||||
<!--Auto refresh (seconds)-->
|
||||
<!-- <meta http-equiv="refresh" content="60"> -->
|
||||
<!-- <meta http-equiv="refresh" content="{{ .Config.Timeout }}"> -->
|
||||
<!--Favicon-->
|
||||
<link href="data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAA/6k7AP+uSQD/z50A7urjAD85MgAAOO8AWlpaAADIawAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADEREQAAAAAzEREREQAAAzEREREREAAzFxEREVERADN3d3VVVREDM3d3dYVlERMzd3d1VVUREzM3ERESERETMzcRESERERMzNxESMREREzM3ESNEQREwMzcSMxEREwAzNyM0REQzAAMzMzMzMzAAADMzMzMzAAAAADMzMwAAD4HwAA4AcAAMADAACAAQAAgAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAACAAQAAwAMAAOAHAAD4HwAA" rel="icon" type="image/x-icon" />
|
||||
<!--Bootstrap theme-->
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<body>
|
||||
<div class="container mt-3">
|
||||
<h2>Online</h2>
|
||||
<p>Scanning interface: {{ .Config.Iface }}</p>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
|
|
@ -13,7 +14,7 @@
|
|||
<th>Hardware</th>
|
||||
<th>Known</th>
|
||||
</tr>
|
||||
{{ range . }}
|
||||
{{ range .Hosts }}
|
||||
{{ if eq .Now 1 }}
|
||||
<tr>
|
||||
<td>{{ .Name }}</td>
|
||||
|
|
@ -41,7 +42,7 @@
|
|||
<th>Last seen</th>
|
||||
<th>Known</th>
|
||||
</tr>
|
||||
{{ range . }}
|
||||
{{ range .Hosts }}
|
||||
<form action="/update_host/" method="post">
|
||||
<input name="id" type="hidden" class="form-control" value="{{ .Id }}">
|
||||
<tr>
|
||||
|
|
|
|||
Loading…
Reference in a new issue