Initial file props window

This commit is contained in:
cyber-dream 2023-05-06 01:07:09 +03:00
parent c95501dbb7
commit 405f45e788
4 changed files with 95 additions and 6 deletions

View File

@ -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")

View File

@ -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)
})
}

View File

@ -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;
}

View File

@ -0,0 +1,53 @@
{{ define "finder/props.tmpl" }}
<div class="TitleBar DragArea">
<button id="closeWindowButton" class="Button" title="Close Window"></button>
<div id="Drag" class="VisualDragArea"></div>
<div class="Lable">
File Properties
</div>
<div id="Drag" class="VisualDragArea"></div>
</div>
<div class="ContentBorder">
<div class="PropertiesList">
<div class="Personal-properties-bio">
<img src="data:{{ .headerProps.Icon.Header }},{{ .headerProps.Icon.Base64 }}" alt="File Icon" style="width: 48px;height: 48px;">
<div class="Personal-properties-textbio">
<div>{{ .file.Name }}</div>
<!-- <div>{{ .headerProps.Info1 }}</div>
<div>{{ .headerProps.Info2 }}</div> -->
</div>
</div>
{{ range $propIsland := .allprops }}
<div id="prop" class="Personal-properties-prop">
<div class="Personal-properties-prop-title">
{{$propIsland.Header}}:
</div>
<div class="Personal-properties-prop-content">
{{range $prop := $propIsland.Props}}
<div class="Personal-properties-prop-row">
<div class="Personal-properties-prop-key">
{{$prop.Key}}:
{{ range $value := $prop.KeyComments }}
<div class="Personal-properties-prop-key-comments">
{{ $value }}
</div>
{{ end }}
</div>
<div class="Personal-properties-prop-values">
{{ range $value := $prop.Values }}
<div class="Personal-properties-prop-value">
{{ $value }}
</div>
{{ end }}
</div>
</div>
{{ end }}
</div>
</div>
{{ end }}
</div>
</div>
</div>
{{ end }}