Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/1046 Reviewed-by: wangjr <wangjr@pcl.ac.cn>pull/1059/head
@@ -433,6 +433,9 @@ var ( | |||||
AuthUser string | AuthUser string | ||||
AuthPassword string | AuthPassword string | ||||
//home page | |||||
RecommentRepoAddr string | |||||
//labelsystem config | //labelsystem config | ||||
LabelTaskName string | LabelTaskName string | ||||
LabelDatasetDeleteQueue string | LabelDatasetDeleteQueue string | ||||
@@ -1229,6 +1232,9 @@ func NewContext() { | |||||
LabelDatasetDeleteQueue = sec.Key("LabelDatasetDeleteQueue").MustString("LabelDatasetDeleteQueue") | LabelDatasetDeleteQueue = sec.Key("LabelDatasetDeleteQueue").MustString("LabelDatasetDeleteQueue") | ||||
DecompressOBSTaskName = sec.Key("DecompressOBSTaskName").MustString("LabelDecompressOBSQueue") | DecompressOBSTaskName = sec.Key("DecompressOBSTaskName").MustString("LabelDecompressOBSQueue") | ||||
sec = Cfg.Section("homepage") | |||||
RecommentRepoAddr = sec.Key("Address").MustString("https://git.openi.org.cn/OpenIOSSG/promote/raw/branch/master/") | |||||
sec = Cfg.Section("cloudbrain") | sec = Cfg.Section("cloudbrain") | ||||
CBAuthUser = sec.Key("USER").MustString("") | CBAuthUser = sec.Key("USER").MustString("") | ||||
CBAuthPassword = sec.Key("PWD").MustString("") | CBAuthPassword = sec.Key("PWD").MustString("") | ||||
@@ -778,6 +778,8 @@ datasets = Datasets | |||||
datasets.desc = Enable Dataset | datasets.desc = Enable Dataset | ||||
cloudbrain_helper=Use GPU/NPU resources to open notebooks, model training tasks, etc. | cloudbrain_helper=Use GPU/NPU resources to open notebooks, model training tasks, etc. | ||||
model_manager = Model | |||||
debug=Debug | debug=Debug | ||||
stop=Stop | stop=Stop | ||||
delete=Delete | delete=Delete | ||||
@@ -782,7 +782,7 @@ datasets=数据集 | |||||
datasets.desc=数据集功能 | datasets.desc=数据集功能 | ||||
cloudbrain_helper=使用GPU/NPU资源,开启Notebook、模型训练任务等 | cloudbrain_helper=使用GPU/NPU资源,开启Notebook、模型训练任务等 | ||||
model_manager = 模型管理 | |||||
model_manager = 模型 | |||||
model_noright=无权限操作 | model_noright=无权限操作 | ||||
debug=调试 | debug=调试 | ||||
@@ -7,6 +7,8 @@ package routers | |||||
import ( | import ( | ||||
"bytes" | "bytes" | ||||
"fmt" | |||||
"io/ioutil" | |||||
"net/http" | "net/http" | ||||
"strings" | "strings" | ||||
@@ -511,3 +513,43 @@ func NotFound(ctx *context.Context) { | |||||
ctx.Data["Title"] = "Page Not Found" | ctx.Data["Title"] = "Page Not Found" | ||||
ctx.NotFound("home.NotFound", nil) | ctx.NotFound("home.NotFound", nil) | ||||
} | } | ||||
func RecommendOrgFromPromote(ctx *context.Context) { | |||||
url := setting.RecommentRepoAddr + "organizations" | |||||
recommendFromPromote(ctx, url) | |||||
} | |||||
func recommendFromPromote(ctx *context.Context, url string) { | |||||
resp, err := http.Get(url) | |||||
if err != nil { | |||||
log.Info("Get organizations url error=" + err.Error()) | |||||
ctx.ServerError("QueryTrainJobList:", err) | |||||
return | |||||
} | |||||
bytes, err := ioutil.ReadAll(resp.Body) | |||||
resp.Body.Close() | |||||
if err != nil { | |||||
log.Info("Get organizations url error=" + err.Error()) | |||||
ctx.ServerError("QueryTrainJobList:", err) | |||||
return | |||||
} | |||||
allLineStr := string(bytes) | |||||
lines := strings.Split(allLineStr, "\n") | |||||
result := make([]string, len(lines)) | |||||
for i, line := range lines { | |||||
tmpIndex := strings.Index(line, ".") | |||||
log.Info("i=" + fmt.Sprint(i) + " line=" + line + " tmpIndex=" + fmt.Sprint(tmpIndex)) | |||||
if tmpIndex == -1 { | |||||
result[i] = strings.Trim(line, " ") | |||||
} else { | |||||
result[i] = strings.Trim(line[tmpIndex+1:], " ") | |||||
} | |||||
} | |||||
ctx.JSON(http.StatusOK, result) | |||||
} | |||||
func RecommendRepoFromPromote(ctx *context.Context) { | |||||
url := setting.RecommentRepoAddr + "projects" | |||||
recommendFromPromote(ctx, url) | |||||
} |
@@ -315,6 +315,8 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
}) | }) | ||||
m.Get("/", routers.Home) | m.Get("/", routers.Home) | ||||
m.Get("/dashboard", routers.Dashboard) | m.Get("/dashboard", routers.Dashboard) | ||||
m.Get("/recommend/org", routers.RecommendOrgFromPromote) | |||||
m.Get("/recommend/repo", routers.RecommendRepoFromPromote) | |||||
m.Group("/explore", func() { | m.Group("/explore", func() { | ||||
m.Get("", func(ctx *context.Context) { | m.Get("", func(ctx *context.Context) { | ||||
ctx.Redirect(setting.AppSubURL + "/explore/repos") | ctx.Redirect(setting.AppSubURL + "/explore/repos") | ||||
@@ -134,7 +134,8 @@ | |||||
{{if .Permission.CanRead $.UnitTypeDatasets}} | {{if .Permission.CanRead $.UnitTypeDatasets}} | ||||
<a class="{{if .PageIsDataset}}active{{end}} item" href="{{.RepoLink}}/datasets?type=0"> | <a class="{{if .PageIsDataset}}active{{end}} item" href="{{.RepoLink}}/datasets?type=0"> | ||||
{{svg "octicon-inbox" 16}} {{.i18n.Tr "datasets"}} | |||||
<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"/><path d="M20.083 15.2l1.202.721a.5.5 0 0 1 0 .858l-8.77 5.262a1 1 0 0 1-1.03 0l-8.77-5.262a.5.5 0 0 1 0-.858l1.202-.721L12 20.05l8.083-4.85zm0-4.7l1.202.721a.5.5 0 0 1 0 .858L12 17.65l-9.285-5.571a.5.5 0 0 1 0-.858l1.202-.721L12 15.35l8.083-4.85zm-7.569-9.191l8.771 5.262a.5.5 0 0 1 0 .858L12 13 2.715 7.429a.5.5 0 0 1 0-.858l8.77-5.262a1 1 0 0 1 1.03 0zM12 3.332L5.887 7 12 10.668 18.113 7 12 3.332z"/></svg> | |||||
{{.i18n.Tr "datasets"}} | |||||
</a> | </a> | ||||
{{end}} | {{end}} | ||||
{{if .Permission.CanRead $.UnitTypeModelManage}} | {{if .Permission.CanRead $.UnitTypeModelManage}} | ||||
@@ -145,7 +146,11 @@ | |||||
{{end}} | {{end}} | ||||
{{if .Permission.CanRead $.UnitTypeCloudBrain}} | {{if .Permission.CanRead $.UnitTypeCloudBrain}} | ||||
<a class="{{if .PageIsCloudBrain}}active{{end}} item" href="{{.RepoLink}}/cloudbrain"> | <a class="{{if .PageIsCloudBrain}}active{{end}} item" href="{{.RepoLink}}/cloudbrain"> | ||||
<span>{{svg "octicon-server" 16}} {{.i18n.Tr "repo.cloudbrain"}}<i class="question circle icon link cloudbrain-question" data-content={{.i18n.Tr "repo.cloudbrain_helper"}} data-position="top center" data-variation="mini"></i></span> | |||||
<span> | |||||
<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"/><path d="M4 3h16a1 1 0 0 1 1 1v7H3V4a1 1 0 0 1 1-1zM3 13h18v7a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-7zm4 3v2h3v-2H7zM7 6v2h3V6H7z"/></svg> | |||||
{{.i18n.Tr "repo.cloudbrain"}} | |||||
<i class="question circle icon link cloudbrain-question" data-content={{.i18n.Tr "repo.cloudbrain_helper"}} data-position="top center" data-variation="mini"></i> | |||||
</span> | |||||
</a> | </a> | ||||
{{end}} | {{end}} | ||||
<!-- {{if .IsSigned}} | <!-- {{if .IsSigned}} | ||||
@@ -149,15 +149,6 @@ | |||||
<label>{{.i18n.Tr "repo.settings.dataset_desc"}}</label> | <label>{{.i18n.Tr "repo.settings.dataset_desc"}}</label> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
{{$isCloudBrainEnabled := .Repository.UnitEnabled $.UnitTypeCloudBrain }} | |||||
<div class="inline field"> | |||||
<label>{{.i18n.Tr "repo.cloudbrain"}}</label> | |||||
<div class="ui checkbox"> | |||||
<input class="enable-system" name="enable_cloud_brain" type="checkbox" {{if $isCloudBrainEnabled}}checked{{end}}> | |||||
<label>{{.i18n.Tr "repo.settings.cloudbrain_desc"}}</label> | |||||
</div> | |||||
</div> | |||||
{{$isModelMangeEnabled := .Repository.UnitEnabled $.UnitTypeModelManage }} | {{$isModelMangeEnabled := .Repository.UnitEnabled $.UnitTypeModelManage }} | ||||
<div class="inline field"> | <div class="inline field"> | ||||
<label>{{.i18n.Tr "repo.model_manager"}}</label> | <label>{{.i18n.Tr "repo.model_manager"}}</label> | ||||
@@ -166,6 +157,14 @@ | |||||
<label>{{.i18n.Tr "repo.settings.model_desc"}}</label> | <label>{{.i18n.Tr "repo.settings.model_desc"}}</label> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
{{$isCloudBrainEnabled := .Repository.UnitEnabled $.UnitTypeCloudBrain }} | |||||
<div class="inline field"> | |||||
<label>{{.i18n.Tr "repo.cloudbrain"}}</label> | |||||
<div class="ui checkbox"> | |||||
<input class="enable-system" name="enable_cloud_brain" type="checkbox" {{if $isCloudBrainEnabled}}checked{{end}}> | |||||
<label>{{.i18n.Tr "repo.settings.cloudbrain_desc"}}</label> | |||||
</div> | |||||
</div> | |||||
{{$isWikiEnabled := or (.Repository.UnitEnabled $.UnitTypeWiki) (.Repository.UnitEnabled $.UnitTypeExternalWiki)}} | {{$isWikiEnabled := or (.Repository.UnitEnabled $.UnitTypeWiki) (.Repository.UnitEnabled $.UnitTypeExternalWiki)}} | ||||
<div class="inline field"> | <div class="inline field"> | ||||
<label>{{.i18n.Tr "repo.wiki"}}</label> | <label>{{.i18n.Tr "repo.wiki"}}</label> | ||||