Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/3142 Reviewed-by: zouap <zouap@pcl.ac.cn>tags/v1.22.11.1^2
| @@ -70,7 +70,7 @@ func CloudBrains(ctx *context.Context) { | |||||
| keyword := strings.Trim(ctx.Query("q"), " ") | keyword := strings.Trim(ctx.Query("q"), " ") | ||||
| ciTasks, _, err := models.Cloudbrains(&models.CloudbrainsOptions{ | |||||
| ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{ | |||||
| ListOptions: models.ListOptions{ | ListOptions: models.ListOptions{ | ||||
| Page: page, | Page: page, | ||||
| PageSize: setting.UI.IssuePagingNum, | PageSize: setting.UI.IssuePagingNum, | ||||
| @@ -84,6 +84,7 @@ func CloudBrains(ctx *context.Context) { | |||||
| IsLatestVersion: modelarts.IsLatestVersion, | IsLatestVersion: modelarts.IsLatestVersion, | ||||
| ComputeResource: listType, | ComputeResource: listType, | ||||
| Type: models.TypeCloudBrainAll, | Type: models.TypeCloudBrainAll, | ||||
| AiCenter: aiCenter, | |||||
| Cluster: cluster, | Cluster: cluster, | ||||
| }) | }) | ||||
| if err != nil { | if err != nil { | ||||
| @@ -92,24 +93,25 @@ func CloudBrains(ctx *context.Context) { | |||||
| } | } | ||||
| models.LoadSpecs4CloudbrainInfo(ciTasks) | models.LoadSpecs4CloudbrainInfo(ciTasks) | ||||
| 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) | |||||
| for i, task := range ciTasks { | |||||
| ciTasks[i].CanDebug = true | |||||
| ciTasks[i].CanDel = true | |||||
| ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource | |||||
| if ciTasks[i].Cloudbrain.Type == models.TypeC2Net { | |||||
| ciTasks[i].Cloudbrain.Spec.Cluster = models.C2NetCluster | |||||
| } else { | |||||
| ciTasks[i].Cloudbrain.Spec.Cluster = models.OpenICluster | |||||
| } | } | ||||
| } | } | ||||
| count := int64(len(tasks)) | |||||
| pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, getTotalPage(count, setting.UI.IssuePagingNum)) | pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, getTotalPage(count, setting.UI.IssuePagingNum)) | ||||
| pager.SetDefaultParams(ctx) | pager.SetDefaultParams(ctx) | ||||
| pager.AddParam(ctx, "listType", "ListType") | pager.AddParam(ctx, "listType", "ListType") | ||||
| ctx.Data["Page"] = pager | ctx.Data["Page"] = pager | ||||
| ctx.Data["PageIsCloudBrain"] = true | ctx.Data["PageIsCloudBrain"] = true | ||||
| ctx.Data["Tasks"] = tasks | |||||
| ctx.Data["Tasks"] = ciTasks | |||||
| ctx.Data["CanCreate"] = true | ctx.Data["CanCreate"] = true | ||||
| ctx.Data["Keyword"] = keyword | ctx.Data["Keyword"] = keyword | ||||
| @@ -812,7 +812,7 @@ func Cloudbrains(ctx *context.Context) { | |||||
| for i, _ := range repos { | for i, _ := range repos { | ||||
| repoIDList = append(repoIDList, repos[i].ID) | repoIDList = append(repoIDList, repos[i].ID) | ||||
| } | } | ||||
| ciTasks, _, err := models.Cloudbrains(&models.CloudbrainsOptions{ | |||||
| ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{ | |||||
| ListOptions: models.ListOptions{ | ListOptions: models.ListOptions{ | ||||
| Page: page, | Page: page, | ||||
| PageSize: setting.UI.IssuePagingNum, | PageSize: setting.UI.IssuePagingNum, | ||||
| @@ -828,29 +828,30 @@ func Cloudbrains(ctx *context.Context) { | |||||
| RepoIDList: repoIDList, | RepoIDList: repoIDList, | ||||
| ComputeResource: listType, | ComputeResource: listType, | ||||
| Type: models.TypeCloudBrainAll, | Type: models.TypeCloudBrainAll, | ||||
| AiCenter: aiCenter, | |||||
| Cluster: cluster, | Cluster: cluster, | ||||
| }) | }) | ||||
| if err != nil { | if err != nil { | ||||
| ctx.ServerError("Get job failed:", err) | ctx.ServerError("Get job failed:", err) | ||||
| return | return | ||||
| } | } | ||||
| models.LoadSpecs4CloudbrainInfo(ciTasks) | |||||
| 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) | |||||
| for i, _ := range ciTasks { | |||||
| ciTasks[i].CanDebug = true | |||||
| ciTasks[i].CanDel = true | |||||
| ciTasks[i].Cloudbrain.ComputeResource = ciTasks[i].ComputeResource | |||||
| if ciTasks[i].Cloudbrain.Type == models.TypeC2Net { | |||||
| ciTasks[i].Cloudbrain.Spec.Cluster = models.C2NetCluster | |||||
| } else { | |||||
| ciTasks[i].Cloudbrain.Spec.Cluster = models.OpenICluster | |||||
| } | } | ||||
| } | } | ||||
| count := int64(len(tasks)) | |||||
| pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, getTotalPage(count, setting.UI.IssuePagingNum)) | pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, getTotalPage(count, setting.UI.IssuePagingNum)) | ||||
| pager.SetDefaultParams(ctx) | pager.SetDefaultParams(ctx) | ||||
| pager.AddParam(ctx, "listType", "ListType") | pager.AddParam(ctx, "listType", "ListType") | ||||
| ctx.Data["Page"] = pager | ctx.Data["Page"] = pager | ||||
| ctx.Data["PageIsUserCloudBrain"] = true | ctx.Data["PageIsUserCloudBrain"] = true | ||||
| ctx.Data["Tasks"] = tasks | |||||
| ctx.Data["Tasks"] = ciTasks | |||||
| ctx.Data["CanCreate"] = true | ctx.Data["CanCreate"] = true | ||||
| ctx.Data["Keyword"] = keyword | ctx.Data["Keyword"] = keyword | ||||
| @@ -71,33 +71,36 @@ | |||||
| document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||||
| $.ajax({ | $.ajax({ | ||||
| type: "GET", | type: "GET", | ||||
| url: "/admin/resources/queue/centers", | |||||
| url: "/api/v1/cloudbrain/get_center_info", | |||||
| dataType: "json", | dataType: "json", | ||||
| data: {}, | data: {}, | ||||
| success: function (res) { | success: function (res) { | ||||
| if (res && res.Code === 0) { | |||||
| var data = res.Data; | |||||
| var aiCenterSelEl = $('#aiCenter-sel'); | |||||
| var itemEl = aiCenterSelEl.find('.menu .item').eq(0); | |||||
| var selectAiCenterCode = aiCenterSelEl.find('.default').attr('aicenter'); | |||||
| var selectAiCenterName = ''; | |||||
| for (var i = 0, iLen = data.length; i < iLen; i++) { | |||||
| var dataI = data[i]; | |||||
| var itemClone = itemEl.clone(); | |||||
| var oHref = itemClone.attr('href'); | |||||
| var oId = itemClone.attr('id'); | |||||
| itemClone.attr('data-value', dataI.AiCenterCode); | |||||
| itemClone.removeAttr('id'); | |||||
| itemClone.attr('href', oHref + dataI.AiCenterCode); | |||||
| itemClone.text(dataI.AiCenterName); | |||||
| aiCenterSelEl.find('.menu').append(itemClone); | |||||
| if (selectAiCenterCode === dataI.AiCenterCode) { | |||||
| selectAiCenterName = dataI.AiCenterName; | |||||
| } | |||||
| var data = res || []; | |||||
| var aiCenterSelEl = $('#aiCenter-sel'); | |||||
| var itemEl = aiCenterSelEl.find('.menu .item').eq(0); | |||||
| var selectAiCenterCode = aiCenterSelEl.find('.default').attr('aicenter'); | |||||
| var selectAiCenterName = ''; | |||||
| var lang = document.querySelector('html').getAttribute('lang') || 'en-US'; | |||||
| var except = ['', 'more']; | |||||
| for (var i = 0, iLen = data.length; i < iLen; i++) { | |||||
| var dataI = data[i]; | |||||
| var aiCenterCode = dataI.name; | |||||
| if (except.indexOf(aiCenterCode) >= 0) continue; | |||||
| var aiCenterName = lang === 'en-US' ? dataI.content_en : dataI.content; | |||||
| var itemClone = itemEl.clone(); | |||||
| var oHref = itemClone.attr('href'); | |||||
| var oId = itemClone.attr('id'); | |||||
| itemClone.attr('data-value', aiCenterCode); | |||||
| itemClone.removeAttr('id'); | |||||
| itemClone.attr('href', oHref + aiCenterCode); | |||||
| itemClone.text(aiCenterName); | |||||
| aiCenterSelEl.find('.menu').append(itemClone); | |||||
| if (selectAiCenterCode === aiCenterCode) { | |||||
| selectAiCenterName = aiCenterName; | |||||
| } | } | ||||
| selectAiCenterCode && aiCenterSelEl.dropdown('set selected', selectAiCenterCode); | |||||
| selectAiCenterName && aiCenterSelEl.dropdown('set text', selectAiCenterName); | |||||
| } | } | ||||
| selectAiCenterCode && aiCenterSelEl.dropdown('set selected', selectAiCenterCode); | |||||
| selectAiCenterName && aiCenterSelEl.dropdown('set text', selectAiCenterName); | |||||
| }, | }, | ||||
| error: function (err) { | error: function (err) { | ||||
| console.log(err); | console.log(err); | ||||
| @@ -85,33 +85,36 @@ | |||||
| document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||||
| $.ajax({ | $.ajax({ | ||||
| type: "GET", | type: "GET", | ||||
| url: "/admin/resources/queue/centers", | |||||
| url: "/api/v1/cloudbrain/get_center_info", | |||||
| dataType: "json", | dataType: "json", | ||||
| data: {}, | data: {}, | ||||
| success: function (res) { | success: function (res) { | ||||
| if (res && res.Code === 0) { | |||||
| var data = res.Data; | |||||
| var aiCenterSelEl = $('#aiCenter-sel'); | |||||
| var itemEl = aiCenterSelEl.find('.menu .item').eq(0); | |||||
| var selectAiCenterCode = aiCenterSelEl.find('.default').attr('aicenter'); | |||||
| var selectAiCenterName = ''; | |||||
| for (var i = 0, iLen = data.length; i < iLen; i++) { | |||||
| var dataI = data[i]; | |||||
| var itemClone = itemEl.clone(); | |||||
| var oHref = itemClone.attr('href'); | |||||
| var oId = itemClone.attr('id'); | |||||
| itemClone.attr('data-value', dataI.AiCenterCode); | |||||
| itemClone.removeAttr('id'); | |||||
| itemClone.attr('href', oHref + dataI.AiCenterCode); | |||||
| itemClone.text(dataI.AiCenterName); | |||||
| aiCenterSelEl.find('.menu').append(itemClone); | |||||
| if (selectAiCenterCode === dataI.AiCenterCode) { | |||||
| selectAiCenterName = dataI.AiCenterName; | |||||
| } | |||||
| var data = res || []; | |||||
| var aiCenterSelEl = $('#aiCenter-sel'); | |||||
| var itemEl = aiCenterSelEl.find('.menu .item').eq(0); | |||||
| var selectAiCenterCode = aiCenterSelEl.find('.default').attr('aicenter'); | |||||
| var selectAiCenterName = ''; | |||||
| var lang = document.querySelector('html').getAttribute('lang') || 'en-US'; | |||||
| var except = ['', 'more']; | |||||
| for (var i = 0, iLen = data.length; i < iLen; i++) { | |||||
| var dataI = data[i]; | |||||
| var aiCenterCode = dataI.name; | |||||
| if (except.indexOf(aiCenterCode) >= 0) continue; | |||||
| var aiCenterName = lang === 'en-US' ? dataI.content_en : dataI.content; | |||||
| var itemClone = itemEl.clone(); | |||||
| var oHref = itemClone.attr('href'); | |||||
| var oId = itemClone.attr('id'); | |||||
| itemClone.attr('data-value', aiCenterCode); | |||||
| itemClone.removeAttr('id'); | |||||
| itemClone.attr('href', oHref + aiCenterCode); | |||||
| itemClone.text(aiCenterName); | |||||
| aiCenterSelEl.find('.menu').append(itemClone); | |||||
| if (selectAiCenterCode === aiCenterCode) { | |||||
| selectAiCenterName = aiCenterName; | |||||
| } | } | ||||
| selectAiCenterCode && aiCenterSelEl.dropdown('set selected', selectAiCenterCode); | |||||
| selectAiCenterName && aiCenterSelEl.dropdown('set text', selectAiCenterName); | |||||
| } | } | ||||
| selectAiCenterCode && aiCenterSelEl.dropdown('set selected', selectAiCenterCode); | |||||
| selectAiCenterName && aiCenterSelEl.dropdown('set text', selectAiCenterName); | |||||
| }, | }, | ||||
| error: function (err) { | error: function (err) { | ||||
| console.log(err); | console.log(err); | ||||
| @@ -119,4 +122,4 @@ | |||||
| }); | }); | ||||
| }); | }); | ||||
| })(); | })(); | ||||
| </script> | |||||
| </script> | |||||