| @@ -433,6 +433,9 @@ var ( | |||
| AuthUser string | |||
| AuthPassword string | |||
| //home page | |||
| RecommentRepoAddr string | |||
| //labelsystem config | |||
| LabelTaskName string | |||
| LabelDatasetDeleteQueue string | |||
| @@ -1229,6 +1232,9 @@ func NewContext() { | |||
| LabelDatasetDeleteQueue = sec.Key("LabelDatasetDeleteQueue").MustString("LabelDatasetDeleteQueue") | |||
| 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") | |||
| CBAuthUser = sec.Key("USER").MustString("") | |||
| CBAuthPassword = sec.Key("PWD").MustString("") | |||
| @@ -778,6 +778,8 @@ datasets = Datasets | |||
| datasets.desc = Enable Dataset | |||
| cloudbrain_helper=Use GPU/NPU resources to open notebooks, model training tasks, etc. | |||
| model_manager = Model | |||
| debug=Debug | |||
| stop=Stop | |||
| delete=Delete | |||
| @@ -782,7 +782,7 @@ datasets=数据集 | |||
| datasets.desc=数据集功能 | |||
| cloudbrain_helper=使用GPU/NPU资源,开启Notebook、模型训练任务等 | |||
| model_manager = 模型管理 | |||
| model_manager = 模型 | |||
| model_noright=无权限操作 | |||
| debug=调试 | |||
| @@ -0,0 +1 @@ | |||
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="120" height="120"><path fill="none" d="M0 0h24v24H0z"/><path d="M20 22h-2v-2a3 3 0 0 0-3-3H9a3 3 0 0 0-3 3v2H4v-2a5 5 0 0 1 5-5h6a5 5 0 0 1 5 5v2zm-8-9a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8z" fill="rgba(0,0,0,0.4)"/></svg> | |||
| @@ -0,0 +1 @@ | |||
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="120" height="120"><path fill="none" d="M0 0h24v24H0z"/><path d="M20 3l2 4v13a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7.004L4 3h16zm0 6H4v10h16V9zm-8 1l4 4h-3v4h-2v-4H8l4-4zm6.764-5H5.236l-.999 2h15.527l-1-2z" fill="rgba(0,0,0,0.4)"/></svg> | |||
| @@ -7,6 +7,8 @@ package routers | |||
| import ( | |||
| "bytes" | |||
| "fmt" | |||
| "io/ioutil" | |||
| "net/http" | |||
| "strings" | |||
| @@ -511,3 +513,43 @@ func NotFound(ctx *context.Context) { | |||
| ctx.Data["Title"] = "Page Not Found" | |||
| 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("/dashboard", routers.Dashboard) | |||
| m.Get("/recommend/org", routers.RecommendOrgFromPromote) | |||
| m.Get("/recommend/repo", routers.RecommendRepoFromPromote) | |||
| m.Group("/explore", func() { | |||
| m.Get("", func(ctx *context.Context) { | |||
| ctx.Redirect(setting.AppSubURL + "/explore/repos") | |||
| @@ -6,6 +6,7 @@ | |||
| package user | |||
| import ( | |||
| "errors" | |||
| "fmt" | |||
| "path" | |||
| "strings" | |||
| @@ -107,6 +108,9 @@ func Profile(ctx *context.Context) { | |||
| ctx.Data["HasOrgsVisible"] = models.HasOrgsVisible(orgs, ctx.User) | |||
| tab := ctx.Query("tab") | |||
| if tab == "" { | |||
| tab = "activity" | |||
| } | |||
| ctx.Data["TabName"] = tab | |||
| page := ctx.QueryInt("page") | |||
| @@ -235,7 +239,7 @@ func Profile(ctx *context.Context) { | |||
| } | |||
| total = int(count) | |||
| ctx.Data["Datasets"] = datasets | |||
| default: | |||
| case "repository": | |||
| repos, count, err = models.SearchRepository(&models.SearchRepoOptions{ | |||
| ListOptions: models.ListOptions{ | |||
| PageSize: setting.UI.User.RepoPagingNum, | |||
| @@ -256,6 +260,9 @@ func Profile(ctx *context.Context) { | |||
| } | |||
| total = int(count) | |||
| default: | |||
| ctx.ServerError("tab error", errors.New("tab error")) | |||
| return | |||
| } | |||
| ctx.Data["Repos"] = repos | |||
| ctx.Data["Total"] = total | |||
| @@ -134,7 +134,8 @@ | |||
| {{if .Permission.CanRead $.UnitTypeDatasets}} | |||
| <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> | |||
| {{end}} | |||
| {{if .Permission.CanRead $.UnitTypeModelManage}} | |||
| @@ -144,8 +145,12 @@ | |||
| </a> | |||
| {{end}} | |||
| {{if .Permission.CanRead $.UnitTypeCloudBrain}} | |||
| <a class="{{if .PageIsCloudBrain}}active{{end}} item" href="{{.RepoLink}}/debugjob"> | |||
| <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> | |||
| <a class="{{if .PageIsCloudBrain}}active{{end}} item" href="{{.RepoLink}}/cloudbrain"> | |||
| <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> | |||
| {{end}} | |||
| <!-- {{if .IsSigned}} | |||
| @@ -149,15 +149,6 @@ | |||
| <label>{{.i18n.Tr "repo.settings.dataset_desc"}}</label> | |||
| </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 }} | |||
| <div class="inline field"> | |||
| <label>{{.i18n.Tr "repo.model_manager"}}</label> | |||
| @@ -166,6 +157,14 @@ | |||
| <label>{{.i18n.Tr "repo.settings.model_desc"}}</label> | |||
| </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)}} | |||
| <div class="inline field"> | |||
| <label>{{.i18n.Tr "repo.wiki"}}</label> | |||
| @@ -50,16 +50,46 @@ | |||
| {{end}} | |||
| <li>{{svg "octicon-clock" 16}} {{.i18n.Tr "user.join_on"}} {{.Owner.CreatedUnix.FormatShort}}</li> | |||
| {{if and .Orgs .HasOrgsVisible}} | |||
| <li> | |||
| <ul class="user-orgs"> | |||
| <li style="border-bottom: none;padding-bottom: 0;"><div style="border-bottom: 1px solid #eaeaea;padding-top: 5px;padding-bottom:5px"> <b> 组织</b></div></li> | |||
| <li style="padding-bottom: 0px;"> | |||
| <!-- <ul class="user-orgs"> | |||
| {{range .Orgs}} | |||
| {{if (or .Visibility.IsPublic (and ($.SignedUser) (or .Visibility.IsLimited (and (.IsUserPartOfOrg $.SignedUserID) .Visibility.IsPrivate) ($.IsAdmin))))}} | |||
| <li> | |||
| <a href="{{.HomeLink}}"><img class="ui image poping up" src="{{.RelAvatarLink}}" data-content="{{.Name}}" data-position="top center" data-variation="tiny inverted"></a> | |||
| <ul> | |||
| <a href="{{.HomeLink}}"><img class="ui image poping up" src="{{.RelAvatarLink}}" data-content="{{.Name}}" data-position="top center" data-variation="tiny inverted"></a> | |||
| <span>{{.Name}}</span> | |||
| </ul> | |||
| </li> | |||
| {{end}} | |||
| {{end}} | |||
| </ul> | |||
| </ul> --> | |||
| {{range .Orgs}} | |||
| <ul class="user-orgs"> | |||
| {{if (or .Visibility.IsPublic (and ($.SignedUser) (or .Visibility.IsLimited (and (.IsUserPartOfOrg $.SignedUserID) .Visibility.IsPrivate) ($.IsAdmin))))}} | |||
| <li class="infor" style="width: 15%;" > | |||
| <a href="{{.HomeLink}}"><img class="ui image poping up" src="{{.RelAvatarLink}}" data-content="{{.Name}}" data-position="top center" data-variation="tiny inverted"></a> | |||
| </li> | |||
| <li class="infor" style="width: 35%;"> | |||
| <a class="ui image poping up" style="color: #0366D6;overflow: hidden; white-space: nowrap; text-overflow: ellipsis;" href="{{.HomeLink}}" data-content="{{.Name}}" data-position="top center" data-variation="tiny inverted">{{.Name}}</a> | |||
| </li> | |||
| <li class="infor" style="width: 25%;"> | |||
| <img style="width: 14px; height: 14px;border: none;" src="/img/member.svg" > | |||
| <span style="color: rgba(0,0,0,.4);padding-left: 5px;">{{.NumMembers}}</span> | |||
| </li> | |||
| <li class="infor" style="width: 25%;"> | |||
| <img style="width: 14px; height: 14px" src="/img/pro_num.svg" > | |||
| <span style="color: rgba(0,0,0,.4);padding-left: 5px;">{{.NumRepos}}</span> | |||
| </li> | |||
| {{end}} | |||
| </ul> | |||
| {{end}} | |||
| </li> | |||
| {{end}} | |||
| {{if and .IsSigned (ne .SignedUserName .Owner.Name)}} | |||
| @@ -83,7 +113,11 @@ | |||
| </div> | |||
| <div class="ui eleven wide column"> | |||
| <div class="ui secondary stackable pointing menu"> | |||
| <a class='{{if and (ne .TabName "datasets") (ne .TabName "activity") (ne .TabName "following") (ne .TabName "followers") (ne .TabName "stars")}}active{{end}} item' href="{{.Owner.HomeLink}}"> | |||
| <!-- <a class='{{if and (ne .TabName "datasets") (ne .TabName "activity") (ne .TabName "following") (ne .TabName "followers") (ne .TabName "stars")}}active{{end}} item' href="{{.Owner.HomeLink}}"> | |||
| {{svg "octicon-repo" 16}} {{.i18n.Tr "user.repositories"}} | |||
| </a> --> | |||
| <a class='{{if eq .TabName "repository" }}active{{end}} item' href="{{.Owner.HomeLink}}?tab=repository"> | |||
| {{svg "octicon-repo" 16}} {{.i18n.Tr "user.repositories"}} | |||
| </a> | |||
| <a class='{{if eq .TabName "datasets"}}active{{end}} item' href="{{.Owner.HomeLink}}?tab=datasets"> | |||
| @@ -144,3 +178,22 @@ | |||
| </div> | |||
| </div> | |||
| {{template "base/footer" .}} | |||
| <style> | |||
| .infor{ | |||
| margin: auto 0; | |||
| } | |||
| .user-orgs{ | |||
| padding: 10px 0px; | |||
| } | |||
| .user-orgs li{ | |||
| max-width: 50%; | |||
| float: right; | |||
| } | |||
| .user.profile .ui.card .extra.content ul { | |||
| padding: 5px 0; | |||
| } | |||
| </style> | |||