2023-05-03 21:50:08 +00:00
|
|
|
package finder
|
|
|
|
|
|
|
|
import (
|
2023-05-18 01:57:44 +00:00
|
|
|
"personalwebsite/apps/appCtx"
|
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 {
|
2023-07-22 23:55:08 +00:00
|
|
|
fs *webfilesystem.WebFileSystem
|
|
|
|
appID string
|
|
|
|
titleBarConfig wde.TitleBarConfig
|
2023-05-18 01:57:44 +00:00
|
|
|
// manifest apps.ApplicationManifest
|
2023-05-03 21:50:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewFinderApplication(webFs *webfilesystem.WebFileSystem) *FinderApplication {
|
|
|
|
return &FinderApplication{
|
2023-05-16 10:51:28 +00:00
|
|
|
fs: webFs,
|
|
|
|
appID: "Finder",
|
2023-07-22 23:55:08 +00:00
|
|
|
titleBarConfig: wde.TitleBarConfig{
|
|
|
|
Lable: "Finder",
|
|
|
|
CloseButton: true,
|
|
|
|
},
|
2023-05-03 21:50:08 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-18 01:57:44 +00:00
|
|
|
|
2023-05-16 10:51:28 +00:00
|
|
|
func (f *FinderApplication) GetAppID() string {
|
|
|
|
return f.appID
|
2023-05-03 21:50:08 +00:00
|
|
|
}
|
|
|
|
|
2023-05-18 01:57:44 +00:00
|
|
|
func (f *FinderApplication) Render(appCtx appCtx.AppContext) gin.H {
|
2023-07-22 23:55:08 +00:00
|
|
|
return gin.H{
|
|
|
|
"TitleBarConfig": f.titleBarConfig,
|
|
|
|
}
|
2023-05-03 21:50:08 +00:00
|
|
|
}
|
|
|
|
|
2023-05-16 10:51:28 +00:00
|
|
|
func (f *FinderApplication) RenderPublicContextMenu(context string, filePath string, data string) gin.H {
|
|
|
|
islands := [][]wde.ContexMenuRow{}
|
|
|
|
islands = append(islands, []wde.ContexMenuRow{})
|
|
|
|
|
2023-05-16 12:12:55 +00:00
|
|
|
//TODO: Links read as source files in props info
|
2023-05-16 10:51:28 +00:00
|
|
|
islands = append(islands, []wde.ContexMenuRow{
|
|
|
|
{Label: "Get Info", Action: "getInfo"},
|
|
|
|
})
|
|
|
|
if context == "FileTileView" {
|
|
|
|
return gin.H{
|
|
|
|
"Islands": islands,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch context {
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
|
|
|
return gin.H{
|
|
|
|
"Islands": islands,
|
|
|
|
}
|
|
|
|
}
|
2023-05-04 14:58:38 +00:00
|
|
|
|
2023-05-07 21:20:40 +00:00
|
|
|
func (f *FinderApplication) RenderProps(filePath string) (gin.H, error) {
|
|
|
|
fileHeader, err := f.fs.Read(filePath, nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-05-05 22:07:09 +00:00
|
|
|
|
|
|
|
return gin.H{
|
2023-05-07 21:20:40 +00:00
|
|
|
"file": fileHeader,
|
|
|
|
}, nil
|
2023-05-05 22:07:09 +00:00
|
|
|
}
|