Browse Source

Merge pull request 'fix-3137' (#3142) from bug-3137 into V20221102

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/3142
Reviewed-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.11.1^2
zouap 3 years ago
parent
commit
f371b447e4
4 changed files with 76 additions and 67 deletions
  1. +13
    -11
      routers/admin/cloudbrains.go
  2. +12
    -11
      routers/user/home.go
  3. +25
    -22
      templates/admin/cloudbrain/search.tmpl
  4. +26
    -23
      templates/admin/cloudbrain/search_dashboard.tmpl

+ 13
- 11
routers/admin/cloudbrains.go View File

@@ -70,7 +70,7 @@ func CloudBrains(ctx *context.Context) {

keyword := strings.Trim(ctx.Query("q"), " ")

ciTasks, _, err := models.Cloudbrains(&models.CloudbrainsOptions{
ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{
ListOptions: models.ListOptions{
Page: page,
PageSize: setting.UI.IssuePagingNum,
@@ -84,6 +84,7 @@ func CloudBrains(ctx *context.Context) {
IsLatestVersion: modelarts.IsLatestVersion,
ComputeResource: listType,
Type: models.TypeCloudBrainAll,
AiCenter: aiCenter,
Cluster: cluster,
})
if err != nil {
@@ -92,24 +93,25 @@ func CloudBrains(ctx *context.Context) {
}

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.SetDefaultParams(ctx)
pager.AddParam(ctx, "listType", "ListType")
ctx.Data["Page"] = pager
ctx.Data["PageIsCloudBrain"] = true
ctx.Data["Tasks"] = tasks
ctx.Data["Tasks"] = ciTasks
ctx.Data["CanCreate"] = true
ctx.Data["Keyword"] = keyword



+ 12
- 11
routers/user/home.go View File

@@ -812,7 +812,7 @@ func Cloudbrains(ctx *context.Context) {
for i, _ := range repos {
repoIDList = append(repoIDList, repos[i].ID)
}
ciTasks, _, err := models.Cloudbrains(&models.CloudbrainsOptions{
ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{
ListOptions: models.ListOptions{
Page: page,
PageSize: setting.UI.IssuePagingNum,
@@ -828,29 +828,30 @@ func Cloudbrains(ctx *context.Context) {
RepoIDList: repoIDList,
ComputeResource: listType,
Type: models.TypeCloudBrainAll,
AiCenter: aiCenter,
Cluster: cluster,
})
if err != nil {
ctx.ServerError("Get job failed:", err)
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.SetDefaultParams(ctx)
pager.AddParam(ctx, "listType", "ListType")
ctx.Data["Page"] = pager
ctx.Data["PageIsUserCloudBrain"] = true
ctx.Data["Tasks"] = tasks
ctx.Data["Tasks"] = ciTasks
ctx.Data["CanCreate"] = true
ctx.Data["Keyword"] = keyword



+ 25
- 22
templates/admin/cloudbrain/search.tmpl View File

@@ -71,33 +71,36 @@
document.addEventListener('DOMContentLoaded', function() {
$.ajax({
type: "GET",
url: "/admin/resources/queue/centers",
url: "/api/v1/cloudbrain/get_center_info",
dataType: "json",
data: {},
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) {
console.log(err);


+ 26
- 23
templates/admin/cloudbrain/search_dashboard.tmpl View File

@@ -85,33 +85,36 @@
document.addEventListener('DOMContentLoaded', function() {
$.ajax({
type: "GET",
url: "/admin/resources/queue/centers",
url: "/api/v1/cloudbrain/get_center_info",
dataType: "json",
data: {},
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) {
console.log(err);
@@ -119,4 +122,4 @@
});
});
})();
</script>
</script>

Loading…
Cancel
Save