Skip to content

Commit 36a521e

Browse files
committed
chg: [template] removes current madness
1 parent f464ae9 commit 36a521e

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

logparser/sshd.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,40 +387,34 @@ func (s *SshdParser) Compile() error {
387387

388388
daily := struct {
389389
Title string
390-
Current string
391390
MinDate string
392391
MaxDate string
393392
CurrentTime string
394393
}{
395394
Title: "sshd failed logins - daily statistics",
396395
MinDate: parsedOldestStr,
397396
MaxDate: parsedNewestStr,
398-
Current: newest,
399397
CurrentTime: parsedNewestStr,
400398
}
401399

402400
monthly := struct {
403401
Title string
404402
MonthList map[string][]string
405403
CurrentTime string
406-
Current string
407404
}{
408405
Title: "sshd failed logins - monthly statistics",
409406
MonthList: months,
410-
CurrentTime: years[0] + months[years[0]][0],
411-
Current: years[0] + months[years[0]][0],
407+
CurrentTime: parsedNewestStr,
412408
}
413409

414410
yearly := struct {
415411
Title string
416412
YearList []string
417-
Current string
418413
CurrentTime string
419414
}{
420415
Title: "sshd failed logins - yearly statistics",
421416
YearList: years,
422-
Current: years[0],
423-
CurrentTime: years[0],
417+
CurrentTime: parsedNewestStr,
424418
}
425419

426420
// Create folder to store resulting files

logparser/sshd/statistics.gohtml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
<title>{{.Title}}</title>
88
<script>
99
var currentType = "statsusername";
10-
var current = {{.CurrentTime}};
10+
var currentTime = {{.CurrentTime}};
11+
var strSplit = currentTime.split('-');
12+
var currentYear = strSplit[0];
13+
var currentMonth = strSplit[1];
14+
var currentDay = strSplit[2];
1115
</script>
1216
<script src="load.js"></script>
1317
<style>
@@ -26,14 +30,14 @@
2630
}
2731
</style>
2832
</head>
29-
<body onload="loadImage({{.Current}}, currentType)">
33+
<body onload="loadImage(currentTime.replace(/-/g, ''), currentType)">
3034
{{end}}
3135

3236

3337
{{ define "footertpl"}}
3438
<span>
3539
<label for="statstype">Type: </label>
36-
<select selected="statsusername" onchange="currentType = this.value; loadImage(current.replace(/-/g, ''), currentType)">
40+
<select selected="statsusername" onchange="currentType = this.value; loadImage(currentYear+currentMonth+currentDay, currentType)">
3741
<option value="statsusername">Usernames</option>
3842
<option value="statssrc">Sources</option>
3943
<option value="statshost">Hosts</option>
@@ -47,13 +51,13 @@
4751
{{ define "dailytpl"}}
4852
<span>
4953
<label for="statsday">Statistics for: </label>
50-
<input id="statsday" type="date" value="{{.CurrentTime}}" min="{{.MinDate}}" max="{{.MaxDate}}" onchange="current = this.value.replace(/-/g, ''); loadImage(current, currentType)"/>
54+
<input id="statsday" type="date" value="{{.CurrentTime}}" min="{{.MinDate}}" max="{{.MaxDate}}" onchange="currentTime = this.value.replace(/-/g, ''); loadImage(currentTime, currentType)"/>
5155
</span>
5256
{{end}}
5357

5458
{{ define "yearlytpl"}}
5559
<span>
56-
<select onchange="current = this.value; loadImage(current, currentType)">
60+
<select onready="currentDay = ''; currentMonth = '';" onchange="currentYear = this.value; loadImage(currentYear, currentType)">
5761
{{range $val := .YearList}}
5862
<option value="{{$val}}">{{$val}}</option>
5963
{{end}}
@@ -63,12 +67,20 @@
6367

6468
{{ define "monthlytpl"}}
6569
<span>
66-
<select onchange="current = this.value.replace(/-/g, ''); loadImage(current, currentType)">
70+
<select onready= "currentDay = '';" onchange="currentMonth = this.value; loadImage(currentYear+currentMonth, currentType)">
6771
{{range $key, $val := .MonthList}}
6872
{{range $month := index $val}}
6973
<option value="{{$month}}">{{$month}}</option>
7074
{{end}}
7175
{{end}}
7276
</select>
7377
</span>
78+
<span>
79+
<select onchange="currentYear = this.value; loadImage(currentYear+currentMonth, currentType)">
80+
{{range $key, $val := .MonthList}}
81+
<option value="{{$key}}">{{$key}}</option>
82+
{{end}}
83+
</select>
84+
</span>
7485
{{end}}
86+
''

0 commit comments

Comments
 (0)