package finder import ( "personalwebsite/apps" "personalwebsite/wde" "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", }, } } 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{} } func (f *FinderApplication) RenderContextMenu(context string, data string) gin.H { islands := [][]wde.ContexMenuRow{} islands = append(islands, []wde.ContexMenuRow{ {Label: "Get Info", Action: "getInfo"}, {Label: "New Directory", Action: "createDir"}, }) if context == "FileTileView" { return gin.H{ "Islands": islands, } } islands = append(islands, []wde.ContexMenuRow{ {Label: "Delete File", Action: "deleteFile"}, // {Label: "Get Info", Action: "getInfo"}, }) switch context { case "directory": default: islands = append(islands, []wde.ContexMenuRow{ {Label: "temp Menu 1", Action: ""}, {Label: "temp Menu 2", Action: ""}, }) } return gin.H{ "Islands": islands, } } func (f *FinderApplication) RenderProps(filePath string) (gin.H, error) { // file, err := f.fs.NewReadDeprecated(filePath) // if err != nil { // return nil // } fileHeader, err := f.fs.Read(filePath, nil) if err != nil { return nil, err } return gin.H{ // "fileId": fileHeader.MongoId, // "fileDataId": fileHeader.Data, "file": fileHeader, }, nil } // func (f *FinderApplication) Routes(routes *gin.RouterGroup) { // routes.GET("render", func(ctx *gin.Context) { // isMobileParam := ctx.Query("isMobile") // isMobile := isMobileParam == "true" // admin := true // if isMobile { // ctx.HTML(http.StatusOK, "finder/mobile-app.tmpl", f.Render(isMobile)) // return // } // if admin { // ctx.HTML(http.StatusOK, "finder/admin-app.tmpl", f.Render(isMobile)) // return // } // ctx.HTML(http.StatusOK, "finder/app.tmpl", f.Render(isMobile)) // }) // 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{}) // }) // routes.GET("contextMenu", func(ctx *gin.Context) { // context := ctx.Query("context") // data := ctx.Query("data") // ginH := f.RenderContextMenu(context, data) // ctx.HTML(http.StatusOK, "wde-widgets/context-menu.tmpl", ginH) // }) // }