From df07e73d30264b9cbe7c4a231ceb704fcd4e8b17 Mon Sep 17 00:00:00 2001 From: liuzx Date: Mon, 8 Aug 2022 18:01:28 +0800 Subject: [PATCH 1/5] add aicenter --- models/cloudbrain.go | 12 ++++++++++++ routers/admin/cloudbrains.go | 2 ++ routers/api/v1/repo/cloudbrain_dashboard.go | 2 ++ routers/user/home.go | 2 ++ 4 files changed, 18 insertions(+) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index f9897b91d..db1a85981 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -372,6 +372,7 @@ type CloudbrainsOptions struct { ComputeResource string BeginTimeUnix int64 EndTimeUnix int64 + AiCenter string } type TaskPod struct { @@ -1403,6 +1404,11 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { ) } } + if (opts.AiCenter) != "" { + cond = cond.And( + builder.Like{"cloudbrain.ai_center", opts.AiCenter}, + ) + } if (opts.IsLatestVersion) != "" { cond = cond.And(builder.Or(builder.And(builder.Eq{"cloudbrain.is_latest_version": opts.IsLatestVersion}, builder.Eq{"cloudbrain.job_type": "TRAIN"}), builder.Neq{"cloudbrain.job_type": "TRAIN"})) @@ -1944,6 +1950,12 @@ func CloudbrainAll(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { } } + if (opts.AiCenter) != "" { + cond = cond.And( + builder.Like{"cloudbrain.ai_center", opts.AiCenter}, + ) + } + if (opts.IsLatestVersion) != "" { cond = cond.And(builder.Or(builder.And(builder.Eq{"cloudbrain.is_latest_version": opts.IsLatestVersion}, builder.Eq{"cloudbrain.job_type": "TRAIN"}), builder.Neq{"cloudbrain.job_type": "TRAIN"})) diff --git a/routers/admin/cloudbrains.go b/routers/admin/cloudbrains.go index 5876baf18..016ec7f8b 100755 --- a/routers/admin/cloudbrains.go +++ b/routers/admin/cloudbrains.go @@ -35,6 +35,7 @@ func CloudBrains(ctx *context.Context) { listType := ctx.Query("listType") jobType := ctx.Query("jobType") jobStatus := ctx.Query("jobStatus") + aiCenter := ctx.Query("aiCenter") ctx.Data["ListType"] = listType ctx.Data["JobType"] = jobType @@ -80,6 +81,7 @@ func CloudBrains(ctx *context.Context) { IsLatestVersion: modelarts.IsLatestVersion, ComputeResource: listType, Type: models.TypeCloudBrainAll, + AiCenter: aiCenter, }) if err != nil { ctx.ServerError("Get job failed:", err) diff --git a/routers/api/v1/repo/cloudbrain_dashboard.go b/routers/api/v1/repo/cloudbrain_dashboard.go index c632f3c8b..18dfe2621 100755 --- a/routers/api/v1/repo/cloudbrain_dashboard.go +++ b/routers/api/v1/repo/cloudbrain_dashboard.go @@ -679,6 +679,7 @@ func GetCloudbrainsDetailData(ctx *context.Context) { jobType := ctx.Query("jobType") jobStatus := ctx.Query("jobStatus") cloudBrainType := ctx.QueryInt("Type") + aiCenter := ctx.Query("aiCenter") page := ctx.QueryInt("page") pageSize := ctx.QueryInt("pagesize") @@ -724,6 +725,7 @@ func GetCloudbrainsDetailData(ctx *context.Context) { NeedRepoInfo: true, BeginTimeUnix: int64(recordBeginTime), EndTimeUnix: endTime.Unix(), + AiCenter: aiCenter, }) if err != nil { ctx.ServerError("Get job failed:", err) diff --git a/routers/user/home.go b/routers/user/home.go index 25b1c518e..40062b2de 100755 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -761,6 +761,7 @@ func Cloudbrains(ctx *context.Context) { listType := ctx.Query("listType") jobType := ctx.Query("jobType") jobStatus := ctx.Query("jobStatus") + aiCenter := ctx.Query("aiCenter") ctx.Data["ListType"] = listType ctx.Data["JobType"] = jobType @@ -825,6 +826,7 @@ func Cloudbrains(ctx *context.Context) { RepoIDList: repoIDList, ComputeResource: listType, Type: models.TypeCloudBrainAll, + AiCenter: aiCenter, }) if err != nil { ctx.ServerError("Get job failed:", err) From cb4b798981f8ddee8d388abaa4f5f2701348db97 Mon Sep 17 00:00:00 2001 From: liuzx Date: Tue, 9 Aug 2022 16:26:02 +0800 Subject: [PATCH 2/5] fix-2633 --- models/cloudbrain.go | 26 +++++++++++++++++++++ routers/admin/cloudbrains.go | 2 ++ routers/api/v1/repo/cloudbrain_dashboard.go | 2 ++ routers/user/home.go | 2 ++ 4 files changed, 32 insertions(+) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index db1a85981..33e550c0c 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -373,6 +373,8 @@ type CloudbrainsOptions struct { BeginTimeUnix int64 EndTimeUnix int64 AiCenter string + NeedDeleteInfo string + Cluster string } type TaskPod struct { @@ -1409,6 +1411,18 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { builder.Like{"cloudbrain.ai_center", opts.AiCenter}, ) } + if (opts.Cluster) != "" { + if opts.Cluster == "resource_cluster_openi" { + cond = cond.And( + builder.Or(builder.Eq{"cloudbrain.type": TypeCloudBrainOne}, builder.Eq{"cloudbrain.type": TypeCloudBrainTwo}), + ) + } + if opts.Cluster == "resource_cluster_c2net" { + cond = cond.And( + builder.Eq{"cloudbrain.type": TypeC2Net}, + ) + } + } if (opts.IsLatestVersion) != "" { cond = cond.And(builder.Or(builder.And(builder.Eq{"cloudbrain.is_latest_version": opts.IsLatestVersion}, builder.Eq{"cloudbrain.job_type": "TRAIN"}), builder.Neq{"cloudbrain.job_type": "TRAIN"})) @@ -1955,6 +1969,18 @@ func CloudbrainAll(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { builder.Like{"cloudbrain.ai_center", opts.AiCenter}, ) } + if (opts.NeedDeleteInfo) != "" { + if opts.NeedDeleteInfo == "yes" { + cond = cond.And( + builder.And(builder.NotNull{"cloudbrain.deleted_at"}), + ) + } + if opts.NeedDeleteInfo == "no" { + cond = cond.And( + builder.And(builder.IsNull{"cloudbrain.deleted_at"}), + ) + } + } if (opts.IsLatestVersion) != "" { cond = cond.And(builder.Or(builder.And(builder.Eq{"cloudbrain.is_latest_version": opts.IsLatestVersion}, diff --git a/routers/admin/cloudbrains.go b/routers/admin/cloudbrains.go index 016ec7f8b..4d8bdd576 100755 --- a/routers/admin/cloudbrains.go +++ b/routers/admin/cloudbrains.go @@ -36,6 +36,7 @@ func CloudBrains(ctx *context.Context) { jobType := ctx.Query("jobType") jobStatus := ctx.Query("jobStatus") aiCenter := ctx.Query("aiCenter") + cluster := ctx.Query("cluster") ctx.Data["ListType"] = listType ctx.Data["JobType"] = jobType @@ -82,6 +83,7 @@ func CloudBrains(ctx *context.Context) { ComputeResource: listType, Type: models.TypeCloudBrainAll, AiCenter: aiCenter, + Cluster: cluster, }) if err != nil { ctx.ServerError("Get job failed:", err) diff --git a/routers/api/v1/repo/cloudbrain_dashboard.go b/routers/api/v1/repo/cloudbrain_dashboard.go index 18dfe2621..52ee3ed2c 100755 --- a/routers/api/v1/repo/cloudbrain_dashboard.go +++ b/routers/api/v1/repo/cloudbrain_dashboard.go @@ -680,6 +680,7 @@ func GetCloudbrainsDetailData(ctx *context.Context) { jobStatus := ctx.Query("jobStatus") cloudBrainType := ctx.QueryInt("Type") aiCenter := ctx.Query("aiCenter") + needDeleteInfo := ctx.Query("needDeleteInfo") page := ctx.QueryInt("page") pageSize := ctx.QueryInt("pagesize") @@ -726,6 +727,7 @@ func GetCloudbrainsDetailData(ctx *context.Context) { BeginTimeUnix: int64(recordBeginTime), EndTimeUnix: endTime.Unix(), AiCenter: aiCenter, + NeedDeleteInfo: needDeleteInfo, }) if err != nil { ctx.ServerError("Get job failed:", err) diff --git a/routers/user/home.go b/routers/user/home.go index 40062b2de..100fbf665 100755 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -762,6 +762,7 @@ func Cloudbrains(ctx *context.Context) { jobType := ctx.Query("jobType") jobStatus := ctx.Query("jobStatus") aiCenter := ctx.Query("aiCenter") + cluster := ctx.Query("cluster") ctx.Data["ListType"] = listType ctx.Data["JobType"] = jobType @@ -827,6 +828,7 @@ func Cloudbrains(ctx *context.Context) { ComputeResource: listType, Type: models.TypeCloudBrainAll, AiCenter: aiCenter, + Cluster: cluster, }) if err != nil { ctx.ServerError("Get job failed:", err) From 5dd98ce8170cc0edc08ebaed642ed2f911724b7b Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 9 Aug 2022 18:02:24 +0800 Subject: [PATCH 3/5] fix issue --- templates/admin/cloudbrain/list.tmpl | 4 ++ templates/admin/cloudbrain/search.tmpl | 68 +++++++++++++------ .../admin/cloudbrain/search_dashboard.tmpl | 68 +++++++++++++------ templates/user/dashboard/cloudbrains.tmpl | 4 ++ web_src/js/features/cloudrbanin.js | 34 +++++++++- 5 files changed, 132 insertions(+), 46 deletions(-) diff --git a/templates/admin/cloudbrain/list.tmpl b/templates/admin/cloudbrain/list.tmpl index cd5913c40..85f6acb0c 100755 --- a/templates/admin/cloudbrain/list.tmpl +++ b/templates/admin/cloudbrain/list.tmpl @@ -14,6 +14,10 @@
diff --git a/templates/admin/cloudbrain/search.tmpl b/templates/admin/cloudbrain/search.tmpl index ddd616eb4..bbfeb811c 100644 --- a/templates/admin/cloudbrain/search.tmpl +++ b/templates/admin/cloudbrain/search.tmpl @@ -7,44 +7,68 @@
+ + diff --git a/templates/admin/cloudbrain/search_dashboard.tmpl b/templates/admin/cloudbrain/search_dashboard.tmpl index e4d74836d..83c9c5ec6 100644 --- a/templates/admin/cloudbrain/search_dashboard.tmpl +++ b/templates/admin/cloudbrain/search_dashboard.tmpl @@ -19,44 +19,68 @@
+ + diff --git a/templates/user/dashboard/cloudbrains.tmpl b/templates/user/dashboard/cloudbrains.tmpl index 8019bc51d..f5aee09a2 100755 --- a/templates/user/dashboard/cloudbrains.tmpl +++ b/templates/user/dashboard/cloudbrains.tmpl @@ -16,6 +16,10 @@ data-debug-again="{{$.i18n.Tr "repo.debug_again"}}" data-debug-task="{{$.i18n.Tr "cloudbrain.DEBUG"}}" data-train-task="{{$.i18n.Tr "cloudbrain.TRAIN"}}" data-inference-task="{{$.i18n.Tr "cloudbrain.INFERENCE"}}" data-benchmark-task="{{$.i18n.Tr "cloudbrain.BENCHMARK"}}" + data-all-cluster="全部集群" + data-all-aiCenter="全部智算中心" + data-cluster-c2net="{{.i18n.Tr "cloudbrain.resource_cluster_c2net"}}" + data-cluster-openi="{{.i18n.Tr "cloudbrain.resource_cluster_openi"}}" data-all-task="{{.i18n.Tr "admin.cloudbrain.all_task_types"}}" data-all-compute="{{.i18n.Tr "admin.cloudbrain.all_computing_resources"}}" data-all-status="{{.i18n.Tr "admin.cloudbrain.all_status"}}">
diff --git a/web_src/js/features/cloudrbanin.js b/web_src/js/features/cloudrbanin.js index 172e6b0bd..f19701e8a 100644 --- a/web_src/js/features/cloudrbanin.js +++ b/web_src/js/features/cloudrbanin.js @@ -526,6 +526,18 @@ function userSearchControll() { return; } const params = new URLSearchParams(window.location.search); + let cluster; + if ($(".cloudbrain_debug").length === 1) { + if (!params.get("cluster")) { + cluster = $(".cloudbrain_debug").data("all-cluster"); + } else { + if (params.get("cluster") === "resource_cluster_c2net") { + cluster = $(".cloudbrain_debug").data("cluster-c2net"); + } else { + cluster = $(".cloudbrain_debug").data("cluster-openi"); + } + } + } let jobType; if ($(".cloudbrain_debug").length === 1) { if (!params.get("jobType")) { @@ -542,13 +554,16 @@ function userSearchControll() { } } } + let aiCenter = !params.get("aiCenter") + ? $(".cloudbrain_debug").data("all-aiCenter") + : params.get("aiCenter"); let listType = !params.get("listType") ? $(".cloudbrain_debug").data("all-compute") : params.get("listType"); let jobStatus = !params.get("jobStatus") ? $(".cloudbrain_debug").data("all-status") : params.get("jobStatus").toUpperCase(); - const dropdownValueArray = [jobType, listType, jobStatus]; + const dropdownValueArray = [cluster, aiCenter, jobType, listType, jobStatus]; $("#userCloud .default.text ").each(function (index, e) { $(e).text(dropdownValueArray[index]); }); @@ -559,6 +574,21 @@ function AdaminSearchControll() { return; } const params = new URLSearchParams(window.location.search); + let cluster; + if ($(".cloudbrain_debug").length === 1) { + if (!params.get("cluster")) { + cluster = $(".cloudbrain_debug").data("all-cluster"); + } else { + if (params.get("cluster") === "resource_cluster_c2net") { + cluster = $(".cloudbrain_debug").data("cluster-c2net"); + } else { + cluster = $(".cloudbrain_debug").data("cluster-openi"); + } + } + } + let aiCenter = !params.get("aiCenter") + ? $(".cloudbrain_debug").data("all-aiCenter") + : params.get("aiCenter"); let jobType = !params.get("jobType") ? $(".cloudbrain_debug").data("all-task") : params.get("jobType"); @@ -568,7 +598,7 @@ function AdaminSearchControll() { let jobStatus = !params.get("jobStatus") ? $(".cloudbrain_debug").data("all-status") : params.get("jobStatus").toUpperCase(); - const dropdownValueArray = [jobType, listType, jobStatus]; + const dropdownValueArray = [cluster, aiCenter, jobType, listType, jobStatus]; $("#adminCloud .default.text ").each(function (index, e) { $(e).text(dropdownValueArray[index]); }); From 6ecaf187a28c95538987939ae8578e7f8026732e Mon Sep 17 00:00:00 2001 From: liuzx Date: Tue, 9 Aug 2022 18:15:27 +0800 Subject: [PATCH 4/5] fix-2633 --- routers/admin/cloudbrains.go | 2 ++ routers/user/home.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/routers/admin/cloudbrains.go b/routers/admin/cloudbrains.go index 4d8bdd576..ec0034f4f 100755 --- a/routers/admin/cloudbrains.go +++ b/routers/admin/cloudbrains.go @@ -41,6 +41,8 @@ func CloudBrains(ctx *context.Context) { ctx.Data["ListType"] = listType ctx.Data["JobType"] = jobType ctx.Data["JobStatus"] = jobStatus + ctx.Data["aiCenter"] = aiCenter + ctx.Data["cluster"] = cluster page := ctx.QueryInt("page") if page <= 0 { diff --git a/routers/user/home.go b/routers/user/home.go index 100fbf665..d8c2565c6 100755 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -767,6 +767,8 @@ func Cloudbrains(ctx *context.Context) { ctx.Data["ListType"] = listType ctx.Data["JobType"] = jobType ctx.Data["JobStatus"] = jobStatus + ctx.Data["aiCenter"] = aiCenter + ctx.Data["cluster"] = cluster page := ctx.QueryInt("page") if page <= 0 { From b448624309647cec42e43bee53574146c8338150 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 10 Aug 2022 09:13:32 +0800 Subject: [PATCH 5/5] fix issue --- options/locale/locale_en-US.ini | 2 + options/locale/locale_zh-CN.ini | 2 + templates/admin/cloudbrain/list.tmpl | 4 +- templates/admin/cloudbrain/search.tmpl | 72 +++++++++---------- .../admin/cloudbrain/search_dashboard.tmpl | 72 +++++++++---------- templates/user/dashboard/cloudbrains.tmpl | 4 +- 6 files changed, 80 insertions(+), 76 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 0d35cc326..8732ea889 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -3086,6 +3086,8 @@ Platform_Tutorial = Tutorial foot.advice_feedback = Feedback [cloudbrain] +all_resource_cluster=All Cluster +all_ai_center=All Computing NET resource_cluster = Resource Cluster resource_cluster_openi = OpenI Resource Cluster resource_cluster_c2net = China Computing NET diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index d34a18cc1..032cb04d1 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -3100,6 +3100,8 @@ Platform_Tutorial=新手指引 foot.advice_feedback = 意见反馈 [cloudbrain] +all_resource_cluster=全部集群 +all_ai_center=全部智算中心 resource_cluster = 算力集群 resource_cluster_openi = 启智集群 resource_cluster_c2net = 智算网络集群 diff --git a/templates/admin/cloudbrain/list.tmpl b/templates/admin/cloudbrain/list.tmpl index 85f6acb0c..0340fa725 100755 --- a/templates/admin/cloudbrain/list.tmpl +++ b/templates/admin/cloudbrain/list.tmpl @@ -14,8 +14,8 @@