Dashboard: Add week start option to global and dashboard preferences (#40010)
* Add global week start option to shared preferences * Add default_week_start to configuration docs * Add week start option to dashboards * Add week start argument to tsdb time range parser * Fix strict check issues * Add tests for week start * Change wording on default_week_start documentation Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update week_start column to be a nullable field Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> * Update configuration to include browser option * Update WeekStartPicker container selector Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> * Add menuShouldPortal to WeekStartPicker to remove deprecation warning Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> * Add inputId to WeekStartPicker * Use e2e selector on WeekStartPicker aria-label * Simplify WeekStartPicker onChange condition * Specify value type on WeekStartPicker weekStarts * Remove setWeekStart side effect from reducer * Fix updateLocale failing to reset week start * Store week start as string to handle empty values Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
This commit is contained in:
co-authored by
achatterjee-grafana
Emil Tullstedt
Hugo Häggmark
Alex Khomenko
parent
db62ce477d
commit
a9faab6b09
@@ -42,4 +42,8 @@ func addPreferencesMigrations(mg *Migrator) {
|
||||
SQLite("UPDATE preferences SET team_id=0 WHERE team_id IS NULL;").
|
||||
Postgres("UPDATE preferences SET team_id=0 WHERE team_id IS NULL;").
|
||||
Mysql("UPDATE preferences SET team_id=0 WHERE team_id IS NULL;"))
|
||||
|
||||
mg.AddMigration("Add column week_start in preferences", NewAddColumnMigration(preferencesV2, &Column{
|
||||
Name: "week_start", Type: DB_NVarchar, Length: 10, Nullable: true,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ func (ss *SQLStore) GetPreferencesWithDefaults(ctx context.Context, query *model
|
||||
res := &models.Preferences{
|
||||
Theme: ss.Cfg.DefaultTheme,
|
||||
Timezone: ss.Cfg.DateFormats.DefaultTimezone,
|
||||
WeekStart: ss.Cfg.DateFormats.DefaultWeekStart,
|
||||
HomeDashboardId: 0,
|
||||
}
|
||||
|
||||
@@ -54,6 +55,9 @@ func (ss *SQLStore) GetPreferencesWithDefaults(ctx context.Context, query *model
|
||||
if p.Timezone != "" {
|
||||
res.Timezone = p.Timezone
|
||||
}
|
||||
if p.WeekStart != "" {
|
||||
res.WeekStart = p.WeekStart
|
||||
}
|
||||
if p.HomeDashboardId != 0 {
|
||||
res.HomeDashboardId = p.HomeDashboardId
|
||||
}
|
||||
@@ -96,6 +100,7 @@ func SavePreferences(cmd *models.SavePreferencesCommand) error {
|
||||
TeamId: cmd.TeamId,
|
||||
HomeDashboardId: cmd.HomeDashboardId,
|
||||
Timezone: cmd.Timezone,
|
||||
WeekStart: cmd.WeekStart,
|
||||
Theme: cmd.Theme,
|
||||
Created: time.Now(),
|
||||
Updated: time.Now(),
|
||||
@@ -104,7 +109,7 @@ func SavePreferences(cmd *models.SavePreferencesCommand) error {
|
||||
return err
|
||||
}
|
||||
prefs.HomeDashboardId = cmd.HomeDashboardId
|
||||
prefs.Timezone = cmd.Timezone
|
||||
prefs.WeekStart = cmd.WeekStart
|
||||
prefs.Theme = cmd.Theme
|
||||
prefs.Updated = time.Now()
|
||||
prefs.Version += 1
|
||||
|
||||
Reference in New Issue
Block a user