Browse Source

首页改版。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.6.1^2
zouap 3 years ago
parent
commit
27630014b9
4 changed files with 122 additions and 59 deletions
  1. +59
    -30
      public/home/home.js
  2. +56
    -23
      routers/home.go
  3. +4
    -3
      routers/routes/routes.go
  4. +3
    -3
      templates/home.tmpl

+ 59
- 30
public/home/home.js View File

@@ -117,6 +117,7 @@ socket.onmessage = function (e) {
continue;
}
}
refresh3DInfo(record);
var recordPrefix = getMsg(record);
if(record.OpType == "6" || record.OpType == "10" || record.OpType == "12" || record.OpType == "13"){
html += recordPrefix + actionName;
@@ -200,6 +201,22 @@ function getTaskLink(record){
return re;
}

function refresh3DInfo(record){
if(record.OpType == "25" || record.OpType == "29" || record.OpType == "31"){
//cloudbrain one
var lines = $('.rotation3D__line blue');
console.log("cloudbrain one line length=" + lines.length);
lines[0].find("span").text(record.RefName);
}else if(record.OpType == "26" || record.OpType == "27" || record.OpType == "28"){
//cloudbrain two
var lines = $('.rotation3D__line blue');
console.log("cloudbrain two line length=" + lines.length);
lines[1].find("span").text(record.RefName);
}

}

function getMsg(record){
var html ="";
html += "<div class=\"swiper-slide item\">";
@@ -418,48 +435,60 @@ queryRecommendData();
function queryRecommendData(){
$.ajax({
type:"GET",
url:"/recommend/org",
url:"/recommend/home",
headers: {
authorization:token,
},
dataType:"json",
async:false,
success:function(json){
displayOrg(json);
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/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) {
// }
// });
}

$.ajax({
type:"GET",
url:"/recommend/imageinfo",
headers: {
authorization:token,
},
dataType:"json",
async:false,
success:function(json){
displayActivity(json);
},
error:function(response) {
}
});
function displayCloudBrain(json){
var completed_task = document.getElementById("completed_task");
completed_task.text(json.completed_task);
var running_task = document.getElementById("running_task");
running_task.text(json.running_task);
var wait_task = document.getElementById("wait_task");
wait_task.text(json.wait_task);
}

function displayActivity(json){


+ 56
- 23
routers/home.go View File

@@ -471,7 +471,7 @@ func ExploreOrganizations(ctx *context.Context) {
return
}

recommendOrgs, err := GetRecommendOrg()
recommendOrgs, err := getRecommendOrg()
if err != nil {
log.Error("GetRecommendOrgInfos failed:%v", err.Error(), ctx.Data["MsgID"])
ctx.ServerError("GetRecommendOrgInfos", err)
@@ -606,31 +606,31 @@ func ExploreImages(ctx *context.Context) {
}

func ExploreDataAnalysisUserTrend(ctx *context.Context) {
ctx.Data["url_params"]="UserTrend"
ctx.Data["url_params"] = "UserTrend"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysisUserAnalysis(ctx *context.Context) {
ctx.Data["url_params"]="UserAnalysis"
ctx.Data["url_params"] = "UserAnalysis"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysisProTrend(ctx *context.Context) {
ctx.Data["url_params"]="ProTrend"
ctx.Data["url_params"] = "ProTrend"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysisProAnalysis(ctx *context.Context) {
ctx.Data["url_params"]="ProAnalysis"
ctx.Data["url_params"] = "ProAnalysis"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysisOverview(ctx *context.Context) {
ctx.Data["url_params"]="Overview"
ctx.Data["url_params"] = "Overview"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysisBrainAnalysis(ctx *context.Context) {
ctx.Data["url_params"]="BrainAnalysis"
ctx.Data["url_params"] = "BrainAnalysis"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysis(ctx *context.Context) {
ctx.Data["url_params"]=""
ctx.Data["url_params"] = ""
ctx.HTML(200, tplExploreExploreDataAnalysis)
}

@@ -640,7 +640,7 @@ func NotFound(ctx *context.Context) {
ctx.NotFound("home.NotFound", nil)
}

func GetRecommendOrg() ([]map[string]interface{}, error) {
func getRecommendOrg() ([]map[string]interface{}, error) {
url := setting.RecommentRepoAddr + "organizations"
result, err := repository.RecommendFromPromote(url)

@@ -668,7 +668,7 @@ func GetRecommendOrg() ([]map[string]interface{}, error) {
}
return resultOrg, nil
}
func GetImageInfo() ([]map[string]interface{}, error) {
func getImageInfo() ([]map[string]interface{}, error) {
url := setting.RecommentRepoAddr + "picture_info"
result, err := repository.RecommendFromPromote(url)

@@ -731,14 +731,14 @@ 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 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")
@@ -750,15 +750,48 @@ func GetUserRankFromPromote(ctx *context.Context) {
ctx.JSON(200, resultUserRank)
}

func RecommendOrgFromPromote(ctx *context.Context) {
resultOrg, err := GetRecommendOrg()
func RecommendHomeInfo(ctx *context.Context) {
resultOrg, err := getRecommendOrg()
if err != nil {
ctx.ServerError("500", err)
return
log.Info("error." + err.Error())
}
ctx.JSON(200, resultOrg)
resultRepo, err := repository.GetRecommendRepoFromPromote("projects")
if err != nil {
log.Info("error." + err.Error())
}
resultImage, err := getImageInfo()
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
ctx.JSON(http.StatusOK, mapInterface)
}

func getCloudbrainNums() (map[string]string, error) {
result := make(map[string]string)
result["completed_task"] = "1800"
result["running_task"] = "20"
result["wait_task"] = "30"
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 {


+ 4
- 3
routers/routes/routes.go View File

@@ -323,10 +323,11 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/dashboard", routers.Dashboard)
go routers.SocketManager.Run()
m.Get("/action/notification", routers.ActionNotification)
m.Get("/recommend/org", routers.RecommendOrgFromPromote)
m.Get("/recommend/repo", routers.RecommendRepoFromPromote)
m.Get("/recommend/home", routers.RecommendHomeInfo)
//m.Get("/recommend/org", routers.RecommendOrgFromPromote)
//m.Get("/recommend/repo", routers.RecommendRepoFromPromote)
m.Get("/recommend/userrank/:index", routers.GetUserRankFromPromote)
m.Get("/recommend/imageinfo", routers.GetImageInfoFromPromote)
//m.Get("/recommend/imageinfo", routers.GetImageInfoFromPromote)
m.Post("/all/search/", routers.Search)
m.Get("/all/search/", routers.EmptySearch)
m.Get("/all/dosearch/", routers.SearchApi)


+ 3
- 3
templates/home.tmpl View File

@@ -4,9 +4,9 @@
<div id="app" v-cloak>
<!--数据-->
<div class="aiData">
<p>完成AI任务<br><strong>1716</strong></p>
<p>运行AI任务<br><strong>120</strong></p>
<p>等待AI任务<br><strong>80</strong></p>
<p>完成AI任务<br><strong id="completed_task">1716</strong></p>
<p>运行AI任务<br><strong id="running_task">120</strong></p>
<p>等待AI任务<br><strong id="wait_task">80</strong></p>
</div>
<!--底座-->
<div class="rotation3D-baseMap"></div>


Loading…
Cancel
Save