personal-website/apps/sunboard/sunboard.go

61 lines
1.1 KiB
Go
Raw Normal View History

2023-07-19 01:35:17 +00:00
package sunboard
import (
"net/http"
2023-07-19 16:38:28 +00:00
"personalwebsite/apps"
2023-07-19 01:35:17 +00:00
"personalwebsite/webfilesystem"
"github.com/gin-gonic/gin"
)
type SunboardApp struct {
2023-07-19 16:38:28 +00:00
fs *webfilesystem.WebFileSystem
appID string
appStorage *apps.ApplicationsStorage
2023-07-19 01:35:17 +00:00
}
2023-07-19 16:38:28 +00:00
func NewSunboardApp(webFs *webfilesystem.WebFileSystem, appStorage *apps.ApplicationsStorage) *SunboardApp {
2023-07-19 01:35:17 +00:00
newApp := SunboardApp{
2023-07-19 16:38:28 +00:00
fs: webFs,
appID: "Sunboard",
appStorage: appStorage,
2023-07-19 01:35:17 +00:00
}
return &newApp
}
func (a *SunboardApp) GetAppID() string {
return a.appID
}
func (a *SunboardApp) PublicRoutes(route *gin.RouterGroup) {
}
func (a *SunboardApp) PrivateRoutes(router *gin.RouterGroup) {
router.POST("render", func(ctx *gin.Context) {
2023-07-19 16:38:28 +00:00
appIcons := []appIcon{}
for _, app := range a.appStorage.Apps {
if app.GetAppID() == "Sunboard" {
continue
}
appIcons = append(appIcons, appIcon{
Type: "Icon",
Icon: "",
Lable: app.GetAppID(),
AppId: app.GetAppID(),
})
}
ctx.HTML(http.StatusOK, "sunboard/sunboard.html", gin.H{
"AppsIcons": appIcons,
})
2023-07-19 01:35:17 +00:00
})
}
2023-07-19 16:38:28 +00:00
type appIcon struct {
AppId string
Type string
Icon string
Lable string
}