Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/2322 Reviewed-by: lewis <747342561@qq.com>pull/2328/head
@@ -6,7 +6,6 @@ | |||
package models | |||
import ( | |||
"code.gitea.io/gitea/modules/blockchain" | |||
"container/list" | |||
"context" | |||
"crypto/md5" | |||
@@ -25,6 +24,8 @@ import ( | |||
"time" | |||
"unicode/utf8" | |||
"code.gitea.io/gitea/modules/blockchain" | |||
"code.gitea.io/gitea/modules/avatar" | |||
"code.gitea.io/gitea/modules/base" | |||
"code.gitea.io/gitea/modules/generate" | |||
@@ -1498,6 +1499,17 @@ func GetUsersByIDs(ids []int64) (UserList, error) { | |||
return ous, err | |||
} | |||
func GetUsersByNames(names []string) (UserList, error) { | |||
ous := make([]*User, 0, len(names)) | |||
if len(names) == 0 { | |||
return ous, nil | |||
} | |||
err := x.In("name", names). | |||
Asc("name"). | |||
Find(&ous) | |||
return ous, err | |||
} | |||
// GetUserIDsByNames returns a slice of ids corresponds to names. | |||
func GetUserIDsByNames(names []string, ignoreNonExistent bool) ([]int64, error) { | |||
ids := make([]int64, 0, len(names)) | |||
@@ -217,9 +217,9 @@ function refresh3DInfo(record){ | |||
//console.log("cloudbrain two line length=" + lines.length); | |||
var span = $('.rotation3D__line').find("span")[1]; | |||
//console.log(span); | |||
span.innerText =record.RefName; | |||
//$('.rotation3D__line').find("span").eq(1).text(record.RefName) | |||
//lines[1].find("span").text(record.RefName); | |||
if(span != null){ | |||
span.innerText =record.RefName; | |||
} | |||
} | |||
} | |||
@@ -452,48 +452,12 @@ function queryRecommendData(){ | |||
displayOrg(json.org); | |||
displayRepo(json.repo); | |||
displayActivity(json.image); | |||
displayCloudBrain(json.cloudbrain) | |||
}, | |||
error:function(response) { | |||
} | |||
}); | |||
// $.ajax({ | |||
// type:"GET", | |||
// url:"/recommend/repo", | |||
// headers: { | |||
// authorization:token, | |||
// }, | |||
// dataType:"json", | |||
// async:false, | |||
// success:function(json){ | |||
// displayRepo(json); | |||
// }, | |||
// error:function(response) { | |||
// } | |||
// }); | |||
// $.ajax({ | |||
// type:"GET", | |||
// url:"/recommend/imageinfo", | |||
// headers: { | |||
// authorization:token, | |||
// }, | |||
// dataType:"json", | |||
// async:false, | |||
// success:function(json){ | |||
// displayActivity(json); | |||
// }, | |||
// error:function(response) { | |||
// } | |||
// }); | |||
} | |||
function displayCloudBrain(json){ | |||
$('#completed_task').text(json.completed_task); | |||
$('#running_task').text(json.running_task); | |||
$('#wait_task').text(json.wait_task); | |||
} | |||
function displayActivity(json){ | |||
var activityDiv = document.getElementById("recommendactivity"); | |||
@@ -7,7 +7,6 @@ package routers | |||
import ( | |||
"bytes" | |||
"fmt" | |||
"net/http" | |||
"strconv" | |||
"strings" | |||
@@ -673,10 +672,19 @@ func getRecommendOrg() ([]map[string]interface{}, error) { | |||
if err != nil { | |||
return nil, err | |||
} | |||
names := make([]string, 0) | |||
for _, userName := range result { | |||
names = append(names, userName) | |||
} | |||
users, _ := models.GetUsersByNames(names) | |||
userMap := make(map[string]*models.User, 0) | |||
for _, user := range users { | |||
userMap[user.Name] = user | |||
} | |||
resultOrg := make([]map[string]interface{}, 0) | |||
for _, userName := range result { | |||
user, err := models.GetUserByName(userName) | |||
if err == nil { | |||
user := userMap[userName] | |||
if user != nil { | |||
userMap := make(map[string]interface{}) | |||
userMap["Name"] = user.Name | |||
userMap["Description"] = user.Description | |||
@@ -689,7 +697,7 @@ func getRecommendOrg() ([]map[string]interface{}, error) { | |||
userMap["NumMembers"] = user.NumMembers | |||
resultOrg = append(resultOrg, userMap) | |||
} else { | |||
log.Info("query user error," + err.Error()) | |||
log.Info("the user not exist," + userName) | |||
} | |||
} | |||
return resultOrg, nil | |||
@@ -758,15 +766,6 @@ func GetRankUser(index string) ([]map[string]interface{}, error) { | |||
return resultOrg, nil | |||
} | |||
// func GetImageInfoFromPromote(ctx *context.Context) { | |||
// imageInfo, err := GetImageInfo() | |||
// if err != nil { | |||
// ctx.ServerError("500", err) | |||
// return | |||
// } | |||
// ctx.JSON(200, imageInfo) | |||
// } | |||
func GetUserRankFromPromote(ctx *context.Context) { | |||
index := ctx.Params("index") | |||
resultUserRank, err := GetRankUser(index) | |||
@@ -790,45 +789,15 @@ func RecommendHomeInfo(ctx *context.Context) { | |||
if err != nil { | |||
log.Info("error." + err.Error()) | |||
} | |||
resultCloudBrain, err := getCloudbrainNums() | |||
if err != nil { | |||
log.Info("error." + err.Error()) | |||
} | |||
mapInterface := make(map[string]interface{}) | |||
mapInterface["org"] = resultOrg | |||
mapInterface["repo"] = resultRepo | |||
mapInterface["image"] = resultImage | |||
mapInterface["cloudbrain"] = resultCloudBrain | |||
//mapInterface["cloudbrain"] = resultCloudBrain | |||
ctx.JSON(http.StatusOK, mapInterface) | |||
} | |||
func getCloudbrainNums() (map[string]string, error) { | |||
result := make(map[string]string) | |||
cloudStatusMap := models.GetAllStatusCloudBrain() | |||
result["completed_task"] = fmt.Sprint(cloudStatusMap["COMPLETED"]) | |||
result["running_task"] = fmt.Sprint(cloudStatusMap["RUNNING"]) | |||
result["wait_task"] = fmt.Sprint(cloudStatusMap["WAITING"]) | |||
return result, nil | |||
} | |||
// func RecommendOrgFromPromote(ctx *context.Context) { | |||
// resultOrg, err := GetRecommendOrg() | |||
// if err != nil { | |||
// ctx.ServerError("500", err) | |||
// return | |||
// } | |||
// ctx.JSON(200, resultOrg) | |||
// } | |||
func RecommendRepoFromPromote(ctx *context.Context) { | |||
result, err := repository.GetRecommendRepoFromPromote("projects") | |||
if err != nil { | |||
ctx.ServerError("500", err) | |||
} else { | |||
ctx.JSON(200, result) | |||
} | |||
} | |||
func HomeTerm(ctx *context.Context) { | |||
ctx.HTML(200, tplHomeTerm) | |||
} |
@@ -131,11 +131,6 @@ func GetRecommendRepoFromPromote(filename string) ([]map[string]interface{}, err | |||
repoMap["ID"] = fmt.Sprint(repo.ID) | |||
repoMap["Name"] = repo.Name | |||
repoMap["Alias"] = repo.Alias | |||
if repo.RepoType == models.RepoCourse { | |||
//Load creator | |||
repo.GetCreator() | |||
repoMap["Creator"] = repo.Creator | |||
} | |||
repoMap["OwnerName"] = repo.OwnerName | |||
repoMap["NumStars"] = repo.NumStars | |||
@@ -597,8 +597,12 @@ | |||
</div> | |||
<div class="required inline field" id="verionname"> | |||
<label>模型版本</label> | |||
<input style="width: 45%;" id="version" name="Version" value="" readonly required | |||
maxlength="255"> | |||
<input style="width: 45%;" id="version" name="Version" value="" readonly required maxlength="255"> | |||
</div> | |||
<div class="unite min_title inline field required"> | |||
<label>模型框架</label> | |||
<input type="hidden" id="Engine" name="Engine" required> | |||
<input style="width: 45%;" id="Engine_name" name="Engine_name" readonly required maxlength="255"> | |||
</div> | |||
<div class="inline field"> | |||
<label>模型标签</label> | |||
@@ -671,6 +675,14 @@ | |||
$('#JobName').val(obj.DisplayJobName).addClass('model_disabled') | |||
$('input[name="JobId"]').val(obj.JobID) | |||
$('input[name="VersionName"]').val(obj.VersionName).addClass('model_disabled') | |||
if(obj.EngineID ==122){ | |||
$('input[name="Engine_name"]').val("MindSpore").addClass('model_disabled'); | |||
$('input[name="Engine"]').val(2); | |||
} | |||
if(obj.EngineID ==121){ | |||
$('input[name="Engine_name"]').val("TensorFlow").addClass('model_disabled'); | |||
$('input[name="Engine"]').val(1); | |||
} | |||
$('.ui.dimmer').css({ "background-color": "rgb(136, 136, 136,0.7)" }) | |||
createModelName() | |||
}, | |||
@@ -692,6 +704,8 @@ | |||
type: 'POST', | |||
data: data, | |||
success: function (res) { | |||
$('input[name="Engine_name"]').val(""); | |||
$('input[name="Engine"]').val(""); | |||
location.href = `/${userName}/${repoPath}/modelmanage/show_model` | |||
$('.ui.modal.second').modal('hide') | |||
}, | |||