2023-05-03 21:50:08 +00:00
|
|
|
package finder
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"personalwebsite/apps"
|
2023-05-04 14:58:38 +00:00
|
|
|
"personalwebsite/wde"
|
2023-05-03 21:50:08 +00:00
|
|
|
"personalwebsite/webfilesystem"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
type FinderApplication struct {
|
|
|
|
fs *webfilesystem.WebFileSystem
|
|
|
|
manifest apps.ApplicationManifest
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewFinderApplication(webFs *webfilesystem.WebFileSystem) *FinderApplication {
|
|
|
|
return &FinderApplication{
|
|
|
|
fs: webFs,
|
|
|
|
manifest: apps.ApplicationManifest{
|
|
|
|
AppId: "finder",
|
|
|
|
WindowName: "TODO DELETE", //TODO DELETE
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func (f *FinderApplication) GetManifest() apps.ApplicationManifest {
|
|
|
|
return f.manifest
|
|
|
|
}
|
|
|
|
func (f *FinderApplication) GetId() string {
|
|
|
|
return f.manifest.AppId
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *FinderApplication) Render(isMobile bool) gin.H {
|
|
|
|
|
|
|
|
return gin.H{}
|
|
|
|
}
|
|
|
|
|
2023-05-04 14:58:38 +00:00
|
|
|
func (f *FinderApplication) RenderContextMenu(context string, data string) gin.H {
|
|
|
|
islands := [][]wde.ContexMenuRow{}
|
|
|
|
switch context {
|
|
|
|
case "FileTileView":
|
|
|
|
islands = [][]wde.ContexMenuRow{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Label: "New Directory",
|
|
|
|
Action: []string{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
case "directory":
|
|
|
|
islands = [][]wde.ContexMenuRow{
|
|
|
|
{
|
|
|
|
{Label: "Test"},
|
|
|
|
{Label: "Delete"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Label: "Get Info",
|
|
|
|
Action: []string{"openApp", "properties"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
islands = [][]wde.ContexMenuRow{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Label: "temp Menu 1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Label: "temp Menu 2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Label: "temp Menu 3",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Label: "temp Menu 4",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gin.H{
|
|
|
|
"Islands": islands,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-03 21:50:08 +00:00
|
|
|
func (f *FinderApplication) Routes(routes *gin.RouterGroup) {
|
|
|
|
routes.GET("render", func(ctx *gin.Context) {
|
|
|
|
isMobileParam := ctx.Query("isMobile")
|
|
|
|
isMobile := isMobileParam == "true"
|
2023-05-03 22:47:00 +00:00
|
|
|
admin := true
|
2023-05-03 21:50:08 +00:00
|
|
|
if isMobile {
|
|
|
|
ctx.HTML(http.StatusOK, "finder/mobile-app.tmpl", f.Render(isMobile))
|
2023-05-03 22:47:00 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if admin {
|
|
|
|
ctx.HTML(http.StatusOK, "finder/admin-app.tmpl", f.Render(isMobile))
|
|
|
|
return
|
2023-05-03 21:50:08 +00:00
|
|
|
}
|
2023-05-03 22:47:00 +00:00
|
|
|
ctx.HTML(http.StatusOK, "finder/app.tmpl", f.Render(isMobile))
|
2023-05-03 21:50:08 +00:00
|
|
|
|
|
|
|
})
|
|
|
|
routes.GET("renderMobileDesktop", func(ctx *gin.Context) {
|
|
|
|
ctx.HTML(http.StatusOK, "finder/mobile-desktop.tmpl", gin.H{})
|
|
|
|
})
|
|
|
|
routes.GET("renderDesktop", func(ctx *gin.Context) {
|
|
|
|
path := ctx.Query("path")
|
|
|
|
if path == "" {
|
|
|
|
ctx.JSON(http.StatusBadRequest, "no path provided")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ctx.HTML(http.StatusOK, "finder/desktop.tmpl", gin.H{})
|
|
|
|
})
|
2023-05-04 14:58:38 +00:00
|
|
|
|
2023-05-04 00:38:24 +00:00
|
|
|
routes.GET("contextMenu", func(ctx *gin.Context) {
|
2023-05-04 14:58:38 +00:00
|
|
|
context := ctx.Query("context")
|
|
|
|
data := ctx.Query("data")
|
|
|
|
ginH := f.RenderContextMenu(context, data)
|
|
|
|
ctx.HTML(http.StatusOK, "wde-widgets/context-menu.tmpl", ginH)
|
2023-05-04 00:38:24 +00:00
|
|
|
})
|
2023-05-03 21:50:08 +00:00
|
|
|
}
|