Création d'une page tableau en lecture seule et possibilité d'exporter en PDF via wkhtmltopdf

This commit is contained in:
2020-06-15 15:05:28 -04:00
parent 3c21412344
commit 6ebe4c90d7
17 changed files with 151 additions and 31 deletions

View File

@ -10,16 +10,27 @@ import (
"gopkg.in/yaml.v2"
)
// Config is the configuration struct
type Config struct {
HTTP HTTPConfig `yaml:"http"`
Data DataConfig `ymal:"data"`
HTTP HTTPConfig `yaml:"http"`
Client ClientConfig `yaml:"client"`
Data DataConfig `ymal:"data"`
}
// HTTPConfig is the configuration part which defines HTTP related params
type HTTPConfig struct {
BaseURL string `yaml:"baseurl" env:"GUESSTIMATE_BASE_URL"`
Address string `yaml:"address" env:"GUESSTIMATE_HTTP_ADDRESS"`
PublicDir string `yaml:"publicDir" env:"GUESSTIMATE_PUBLIC_DIR"`
}
// ClientConfig is the configuration part which defines the client app related params
type ClientConfig struct {
BaseURL string `yaml:"baseurl" env:"GUESSTIMATE_CLIENT_BASE_URL"`
Address string `yaml:"address" env:"GUESSTIMATE_CLIENT_HTTP_ADDRESS"`
}
// DataConfig is the configuration part which defines data related params
type DataConfig struct {
Path string `yaml:"path" env:"GUESSTIMATE_DATA_PATH"`
}
@ -40,6 +51,7 @@ func NewFromFile(filepath string) (*Config, error) {
return config, nil
}
// WithEnvironment retrieves the configuration from env vars
func WithEnvironment(conf *Config) error {
if err := env.Parse(conf); err != nil {
return err
@ -48,23 +60,31 @@ func WithEnvironment(conf *Config) error {
return nil
}
// NewDumpDefault retrieves the default configuration
func NewDumpDefault() *Config {
config := NewDefault()
return config
}
// NewDefault creates and returns a new default configuration
func NewDefault() *Config {
return &Config{
HTTP: HTTPConfig{
BaseURL: "localhost",
Address: ":8081",
PublicDir: "public",
},
Client: ClientConfig{
BaseURL: "localhost",
Address: ":8080",
},
Data: DataConfig{
Path: "guesstimate.db",
},
}
}
// Dump writes a given config to a config file
func Dump(config *Config, w io.Writer) error {
data, err := yaml.Marshal(config)
if err != nil {

View File

@ -2,6 +2,7 @@ package config
import "gitlab.com/wpetit/goweb/service"
// ServiceProvider returns the current config service
func ServiceProvider(config *Config) service.Provider {
return func(ctn *service.Container) (interface{}, error) {
return config, nil

View File

@ -5,6 +5,7 @@ import (
"gitlab.com/wpetit/goweb/service"
)
// ServiceName defines the project's service
const ServiceName service.Name = "config"
// From retrieves the config service in the given container