personal-website/apps/sunboard/sunboard.go

63 lines
1.2 KiB
Go

package sunboard
import (
"net/http"
"personalwebsite/apps"
"personalwebsite/webfilesystem"
"github.com/gin-gonic/gin"
)
type SunboardApp struct {
fs *webfilesystem.WebFileSystem
appID string
appStorage *apps.ApplicationsStorage
}
func NewSunboardApp(webFs *webfilesystem.WebFileSystem, appStorage *apps.ApplicationsStorage) *SunboardApp {
newApp := SunboardApp{
fs: webFs,
appID: "Sunboard",
appStorage: appStorage,
}
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) {
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(),
Path: "/Applications/" + app.GetAppID() + ".app", //FIXME
})
}
ctx.HTML(http.StatusOK, "sunboard/sunboard.html", gin.H{
"AppsIcons": appIcons,
})
})
}
type appIcon struct {
AppId string
Type string
Icon string
Lable string
Path string
}