From ffd5fb813914130d55e52b1a8cbeae5f62cbe782 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Wed, 24 Oct 2018 16:38:04 +0200 Subject: [PATCH] Set heatmap color range configurable (#5165) --- custom/conf/app.ini.sample | 2 ++ modules/setting/setting.go | 2 ++ modules/templates/helper.go | 3 +++ templates/base/footer.tmpl | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/custom/conf/app.ini.sample b/custom/conf/app.ini.sample index 47d7bcb6a40..1a85f9364d6 100644 --- a/custom/conf/app.ini.sample +++ b/custom/conf/app.ini.sample @@ -85,6 +85,8 @@ MAX_DISPLAY_FILE_SIZE = 8388608 SHOW_USER_EMAIL = true ; Set the default theme for the Gitea install DEFAULT_THEME = gitea +; Set the color range to use for heatmap (default to `['#f4f4f4', '#459928']` but can use `['#2d303b', '#80bb46']` with the theme `arc-green`) +HEATMAP_COLOR_RANGE = `['#f4f4f4', '#459928']` [ui.admin] ; Number of users that are displayed on one page diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 0523c308981..0eaf58988fe 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -300,6 +300,7 @@ var ( MaxDisplayFileSize int64 ShowUserEmail bool DefaultTheme string + HeatmapColorRange string Admin struct { UserPagingNum int @@ -326,6 +327,7 @@ var ( ThemeColorMetaTag: `#6cc644`, MaxDisplayFileSize: 8388608, DefaultTheme: `gitea`, + HeatmapColorRange: `['#f4f4f4', '#459928']`, Admin: struct { UserPagingNum int RepoPagingNum int diff --git a/modules/templates/helper.go b/modules/templates/helper.go index ce077d1a928..16627549e7c 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -193,6 +193,9 @@ func NewFuncMap() []template.FuncMap { "DefaultTheme": func() string { return setting.UI.DefaultTheme }, + "HeatmapColorRange": func() string { + return setting.UI.HeatmapColorRange + }, "dict": func(values ...interface{}) (map[string]interface{}, error) { if len(values) == 0 { return nil, errors.New("invalid dict call") diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index 1734d32600a..320b4fa1dbf 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -65,7 +65,7 @@ var heatmap = calendarHeatmap() .data(chartData) .selector('#user-heatmap') - .colorRange(['#f4f4f4', '#459928']) + .colorRange({{SafeJS HeatmapColorRange}}) .tooltipEnabled(true); heatmap(); });