Add filer command line parameter to let Filer UI show/hide directory delete button

This commit is contained in:
yulai.li 2022-06-15 00:30:49 +08:00
parent 14e0d8613b
commit 28cda854eb
4 changed files with 31 additions and 22 deletions

View file

@ -55,6 +55,7 @@ type FilerOptions struct {
debug *bool debug *bool
debugPort *int debugPort *int
localSocket *string localSocket *string
showUIDirectoryDelete *bool
} }
func init() { func init() {
@ -82,6 +83,7 @@ func init() {
f.debug = cmdFiler.Flag.Bool("debug", false, "serves runtime profiling data, e.g., http://localhost:<debug.port>/debug/pprof/goroutine?debug=2") f.debug = cmdFiler.Flag.Bool("debug", false, "serves runtime profiling data, e.g., http://localhost:<debug.port>/debug/pprof/goroutine?debug=2")
f.debugPort = cmdFiler.Flag.Int("debug.port", 6060, "http port for debugging") f.debugPort = cmdFiler.Flag.Int("debug.port", 6060, "http port for debugging")
f.localSocket = cmdFiler.Flag.String("localSocket", "", "default to /tmp/seaweedfs-filer-<port>.sock") f.localSocket = cmdFiler.Flag.String("localSocket", "", "default to /tmp/seaweedfs-filer-<port>.sock")
f.showUIDirectoryDelete = cmdFiler.Flag.Bool("ui.deleteDir", false, "enable filer UI show delete directory button")
// start s3 on filer // start s3 on filer
filerStartS3 = cmdFiler.Flag.Bool("s3", false, "whether to start S3 gateway") filerStartS3 = cmdFiler.Flag.Bool("s3", false, "whether to start S3 gateway")
@ -216,6 +218,7 @@ func (fo *FilerOptions) startFiler() {
Cipher: *fo.cipher, Cipher: *fo.cipher,
SaveToFilerLimit: int64(*fo.saveToFilerLimit), SaveToFilerLimit: int64(*fo.saveToFilerLimit),
ConcurrentUploadLimit: int64(*fo.concurrentUploadLimitMB) * 1024 * 1024, ConcurrentUploadLimit: int64(*fo.concurrentUploadLimitMB) * 1024 * 1024,
ShowUIDirectoryDelete: *fo.showUIDirectoryDelete,
}) })
if nfs_err != nil { if nfs_err != nil {
glog.Fatalf("Filer startup error: %v", nfs_err) glog.Fatalf("Filer startup error: %v", nfs_err)

View file

@ -3,7 +3,6 @@ package weed_server
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"net/http" "net/http"
"os" "os"
"sync" "sync"
@ -17,6 +16,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/pb" "github.com/chrislusf/seaweedfs/weed/pb"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb" "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util"
@ -67,6 +67,7 @@ type FilerOption struct {
Cipher bool Cipher bool
SaveToFilerLimit int64 SaveToFilerLimit int64
ConcurrentUploadLimit int64 ConcurrentUploadLimit int64
ShowUIDirectoryDelete bool
} }
type FilerServer struct { type FilerServer struct {

View file

@ -73,7 +73,7 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque
return return
} }
ui.StatusTpl.Execute(w, struct { err = ui.StatusTpl.Execute(w, struct {
Path string Path string
Breadcrumbs []ui.Breadcrumb Breadcrumbs []ui.Breadcrumb
Entries interface{} Entries interface{}
@ -81,6 +81,7 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque
LastFileName string LastFileName string
ShouldDisplayLoadMore bool ShouldDisplayLoadMore bool
EmptyFolder bool EmptyFolder bool
ShowDirectoryDelete bool
}{ }{
path, path,
ui.ToBreadcrumb(path), ui.ToBreadcrumb(path),
@ -89,5 +90,9 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque
lastFileName, lastFileName,
shouldDisplayLoadMore, shouldDisplayLoadMore,
emptyFolder, emptyFolder,
fs.option.ShowUIDirectoryDelete,
}) })
if err != nil {
glog.V(0).Infof("Template Execute Error: %v", err)
}
} }

View file

@ -116,6 +116,7 @@
{{ else }} {{ else }}
<table width="100%" class="table table-hover"> <table width="100%" class="table table-hover">
{{ $path := .Path }} {{ $path := .Path }}
{{ $showDirDel := .ShowDirectoryDelete }}
{{ range $entry_index, $entry := .Entries }} {{ range $entry_index, $entry := .Entries }}
<tr> <tr>
<td> <td>
@ -131,14 +132,12 @@
{{ end }} {{ end }}
</td> </td>
<td align="right" nowrap> <td align="right" nowrap>
{{if $entry.IsDirectory}} {{ if not $entry.IsDirectory }}
{{else}}
{{ $entry.Mime }}&nbsp; {{ $entry.Mime }}&nbsp;
{{ end }} {{ end }}
</td> </td>
<td align="right" nowrap> <td align="right" nowrap>
{{if $entry.IsDirectory}} {{ if not $entry.IsDirectory }}
{{else}}
{{ $entry.Size | humanizeBytes }}&nbsp; {{ $entry.Size | humanizeBytes }}&nbsp;
{{ end }} {{ end }}
</td> </td>
@ -150,11 +149,12 @@
<label class="btn" onclick="handleRename('{{ $entry.Name }}', '{{ printpath $path "/" }}')"> <label class="btn" onclick="handleRename('{{ $entry.Name }}', '{{ printpath $path "/" }}')">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span> <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</label> </label>
{{if $entry.IsDirectory}} {{ if and $entry.IsDirectory $showDirDel }}
<label class="btn" onclick="handleDelete('{{ printpath $path "/" $entry.Name "/" }}')"> <label class="btn" onclick="handleDelete('{{ printpath $path "/" $entry.Name "/" }}')">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
</label> </label>
{{else}} {{ end }}
{{ if not $entry.IsDirectory }}
<label class="btn" onclick="handleDelete('{{ printpath $path "/" $entry.Name }}')"> <label class="btn" onclick="handleDelete('{{ printpath $path "/" $entry.Name }}')">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
</label> </label>