summaryrefslogtreecommitdiffstats
path: root/routers/admin/admin.go
diff options
context:
space:
mode:
authorJohn Olheiser <john.olheiser@gmail.com>2020-02-25 16:54:13 -0600
committerGitHub <noreply@github.com>2020-02-25 16:54:13 -0600
commite5944a9521102c4917399a6550a0756919527944 (patch)
treee893caf967a7aacf276d1db265d9a91cd8b2b86f /routers/admin/admin.go
parentc161bb013e091c0bcc524f07d50c028d9daf8cce (diff)
downloadgitea-e5944a9521102c4917399a6550a0756919527944.tar.gz
gitea-e5944a9521102c4917399a6550a0756919527944.zip
Change admin dashboard to POST (#10465)
* Add form and convert to POST * Redirect for flash Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'routers/admin/admin.go')
-rw-r--r--routers/admin/admin.go30
1 files changed, 19 insertions, 11 deletions
diff --git a/routers/admin/admin.go b/routers/admin/admin.go
index cd425271a3..1b4a8631cd 100644
--- a/routers/admin/admin.go
+++ b/routers/admin/admin.go
@@ -16,6 +16,7 @@ import (
"time"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/auth"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/cron"
@@ -31,7 +32,6 @@ import (
"gitea.com/macaron/macaron"
"gitea.com/macaron/session"
- "github.com/unknwon/com"
)
const (
@@ -145,15 +145,29 @@ func Dashboard(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("admin.dashboard")
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminDashboard"] = true
+ ctx.Data["Stats"] = models.GetStatistic()
+ // FIXME: update periodically
+ updateSystemStatus()
+ ctx.Data["SysStatus"] = sysStatus
+ ctx.HTML(200, tplDashboard)
+}
+
+// DashboardPost run an admin operation
+func DashboardPost(ctx *context.Context, form auth.AdminDashboardForm) {
+ ctx.Data["Title"] = ctx.Tr("admin.dashboard")
+ ctx.Data["PageIsAdmin"] = true
+ ctx.Data["PageIsAdminDashboard"] = true
+ ctx.Data["Stats"] = models.GetStatistic()
+ updateSystemStatus()
+ ctx.Data["SysStatus"] = sysStatus
// Run operation.
- op, _ := com.StrTo(ctx.Query("op")).Int()
- if op > 0 {
+ if form.Op > 0 {
var err error
var success string
shutdownCtx := graceful.GetManager().ShutdownContext()
- switch Operation(op) {
+ switch Operation(form.Op) {
case cleanInactivateUser:
success = ctx.Tr("admin.dashboard.delete_inactivate_accounts_success")
err = models.DeleteInactivateUsers()
@@ -191,15 +205,9 @@ func Dashboard(ctx *context.Context) {
} else {
ctx.Flash.Success(success)
}
- ctx.Redirect(setting.AppSubURL + "/admin")
- return
}
- ctx.Data["Stats"] = models.GetStatistic()
- // FIXME: update periodically
- updateSystemStatus()
- ctx.Data["SysStatus"] = sysStatus
- ctx.HTML(200, tplDashboard)
+ ctx.Redirect(setting.AppSubURL + "/admin")
}
// SendTestMail send test mail to confirm mail service is OK