Skip to content

Commit

Permalink
Allow configuring default point average rounding method
Browse files Browse the repository at this point in the history
This resolves #634
  • Loading branch information
StevenWeathers committed Oct 14, 2024
1 parent 27c4a87 commit d0c1419
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 161 deletions.
143 changes: 72 additions & 71 deletions docs/CONFIGURATION.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func InitConfig(logger *otelzap.Logger) Config {
viper.SetDefault("config.require_teams", false)
viper.SetDefault("config.subscriptions_enabled", false)
viper.SetDefault("config.retro_default_template_id", "5c3b4783-82cb-45a4-ac7b-c956c6b4047e")
viper.SetDefault("config.default_point_average_rounding", "ceil")

viper.SetDefault("subscription.account_secret", "")
viper.SetDefault("subscription.webhook_secret", "")
Expand Down
47 changes: 24 additions & 23 deletions internal/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,30 @@ type Smtp struct {

// AppConfig is the application configuration
type AppConfig struct {
AesHashkey string `mapstructure:"aes_hashkey"`
AllowedPointValues []string `mapstructure:"allowedPointValues"`
DefaultPointValues []string `mapstructure:"defaultPointValues"`
ShowWarriorRank bool `mapstructure:"show_warrior_rank"`
AvatarService string `mapstructure:"avatar_service"`
ToastTimeout int `mapstructure:"toast_timeout"`
AllowGuests bool `mapstructure:"allow_guests"`
AllowRegistration bool `mapstructure:"allow_registration"`
AllowJiraImport bool `mapstructure:"allow_jira_import"`
AllowCsvImport bool `mapstructure:"allow_csv_import"`
DefaultLocale string `mapstructure:"default_locale"`
AllowExternalApi bool `mapstructure:"allow_external_api"`
ExternalApiVerifyRequired bool `mapstructure:"external_api_verify_required"`
UserApikeyLimit int `mapstructure:"user_apikey_limit"`
ShowActiveCountries bool `mapstructure:"show_active_countries"`
CleanupBattlesDaysOld int `mapstructure:"cleanup_battles_days_old"`
CleanupGuestsDaysOld int `mapstructure:"cleanup_guests_days_old"`
CleanupRetrosDaysOld int `mapstructure:"cleanup_retros_days_old"`
CleanupStoryboardsDaysOld int `mapstructure:"cleanup_storyboards_days_old"`
OrganizationsEnabled bool `mapstructure:"organizations_enabled"`
RequireTeams bool `mapstructure:"require_teams"`
SubscriptionsEnabled bool `mapstructure:"subscriptions_enabled"`
RetroDefaultTemplateID string `mapstructure:"retro_default_template_id"`
AesHashkey string `mapstructure:"aes_hashkey"`
AllowedPointValues []string `mapstructure:"allowedPointValues"`
DefaultPointValues []string `mapstructure:"defaultPointValues"`
ShowWarriorRank bool `mapstructure:"show_warrior_rank"`
AvatarService string `mapstructure:"avatar_service"`
ToastTimeout int `mapstructure:"toast_timeout"`
AllowGuests bool `mapstructure:"allow_guests"`
AllowRegistration bool `mapstructure:"allow_registration"`
AllowJiraImport bool `mapstructure:"allow_jira_import"`
AllowCsvImport bool `mapstructure:"allow_csv_import"`
DefaultLocale string `mapstructure:"default_locale"`
AllowExternalApi bool `mapstructure:"allow_external_api"`
ExternalApiVerifyRequired bool `mapstructure:"external_api_verify_required"`
UserApikeyLimit int `mapstructure:"user_apikey_limit"`
ShowActiveCountries bool `mapstructure:"show_active_countries"`
CleanupBattlesDaysOld int `mapstructure:"cleanup_battles_days_old"`
CleanupGuestsDaysOld int `mapstructure:"cleanup_guests_days_old"`
CleanupRetrosDaysOld int `mapstructure:"cleanup_retros_days_old"`
CleanupStoryboardsDaysOld int `mapstructure:"cleanup_storyboards_days_old"`
OrganizationsEnabled bool `mapstructure:"organizations_enabled"`
RequireTeams bool `mapstructure:"require_teams"`
SubscriptionsEnabled bool `mapstructure:"subscriptions_enabled"`
RetroDefaultTemplateID string `mapstructure:"retro_default_template_id"`
DefaultPointAverageRounding string `mapstructure:"default_point_average_rounding"`
}

// Feature is the application feature enablement configuration
Expand Down
67 changes: 34 additions & 33 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,39 +223,40 @@ func main() {
AnalyticsEnabled: c.Analytics.Enabled,
AnalyticsID: c.Analytics.ID,
AppConfig: thunderdome.AppConfig{
AllowedPointValues: c.Config.AllowedPointValues,
DefaultPointValues: c.Config.DefaultPointValues,
ShowWarriorRank: c.Config.ShowWarriorRank,
AvatarService: c.Config.AvatarService,
ToastTimeout: c.Config.ToastTimeout,
AllowGuests: c.Config.AllowGuests,
AllowRegistration: c.Config.AllowRegistration && c.Auth.Method == "normal",
AllowJiraImport: c.Config.AllowJiraImport,
AllowCsvImport: c.Config.AllowCsvImport,
DefaultLocale: c.Config.DefaultLocale,
OrganizationsEnabled: c.Config.OrganizationsEnabled,
ExternalAPIEnabled: c.Config.AllowExternalApi,
UserAPIKeyLimit: c.Config.UserApikeyLimit,
AppVersion: version,
CookieName: c.Http.FrontendCookieName,
PathPrefix: c.Http.PathPrefix,
CleanupGuestsDaysOld: c.Config.CleanupGuestsDaysOld,
CleanupBattlesDaysOld: c.Config.CleanupBattlesDaysOld,
CleanupRetrosDaysOld: c.Config.CleanupRetrosDaysOld,
CleanupStoryboardsDaysOld: c.Config.CleanupStoryboardsDaysOld,
ShowActiveCountries: c.Config.ShowActiveCountries,
LdapEnabled: ldapEnabled,
HeaderAuthEnabled: headerAuthEnabled,
GoogleAuthEnabled: c.Auth.Google.Enabled,
FeaturePoker: c.Feature.Poker,
FeatureRetro: c.Feature.Retro,
FeatureStoryboard: c.Feature.Storyboard,
RequireTeams: c.Config.RequireTeams,
SubscriptionsEnabled: c.Config.SubscriptionsEnabled,
Subscription: c.Subscription,
RepoURL: repoURL,
RetroDefaultTemplateID: c.Config.RetroDefaultTemplateID,
WebsocketSubdomain: c.Http.WebsocketSubdomain,
AllowedPointValues: c.Config.AllowedPointValues,
DefaultPointValues: c.Config.DefaultPointValues,
ShowWarriorRank: c.Config.ShowWarriorRank,
AvatarService: c.Config.AvatarService,
ToastTimeout: c.Config.ToastTimeout,
AllowGuests: c.Config.AllowGuests,
AllowRegistration: c.Config.AllowRegistration && c.Auth.Method == "normal",
AllowJiraImport: c.Config.AllowJiraImport,
AllowCsvImport: c.Config.AllowCsvImport,
DefaultLocale: c.Config.DefaultLocale,
OrganizationsEnabled: c.Config.OrganizationsEnabled,
ExternalAPIEnabled: c.Config.AllowExternalApi,
UserAPIKeyLimit: c.Config.UserApikeyLimit,
AppVersion: version,
CookieName: c.Http.FrontendCookieName,
PathPrefix: c.Http.PathPrefix,
CleanupGuestsDaysOld: c.Config.CleanupGuestsDaysOld,
CleanupBattlesDaysOld: c.Config.CleanupBattlesDaysOld,
CleanupRetrosDaysOld: c.Config.CleanupRetrosDaysOld,
CleanupStoryboardsDaysOld: c.Config.CleanupStoryboardsDaysOld,
ShowActiveCountries: c.Config.ShowActiveCountries,
LdapEnabled: ldapEnabled,
HeaderAuthEnabled: headerAuthEnabled,
GoogleAuthEnabled: c.Auth.Google.Enabled,
FeaturePoker: c.Feature.Poker,
FeatureRetro: c.Feature.Retro,
FeatureStoryboard: c.Feature.Storyboard,
RequireTeams: c.Config.RequireTeams,
SubscriptionsEnabled: c.Config.SubscriptionsEnabled,
Subscription: c.Subscription,
RepoURL: repoURL,
RetroDefaultTemplateID: c.Config.RetroDefaultTemplateID,
WebsocketSubdomain: c.Http.WebsocketSubdomain,
DefaultPointAverageRounding: c.Config.DefaultPointAverageRounding,
},
},
}, uiFilesystem, uiHTTPFilesystem)
Expand Down
67 changes: 34 additions & 33 deletions thunderdome/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,40 @@ type SubscriptionConfig struct {
}

