diff --git a/models/action.go b/models/action.go index e8a1336566e1..47d056ae3a55 100644 --- a/models/action.go +++ b/models/action.go @@ -289,12 +289,13 @@ func (a *Action) GetIssueContent() string { // GetFeedsOptions options for retrieving feeds type GetFeedsOptions struct { - RequestedUser *User // the user we want activity for - RequestedTeam *Team // the team we want activity for - Actor *User // the user viewing the activity - IncludePrivate bool // include private actions - OnlyPerformedBy bool // only actions performed by requested user - IncludeDeleted bool // include deleted actions + RequestedUser *User // the user we want activity for + RequestedTeam *Team // the team we want activity for + Actor *User // the user viewing the activity + IncludePrivate bool // include private actions + OnlyPerformedBy bool // only actions performed by requested user + IncludeDeleted bool // include deleted actions + Date string // the day we want activity for: YYYY-MM-DD } // GetFeeds returns actions according to the provided options @@ -380,5 +381,17 @@ func activityQueryCondition(opts GetFeedsOptions) (builder.Cond, error) { cond = cond.And(builder.Eq{"is_deleted": false}) } + if opts.Date != "" { + dateLow, err := time.Parse("2006-01-02", opts.Date) + if err != nil { + log.Warn("Unable to parse %s, filter not applied: %v", opts.Date, err) + } else { + dateHigh := dateLow.Add(86399000000000) // 23h59m59s + + cond = cond.And(builder.Gte{"created_unix": dateLow.Unix()}) + cond = cond.And(builder.Lte{"created_unix": dateHigh.Unix()}) + } + } + return cond, nil } diff --git a/modules/setting/repository.go b/modules/setting/repository.go index 966ff9e888be..a6fc73651a30 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -43,7 +43,7 @@ var ( PrefixArchiveFiles bool DisableMirrors bool DisableMigrations bool - DisableStars bool `ini:"DISABLE_STARS"` + DisableStars bool `ini:"DISABLE_STARS"` DefaultBranch string AllowAdoptionOfUnadoptedRepositories bool AllowDeleteOfUnadoptedRepositories bool diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 4d6c2eb2fc89..9ca206d9954a 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2269,7 +2269,7 @@ auths.tip.google_plus=从谷歌 API 控制台 (https://console.developers.google auths.tip.openid_connect=使用 OpenID 连接发现 URL (/.well-known/openid-configuration) 来指定终点 auths.tip.twitter=访问 https://dev.twitter.com/apps,创建应用并确保启用了"允许此应用程序用于登录 Twitter"的选项。 auths.tip.discord=在 https://discordapp.com/developers/applications/me 上注册新应用程序 -auths.tip.gitea=注册一个新的 OAuth2 应用程序。可以访问 https://docs.gitea.io/en-us/oauth 2-product/ 查看帮助 。 +auths.tip.gitea=注册一个新的 OAuth2 应用程序,可以访问 https://docs.gitea.io/en-us/oauth2-provider/ 查看帮助 。 auths.tip.yandex=在 https://oauth.yandex.com/client/new 上创建一个新的应用程序。在“ Yandex.Passport API”这部分中选择以下权限:“访问电子邮件地址(Access to email address)”,“访问用户头像(Access to user avatar)”和“访问用户名,名字和姓氏,性别(Access to username, first name and surname, genderAccess to username, first name and surname, gender)” auths.tip.mastodon=输入您想要认证的 mastodon 实例的自定义 URL (或使用默认值) auths.edit=修改认证源 diff --git a/routers/api/v1/settings/settings.go b/routers/api/v1/settings/settings.go index 187075ba3e44..e6417e40748c 100644 --- a/routers/api/v1/settings/settings.go +++ b/routers/api/v1/settings/settings.go @@ -57,10 +57,10 @@ func GetGeneralRepoSettings(ctx *context.APIContext) { // "200": // "$ref": "#/responses/GeneralRepoSettings" ctx.JSON(http.StatusOK, api.GeneralRepoSettings{ - MirrorsDisabled: setting.Repository.DisableMirrors, - HTTPGitDisabled: setting.Repository.DisableHTTPGit, - MigrationsDisabled: setting.Repository.DisableMigrations, - StarsDisabled: setting.Repository.DisableStars, + MirrorsDisabled: setting.Repository.DisableMirrors, + HTTPGitDisabled: setting.Repository.DisableHTTPGit, + MigrationsDisabled: setting.Repository.DisableMigrations, + StarsDisabled: setting.Repository.DisableStars, TimeTrackingDisabled: !setting.Service.EnableTimetracking, LFSDisabled: !setting.LFS.StartServer, }) diff --git a/routers/user/home.go b/routers/user/home.go index a8a8a5f3d750..a8020b64e048 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -156,6 +156,7 @@ func Dashboard(ctx *context.Context) { IncludePrivate: true, OnlyPerformedBy: false, IncludeDeleted: false, + Date: ctx.Query("date"), }) if ctx.Written() { diff --git a/routers/user/profile.go b/routers/user/profile.go index 7c720cd87612..f78279adcae3 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -202,6 +202,7 @@ func Profile(ctx *context.Context) { IncludePrivate: showPrivate, OnlyPerformedBy: true, IncludeDeleted: false, + Date: ctx.Query("date"), }) if ctx.Written() { return diff --git a/web_src/js/components/ActivityHeatmap.vue b/web_src/js/components/ActivityHeatmap.vue index 7eb129d1397b..63e38ea69e1e 100644 --- a/web_src/js/components/ActivityHeatmap.vue +++ b/web_src/js/components/ActivityHeatmap.vue @@ -10,6 +10,7 @@ :end-date="endDate" :values="values" :range-color="colorRange" + @day-click="handleDayClick($event)" /> @@ -48,7 +49,25 @@ export default { } return s; } - } + }, + methods: { + handleDayClick(e) { + // Reset filter if same date is clicked + const params = new URLSearchParams(document.location.search); + const queryDate = params.get('date'); + // Timezone has to be stripped because toISOString() converts to UTC + const clickedDate = new Date(e.date - (e.date.getTimezoneOffset() * 60000)).toISOString().substring(0, 10); + + if (queryDate && queryDate === clickedDate) { + params.delete('date'); + } else { + params.set('date', clickedDate); + } + + const newSearch = params.toString(); + window.location.search = newSearch.length ? `?${newSearch}` : ''; + } + }, };