add breadcrumb to filer UI

This commit is contained in:
Chris Lu 2018-05-24 23:42:13 -07:00
parent a01557f4cb
commit f8776ad5cd
4 changed files with 37 additions and 4 deletions

View file

@ -34,9 +34,11 @@ func (fs *FilerServer) registerHandler(w http.ResponseWriter, r *http.Request) {
entry := &filer2.Entry{
FullPath: filer2.FullPath(path),
Attr: filer2.Attr{
Mode: 0660,
Uid: uint32(uid),
Gid: uint32(gid),
Mode: 0660,
Crtime: time.Now(),
Mtime: time.Now(),
Uid: uint32(uid),
Gid: uint32(gid),
},
Chunks: []*filer_pb.FileChunk{{
FileId: fileId,

View file

@ -52,12 +52,14 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.Reque
args := struct {
Path string
Breadcrumbs []ui.Breadcrumb
Entries interface{}
Limit int
LastFileName string
ShouldDisplayLoadMore bool
}{
path,
ui.ToBreadcrumb(path),
entries,
limit,
lastFileName,

View file

@ -0,0 +1,24 @@
package master_ui
import (
"strings"
"path/filepath"
)
type Breadcrumb struct {
Name string
Link string
}
func ToBreadcrumb(fullpath string) (crumbs []Breadcrumb) {
parts := strings.Split(fullpath, "/")
for i := 0; i < len(parts); i++ {
crumbs = append(crumbs, Breadcrumb{
Name: parts[i] + "/",
Link: "/" + filepath.Join(parts[0:i+1]...),
})
}
return
}

View file

@ -20,7 +20,12 @@ var StatusTpl = template.Must(template.New("status").Parse(`<!DOCTYPE html>
</h1>
</div>
<div class="row">
{{.Path}}
{{ range $entry := .Breadcrumbs }}
<a href={{ $entry.Link }} >
{{ $entry.Name }}
</a>
{{ end }}
</div>
<div class="row">