From 754f76c7a4da07f966a6e5b9461eaeb015f57bd6 Mon Sep 17 00:00:00 2001 From: liuzx Date: Tue, 1 Nov 2022 11:18:10 +0800 Subject: [PATCH 1/2] fix-3124 --- routers/admin/cloudbrains.go | 20 +++--- routers/api/v1/repo/cloudbrain_dashboard.go | 76 +++++++++++---------- routers/user/home.go | 19 +++--- 3 files changed, 62 insertions(+), 53 deletions(-) diff --git a/routers/admin/cloudbrains.go b/routers/admin/cloudbrains.go index d03c00ae6..5f42c8a51 100755 --- a/routers/admin/cloudbrains.go +++ b/routers/admin/cloudbrains.go @@ -70,7 +70,7 @@ func CloudBrains(ctx *context.Context) { keyword := strings.Trim(ctx.Query("q"), " ") - ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{ + ciTasks, _, err := models.Cloudbrains(&models.CloudbrainsOptions{ ListOptions: models.ListOptions{ Page: page, PageSize: setting.UI.IssuePagingNum, @@ -84,7 +84,6 @@ func CloudBrains(ctx *context.Context) { IsLatestVersion: modelarts.IsLatestVersion, ComputeResource: listType, Type: models.TypeCloudBrainAll, - AiCenter: aiCenter, Cluster: cluster, }) if err != nil { @@ -93,19 +92,24 @@ func CloudBrains(ctx *context.Context) { } models.LoadSpecs4CloudbrainInfo(ciTasks) - - for i, task := range ciTasks { - ciTasks[i].CanDebug = true - ciTasks[i].CanDel = true - ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource + tasks := []*models.CloudbrainInfo{} + + for _, task := range ciTasks { + if aiCenter == "" || aiCenter == task.Cloudbrain.Spec.AiCenterCode { + task.CanDebug = true + task.CanDel = true + task.Cloudbrain.ComputeResource = task.ComputeResource + tasks = append(tasks, task) + } } + count := int64(len(tasks)) pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, getTotalPage(count, setting.UI.IssuePagingNum)) pager.SetDefaultParams(ctx) pager.AddParam(ctx, "listType", "ListType") ctx.Data["Page"] = pager ctx.Data["PageIsCloudBrain"] = true - ctx.Data["Tasks"] = ciTasks + ctx.Data["Tasks"] = tasks ctx.Data["CanCreate"] = true ctx.Data["Keyword"] = keyword diff --git a/routers/api/v1/repo/cloudbrain_dashboard.go b/routers/api/v1/repo/cloudbrain_dashboard.go index fdc8d64bb..d1ccf1bf5 100755 --- a/routers/api/v1/repo/cloudbrain_dashboard.go +++ b/routers/api/v1/repo/cloudbrain_dashboard.go @@ -732,7 +732,7 @@ func GetCloudbrainsDetailData(ctx *context.Context) { keyword := strings.Trim(ctx.Query("q"), " ") - ciTasks, count, err := models.CloudbrainAll(&models.CloudbrainsOptions{ + ciTasks, _, err := models.CloudbrainAll(&models.CloudbrainsOptions{ ListOptions: models.ListOptions{ Page: page, PageSize: pageSize, @@ -747,8 +747,8 @@ func GetCloudbrainsDetailData(ctx *context.Context) { NeedRepoInfo: true, BeginTimeUnix: int64(recordBeginTime), EndTimeUnix: endTime.Unix(), - AiCenter: aiCenter, - NeedDeleteInfo: needDeleteInfo, + // AiCenter: aiCenter, + NeedDeleteInfo: needDeleteInfo, }) if err != nil { ctx.ServerError("Get job failed:", err) @@ -758,43 +758,45 @@ func GetCloudbrainsDetailData(ctx *context.Context) { nilTime := time.Time{} tasks := []models.TaskDetail{} for i, task := range ciTasks { - ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource - var taskDetail models.TaskDetail - taskDetail.ID = ciTasks[i].Cloudbrain.ID - taskDetail.JobID = ciTasks[i].Cloudbrain.JobID - taskDetail.JobName = ciTasks[i].JobName - taskDetail.DisplayJobName = ciTasks[i].DisplayJobName - taskDetail.Status = ciTasks[i].Status - taskDetail.JobType = ciTasks[i].JobType - taskDetail.CreatedUnix = ciTasks[i].Cloudbrain.CreatedUnix - taskDetail.RunTime = ciTasks[i].Cloudbrain.TrainJobDuration - taskDetail.StartTime = ciTasks[i].StartTime - taskDetail.EndTime = ciTasks[i].EndTime - taskDetail.ComputeResource = ciTasks[i].ComputeResource - taskDetail.Type = ciTasks[i].Cloudbrain.Type - taskDetail.UserName = ciTasks[i].User.Name - taskDetail.RepoID = ciTasks[i].RepoID - if ciTasks[i].Repo != nil { - taskDetail.RepoName = ciTasks[i].Repo.OwnerName + "/" + ciTasks[i].Repo.Name - taskDetail.RepoAlias = ciTasks[i].Repo.OwnerName + "/" + ciTasks[i].Repo.Alias - } - if ciTasks[i].Cloudbrain.WorkServerNumber >= 1 { - taskDetail.WorkServerNum = int64(ciTasks[i].Cloudbrain.WorkServerNumber) - } else { - taskDetail.WorkServerNum = 1 - } - taskDetail.CardDuration = repo.GetCloudbrainCardDuration(ciTasks[i].Cloudbrain) - taskDetail.WaitTime = repo.GetCloudbrainWaitTime(ciTasks[i].Cloudbrain) + if aiCenter == "" || aiCenter == task.Cloudbrain.Spec.AiCenterCode { + ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource + var taskDetail models.TaskDetail + taskDetail.ID = ciTasks[i].Cloudbrain.ID + taskDetail.JobID = ciTasks[i].Cloudbrain.JobID + taskDetail.JobName = ciTasks[i].JobName + taskDetail.DisplayJobName = ciTasks[i].DisplayJobName + taskDetail.Status = ciTasks[i].Status + taskDetail.JobType = ciTasks[i].JobType + taskDetail.CreatedUnix = ciTasks[i].Cloudbrain.CreatedUnix + taskDetail.RunTime = ciTasks[i].Cloudbrain.TrainJobDuration + taskDetail.StartTime = ciTasks[i].StartTime + taskDetail.EndTime = ciTasks[i].EndTime + taskDetail.ComputeResource = ciTasks[i].ComputeResource + taskDetail.Type = ciTasks[i].Cloudbrain.Type + taskDetail.UserName = ciTasks[i].User.Name + taskDetail.RepoID = ciTasks[i].RepoID + if ciTasks[i].Repo != nil { + taskDetail.RepoName = ciTasks[i].Repo.OwnerName + "/" + ciTasks[i].Repo.Name + taskDetail.RepoAlias = ciTasks[i].Repo.OwnerName + "/" + ciTasks[i].Repo.Alias + } + if ciTasks[i].Cloudbrain.WorkServerNumber >= 1 { + taskDetail.WorkServerNum = int64(ciTasks[i].Cloudbrain.WorkServerNumber) + } else { + taskDetail.WorkServerNum = 1 + } + taskDetail.CardDuration = repo.GetCloudbrainCardDuration(ciTasks[i].Cloudbrain) + taskDetail.WaitTime = repo.GetCloudbrainWaitTime(ciTasks[i].Cloudbrain) - if ciTasks[i].Cloudbrain.DeletedAt != nilTime || ciTasks[i].Repo == nil { - taskDetail.IsDelete = true - } else { - taskDetail.IsDelete = false + if ciTasks[i].Cloudbrain.DeletedAt != nilTime || ciTasks[i].Repo == nil { + taskDetail.IsDelete = true + } else { + taskDetail.IsDelete = false + } + taskDetail.Spec = ciTasks[i].Spec + tasks = append(tasks, taskDetail) } - taskDetail.Spec = ciTasks[i].Spec - tasks = append(tasks, taskDetail) } - + count := int64(len(tasks)) pager := context.NewPagination(int(count), pageSize, page, getTotalPage(count, pageSize)) pager.SetDefaultParams(ctx) pager.AddParam(ctx, "listType", "ListType") diff --git a/routers/user/home.go b/routers/user/home.go index 1a20c26e2..345b9d296 100755 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -812,7 +812,7 @@ func Cloudbrains(ctx *context.Context) { for i, _ := range repos { repoIDList = append(repoIDList, repos[i].ID) } - ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{ + ciTasks, _, err := models.Cloudbrains(&models.CloudbrainsOptions{ ListOptions: models.ListOptions{ Page: page, PageSize: setting.UI.IssuePagingNum, @@ -828,7 +828,6 @@ func Cloudbrains(ctx *context.Context) { RepoIDList: repoIDList, ComputeResource: listType, Type: models.TypeCloudBrainAll, - AiCenter: aiCenter, Cluster: cluster, }) if err != nil { @@ -836,18 +835,22 @@ func Cloudbrains(ctx *context.Context) { return } models.LoadSpecs4CloudbrainInfo(ciTasks) - for i, task := range ciTasks { - ciTasks[i].CanDebug = true - ciTasks[i].CanDel = true - ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource + tasks := []*models.CloudbrainInfo{} + for _, task := range ciTasks { + if aiCenter == "" || aiCenter == task.Cloudbrain.Spec.AiCenterCode { + task.CanDebug = true + task.CanDel = true + task.Cloudbrain.ComputeResource = task.ComputeResource + tasks = append(tasks, task) + } } - + count := int64(len(tasks)) pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, getTotalPage(count, setting.UI.IssuePagingNum)) pager.SetDefaultParams(ctx) pager.AddParam(ctx, "listType", "ListType") ctx.Data["Page"] = pager ctx.Data["PageIsUserCloudBrain"] = true - ctx.Data["Tasks"] = ciTasks + ctx.Data["Tasks"] = tasks ctx.Data["CanCreate"] = true ctx.Data["Keyword"] = keyword From 6c775e03cf921cd72347b963e32c34f6a6b97cff Mon Sep 17 00:00:00 2001 From: chenshihai Date: Tue, 1 Nov 2022 14:11:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?#3124=20=E4=B8=AA=E4=BA=BA=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E5=92=8C=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0=E7=9A=84?= =?UTF-8?q?=E4=BA=91=E8=84=91=E4=BB=BB=E5=8A=A1=E5=88=97=E8=A1=A8=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=99=BA=E7=AE=97=E4=B8=AD=E5=BF=83=E4=B8=8D=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/admin/cloudbrain/search.tmpl | 56 +++++++++++++++---- .../admin/cloudbrain/search_dashboard.tmpl | 56 +++++++++++++++---- web_src/js/features/cloudrbanin.js | 4 +- 3 files changed, 90 insertions(+), 26 deletions(-) diff --git a/templates/admin/cloudbrain/search.tmpl b/templates/admin/cloudbrain/search.tmpl index 3562672a8..5d250db29 100644 --- a/templates/admin/cloudbrain/search.tmpl +++ b/templates/admin/cloudbrain/search.tmpl @@ -16,19 +16,11 @@ {{.i18n.Tr "cloudbrain.resource_cluster_c2net"}} - - \ No newline at end of file + + diff --git a/templates/admin/cloudbrain/search_dashboard.tmpl b/templates/admin/cloudbrain/search_dashboard.tmpl index c2d3d139e..d6ec1d5e4 100644 --- a/templates/admin/cloudbrain/search_dashboard.tmpl +++ b/templates/admin/cloudbrain/search_dashboard.tmpl @@ -28,19 +28,11 @@ {{.i18n.Tr "cloudbrain.resource_cluster_c2net"}} - - \ No newline at end of file + + \ No newline at end of file diff --git a/web_src/js/features/cloudrbanin.js b/web_src/js/features/cloudrbanin.js index c5fb6cdc4..b2c4869da 100644 --- a/web_src/js/features/cloudrbanin.js +++ b/web_src/js/features/cloudrbanin.js @@ -529,7 +529,7 @@ function userSearchControll() { : params.get("jobStatus").toUpperCase(); const dropdownValueArray = [cluster, aiCenter, jobType, listType, jobStatus]; $("#userCloud .default.text ").each(function (index, e) { - $(e).text(dropdownValueArray[index]); + index != 1 && $(e).text(dropdownValueArray[index]); }); } @@ -564,7 +564,7 @@ function AdaminSearchControll() { : params.get("jobStatus").toUpperCase(); const dropdownValueArray = [cluster, aiCenter, jobType, listType, jobStatus]; $("#adminCloud .default.text ").each(function (index, e) { - $(e).text(dropdownValueArray[index]); + index != 1 && $(e).text(dropdownValueArray[index]); }); } userSearchControll();