dashboard.go 910 B

123456789101112131415161718192021222324252627282930
  1. package core
  2. import (
  3. "net/http"
  4. "github.com/jmoiron/sqlx/types"
  5. "github.com/labstack/echo/v4"
  6. )
  7. // GetDashboardCharts returns chart data points to render on the dashboard.
  8. func (c *Core) GetDashboardCharts() (types.JSONText, error) {
  9. var out types.JSONText
  10. if err := c.q.GetDashboardCharts.Get(&out); err != nil {
  11. return nil, echo.NewHTTPError(http.StatusInternalServerError,
  12. c.i18n.Ts("globals.messages.errorFetching", "name", "dashboard charts", "error", pqErrMsg(err)))
  13. }
  14. return out, nil
  15. }
  16. // GetDashboardCounts returns stats counts to show on the dashboard.
  17. func (c *Core) GetDashboardCounts() (types.JSONText, error) {
  18. var out types.JSONText
  19. if err := c.q.GetDashboardCounts.Get(&out); err != nil {
  20. return nil, echo.NewHTTPError(http.StatusInternalServerError,
  21. c.i18n.Ts("globals.messages.errorFetching", "name", "dashboard stats", "error", pqErrMsg(err)))
  22. }
  23. return out, nil
  24. }