| @@ -344,13 +344,3 @@ func subMonth(t1, t2 time.Time) (month int) { | |||
| month = yearInterval*12 + monthInterval | |||
| return month | |||
| } | |||
| func QueryAllRepo() []*Repository { | |||
| sess := x.NewSession() | |||
| defer sess.Close() | |||
| sess.Select("*").Table("repository") | |||
| repositoryList := make([]*Repository, 0) | |||
| sess.Find(&repositoryList) | |||
| return repositoryList | |||
| } | |||
| @@ -87,7 +87,7 @@ write = Write | |||
| preview = Preview | |||
| loading = Loading… | |||
| error404_index = Request forbidden by administrative rules | |||
| error404_index = Request forbidden by administrative rules | |||
| error500_index = Internal Server Error | |||
| error404 = The page you are trying to reach either <strong>does not exist</strong> or <strong>you are not authorized</strong> to view it. | |||
| error500= Sorry, the site has encountered some problems, we are trying to <strong>fix the page</strong>, please try again later. | |||
| @@ -1243,6 +1243,11 @@ pulls.reject_count_1 = "%d change request" | |||
| pulls.reject_count_n = "%d change requests" | |||
| pulls.waiting_count_1 = "%d waiting review" | |||
| pulls.waiting_count_n = "%d waiting reviews" | |||
| pulls.commits_count_1=This branch is %d commit behind the upstream. | |||
| pulls.commits_count_n=This branch is %d commit behind the upstream. | |||
| pulls.fetch_upstream=Fetch upstream | |||
| pulls.upstream_up_to_date=No new commits to fetch | |||
| pulls.upstream_error=Cannot get upstream info | |||
| pulls.no_merge_desc = This pull request cannot be merged because all repository merge options are disabled. | |||
| pulls.no_merge_helper = Enable merge options in the repository settings or merge the pull request manually. | |||
| @@ -1245,6 +1245,11 @@ pulls.reject_count_1=%d 变更请求 | |||
| pulls.reject_count_n=%d 变更请求 | |||
| pulls.waiting_count_1=%d 个正在等待审核 | |||
| pulls.waiting_count_n=%d 个正在等待审核 | |||
| pulls.commits_count_1=当前分支落后上游分支 %d 个提交 | |||
| pulls.commits_count_n=当前分支落后上游分支 %d 个提交 | |||
| pulls.fetch_upstream=拉取上游更新 | |||
| pulls.upstream_up_to_date=上游分支没有新的更新 | |||
| pulls.upstream_error=获取上游分支信息错误 | |||
| pulls.no_merge_desc=由于未启用合并选项,此合并请求无法被合并。 | |||
| pulls.no_merge_helper=在项目设置中启用合并选项或者手工合并请求。 | |||
| @@ -18,7 +18,11 @@ func TimeingCountData() { | |||
| yesterday := currentTimeNow.AddDate(0, 0, -1) | |||
| repoList := models.QueryAllRepo() | |||
| repoList, err := models.GetAllRepositories() | |||
| if err != nil { | |||
| log.Error("query repo error.") | |||
| return | |||
| } | |||
| log.Info("start to query wiki data") | |||
| for _, repoRecord := range repoList { | |||
| wikiPath := models.WikiPath(repoRecord.OwnerName, repoRecord.Name) | |||
| @@ -790,6 +790,44 @@ func renderCode(ctx *context.Context) { | |||
| } | |||
| } | |||
| //如果是fork的仓库 | |||
| if ctx.Repo.Repository.IsFork { | |||
| //获得fetchUpstream对应的分支参数 | |||
| /* | |||
| // 1. /{:baseOwner}/{:baseRepoName}/compare/{:baseBranch}...{:headBranch} | |||
| // 2. /{:baseOwner}/{:baseRepoName}/compare/{:baseBranch}...{:headOwner}:{:headBranch} | |||
| // 3. /{:baseOwner}/{:baseRepoName}/compare/{:baseBranch}...{:headOwner}/{:headRepoName}:{:headBranch} | |||
| */ | |||
| baseGitRepo, err := git.OpenRepository(ctx.Repo.Repository.BaseRepo.RepoPath()) | |||
| defer baseGitRepo.Close() | |||
| if err != nil { | |||
| log.Error("error open baseRepo:%s",ctx.Repo.Repository.BaseRepo.RepoPath()) | |||
| ctx.Data["FetchUpstreamCnt"] = -1 // minus value indicates error | |||
| }else{ | |||
| if _,error:= baseGitRepo.GetBranch(ctx.Repo.BranchName);error==nil{ | |||
| //base repo has the same branch, then compare between current repo branch and base repo's branch | |||
| compareUrl := ctx.Repo.BranchName + "..." + ctx.Repo.Repository.BaseRepo.OwnerName + "/" + ctx.Repo.Repository.BaseRepo.Name + ":" + ctx.Repo.BranchName | |||
| ctx.SetParams("*",compareUrl) | |||
| }else{ | |||
| //else, compare between current repo branch and base repo's default branch | |||
| compareUrl := ctx.Repo.BranchName + "..." + ctx.Repo.Repository.BaseRepo.OwnerName + "/" + ctx.Repo.Repository.BaseRepo.Name + ":" + ctx.Repo.Repository.BaseRepo.DefaultBranch | |||
| ctx.SetParams("*",compareUrl) | |||
| } | |||
| _, _, headGitRepo, compareInfo, _, _ := ParseCompareInfo(ctx) | |||
| defer headGitRepo.Close() | |||
| if compareInfo!= nil { | |||
| if compareInfo.Commits!=nil { | |||
| log.Info("compareInfoCommits数量:%d",compareInfo.Commits.Len()) | |||
| ctx.Data["FetchUpstreamCnt"] = compareInfo.Commits.Len() | |||
| }else{ | |||
| log.Info("compareInfo nothing different") | |||
| ctx.Data["FetchUpstreamCnt"] = 0 | |||
| } | |||
| }else{ | |||
| ctx.Data["FetchUpstreamCnt"] = -1 // minus value indicates error | |||
| } | |||
| } | |||
| } | |||
| ctx.Data["Paths"] = paths | |||
| ctx.Data["TreeLink"] = treeLink | |||
| ctx.Data["TreeNames"] = treeNames | |||
| @@ -1,12 +1,12 @@ | |||
| <div class="repos--seach"> | |||
| <div class="ui container"> | |||
| <div class="ui two column centered grid"> | |||
| <form class="mobile ten wide tablet computer column ui form ignore-dirty"> | |||
| <form class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty"> | |||
| <div class="ui fluid action input"> | |||
| <input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus> | |||
| <input type="hidden" name="tab" value="{{$.TabName}}"> | |||
| <input type="hidden" name="sort" value="{{$.SortType}}"> | |||
| <button class="ui blue button">{{.i18n.Tr "explore.search"}}</button> | |||
| <button class="ui green button">{{.i18n.Tr "explore.search"}}</button> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| @@ -1,11 +1,11 @@ | |||
| <div class="repos--seach"> | |||
| <div class="ui container"> | |||
| <div class="ui two column centered grid"> | |||
| <form class="sixteen wide mobile eight fourteen tablet fourteen wide computer column ui form ignore-dirty"> | |||
| <form class="fourteen wide mobile ten wide tablet ten wide computer column ui form ignore-dirty"> | |||
| <div class="ui fluid action input"> | |||
| <input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus> | |||
| <input type="hidden" name="tab" value="{{$.TabName}}"> | |||
| <button class="ui blue button">{{.i18n.Tr "explore.search"}}</button> | |||
| <button class="ui green button">{{.i18n.Tr "explore.search"}}</button> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| @@ -271,19 +271,28 @@ | |||
| <div class="three wide column"> | |||
| <!--任务状态 --> | |||
| <!-- <span class="ui compact button job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}"> | |||
| {{.Status}} | |||
| <span class="job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}"> | |||
| <!-- {{.Status}} --> | |||
| <!-- {{if eq .Status "RUNNING"}} | |||
| <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-stop"></i><span style="margin-left: 0.4em;font-size: 12px;">运行中</span></span> | |||
| <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-stop"></i><span style="margin-left: 0.4em;font-size: 12px;">运行中</span></span> | |||
| {{else}} | |||
| {{.Status}} | |||
| {{end}} --> | |||
| <span style="display:flex;position: relative; justify-content: flex-start;"><i class="{{.Status}}"></i><span style="margin-left: 0.4em;font-size: 12px;">{{.Status}}</span></span> | |||
| </span> | |||
| <!-- <span class="job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}" > | |||
| {{if eq .Status "STOPPED"}} | |||
| <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-stop"></i><span style="margin-left: 0.4em;font-size: 12px;">已停止</span></span> | |||
| {{else if eq .Status "RUNNING"}} | |||
| <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-running"></i><span style="margin-left: 0.4em;font-size: 12px;">运行中</span></span> | |||
| {{else if eq .Status "FAILED"}} | |||
| <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-running"></i><span style="margin-left: 0.4em;font-size: 12px;">运行失败</span></span> | |||
| {{else if eq .Status "WAITING"}} | |||
| <span style="display:flex;position: relative; justify-content: flex-start;"><i class="showCircle"></i><span style="margin-left: 0.4em;font-size: 12px;">初始化等待</span></span> | |||
| {{end}} | |||
| </span> --> | |||
| {{if eq .Status "STOPPED"}} | |||
| <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-stop"></i><span style="margin-left: 0.4em;font-size: 12px;">已停止</span></span> | |||
| {{else if eq .Status "RUNNING"}} | |||
| <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-running"></i><span style="margin-left: 0.4em;font-size: 12px;">运行中</span></span> | |||
| {{else if eq .Status "FAILED"}} | |||
| <span style="display:flex;position: relative; justify-content: flex-start;"><i class="i-round i-bg-running"></i><span style="margin-left: 0.4em;font-size: 12px;">运行失败</span></span> | |||
| {{else if eq .Status "WAITING"}} | |||
| <span style="display:flex;position: relative; justify-content: flex-start;"><i class="showCircle"></i><span style="margin-left: 0.4em;font-size: 12px;">初始化等待</span></span> | |||
| {{end}} | |||
| <!-- 任务创建时间 --> | |||
| <span class="">{{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}</span> | |||
| </div> | |||
| @@ -456,15 +465,18 @@ | |||
| $(document).ready(loadJobStatus); | |||
| function loadJobStatus() { | |||
| $(".job-status").each((index, job) => { | |||
| console.log("---------",index,job) | |||
| const jobID = job.dataset.jobid; | |||
| const repoPath = job.dataset.repopath; | |||
| if (job.textContent.trim() == 'STOPPED') { | |||
| return | |||
| } | |||
| $.get(`/api/v1/repos/${repoPath}/cloudbrain/${jobID}`, (data) => { | |||
| const jobID = data.JobID | |||
| const status = data.JobStatus | |||
| console.log("status",status) | |||
| if (status != job.textContent.trim()) { | |||
| //$('#' + jobID).text(status) | |||
| //if (status == 'STOPPED') { | |||
| @@ -37,7 +37,7 @@ | |||
| </div> | |||
| {{if .Permission.CanWrite $.UnitTypeDatasets}} | |||
| <div class="column four wide right aligned"> | |||
| <a class="ui button primary" href="javascript:void(0)" id="dataset-edit"> | |||
| <a class="ui green button" href="javascript:void(0)" id="dataset-edit"> | |||
| {{.i18n.Tr "dataset.edit"}} | |||
| </a> | |||
| </div> | |||
| @@ -66,7 +66,7 @@ | |||
| <input name="type" value="{{.Type}}" type="hidden" /> | |||
| <div class="sixteen wide column"> | |||
| <a class="ui button" id="cancel">{{.i18n.Tr "cancel"}}</a> | |||
| <button class="ui primary button" id="submit">{{.i18n.Tr "dataset.update_dataset"}}</button> | |||
| <button class="ui green button" id="submit">{{.i18n.Tr "dataset.update_dataset"}}</button> | |||
| </div> | |||
| </div> | |||
| @@ -154,6 +154,21 @@ | |||
| <a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch | EscapePound}}...{{if ne .Repository.Owner.Name .BaseRepo.Owner.Name}}{{.Repository.Owner.Name}}:{{end}}{{.BranchName | EscapePound}}"> | |||
| <button id="new-pull-request" class="ui compact basic button">{{if .PullRequestCtx.Allowed}}{{.i18n.Tr "repo.pulls.compare_changes"}}{{else}}{{.i18n.Tr "action.compare_branch"}}{{end}}</button> | |||
| </a> | |||
| {{if and .Repository.IsFork .PullRequestCtx.Allowed}} | |||
| {{if gt .FetchUpstreamCnt 0 }} | |||
| <a href="{{.Repository.Link}}/compare/{{.BranchName | EscapePound}}...{{.BaseRepo.Owner.Name}}:{{.BaseRepo.DefaultBranch | EscapePound}}"> | |||
| <button id="new-pull-request" class="ui compact basic button" title="{{$.i18n.Tr (TrN $.i18n.Lang .FetchUpstreamCnt "repo.pulls.commits_count_1" "repo.pulls.commits_count_n") .FetchUpstreamCnt}}">{{.i18n.Tr "repo.pulls.fetch_upstream"}}</button> | |||
| </a> | |||
| {{else if lt .FetchUpstreamCnt 0}} | |||
| <a href="{{.Repository.Link}}/compare/{{.BranchName | EscapePound}}...{{.BaseRepo.Owner.Name}}:{{.BaseRepo.DefaultBranch | EscapePound}}"> | |||
| <button id="new-pull-request" class="ui compact basic button" title="{{.i18n.Tr "repo.pulls.upstream_error"}}">{{.i18n.Tr "repo.pulls.fetch_upstream"}}</button> | |||
| </a> | |||
| {{else}} | |||
| <a href="{{.Repository.Link}}/compare/{{.BranchName | EscapePound}}...{{.BaseRepo.Owner.Name}}:{{.BaseRepo.DefaultBranch | EscapePound}}"> | |||
| <button id="new-pull-request" class="ui compact basic button" title="{{.i18n.Tr "repo.pulls.upstream_up_to_date"}}">{{.i18n.Tr "repo.pulls.fetch_upstream"}}</button> | |||
| </a> | |||
| {{end}} | |||
| {{end}} | |||
| </div> | |||
| {{end}} | |||
| {{else}} | |||
| @@ -3,12 +3,7 @@ | |||
| {{template "repo/header" .}} | |||
| <div class="ui container"> | |||
| <div class="ui three column stackable grid"> | |||
| <div class="column" style="display: flex;align-items: center;"> | |||
| <div class="ui large breadcrumb"> | |||
| <a href="{{.RepoLink}}/issues">{{.i18n.Tr "repo.issues"}}</a> | |||
| <div class="divider"> / </div> | |||
| </div> | |||
| <div class="column" style="display: flex;align-items: center;"> | |||
| </div> | |||
| <div class="column center aligned"> | |||
| {{template "repo/issue/search" .}} | |||
| @@ -7,7 +7,7 @@ | |||
| <input type="hidden" name="assignee" value="{{$.AssigneeID}}"/> | |||
| <div class="ui search action input"> | |||
| <input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus> | |||
| <button class="ui blue button" type="submit">{{.i18n.Tr "explore.search"}}</button> | |||
| <button class="ui green button" type="submit">{{.i18n.Tr "explore.search"}}</button> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -74,7 +74,7 @@ | |||
| <input type="hidden" name="state" value="{{$.State}}"/> | |||
| <div class="ui search action input"> | |||
| <input name="q" value="{{$.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus> | |||
| <button class="ui blue button" type="submit">{{.i18n.Tr "explore.search"}}</button> | |||
| <button class="ui green button" type="submit">{{.i18n.Tr "explore.search"}}</button> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -197,13 +197,13 @@ export default { | |||
| }) | |||
| }, | |||
| postTopic(){ | |||
| const patter = /^[\u4e00-\u9fa5a-z0-9][\u4e00-\u9fa5a-zA-Z0-9-]{0,35}$/ | |||
| const patter = /^[\u4e00-\u9fa5a-zA-Z0-9][\u4e00-\u9fa5a-zA-Z0-9-]{0,34}$/ | |||
| let regexp = patter.test(this.input) | |||
| console.log("regexp",regexp) | |||
| if(!regexp){ | |||
| this.$notify({ | |||
| message: '主题必须以中文、字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符', | |||
| message: '标签名必须以中文、字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符', | |||
| duration: 3000, | |||
| type:'error' | |||
| }); | |||
| @@ -224,15 +224,15 @@ footer .column{margin-bottom:0!important; padding-bottom:0!important;} | |||
| // icon cloudbrain | |||
| .i-round{display:inline-block;width:18px;height:18px;background:url("/img/icons.svg");background-position: -496px -52px;} | |||
| .i-bg-organ{background-position: -496px -52px;} | |||
| .i-bg-stop{background-position: -459px -52px;} | |||
| .i-bg-running{background-position: -478px -52px;} | |||
| .STOPPED{display:inline-block;width:18px;height:18px;background:url("/img/icons.svg");background-position: -496px -52px;background-position: -459px -52px;} | |||
| .RUNNING{display:inline-block;width:18px;height:18px;background:url("/img/icons.svg");background-position: -496px -52px;background-position: -478px -52px;} | |||
| .i-bg-orange{background-position: -495px -51px;} | |||
| .i-bg-red{background-position: -532px -52px;} | |||
| .FAILED{display:inline-block;width:18px;height:18px;background:url("/img/icons.svg");background-position: -496px -52px;background-position: -532px -52px;} | |||
| .i-bg-green{background-position: -441px -52px;} | |||
| .i-bg-used{background-position: -514px -52px;} | |||
| .icon-bind{background-position: -550px -52px;} | |||
| .icon-unbind{background-position: -568px -52px;} | |||
| .showCircle{display:inline-block;background-image:url('/img/loading.gif');background-repeat:no-repeat;width:16px;height:16px;background-size:16px 16px;margin-right:5px;} | |||
| .WAITING{display:inline-block;background-image:url('/img/loading.gif');background-repeat:no-repeat;width:16px;height:16px;background-size:16px 16px;margin-right:5px;} | |||
| .text_over{ | |||
| overflow: hidden; | |||
| text-overflow: ellipsis; | |||