Browse Source

mod req

tags/v1.21.12.1
lewis 4 years ago
parent
commit
70e2aabdca
3 changed files with 23 additions and 6 deletions
  1. +12
    -0
      routers/repo/cloudbrain.go
  2. +10
    -5
      routers/repo/dir.go
  3. +1
    -1
      templates/repo/datasets/dirs/dir_list.tmpl

+ 12
- 0
routers/repo/cloudbrain.go View File

@@ -349,11 +349,23 @@ func CloudBrainShowModels(ctx *context.Context) {
//get dirs //get dirs





ctx.Data["task"] = task ctx.Data["task"] = task
ctx.Data["jobID"] = jobID ctx.Data["jobID"] = jobID
ctx.HTML(200, tplCloudBrainShowModels) ctx.HTML(200, tplCloudBrainShowModels)
} }


func getModelDirs(uuid string, parentDir string) (string, error) {
var req string
if parentDir == "" {
req = "uuid=" + uuid
} else {
req = "uuid=" + uuid + "&parentDir=" + parentDir
}

return getDirs(req)
}

func CloudBrainDownloadModel(ctx *context.Context) { func CloudBrainDownloadModel(ctx *context.Context) {
filePath := ctx.Query("file_path") filePath := ctx.Query("file_path")
fileName := ctx.Query("file_name") fileName := ctx.Query("file_name")


+ 10
- 5
routers/repo/dir.go View File

@@ -58,7 +58,7 @@ func DirIndex(ctx *context.Context) {
dirArray = []string{attachment.Name} dirArray = []string{attachment.Name}
} }


dirs, err := getDirs(uuid, parentDir)
dirs, err := getDatasetDirs(uuid, parentDir)
if err != nil { if err != nil {
log.Error("getDirs failed:", err.Error()) log.Error("getDirs failed:", err.Error())
ctx.ServerError("getDirs failed:", err) ctx.ServerError("getDirs failed:", err)
@@ -75,13 +75,13 @@ func DirIndex(ctx *context.Context) {


ctx.Data["Path"] = dirArray ctx.Data["Path"] = dirArray
ctx.Data["Dirs"] = fileInfos ctx.Data["Dirs"] = fileInfos
ctx.Data["Uuid"] = uuid
ctx.Data["PageIsDataset"] = true ctx.Data["PageIsDataset"] = true


ctx.HTML(200, tplDirIndex) ctx.HTML(200, tplDirIndex)
} }


func getDirs(uuid string, parentDir string) (string, error) {
var dirs string
func getDatasetDirs(uuid string, parentDir string) (string, error) {
var req string var req string
if parentDir == "" { if parentDir == "" {
req = "uuid=" + uuid req = "uuid=" + uuid
@@ -89,7 +89,13 @@ func getDirs(uuid string, parentDir string) (string, error) {
req = "uuid=" + uuid + "&parentDir=" + parentDir req = "uuid=" + uuid + "&parentDir=" + parentDir
} }


url := setting.DecompressAddress + "/dirs?" + req
return getDirs(req)
}

func getDirs(req string) (string, error) {
var dirs string

url := setting.DecompressAddress + "/dirs/dataset?" + req
reqHttp, err := http.NewRequest(http.MethodGet, url, nil) reqHttp, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil { if err != nil {
log.Error("http.NewRequest failed:", err.Error()) log.Error("http.NewRequest failed:", err.Error())
@@ -127,6 +133,5 @@ func getDirs(uuid string, parentDir string) (string, error) {
} }


dirs = resp.FileInfos dirs = resp.FileInfos

return dirs, nil return dirs, nil
} }

+ 1
- 1
templates/repo/datasets/dirs/dir_list.tmpl View File

@@ -6,7 +6,7 @@
<td class="name four wide"> <td class="name four wide">
<span class="truncate"> <span class="truncate">
<span class="octicon octicon-file-directory"></span> <span class="octicon octicon-file-directory"></span>
<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>
</span> </span>


Loading…
Cancel
Save