Browse Source

Merge branch 'grampus-notebook' of openi.pcl.ac.cn:OpenI/aiforge into grampus-notebook

tags/v1.22.12.1^2
zhoupzh 3 years ago
parent
commit
203e00a7bb
1 changed files with 35 additions and 3 deletions
  1. +35
    -3
      routers/repo/grampus.go

+ 35
- 3
routers/repo/grampus.go View File

@@ -1127,16 +1127,48 @@ func GrampusNotebookShow(ctx *context.Context) {
task.Parameters = ""
}
}
user, err := models.GetUserByID(task.UserID)
if err == nil {
task.User = user
}

prepareSpec4Show(ctx, task)
datasetList := make([]NotebookDataset, 0)
_ = json.Unmarshal([]byte(task.DataUrl), &datasetList)

ctx.Data["task"] = task
ctx.Data["datasetDownload"] = datasetList
ctx.Data["datasetDownload"] = getDatasetDownloadInfo(ctx, task)
ctx.Data["canDownload"] = cloudbrain.CanModifyJob(ctx, task)
ctx.Data["ai_center"] = cloudbrainService.GetAiCenterShow(task.AiCenter, ctx)
ctx.HTML(http.StatusOK, tplGrampusNotebookShow)
}

func getDatasetDownloadInfo(ctx *context.Context, task *models.Cloudbrain) []models.DatasetDownload {
datasetDownload := make([]models.DatasetDownload, 0)
if ctx.IsSigned {
if task.Uuid != "" && task.UserID == ctx.User.ID {
datasetDownload = GetCloudBrainDataSetInfo(task.Uuid, task.DatasetName, true)
}
}
datasetObsUrlList := make([]NotebookDataset, 0)
_ = json.Unmarshal([]byte(task.DataUrl), &datasetObsUrlList)

for _, datasetInfo := range datasetDownload {
match := false
for _, datasetObs := range datasetObsUrlList {

if strings.Contains(datasetObs.DatasetUrl, datasetInfo.DatasetName) {
datasetInfo.DatasetDownloadLink = datasetObs.DatasetUrl
match = true
break
}
}
if !match {
datasetInfo.DatasetDownloadLink = ""
}

}
return datasetDownload
}

func GrampusTrainJobShow(ctx *context.Context) {
ctx.Data["PageIsCloudBrain"] = true



Loading…
Cancel
Save