2023-04-09 11:22:48 +05:00
|
|
|
package views
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
2023-07-22 15:24:01 +05:00
|
|
|
"github.com/ordinary-dev/phoenix/database"
|
2023-04-09 11:22:48 +05:00
|
|
|
"gorm.io/gorm"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ShowMainPage(c *gin.Context, db *gorm.DB) {
|
|
|
|
// Get a list of groups with links
|
2023-07-22 15:24:01 +05:00
|
|
|
var groups []database.Group
|
2023-07-21 09:48:57 +05:00
|
|
|
result := db.
|
2023-07-22 15:24:01 +05:00
|
|
|
Model(&database.Group{}).
|
2023-07-21 09:48:57 +05:00
|
|
|
Preload("Links").
|
|
|
|
Find(&groups)
|
|
|
|
|
|
|
|
if result.Error != nil {
|
|
|
|
ShowError(c, result.Error)
|
2023-04-09 11:22:48 +05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
c.HTML(http.StatusOK, "index.html.tmpl", gin.H{
|
|
|
|
"groups": groups,
|
|
|
|
})
|
|
|
|
}
|