diff --git a/routers/user/home.go b/routers/user/home.go index f7f1786b33..779971ca97 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -114,8 +114,14 @@ func Dashboard(ctx *context.Context) { ctx.Data["SearchLimit"] = setting.UI.User.RepoPagingNum // no heatmap access for admins; GetUserHeatmapDataByUser ignores the calling user // so everyone would get the same empty heatmap - ctx.Data["EnableHeatmap"] = setting.Service.EnableUserHeatmap && !ctxUser.KeepActivityPrivate - ctx.Data["HeatmapUser"] = ctxUser.Name + if setting.Service.EnableUserHeatmap && !ctxUser.KeepActivityPrivate { + data, err := models.GetUserHeatmapDataByUser(ctxUser) + if err != nil { + ctx.ServerError("GetUserHeatmapDataByUser", err) + return + } + ctx.Data["HeatmapData"] = data + } var err error var mirrors []*models.Repository diff --git a/routers/user/profile.go b/routers/user/profile.go index 8bf5cacc56..36f3d0735d 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -94,10 +94,18 @@ func Profile(ctx *context.Context) { ctx.Data["PageIsUserProfile"] = true ctx.Data["Owner"] = ctxUser ctx.Data["OpenIDs"] = openIDs + // no heatmap access for admins; GetUserHeatmapDataByUser ignores the calling user // so everyone would get the same empty heatmap - ctx.Data["EnableHeatmap"] = setting.Service.EnableUserHeatmap && !ctxUser.KeepActivityPrivate - ctx.Data["HeatmapUser"] = ctxUser.Name + if setting.Service.EnableUserHeatmap && !ctxUser.KeepActivityPrivate { + data, err := models.GetUserHeatmapDataByUser(ctxUser) + if err != nil { + ctx.ServerError("GetUserHeatmapDataByUser", err) + return + } + ctx.Data["HeatmapData"] = data + } + if len(ctxUser.Description) != 0 { ctx.Data["RenderedDescription"] = string(markdown.Render([]byte(ctxUser.Description), ctx.Repo.RepoLink, map[string]string{"mode": "document"})) } diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 4738b91463..c8e669387b 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -36,8 +36,6 @@ SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}}, Tribute: {{if .RequireTribute}}true{{else}}false{{end}}, U2F: {{if .RequireU2F}}true{{else}}false{{end}}, - Heatmap: {{if .EnableHeatmap}}true{{else}}false{{end}}, - heatmapUser: {{if .HeatmapUser}}'{{.HeatmapUser}}'{{else}}null{{end}}, NotificationSettings: { MinTimeout: {{NotificationSettings.MinTimeout}}, TimeoutStep: {{NotificationSettings.TimeoutStep}}, diff --git a/templates/user/dashboard/dashboard.tmpl b/templates/user/dashboard/dashboard.tmpl index 7a4968ebe6..dc04d65651 100644 --- a/templates/user/dashboard/dashboard.tmpl +++ b/templates/user/dashboard/dashboard.tmpl @@ -5,10 +5,7 @@ {{template "base/alert" .}}
- {{if .EnableHeatmap}} - {{template "user/dashboard/heatmap" .}} -
- {{end}} + {{template "user/heatmap" .}} {{template "user/dashboard/feeds" .}}
{{template "user/dashboard/repolist" .}} diff --git a/templates/user/dashboard/heatmap.tmpl b/templates/user/heatmap.tmpl similarity index 51% rename from templates/user/dashboard/heatmap.tmpl rename to templates/user/heatmap.tmpl index 626c70dd8d..a569405d16 100644 --- a/templates/user/dashboard/heatmap.tmpl +++ b/templates/user/heatmap.tmpl @@ -1,7 +1,8 @@ -
- +{{if .HeatmapData}} +
{{.i18n.Tr "user.heatmap.loading"}}
- -
+
+
+{{end}} diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 3a3192a828..d6b99b3861 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -108,10 +108,7 @@

{{.i18n.Tr "user.disabled_public_activity"}}

{{end}} - {{if .EnableHeatmap}} - {{template "user/dashboard/heatmap" .}} -
- {{end}} + {{template "user/heatmap" .}}
{{template "user/dashboard/feeds" .}}
diff --git a/web_src/js/components/ActivityHeatmap.vue b/web_src/js/components/ActivityHeatmap.vue index 1970cb609a..943bf704e2 100644 --- a/web_src/js/components/ActivityHeatmap.vue +++ b/web_src/js/components/ActivityHeatmap.vue @@ -1,13 +1,9 @@