Ocean/Admin/Scheme/LoggingViewer.go

77 lines
2.1 KiB
Go
Raw Permalink Normal View History

2015-06-22 15:38:55 +00:00
package Scheme
import (
"html/template"
)
// The type for the web logger viewer template
type LoggingViewer struct {
Title string
SetLiveView bool
CurrentLevel string
CurrentTimeRange string
CurrentCategory string
CurrentImpact string
CurrentSeverity string
CurrentMessageName string
CurrentSender string
CurrentPage string
2015-06-22 18:54:38 +00:00
NextPage string
PreviousPage string
LastPage string
2015-06-22 15:38:55 +00:00
MessageNames []MessageNames
Sender []Sender
Events []LogEvent
}
// The type for the message names is necessary to be able to define a function on it.
type MessageNames string
// The type for the senders is necessary to be able to define a function on it.
type Sender string
// This function is used from the template to mark selected values. This is for the type MessageNames.
func (lv MessageNames) IsSelected(field MessageNames, currentValue string) string {
if string(field) == currentValue {
return ` selected`
} else {
return ``
}
}
// This function is necessary to mark the HTML attribute as safe. Only then it is possible
// to change plain HTML code.
func (lv MessageNames) Safe(element string) template.HTMLAttr {
return template.HTMLAttr(element)
}
// This function is used from the template to mark selected values. This is for the type Sender.
func (lv Sender) IsSelected(field Sender, currentValue string) string {
if string(field) == currentValue {
return ` selected`
} else {
return ``
}
}
// This function is necessary to mark the HTML attribute as safe. Only then it is possible
// to change plain HTML code.
func (lv Sender) Safe(element string) template.HTMLAttr {
return template.HTMLAttr(element)
}
// This function is used from the template to mark selected values.
func (lv LoggingViewer) IsSelected(field, currentValue string) string {
if field == currentValue {
return ` selected`
} else {
return ``
}
}
// This function is necessary to mark the HTML attribute as safe. Only then it is possible
// to change plain HTML code.
func (lv LoggingViewer) Safe(element string) template.HTMLAttr {
return template.HTMLAttr(element)
}