| @@ -307,6 +307,9 @@ func NewFuncMap() []template.FuncMap { | |||||
| "tasks": tasks, | "tasks": tasks, | ||||
| "categories": categories, | "categories": categories, | ||||
| "licenses": licenses, | "licenses": licenses, | ||||
| "DatasetPathJoin": func(arr []string, index int, seq string) string { | |||||
| return strings.Join(arr[0:index+1], seq) | |||||
| }, | |||||
| }} | }} | ||||
| } | } | ||||
| @@ -29,6 +29,7 @@ type FileInfo struct { | |||||
| func DirIndex(ctx *context.Context) { | func DirIndex(ctx *context.Context) { | ||||
| uuid := ctx.Params("uuid") | uuid := ctx.Params("uuid") | ||||
| parentDir := ctx.Query("parentDir") | parentDir := ctx.Query("parentDir") | ||||
| dirArray := strings.Split(parentDir, "/") | |||||
| if parentDir == "" { | if parentDir == "" { | ||||
| attachment, err := models.GetAttachmentByUUID(uuid) | attachment, err := models.GetAttachmentByUUID(uuid) | ||||
| @@ -41,15 +42,13 @@ func DirIndex(ctx *context.Context) { | |||||
| log.Error("The file is not zip file, can not query the dir") | log.Error("The file is not zip file, can not query the dir") | ||||
| ctx.ServerError("The file is not zip file, can not query the dir", errors.New("The file is not zip file, can not query the dir")) | ctx.ServerError("The file is not zip file, can not query the dir", errors.New("The file is not zip file, can not query the dir")) | ||||
| return | return | ||||
| } else { | |||||
| if attachment.DecompressState != models.DecompressStateDone { | |||||
| log.Error("The file has not been decompressed completely now") | |||||
| ctx.ServerError("The file has not been decompressed completely now", errors.New("The file has not been decompressed completely now")) | |||||
| return | |||||
| } | |||||
| } else if attachment.DecompressState != models.DecompressStateDone { | |||||
| log.Error("The file has not been decompressed completely now") | |||||
| ctx.ServerError("The file has not been decompressed completely now", errors.New("The file has not been decompressed completely now")) | |||||
| return | |||||
| } | } | ||||
| ctx.Data["Title"] = attachment.Name | |||||
| // ctx.Data["OriginName"] = attachment.Name | |||||
| } | } | ||||
| files, err := ioutil.ReadDir(setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.BasePath + | files, err := ioutil.ReadDir(setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.BasePath + | ||||
| @@ -87,7 +86,9 @@ func DirIndex(ctx *context.Context) { | |||||
| i++ | i++ | ||||
| } | } | ||||
| ctx.Data["Path"] = dirArray | |||||
| ctx.Data["Dirs"] = fileInfos | ctx.Data["Dirs"] = fileInfos | ||||
| ctx.Data["PageIsDataset"] = true | |||||
| ctx.HTML(200, tplDirIndex) | ctx.HTML(200, tplDirIndex) | ||||
| } | } | ||||
| @@ -2,15 +2,15 @@ | |||||
| {{range .Dirs}} | {{range .Dirs}} | ||||
| <div class="ui grid item"> | <div class="ui grid item"> | ||||
| <div class="row"> | <div class="row"> | ||||
| <div class="six wide column"> | |||||
| <div class="ten wide column"> | |||||
| <a class="title" href="{{if .IsDir}}{{$.RepoLink}}/datasets/dirs/{{.UUID}}?parentDir={{.ParenDir}}{{end}}"> | <a class="title" href="{{if .IsDir}}{{$.RepoLink}}/datasets/dirs/{{.UUID}}?parentDir={{.ParenDir}}{{end}}"> | ||||
| <span class="fitted">{{if .IsDir}} {{svg "octicon-file-directory" 16}}{{else}}{{svg "octicon-file" 16}}{{end}}</span> {{.FileName}} | |||||
| <span class="fitted">{{if .IsDir}} {{svg "octicon-file-directory" 16}}{{else}}{{svg "octicon-file" 16}}{{end}}</span> {{.FileName}} | |||||
| </a> | </a> | ||||
| </div> | </div> | ||||
| <div class="two wide column"> | <div class="two wide column"> | ||||
| {{.Size | FileSize}} | {{.Size | FileSize}} | ||||
| </div> | </div> | ||||
| <div class="six wide column"> | |||||
| <div class="four wide column"> | |||||
| <span>{{.ModTime}}</span> | <span>{{.ModTime}}</span> | ||||
| </div> | </div> | ||||
| @@ -5,24 +5,20 @@ | |||||
| <div class="ui stackable grid {{if .Error}}hide{{end}}" id="dir-content"> | <div class="ui stackable grid {{if .Error}}hide{{end}}" id="dir-content"> | ||||
| <div class="row"> | <div class="row"> | ||||
| <div class="column sixteen wide"> | <div class="column sixteen wide"> | ||||
| <h2>{{.Title}}</h2> | |||||
| <p> | |||||
| {{ range $index, $item := .Path }} | |||||
| <a href='{{$.Link}}/?parentDir={{if gt $index 0}}{{DatasetPathJoin $.Path $index "/"}}{{else}}{{$item}}{{end}}'>{{ $item }}</a>/ | |||||
| {{ end }} | |||||
| </p> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <div class="ui divider"></div> | |||||
| <div class="ui grid"> | <div class="ui grid"> | ||||
| <div class="row"> | <div class="row"> | ||||
| <div class="ui twelve wide column"> | |||||
| <div class="ui sixteen wide column"> | |||||
| <div class="ui two column stackable grid"> | |||||
| <div class="column"> | |||||
| <h2>{{.i18n.Tr "dataset.dir"}}</h2> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <div class="ui sixteen wide column"> | |||||
| <div class="dir list"> | <div class="dir list"> | ||||
| {{/* {{template "repo/datasets/dirs/dir_list" .}} */}} | |||||
| {{template "repo/datasets/dirs/dir_list" .}} | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||