mirror of
https://github.com/wahyd4/next-dashboard.git
synced 2026-08-09 12:36:03 +10:00
36 lines
1007 B
Go
36 lines
1007 B
Go
package controllers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/jinzhu/gorm"
|
|
"github.com/wahyd4/next-dashboard/models"
|
|
)
|
|
|
|
type DashboardController struct {
|
|
DB *gorm.DB
|
|
}
|
|
|
|
func (controller *DashboardController) Database(c *gin.Context) {
|
|
var records []*models.DBSummary
|
|
controller.DB.Limit(20).Order("created_at desc").Where("name = ?", c.Param("name")).Find(&records)
|
|
c.JSON(http.StatusOK, records)
|
|
}
|
|
|
|
func (controller *DashboardController) HTTPEndpoint(c *gin.Context) {
|
|
var records []*models.HTTPHealth
|
|
controller.DB.Limit(20).Order("created_at desc").Where("name = ?", c.Param("name")).Find(&records)
|
|
c.JSON(http.StatusOK, records)
|
|
}
|
|
|
|
func (controller *DashboardController) Event(c *gin.Context) {
|
|
var records []*models.WebHookData
|
|
controller.DB.Limit(20).Order("created_at desc").Where("name = ?", c.Param("name")).Find(&records)
|
|
c.JSON(http.StatusOK, records)
|
|
}
|
|
|
|
func (controller *DashboardController) Show(c *gin.Context) {
|
|
c.JSON(http.StatusOK, models.GlobalConfig)
|
|
}
|