Add group widget

This commit is contained in:
Svilen Markov
2024-08-01 21:34:07 +01:00
parent 795caa5d9d
commit 738bcf8bcb
10 changed files with 249 additions and 4 deletions

View File

@ -63,6 +63,8 @@ func New(widgetType string) (Widget, error) {
widget = &Search{}
case "extension":
widget = &Extension{}
case "group":
widget = &Group{}
default:
return nil, fmt.Errorf("unknown widget type: %s", widgetType)
}
@ -100,10 +102,6 @@ func (w *Widgets) UnmarshalYAML(node *yaml.Node) error {
return err
}
if err := widget.Initialize(); err != nil {
return err
}
*w = append(*w, widget)
}
@ -119,6 +117,7 @@ type Widget interface {
GetID() uint64
SetID(uint64)
HandleRequest(w http.ResponseWriter, r *http.Request)
SetHideHeader(bool)
}
type cacheType int
@ -144,6 +143,7 @@ type widgetBase struct {
cacheType cacheType `yaml:"-"`
nextUpdate time.Time `yaml:"-"`
updateRetriedTimes int `yaml:"-"`
HideHeader bool `yaml:"-"`
}
func (w *widgetBase) RequiresUpdate(now *time.Time) bool {
@ -170,6 +170,10 @@ func (w *widgetBase) SetID(id uint64) {
w.ID = id
}
func (w *widgetBase) SetHideHeader(value bool) {
w.HideHeader = value
}
func (widget *widgetBase) HandleRequest(w http.ResponseWriter, r *http.Request) {
http.Error(w, "not implemented", http.StatusNotImplemented)
}