Skip to content

Commit

Permalink
Config for history
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Oct 6, 2023
1 parent a180ae3 commit a4a0fb2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions internal/web/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func saveConfigHandler(w http.ResponseWriter, r *http.Request) {
AppConfig.Color = r.FormValue("color")
AppConfig.IgnoreIP = r.FormValue("ignoreip")
AppConfig.LogLevel = r.FormValue("loglevel")
AppConfig.HistDays = r.FormValue("history")

timeout := r.FormValue("timeout")
AppConfig.Timeout, err = strconv.Atoi(timeout)
Expand Down
2 changes: 0 additions & 2 deletions internal/web/line.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
func lineHandler(w http.ResponseWriter, r *http.Request) {
var guiData models.GuiData

updateAllHosts()

guiData.Config = AppConfig
guiData.Hosts = []models.Host{}

Expand Down
6 changes: 1 addition & 5 deletions internal/web/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func sortByIPs(method string) {
}

func sortHandler(w http.ResponseWriter, r *http.Request) {
var guiData models.GuiData

sortMethod := r.FormValue("sort_method")

Expand Down Expand Up @@ -76,10 +75,7 @@ func sortHandler(w http.ResponseWriter, r *http.Request) {
updateAllHosts()
}

guiData.Config = AppConfig
guiData.Hosts = AllHosts

execTemplate(w, "line", guiData)
http.Redirect(w, r, r.Header.Get("Referer"), 302)
}

func sortByField(method string, field string) {
Expand Down
4 changes: 4 additions & 0 deletions internal/web/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
</select>
</td>
</tr>
<tr>
<td>Keep history (days)</td>
<td><input name="history" type="text" class="form-control" value="{{ .Config.HistDays }}"></td>
</tr>
<tr>
<td><button type="submit" class="btn btn-primary">Save</button></td>
</form>
Expand Down

0 comments on commit a4a0fb2

Please sign in to comment.