report

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REPORT_FORMAT_XLSX ReportFormat = "xlsx"
	REPORT_FORMAT_CSV  ReportFormat = "csv"
	REPORT_FORMAT_TSV  ReportFormat = "tsv"
	REPORT_FORMAT_PDF  ReportFormat = "pdf"

	TARGET_OBJECTS string = "objects"
	TARGET_SHEET   string = "sheet"

	DRIVER_SENSE    string = "sense"
	DRIVER_BUILT_IN string = "built_in"
)
View Source
const (
	ROW_LIMIT_PER_SHEET int = 1000000
)

Variables

View Source
var (
	QlikPredefinedColorMap = map[string]*ARGBColor{
		"yellow":       {R: 255, G: 255, B: 0},
		"white":        {R: 255, G: 255, B: 255},
		"red":          {R: 128, G: 0, B: 0},
		"magenta":      {R: 128, G: 0, B: 128},
		"lightred":     {R: 255, G: 0, B: 0},
		"lightmagenta": {R: 255, G: 0, B: 255},
		"lightgreen":   {R: 0, G: 255, B: 0},
		"lightgray":    {R: 192, G: 192, B: 192},
		"lightcyan":    {R: 0, G: 255, B: 255},
		"lightblue":    {R: 0, G: 0, B: 255},
		"green":        {R: 0, G: 238, B: 0},
		"darkgray":     {R: 128, G: 128, B: 128},
		"cyan":         {R: 0, G: 128, B: 128},
		"brown":        {R: 128, G: 128, B: 0},
		"blue":         {R: 0, G: 0, B: 128},
		"black ":       {R: 0, G: 0, B: 0},
	}
)

Functions

func GetCSVHeader

func GetCSVHeader() string

func GetCellColorFont

func GetCellColorFont(attrs []*enigma.NxSimpleValue, excelStyle *excelize.Style, cellLogger *zerolog.Logger) *util.Result

func GetPivotCellStyle

func GetPivotCellStyle(cell *enigma.NxPivotValuePoint, cellLogger *zerolog.Logger) (*excelize.Style, *util.Result)

func GetStackCellStyle

func GetStackCellStyle(cell *enigma.NxCell, cellLogger *zerolog.Logger) (*excelize.Style, *util.Result)

Types

type ARGBColor

type ARGBColor struct {
	A int
	R int
	G int
	B int
}

func NewARGBColorFromQlikAttr

func NewARGBColorFromQlikAttr(attr *enigma.NxSimpleValue) (*ARGBColor, *util.Result)

func NewARGBFromQlikColor added in v0.6.0

func NewARGBFromQlikColor(t string) (*ARGBColor, *util.Result)

func (ARGBColor) AssignBgStyle

func (c ARGBColor) AssignBgStyle(excelStyle *excelize.Style)

func (ARGBColor) AssignFontStyle

func (c ARGBColor) AssignFontStyle(excelStyle *excelize.Style)

func (ARGBColor) AssignLuminanceFont

func (c ARGBColor) AssignLuminanceFont(excelStyle *excelize.Style)

type AuditLog

type AuditLog struct {
	// contains filtered or unexported fields
}

func NewAuditLog

func NewAuditLog(fn string) (*AuditLog, *util.Result)

func (*AuditLog) Close

func (audit *AuditLog) Close()

func (*AuditLog) OpenFile

func (audit *AuditLog) OpenFile(fn string) *util.Result

func (*AuditLog) Record

func (audit *AuditLog) Record(r AuditRecord) *util.Result

type AuditRecord

type AuditRecord struct {
	Timestamp       time.Time
	UserDir         string
	UserId          string
	IpAddr          string
	AppId           string
	Cmd             string
	Ids             []string
	ReportFileName  string
	ReportFileSize  int
	ReportTotalRows int
}

func (AuditRecord) GetCSVLine

func (f AuditRecord) GetCSVLine() []string

type BuiltInReportPrinter added in v0.6.0

