chg: [template] removes current madness

nifi
Jean-Louis Huynen 2020-02-10 17:13:24 +01:00
parent f464ae9c1c
commit 36a521e7b1
No known key found for this signature in database
GPG Key ID: 64799157F4BD6B93
2 changed files with 20 additions and 14 deletions

View File

@ -387,7 +387,6 @@ func (s *SshdParser) Compile() error {
daily := struct { daily := struct {
Title string Title string
Current string
MinDate string MinDate string
MaxDate string MaxDate string
CurrentTime string CurrentTime string
@ -395,7 +394,6 @@ func (s *SshdParser) Compile() error {
Title: "sshd failed logins - daily statistics", Title: "sshd failed logins - daily statistics",
MinDate: parsedOldestStr, MinDate: parsedOldestStr,
MaxDate: parsedNewestStr, MaxDate: parsedNewestStr,
Current: newest,
CurrentTime: parsedNewestStr, CurrentTime: parsedNewestStr,
} }
@ -403,24 +401,20 @@ func (s *SshdParser) Compile() error {
Title string Title string
MonthList map[string][]string MonthList map[string][]string
CurrentTime string CurrentTime string
Current string
}{ }{
Title: "sshd failed logins - monthly statistics", Title: "sshd failed logins - monthly statistics",
MonthList: months, MonthList: months,
CurrentTime: years[0] + months[years[0]][0], CurrentTime: parsedNewestStr,
Current: years[0] + months[years[0]][0],
} }
yearly := struct { yearly := struct {
Title string Title string
YearList []string YearList []string
Current string
CurrentTime string CurrentTime string
}{ }{
Title: "sshd failed logins - yearly statistics", Title: "sshd failed logins - yearly statistics",
YearList: years, YearList: years,
Current: years[0], CurrentTime: parsedNewestStr,
CurrentTime: years[0],
} }
// Create folder to store resulting files // Create folder to store resulting files

View File

@ -7,7 +7,11 @@
<title>{{.Title}}</title> <title>{{.Title}}</title>
<script> <script>
var currentType = "statsusername"; var currentType = "statsusername";
var current = {{.CurrentTime}}; var currentTime = {{.CurrentTime}};
var strSplit = currentTime.split('-');
var currentYear = strSplit[0];
var currentMonth = strSplit[1];
var currentDay = strSplit[2];
</script> </script>
<script src="load.js"></script> <script src="load.js"></script>
<style> <style>
@ -26,14 +30,14 @@
} }
</style> </style>
</head> </head>
<body onload="loadImage({{.Current}}, currentType)"> <body onload="loadImage(currentTime.replace(/-/g, ''), currentType)">
{{end}} {{end}}
{{ define "footertpl"}} {{ define "footertpl"}}
<span> <span>
<label for="statstype">Type: </label> <label for="statstype">Type: </label>
<select selected="statsusername" onchange="currentType = this.value; loadImage(current.replace(/-/g, ''), currentType)"> <select selected="statsusername" onchange="currentType = this.value; loadImage(currentYear+currentMonth+currentDay, currentType)">
<option value="statsusername">Usernames</option> <option value="statsusername">Usernames</option>
<option value="statssrc">Sources</option> <option value="statssrc">Sources</option>
<option value="statshost">Hosts</option> <option value="statshost">Hosts</option>
@ -47,13 +51,13 @@
{{ define "dailytpl"}} {{ define "dailytpl"}}
<span> <span>
<label for="statsday">Statistics for: </label> <label for="statsday">Statistics for: </label>
<input id="statsday" type="date" value="{{.CurrentTime}}" min="{{.MinDate}}" max="{{.MaxDate}}" onchange="current = this.value.replace(/-/g, ''); loadImage(current, currentType)"/> <input id="statsday" type="date" value="{{.CurrentTime}}" min="{{.MinDate}}" max="{{.MaxDate}}" onchange="currentTime = this.value.replace(/-/g, ''); loadImage(currentTime, currentType)"/>
</span> </span>
{{end}} {{end}}
{{ define "yearlytpl"}} {{ define "yearlytpl"}}
<span> <span>
<select onchange="current = this.value; loadImage(current, currentType)"> <select onready="currentDay = ''; currentMonth = '';" onchange="currentYear = this.value; loadImage(currentYear, currentType)">
{{range $val := .YearList}} {{range $val := .YearList}}
<option value="{{$val}}">{{$val}}</option> <option value="{{$val}}">{{$val}}</option>
{{end}} {{end}}
@ -63,7 +67,7 @@
{{ define "monthlytpl"}} {{ define "monthlytpl"}}
<span> <span>
<select onchange="current = this.value.replace(/-/g, ''); loadImage(current, currentType)"> <select onready= "currentDay = '';" onchange="currentMonth = this.value; loadImage(currentYear+currentMonth, currentType)">
{{range $key, $val := .MonthList}} {{range $key, $val := .MonthList}}
{{range $month := index $val}} {{range $month := index $val}}
<option value="{{$month}}">{{$month}}</option> <option value="{{$month}}">{{$month}}</option>
@ -71,4 +75,12 @@
{{end}} {{end}}
</select> </select>
</span> </span>
<span>
<select onchange="currentYear = this.value; loadImage(currentYear+currentMonth, currentType)">
{{range $key, $val := .MonthList}}
<option value="{{$key}}">{{$key}}</option>
{{end}}
</select>
</span>
{{end}} {{end}}
''