From 2347c21cdd208a49b6393c1b0a66eab76a68e2bd Mon Sep 17 00:00:00 2001 From: "yulai.li" Date: Thu, 7 Apr 2022 15:11:05 +0800 Subject: [PATCH] Tune filer UI add rename feature --- weed/server/filer_server_handlers_read_dir.go | 6 +++ weed/server/filer_ui/filer.html | 44 ++++++++++++++++--- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/weed/server/filer_server_handlers_read_dir.go b/weed/server/filer_server_handlers_read_dir.go index f67e90d38..8382cfc76 100644 --- a/weed/server/filer_server_handlers_read_dir.go +++ b/weed/server/filer_server_handlers_read_dir.go @@ -46,8 +46,10 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque path = "" } + emptyFolder := true if len(entries) > 0 { lastFileName = entries[len(entries)-1].Name() + emptyFolder = false } glog.V(4).Infof("listDirectory %s, last file %s, limit %d: %d items", path, lastFileName, limit, len(entries)) @@ -59,12 +61,14 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque Limit int LastFileName string ShouldDisplayLoadMore bool + EmptyFolder bool }{ path, entries, limit, lastFileName, shouldDisplayLoadMore, + emptyFolder, }) return } @@ -76,6 +80,7 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque Limit int LastFileName string ShouldDisplayLoadMore bool + EmptyFolder bool }{ path, ui.ToBreadcrumb(path), @@ -83,5 +88,6 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque limit, lastFileName, shouldDisplayLoadMore, + emptyFolder, }) } diff --git a/weed/server/filer_ui/filer.html b/weed/server/filer_ui/filer.html index e4dd32f50..2f26f297d 100644 --- a/weed/server/filer_ui/filer.html +++ b/weed/server/filer_ui/filer.html @@ -44,6 +44,12 @@ border-radius: 2px; } + .info { + background: #fff; + border: 1px solid #fff; + border-radius: 2px; + } + .footer { position: absolute; bottom: 10px; @@ -63,6 +69,14 @@ width: 60px; text-align: right; } + + .add-files { + font-size: 46px; + text-align: center; + border: 1px dashed #999; + padding-bottom: 9px; + margin: 0 2px; + } @@ -126,11 +140,16 @@ {{else}} {{end}} + {{ end }} - + {{if .EmptyFolder}} +
+ + +
+ {{end}} @@ -208,10 +227,10 @@ var values = Object.values(uploadList); var html = '\n'; for (let i of values) { - html += '\n\n'; - html += '\n\n'; + html += '\n
' + i.name + '' + i.percent + '%
' + i.name + '<\/td>\n'; + html += '' + i.percent + '% <\/td>\n<\/tr>\n'; } - html += '
\n'; + html += '<\/table>\n'; progressArea.innerHTML = html; if (values.length > 0) { progressArea.attributes.style.value = ''; @@ -263,7 +282,7 @@ function handleCreateDir() { var dirName = prompt('Directory Name:', ''); dirName = dirName.trim(); - if (dirName == null && dirName == '') { + if (dirName == null || dirName == '') { return; } var baseUrl = window.location.href; @@ -281,6 +300,21 @@ window.location.reload(); } + function handleRename(originName, basePath) { + var newName = prompt('New Name:', originName); + if (newName == null || newName == '') { + return; + } + var url = basePath + newName; + var originPath = basePath + originName; + url += '?mv.from=' + originPath; + var xhr = new XMLHttpRequest(); + xhr.open('POST', url, false); + xhr.setRequestHeader('Content-Type', ''); + xhr.send(); + window.location.reload(); + } + function handleDelete(path) { if (!confirm('Are you sure to delete ' + path + '?')) { return;