admin.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package admin
  5. import (
  6. "strings"
  7. "github.com/codegangsta/martini"
  8. "github.com/gogits/gogs/models"
  9. "github.com/gogits/gogs/modules/base"
  10. "github.com/gogits/gogs/modules/middleware"
  11. )
  12. func Dashboard(ctx *middleware.Context) {
  13. ctx.Data["Title"] = "Admin Dashboard"
  14. ctx.Data["PageIsDashboard"] = true
  15. ctx.Data["Stats"] = models.GetStatistic()
  16. ctx.HTML(200, "admin/dashboard")
  17. }
  18. func Users(ctx *middleware.Context) {
  19. ctx.Data["Title"] = "User Management"
  20. ctx.Data["PageIsUsers"] = true
  21. var err error
  22. ctx.Data["Users"], err = models.GetUsers(100, 0)
  23. if err != nil {
  24. ctx.Handle(200, "admin.Users", err)
  25. return
  26. }
  27. ctx.HTML(200, "admin/users")
  28. }
  29. func Repositories(ctx *middleware.Context) {
  30. ctx.Data["Title"] = "Repository Management"
  31. ctx.Data["PageIsRepos"] = true
  32. var err error
  33. ctx.Data["Repos"], err = models.GetRepos(100, 0)
  34. if err != nil {
  35. ctx.Handle(200, "admin.Repositories", err)
  36. return
  37. }
  38. ctx.HTML(200, "admin/repos")
  39. }
  40. func Config(ctx *middleware.Context) {
  41. ctx.Data["Title"] = "Server Configuration"
  42. ctx.Data["PageIsConfig"] = true
  43. ctx.Data["AppUrl"] = base.AppUrl
  44. ctx.Data["Domain"] = base.Domain
  45. ctx.Data["RunUser"] = base.RunUser
  46. ctx.Data["RunMode"] = strings.Title(martini.Env)
  47. ctx.Data["RepoRootPath"] = base.RepoRootPath
  48. ctx.Data["Service"] = base.Service
  49. ctx.Data["DbCfg"] = models.DbCfg
  50. ctx.Data["MailerEnabled"] = false
  51. if base.MailService != nil {
  52. ctx.Data["MailerEnabled"] = true
  53. ctx.Data["Mailer"] = base.MailService
  54. }
  55. ctx.Data["CacheAdapter"] = base.CacheAdapter
  56. ctx.Data["CacheConfig"] = base.CacheConfig
  57. ctx.Data["LogMode"] = base.LogMode
  58. ctx.Data["LogConfig"] = base.LogConfig
  59. ctx.HTML(200, "admin/config")
  60. }