type AppConfig struct {
AllowedPointValues []string
DefaultPointValues []string
ShowWarriorRank bool
AvatarService string
ToastTimeout int
AllowGuests bool
AllowRegistration bool
AllowJiraImport bool
AllowCsvImport bool
DefaultLocale string
OrganizationsEnabled bool
AppVersion string
CookieName string
PathPrefix string
ExternalAPIEnabled bool
UserAPIKeyLimit int
CleanupGuestsDaysOld int
CleanupBattlesDaysOld int
CleanupRetrosDaysOld int
CleanupStoryboardsDaysOld int
ShowActiveCountries bool
LdapEnabled bool
HeaderAuthEnabled bool
GoogleAuthEnabled bool
FeaturePoker bool
FeatureRetro bool
FeatureStoryboard bool
RequireTeams bool
RepoURL string
SubscriptionsEnabled bool
Subscription SubscriptionConfig
RetroDefaultTemplateID string
WebsocketSubdomain string
AllowedPointValues []string
DefaultPointValues []string
ShowWarriorRank bool
AvatarService string
ToastTimeout int
AllowGuests bool
AllowRegistration bool
AllowJiraImport bool
AllowCsvImport bool
DefaultLocale string
OrganizationsEnabled bool
AppVersion string
CookieName string
PathPrefix string
ExternalAPIEnabled bool
UserAPIKeyLimit int
CleanupGuestsDaysOld int
CleanupBattlesDaysOld int
CleanupRetrosDaysOld int
CleanupStoryboardsDaysOld int
ShowActiveCountries bool
LdapEnabled bool
HeaderAuthEnabled bool
GoogleAuthEnabled bool
FeaturePoker bool
FeatureRetro bool
FeatureStoryboard bool
RequireTeams bool
RepoURL string
SubscriptionsEnabled bool
Subscription SubscriptionConfig
RetroDefaultTemplateID string
WebsocketSubdomain string
DefaultPointAverageRounding string
}

type UIConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/poker/CreatePokerGame.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
let battleName = '';
let plans = [];
let autoFinishVoting = true;
let pointAverageRounding = 'ceil';
let pointAverageRounding = AppConfig.DefaultPointAverageRounding || 'ceil';
let joinCode = '';
let leaderCode = '';
let selectedTeam = '';
Expand Down

0 comments on commit d0c1419

Please sign in to comment.