type BuiltInReportPrinter struct {
	ExcelPrinter *ExcelReportPrinter
	CsvPrinter   *CsvReportPrinter
}

func NewBuiltInReportPrinter added in v0.6.0

func NewBuiltInReportPrinter() *BuiltInReportPrinter

func (BuiltInReportPrinter) GetReportResult added in v0.6.0

func (p BuiltInReportPrinter) GetReportResult(id string) (*ReportResult, *util.Result)

func (*BuiltInReportPrinter) Print added in v0.6.0

func (p *BuiltInReportPrinter) Print(r Report) *util.Result

type CellPos

type CellPos struct {
	CubeRowIx     int
	CubeColIx     int
	ExcelCellName string
}

type ColumnHeaderFormat added in v0.6.0

type ColumnHeaderFormat struct {
	Order   int    `json:"order"`
	Label   string `json:"label"`
	FgColor string `json:"fg_color"`
	BgColor string `json:"bg_color"`
	NumFmt  string `json:"num_fmt"`
	DateFmt string `json:"date_fmt"`
}

func (ColumnHeaderFormat) GetHeaderCellStyle added in v0.6.0

func (f ColumnHeaderFormat) GetHeaderCellStyle(colInfo *engine.ColumnInfo, cellLogger *zerolog.Logger) (*excelize.Style, *util.Result)

type CsvReportPrinter added in v0.6.0

type CsvReportPrinter struct {
	ReportPrinterBase
	ObjId     string
	ObjLayout *engine.ObjectLayoutEx
	Writer    *csv.Writer
	ColCnt    int
	RowCnt    int
}

func NewCsvReportPrinter added in v0.6.0

func NewCsvReportPrinter() *CsvReportPrinter

func (CsvReportPrinter) GetReportResult added in v0.6.0

func (p CsvReportPrinter) GetReportResult(id string) (*ReportResult, *util.Result)

func (*CsvReportPrinter) Print added in v0.6.0

func (p *CsvReportPrinter) Print(r Report) *util.Result

type CustomHeader

type CustomHeader struct {
	Label string `json:"label,omitempty"`
	Text  string `json:"text,omitempty"`
}

type ExcelReportPrinter

type ExcelReportPrinter struct {
	ReportPrinterBase
}

func NewExcelReportPrinter

func NewExcelReportPrinter() *ExcelReportPrinter

func (*ExcelReportPrinter) CheckRowsLimit

func (p *ExcelReportPrinter) CheckRowsLimit(r Report, layout *engine.ObjectLayoutEx) *util.Result

func (ExcelReportPrinter) GetReportResult

func (p ExcelReportPrinter) GetReportResult(id string) (*ReportResult, *util.Result)

func (*ExcelReportPrinter) Print

func (p *ExcelReportPrinter) Print(r Report) *util.Result

type IReportPrinter

type IReportPrinter interface {
	Print(r Report) *util.Result
	GetReportResult(id string) (*ReportResult, *util.Result)
}

type Report

