Browse Source

Merge branch 'V20211018' into fix-333

pull/514/head
lewis 3 years ago
parent
commit
800e765fdf
15 changed files with 107 additions and 43 deletions
  1. +0
    -10
      models/user_business_analysis.go
  2. +6
    -1
      options/locale/locale_en-US.ini
  3. +5
    -0
      options/locale/locale_zh-CN.ini
  4. +5
    -1
      routers/repo/user_data_analysis.go
  5. +38
    -0
      routers/repo/view.go
  6. +2
    -2
      templates/explore/dataset_search.tmpl
  7. +2
    -2
      templates/explore/search.tmpl
  8. +23
    -11
      templates/repo/cloudbrain/index.tmpl
  9. +2
    -2
      templates/repo/datasets/index.tmpl
  10. +15
    -0
      templates/repo/home.tmpl
  11. +1
    -6
      templates/repo/issue/list.tmpl
  12. +1
    -1
      templates/repo/issue/search.tmpl
  13. +1
    -1
      templates/user/dashboard/issues.tmpl
  14. +2
    -2
      web_src/js/components/EditTopics.vue
  15. +4
    -4
      web_src/less/openi.less

+ 0
- 10
models/user_business_analysis.go View File

@@ -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
}

+ 6
- 1
options/locale/locale_en-US.ini View File

@@ -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.


+ 5
- 0
options/locale/locale_zh-CN.ini View File

@@ -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=在项目设置中启用合并选项或者手工合并请求。


+ 5
- 1
routers/repo/user_data_analysis.go View File

@@ -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)


+ 38
- 0
routers/repo/view.go View File

@@ -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


+ 2
- 2
templates/explore/dataset_search.tmpl View File

@@ -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>


+ 2
- 2
templates/explore/search.tmpl View File

@@ -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>


+ 23
- 11
templates/repo/cloudbrain/index.tmpl View File

@@ -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') {


+ 2
- 2
templates/repo/datasets/index.tmpl View File

@@ -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>



+ 15
- 0
templates/repo/home.tmpl View File

@@ -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}}


+ 1
- 6
templates/repo/issue/list.tmpl View File

@@ -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" .}}


+ 1
- 1
templates/repo/issue/search.tmpl View File

@@ -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>

+ 1
- 1
templates/user/dashboard/issues.tmpl View File

@@ -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>


+ 2
- 2
web_src/js/components/EditTopics.vue View File

@@ -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'
});


+ 4
- 4
web_src/less/openi.less View File

@@ -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;


Loading…
Cancel
Save