From 405f45e788c61f726bec36be065ce759e0ce65e4 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Sat, 6 May 2023 01:07:09 +0300 Subject: [PATCH] Initial file props window --- apps/finder/finder.go | 14 +++++++-- apps/finder/routes.go | 6 ++++ resources/sys/finder/finder.js | 28 +++++++++++++++--- templates/finder/props.tmpl | 53 ++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 templates/finder/props.tmpl diff --git a/apps/finder/finder.go b/apps/finder/finder.go index 1dac72d..b8961fe 100644 --- a/apps/finder/finder.go +++ b/apps/finder/finder.go @@ -30,7 +30,6 @@ func (f *FinderApplication) GetId() string { } func (f *FinderApplication) Render(isMobile bool) gin.H { - return gin.H{} } @@ -39,6 +38,7 @@ func (f *FinderApplication) RenderContextMenu(context string, data string) gin.H islands = append(islands, []wde.ContexMenuRow{ {Label: "Get Info", Action: "getInfo"}, + {Label: "New Directory", Action: "createDir"}, }) if context == "FileTileView" { return gin.H{ @@ -53,7 +53,6 @@ func (f *FinderApplication) RenderContextMenu(context string, data string) gin.H switch context { case "directory": - default: islands = append(islands, []wde.ContexMenuRow{ {Label: "temp Menu 1", Action: ""}, @@ -66,6 +65,17 @@ func (f *FinderApplication) RenderContextMenu(context string, data string) gin.H } } +func (f *FinderApplication) RenderProps(filePath string) gin.H { + file, err := f.fs.NewRead(filePath) + if err != nil { + return nil + } + + return gin.H{ + "file": file, + } +} + // func (f *FinderApplication) Routes(routes *gin.RouterGroup) { // routes.GET("render", func(ctx *gin.Context) { // isMobileParam := ctx.Query("isMobile") diff --git a/apps/finder/routes.go b/apps/finder/routes.go index 3f39fb5..cb569c5 100644 --- a/apps/finder/routes.go +++ b/apps/finder/routes.go @@ -40,4 +40,10 @@ func (f *FinderApplication) Routes(routes *gin.RouterGroup) { ginH := f.RenderContextMenu(context, data) ctx.HTML(http.StatusOK, "wde-widgets/context-menu.tmpl", ginH) }) + + routes.GET("renderProps", func(ctx *gin.Context) { + filePath := ctx.Query("path") + ginH := f.RenderProps(filePath) + ctx.HTML(http.StatusOK, "finder/props.tmpl", ginH) + }) } diff --git a/resources/sys/finder/finder.js b/resources/sys/finder/finder.js index da6b607..ffbe3e8 100644 --- a/resources/sys/finder/finder.js +++ b/resources/sys/finder/finder.js @@ -202,7 +202,7 @@ class Finder{ overlay.appendChild(menu) document.body.appendChild(overlay) - overlay.addEventListener('click',(event) => { + overlay.addEventListener('click', (event) => { if (event.target.classList.contains("Row")){ //TODO add uuid id to rows to more accurate checks?? let fileType = target.getAttribute("fileType") let fileName = target.getAttribute("name") @@ -225,21 +225,41 @@ class Finder{ console.log(fileName) // break fetch(`/fs/delete?` + new URLSearchParams({ - path: `${this.path}/${fileName}` //FIXME + path: `${this.path}/${fileName}` })) .then((response) => { console.log(response.status) if (response.status == 200){ this.OpenDir(this.path) + } }) + .catch((error) => { WebDesktopEnvironment.Alert(error); }) break case "getInfo": - // console.log("Open Properties") - WebDesktopEnvironment.Open("props-viewer", `${this.path}/${fileName}`) + fetch(`/application/${this.appId}/renderProps?` + new URLSearchParams({ + path: `${this.path}/${fileName}` + })) + .then((response) => { + console.log(response) + if (response.status == 200){ + console.log("Success") + return response.text(); + } + }) + .then((html) =>{ + let newWindow = WebDesktopEnvironment.CreateNewWindow(this.appId, 350, 500 ) + newWindow.innerHTML = html + newWindow.querySelector("#closeWindowButton").addEventListener('click', function (params) { + WebDesktopEnvironment.CloseWindow(newWindow) + }) + }) + .catch((error) => { + WebDesktopEnvironment.Alert(error); + }) default: break; } diff --git a/templates/finder/props.tmpl b/templates/finder/props.tmpl new file mode 100644 index 0000000..fbd27be --- /dev/null +++ b/templates/finder/props.tmpl @@ -0,0 +1,53 @@ +{{ define "finder/props.tmpl" }} +
+ +
+
+ File Properties +
+
+
+
+
+
+ File Icon +
+
{{ .file.Name }}
+ +
+
+ {{ range $propIsland := .allprops }} +
+
+ {{$propIsland.Header}}: +
+
+ {{range $prop := $propIsland.Props}} +
+
+ {{$prop.Key}}: + {{ range $value := $prop.KeyComments }} +
+ {{ $value }} +
+ {{ end }} +
+
+ {{ range $value := $prop.Values }} +
+ {{ $value }} +
+ {{ end }} +
+
+ {{ end }} +
+
+ {{ end }} +
+
+ +{{ end }} + + \ No newline at end of file