type Report struct {
	ID    *string `json:"id,omitempty" yaml:"id,omitempty" bson:"id,omitempty"`
	Name  *string `json:"name,omitempty" yaml:"name,omitempty" bson:"name,omitempty"`
	IsSub bool    `json:"is_sub,omitempty" yaml:"is_sub,omitempty" bson:"is_sub,omitempty"`

	// report target
	// `Target` can be `objects` or `sheet`
	// `TargetIDs` contains either:
	//  - array of object ids, when `Target` is `objects`
	//  - or TargetIDs[0] = sheetID, when `Target` is `sheet`
	Doc       *enigma.Doc `json:"-,omitempty" yaml:"-,omitempty" bson:"-,omitempty"`
	AppId     string      `json:"app_id,omitempty" yaml:"app_id,omitempty" bson:"app_id,omitempty"`
	Target    string      `json:"target,omitempty" yaml:"target,omitempty" bson:"target,omitempty"`
	TargetIDs []string    `json:"target_ids,omitempty" yaml:"target_ids,omitempty" bson:"target_ids,omitempty"`

	// layout
	Headers                []CustomHeader                `json:"headers,omitempty" yaml:"headers,omitempty" bson:"headers,omitempty"`
	OptionalTargetTitles   map[string]string             `json:"optional_target_titles,omitempty" yaml:"optional_target_titles,omitempty" bson:"optional_target_titles,omitempty"`
	OutputCurrentSelection bool                          `json:"output_current_selection,omitempty" yaml:"output_current_selection,omitempty" bson:"output_current_selection,omitempty"`
	CurrentSelectionOrder  map[string]int                `json:"current_selection_order" yaml:"current_selection_order" bson:"current_selection_order"`
	ColumnHeaderFormats    map[string]ColumnHeaderFormat `json:"column_header_formats,omitempty" yaml:"column_header_formats,omitempty" bson:"column_header_formats,omitempty"` // only supports stack object

	// output
	Driver       *string       `json:"driver,omitempty" yaml:"driver,omitempty" bson:"driver,omitempty"`
	OutputFormat *ReportFormat `json:"output_format,omitempty" yaml:"output_format,omitempty" bson:"output_format,omitempty"`
	OutputFolder *string       `json:"output_folder,omitempty" yaml:"output_folder,omitempty" bson:"output_folder,omitempty"`
	OutputOffset *enigma.Rect  `json:"output_offset,omitempty" yaml:"output_offset,omitempty" bson:"output_offset,omitempty"`

	// logging
	LogFolder *string         `json:"log_folder,omitempty" yaml:"log_folder,omitempty" bson:"log_folder,omitempty"`
	Logger    *zerolog.Logger `json:"-" yaml:"-" bson:"-"`
}

user has to apply any needed selection before printing report

func (Report) IsValid

func (r Report) IsValid() bool

func (*Report) Validate

func (r *Report) Validate() *util.Result

type ReportFormat

type ReportFormat string

func (ReportFormat) IsCsv added in v0.6.0

func (f ReportFormat) IsCsv() bool

func (ReportFormat) IsExcel

func (f ReportFormat) IsExcel() bool

func (ReportFormat) IsPdf added in v0.6.0

func (f ReportFormat) IsPdf() bool

func (ReportFormat) IsTsv added in v0.6.0

func (f ReportFormat) IsTsv() bool

func (ReportFormat) IsValid

func (f ReportFormat) IsValid() bool

func (*ReportFormat) MaybeDefault

func (f *ReportFormat) MaybeDefault()

type ReportPrinterBase

type ReportPrinterBase struct {
	ReportResults map[string]*ReportResult //report-id -> report-results
	Doc           *enigma.Doc
	R             Report
	Logger        *zerolog.Logger
}

type ReportResult

type ReportResult struct {
	ID          string          `json:"id,omitempty" yaml:"id,omitempty"`
	Result      *util.Result    `json:"result,omitempty" yaml:"result,omitempty" bson:"result,omitempty"`
	ReportFile  *string         `json:"report_file,omitempty" yaml:"report_file,omitempty" bson:"report_file,omitempty"`
	LogFile     *string         `json:"log_file,omitempty" yaml:"log_file,omitempty" bson:"log_file,omitempty"`
	Logger      *zerolog.Logger `json:"-,omitempty" yaml:"-,omitempty" bson:"-"`
	PrintedRows int             `json:"printed_rows,omitempty" yaml:"printed_rows,omitempty"`
}

func NewReportResult

func NewReportResult(r Report) (*ReportResult, *util.Result)

type SenseReportPrinter

type SenseReportPrinter struct {
	ReportPrinterBase
	// contains filtered or unexported fields
}

func NewSenseReportPrinter

func NewSenseReportPrinter(_qrsClient *qrs.Client) *SenseReportPrinter

func (SenseReportPrinter) GetReportResult

func (p SenseReportPrinter) GetReportResult(id string) (*ReportResult, *util.Result)

func (*SenseReportPrinter) Print

func (p *SenseReportPrinter) Print(r Report) *util.Result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL