tsviewer/features/web/index/page.go

35 lines
783 B
Go
Raw Normal View History

2019-01-21 17:53:33 +00:00
package index
import (
"html/template"
"io"
"git.cliffbreak.de/Cliffbreak/tsviewer/features/api/channel"
"git.cliffbreak.de/Cliffbreak/tsviewer/features/api/client"
"git.cliffbreak.de/Cliffbreak/tsviewer/features/api/server"
)
type Service interface {
ServerInfo() (*server.Server, error)
Clients() ([]*client.Client, error)
Channels() ([]*channel.Channel, error)
}
type IndexPage struct {
Server server.Server
Channels []*channel.Channel
Clients []*client.Client
}
func NewPage(server server.Server, channels []*channel.Channel, clients []*client.Client) *IndexPage {
return &IndexPage{
Server: server,
Channels: channels,
Clients: clients,
}
}
func (page IndexPage) Send(w io.Writer, t template.Template) {
t.Lookup("index.html").Execute(w, page)
}