Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collection ¶
A Collection is a collection of reports
var Registry *Collection
Registry is the report collection of the application
func NewCollection ¶
func NewCollection() *Collection
NewCollection returns a pointer to a new Collection instance
func (*Collection) Add ¶
func (rr *Collection) Add(r Report)
Add adds the given report to our Collection
func (*Collection) Get ¶
func (rr *Collection) Get(id string) (Report, bool)
Get returns the Report with the given id
func (*Collection) MustGet ¶
func (rr *Collection) MustGet(id string) Report
MustGet returns the Report with the given id. It panics if the record doesn't exist.
func (*Collection) Replace ¶
func (rr *Collection) Replace(r Report)
Replace the given report in our Collection
type Data ¶
type Data map[string]interface{}
Data holds the item specific data used to render a report.
type Document ¶
type Document struct {
// Content is the binary content of the rendered report
Content []byte
// MimeType of the content
MimeType string
// Filename for the document
Filename string
}
A Document is the result of rendering a report
type Report ¶
type Report interface {
fmt.Stringer
// ID returns the unique identifying code of this report
ID() string
// Model that this report is bound to.
Model() models.Modeler
// Render this report.
Render(id int64, additionalData Data) (*Document, error)
// Init initializes the report. Init is called at bootstrap.
Init() error
// Type returns the type of the record
Type() string
}
A Report is bound to a model and can render a report given an ID of the model.
A report typically contains: - A template - A rendering mechanism to inject data into the template and provide the output to the user.
type TextReport ¶
type TextReport struct {
Id string
Name string
Modeler models.Modeler
MimeType string
Filename string
Template string
DataFunc func(int64, Data) Data
}
A TextReport is a simple text or html report.
It uses the html/template package if the report"s mime type is text/html and text/template if the mimetype is text/plain.
func (*TextReport) ID ¶
func (r *TextReport) ID() string
ID returns the unique identifying code of this report
func (*TextReport) Init ¶
func (r *TextReport) Init() error
Init initializes the report. Init is called at bootstrap.
func (*TextReport) Model ¶
func (r *TextReport) Model() models.Modeler
Model returns the name of the model that this report is bound to.
func (*TextReport) Render ¶
func (r *TextReport) Render(id int64, additionalData Data) (*Document, error)
Render this report. Returns the rendered report, the report mimetype,the report filename and an error.
func (*TextReport) String ¶
func (r *TextReport) String() string