diff --git a/internal/config/config.go b/internal/config/config.go index 398963691..a08a825e8 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -32,33 +32,34 @@ import ( // Config represents the configuration for the server. type Config struct { - Host string // Server host - Port int // Server port - DAGs string // Location of DAG files - Executable string // Executable path - WorkDir string // Default working directory - IsBasicAuth bool // Enable basic auth - BasicAuthUsername string // Basic auth username - BasicAuthPassword string // Basic auth password - LogEncodingCharset string // Log encoding charset - LogDir string // Log directory - DataDir string // Data directory - SuspendFlagsDir string // Suspend flags directory - AdminLogsDir string // Directory for admin logs - BaseConfig string // Common config file for all DAGs. - NavbarColor string // Navbar color for the web UI - NavbarTitle string // Navbar title for the web UI - Env sync.Map // Store environment variables - TLS *TLS // TLS configuration - IsAuthToken bool // Enable auth token for API - AuthToken string // Auth token for API - LatestStatusToday bool // Show latest status today or the latest status - BasePath string // Base path for the server - APIBaseURL string // Base URL for API - Debug bool // Enable debug mode (verbose logging) - LogFormat string // Log format - TZ string // The server time zone - Location *time.Location // The server location + Host string // Server host + Port int // Server port + DAGs string // Location of DAG files + Executable string // Executable path + WorkDir string // Default working directory + IsBasicAuth bool // Enable basic auth + BasicAuthUsername string // Basic auth username + BasicAuthPassword string // Basic auth password + LogEncodingCharset string // Log encoding charset + LogDir string // Log directory + DataDir string // Data directory + SuspendFlagsDir string // Suspend flags directory + AdminLogsDir string // Directory for admin logs + BaseConfig string // Common config file for all DAGs. + NavbarColor string // Navbar color for the web UI + NavbarTitle string // Navbar title for the web UI + Env sync.Map // Store environment variables + TLS *TLS // TLS configuration + IsAuthToken bool // Enable auth token for API + AuthToken string // Auth token for API + LatestStatusToday bool // Show latest status today or the latest status + BasePath string // Base path for the server + APIBaseURL string // Base URL for API + Debug bool // Enable debug mode (verbose logging) + LogFormat string // Log format + TZ string // The server time zone + Location *time.Location // The server location + MaxDashboardPageLimit int // The default page limit for the dashboard } type TLS struct { @@ -184,6 +185,7 @@ func setupViper() error { viper.SetDefault("navbarTitle", "Dagu") viper.SetDefault("basePath", "") viper.SetDefault("apiBaseURL", "/api/v1") + viper.SetDefault("maxDashboardPageLimit", 100) // Set executable path // This is used for invoking the workflow process on the server. @@ -216,6 +218,7 @@ func bindEnvs() { _ = viper.BindEnv("basePath", "DAGU_BASE_PATH") _ = viper.BindEnv("apiBaseURL", "DAGU_API_BASE_URL") _ = viper.BindEnv("tz", "DAGU_TZ") + _ = viper.BindEnv("maxDashboardPageLimit", "DAGU_MAX_DASHBOARD_PAGE_LIMIT") // Basic authentication _ = viper.BindEnv("isBasicAuth", "DAGU_IS_BASICAUTH") diff --git a/internal/frontend/frontend.go b/internal/frontend/frontend.go index 4b078eff8..881d61224 100644 --- a/internal/frontend/frontend.go +++ b/internal/frontend/frontend.go @@ -34,17 +34,17 @@ func New(cfg *config.Config, lg logger.Logger, cli client.Client) *server.Server )) serverParams := server.NewServerArgs{ - Host: cfg.Host, - Port: cfg.Port, - TLS: cfg.TLS, - Logger: lg, - Handlers: hs, - AssetsFS: assetsFS, - NavbarColor: cfg.NavbarColor, - NavbarTitle: cfg.NavbarTitle, - BasePath: cfg.BasePath, - APIBaseURL: cfg.APIBaseURL, - TimeZone: cfg.TZ, + Host: cfg.Host, + Port: cfg.Port, + TLS: cfg.TLS, + Logger: lg, + Handlers: hs, + AssetsFS: assetsFS, + NavbarColor: cfg.NavbarColor, + NavbarTitle: cfg.NavbarTitle, + APIBaseURL: cfg.APIBaseURL, + MaxDashboardPageLimit: cfg.MaxDashboardPageLimit, + TimeZone: cfg.TZ, } if cfg.IsAuthToken { diff --git a/internal/frontend/server/server.go b/internal/frontend/server/server.go index fb5e17683..650448c83 100644 --- a/internal/frontend/server/server.go +++ b/internal/frontend/server/server.go @@ -60,11 +60,12 @@ type NewServerArgs struct { AssetsFS fs.FS // Configuration for the frontend - NavbarColor string - NavbarTitle string - BasePath string - APIBaseURL string - TimeZone string + NavbarColor string + NavbarTitle string + BasePath string + APIBaseURL string + TimeZone string + MaxDashboardPageLimit int } type BasicAuth struct { @@ -91,11 +92,12 @@ func New(params NewServerArgs) *Server { handlers: params.Handlers, assets: params.AssetsFS, funcsConfig: funcsConfig{ - NavbarColor: params.NavbarColor, - NavbarTitle: params.NavbarTitle, - BasePath: params.BasePath, - APIBaseURL: params.APIBaseURL, - TZ: params.TimeZone, + NavbarColor: params.NavbarColor, + NavbarTitle: params.NavbarTitle, + BasePath: params.BasePath, + APIBaseURL: params.APIBaseURL, + TZ: params.TimeZone, + MaxDashboardPageLimit: params.MaxDashboardPageLimit, }, } } diff --git a/internal/frontend/server/templates.go b/internal/frontend/server/templates.go index cf00d1ce2..50063e363 100644 --- a/internal/frontend/server/templates.go +++ b/internal/frontend/server/templates.go @@ -55,11 +55,12 @@ func (srv *Server) useTemplate( } type funcsConfig struct { - NavbarColor string - NavbarTitle string - BasePath string - APIBaseURL string - TZ string + NavbarColor string + NavbarTitle string + BasePath string + APIBaseURL string + TZ string + MaxDashboardPageLimit int } func defaultFunctions(cfg funcsConfig) template.FuncMap { @@ -89,6 +90,9 @@ func defaultFunctions(cfg funcsConfig) template.FuncMap { "tz": func() string { return cfg.TZ }, + "maxDashboardPageLimit": func() int { + return cfg.MaxDashboardPageLimit + }, } } diff --git a/internal/frontend/templates/base.gohtml b/internal/frontend/templates/base.gohtml index c8eb9ab2d..694a04789 100644 --- a/internal/frontend/templates/base.gohtml +++ b/internal/frontend/templates/base.gohtml @@ -1,27 +1,28 @@ {{define "base"}} -
- - - -