Working on issue and install page

tokarchuk/v1.17
Unknown 11 years ago
parent f76eb8a666
commit 34f4af9ebf
  1. 6
      models/issue.go
  2. 1
      models/repo.go
  3. 12
      routers/repo/issue.go
  4. 60
      routers/user/user.go
  5. 54
      templates/install.tmpl
  6. 4
      templates/issue/list.tmpl
  7. 15
      templates/issue/user.tmpl

@ -136,6 +136,12 @@ func GetIssues(userId, repoId, posterId, milestoneId int64, page int, isClosed,
return issues, err return issues, err
} }
// GetUserIssueCount returns the number of issues that were created by given user in repository.
func GetUserIssueCount(userId, repoId int64) int64 {
count, _ := orm.Where("poster_id=?", userId).And("repo_id=?", repoId).Count(new(Issue))
return count
}
// UpdateIssue updates information of issue. // UpdateIssue updates information of issue.
func UpdateIssue(issue *Issue) error { func UpdateIssue(issue *Issue) error {
_, err := orm.Id(issue.Id).AllCols().Update(issue) _, err := orm.Id(issue.Id).AllCols().Update(issue)

@ -84,6 +84,7 @@ type Repository struct {
NumForks int NumForks int
NumIssues int NumIssues int
NumClosedIssues int NumClosedIssues int
NumOpenIssues int `xorm:"-"`
IsPrivate bool IsPrivate bool
IsBare bool IsBare bool
Created time.Time `xorm:"created"` Created time.Time `xorm:"created"`

@ -21,13 +21,21 @@ func Issues(ctx *middleware.Context) {
ctx.Data["Title"] = "Issues" ctx.Data["Title"] = "Issues"
ctx.Data["IsRepoToolbarIssues"] = true ctx.Data["IsRepoToolbarIssues"] = true
ctx.Data["IsRepoToolbarIssuesList"] = true ctx.Data["IsRepoToolbarIssuesList"] = true
ctx.Data["ViewType"] = "all"
milestoneId, _ := base.StrTo(ctx.Query("milestone")).Int() milestoneId, _ := base.StrTo(ctx.Query("milestone")).Int()
page, _ := base.StrTo(ctx.Query("page")).Int() page, _ := base.StrTo(ctx.Query("page")).Int()
var posterId int64 = 0
if ctx.Query("type") == "created_by" {
posterId = ctx.User.Id
ctx.Data["ViewType"] = "created_by"
}
ctx.Data["IssueCreatedCount"] = models.GetUserIssueCount(ctx.User.Id, ctx.Repo.Repository.Id)
// Get issues. // Get issues.
issues, err := models.GetIssues(0, ctx.Repo.Repository.Id, 0, issues, err := models.GetIssues(0, ctx.Repo.Repository.Id, posterId, int64(milestoneId), page,
int64(milestoneId), page, ctx.Query("state") == "closed", false, ctx.Query("labels"), ctx.Query("sortType")) ctx.Query("state") == "closed", false, ctx.Query("labels"), ctx.Query("sortType"))
if err != nil { if err != nil {
ctx.Handle(200, "issue.Issues: %v", err) ctx.Handle(200, "issue.Issues: %v", err)
return return

@ -286,6 +286,66 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
func Issues(ctx *middleware.Context) { func Issues(ctx *middleware.Context) {
ctx.Data["Title"] = "Your Issues" ctx.Data["Title"] = "Your Issues"
ctx.Data["ViewType"] = "all"
page, _ := base.StrTo(ctx.Query("page")).Int()
var posterId int64 = 0
if ctx.Query("type") == "created_by" {
posterId = ctx.User.Id
ctx.Data["ViewType"] = "created_by"
}
// Get all repositories.
repos, err := models.GetRepositories(ctx.User)
if err != nil {
ctx.Handle(200, "user.Issues(get repository)", err)
return
}
var closedIssueCount, createdByCount int
// Get all issues.
allIssues := make([]models.Issue, 0, 5*len(repos))
for i, repo := range repos {
issues, err := models.GetIssues(0, repo.Id, posterId, 0, page, false, false, "", "")
if err != nil {
ctx.Handle(200, "user.Issues(get issues)", err)
return
}
closedIssueCount += repo.NumClosedIssues
repos[i].NumOpenIssues = repo.NumIssues - repo.NumClosedIssues
allIssues = append(allIssues, issues...)
}
showIssues := make([]models.Issue, 0, len(allIssues))
isShowClosed := ctx.Query("state") == "closed"
ctx.Data["IsShowClosed"] = isShowClosed
// Get posters and filter issues.
for i := range allIssues {
u, err := models.GetUserById(allIssues[i].PosterId)
if err != nil {
ctx.Handle(200, "user.Issues(get poster): %v", err)
return
}
allIssues[i].Poster = u
if u.Id == ctx.User.Id {
createdByCount++
}
if isShowClosed == allIssues[i].IsClosed {
showIssues = append(showIssues, allIssues[i])
}
}
ctx.Data["Repos"] = repos
ctx.Data["Issues"] = showIssues
ctx.Data["AllIssueCount"] = len(allIssues)
ctx.Data["ClosedIssueCount"] = closedIssueCount
ctx.Data["OpenIssueCount"] = len(allIssues) - closedIssueCount
ctx.Data["CreatedByCount"] = createdByCount
ctx.HTML(200, "issue/user") ctx.HTML(200, "issue/user")
} }

@ -2,13 +2,12 @@
<div id="body" class="container"> <div id="body" class="container">
<form action="/install" method="post" class="form-horizontal card" id="install-card"> <form action="/install" method="post" class="form-horizontal card" id="install-card">
{{.CsrfTokenHtml}} {{.CsrfTokenHtml}}
<h3>Install Steps For First Running</h3> <h3>Install Steps For First-time Run</h3>
<div class="alert alert-danger form-error{{if .HasError}}{{else}} hidden{{end}}">{{.ErrorMsg}}</div> <div class="alert alert-danger form-error{{if .HasError}}{{else}} hidden{{end}}">{{.ErrorMsg}}</div>
<p class="help-block text-center">GoGits need MySQL or PostgreSQL server</p> <p class="help-block text-center">Gogs requires MySQL or PostgreSQL based on your choice</p>
<div class="form-group"> <div class="form-group">
<label class="col-md-3 control-label">Database Type: </label> <label class="col-md-3 control-label">Database Type: </label>
<div class="col-md-8"> <div class="col-md-8">
<select name="database" id="install-database" class="form-control"> <select name="database" id="install-database" class="form-control">
<option value="mysql">MySQL</option> <option value="mysql">MySQL</option>
@ -46,20 +45,24 @@
<input name="passwd" type="password" class="form-control" placeholder="Type mysql password" required="required"> <input name="passwd" type="password" class="form-control" placeholder="Type mysql password" required="required">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-md-3 control-label">Database: </label> <label class="col-md-3 control-label">Database Name: </label>
<div class="col-md-8"> <div class="col-md-8">
<input name="database" type="text" class="form-control" placeholder="Type mysql database name" value="gogs" required="required"> <input name="database" type="text" class="form-control" placeholder="Type mysql database name" value="gogs" required="required">
<p class="help-block">Recommend use INNODB engine with utf8_general_ci charset.</p> <p class="help-block">Recommend use INNODB engine with utf8_general_ci charset.</p>
</div> </div>
</div> </div>
<div class="form-group pgsql-setting hide"> <div class="form-group pgsql-setting hide">
<label class="col-md-3 text-right">SSL MODE: </label> <label class="col-md-3 control-label">SSL Mode: </label>
<div class="col-md-8"> <div class="col-md-8">
<input name="ssl-mode" type="checkbox" class="form-control"> <select name="ssl_mode" class="form-control">
<p class="help-block">Use SSL protocol to connect PostgreSQL.</p> <option value="disable">Disable</option>
<option value="require">Require</option>
<option value="verify-full">Verify Full</option>
</select>
</div> </div>
</div> </div>
</div> </div>
@ -74,15 +77,15 @@
</div> </div>
</div> </div>
<div class="form-group"> <!-- <div class="form-group">
<div class="col-md-8 col-md-offset-3"> <div class="col-md-8 col-md-offset-3">
<button class="btn btn-sm btn-info">Test Connection</button> <button class="btn btn-sm btn-info">Test Connection</button>
</div> </div>
</div> </div> -->
<hr/> <hr/>
<p class="help-block text-center">General settings for GoGits</p> <p class="help-block text-center">General Settings of Gogs</p>
<div class="form-group"> <div class="form-group">
<label class="col-md-3 control-label">Repository Path: </label> <label class="col-md-3 control-label">Repository Path: </label>
@ -98,8 +101,7 @@
<div class="col-md-8"> <div class="col-md-8">
<input name="system-user" type="text" class="form-control" placeholder="Type mysql password" value="root" required="required"> <input name="system-user" type="text" class="form-control" placeholder="Type mysql password" value="root" required="required">
<p class="help-block">The user has access to visit and run Gogs.</p>
<p class="help-block">The user has access to visit and run GoGits.</p>
</div> </div>
</div> </div>
@ -125,7 +127,7 @@
<hr/> <hr/>
<div class="form-group text-center"> <div class="form-group text-center">
<button class="btn btn-danger btn-lg">Install GoGits</button> <button class="btn btn-danger btn-lg">Install Gogs</button>
<button class="btn btn-default btn-sm" type="button" data-toggle="modal" data-target="#advance-options-modal"> <button class="btn btn-default btn-sm" type="button" data-toggle="modal" data-target="#advance-options-modal">
Advanced Options Advanced Options
</button> </button>
@ -163,20 +165,28 @@
<p class="text-center help-block">Notification Settings</p> <p class="text-center help-block">Notification Settings</p>
<div class="form-group"> <div class="form-group">
<label class="col-md-6 text-right">Enable Register Confirmation: </label> <div class="col-md-offset-3 col-md-7">
<div class="checkbox">
<div class="col-md-4"> <label>
<input name="system-user" type="checkbox" class="form-control"> <input name="system-user" type="checkbox">
<strong>Enable Register Confirmation</strong>
</label>
</div>
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-md-6 text-right">Enable Mail Notification: </label>
<div class="col-md-4"> <div class="form-group">
<input name="system-user" type="checkbox" class="form-control"> <div class="col-md-offset-3 col-md-7">
<div class="checkbox">
<label>
<input name="system-user" type="checkbox">
<strong>Enable Mail Notification</strong>
</label>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-success" data-dismiss="modal">Confirm</button> <button type="button" class="btn btn-success" data-dismiss="modal">Confirm</button>
</div> </div>

@ -6,9 +6,9 @@
<div id="issue"> <div id="issue">
<div class="col-md-3 filter-list"> <div class="col-md-3 filter-list">
<ul class="list-unstyled"> <ul class="list-unstyled">
<li><a href="#" class="active">All Issues <strong class="pull-right">{{.IssueCount}}</strong></a></li> <li><a href="/{{.RepositoryLink}}/issues"{{if eq .ViewType "all"}} class="active"{{end}}>All Issues <strong class="pull-right">{{.IssueCount}}</strong></a></li>
<!-- <li><a href="#">Assigned to you</a></li> --> <!-- <li><a href="#">Assigned to you</a></li> -->
<li><a href="#">Created by you</a></li> <li><a href="/{{.RepositoryLink}}/issues?type=created_by"{{if eq .ViewType "created_by"}} class="active"{{end}}>Created by you <strong class="pull-right">{{.IssueCreatedCount}}</strong></a></li>
<!-- <li><a href="#">Mentioned</a></li> --> <!-- <li><a href="#">Mentioned</a></li> -->
</ul> </ul>
</div> </div>

@ -16,21 +16,20 @@
<div id="issue"> <div id="issue">
<div class="col-md-3 filter-list"> <div class="col-md-3 filter-list">
<ul class="list-unstyled"> <ul class="list-unstyled">
<li><a href="#" class="active">In your repositories <strong class="pull-right">10</strong></a></li> <li><a href="/issues"{{if eq .ViewType "all"}} class="active"{{end}}>In your repositories <strong class="pull-right">{{.AllIssueCount}}</strong></a></li>
<!-- <li><a href="#">Assigned to you</a></li> -->
<li><a href="#">Created by you</a></li>
<!-- <li><a href="#">Assigned to you</a></li> --> <!-- <li><a href="#">Assigned to you</a></li> -->
<li><a href="/issues?type=created_by"{{if eq .ViewType "created_by"}} class="active"{{end}}>Created by you <strong class="pull-right">{{.CreatedByCount}}</strong></a></li>
<li><hr/></li> <li><hr/></li>
<li><a href="" class="sm">gogits/gogs <strong class="pull-right">12</strong></a></li> {{range .Repos}}
<li><a href="" class="sm">gogits/session <strong class="pull-right">8</strong></a></li> <li><a href="" class="sm">{{.OwnerId}}/{{.Name}} <strong class="pull-right">{{.NumOpenIssues}}</strong></a></li>
<li><a href="" class="sm">gogits/git <strong class="pull-right">2</strong></a></li> {{end}}
</ul> </ul>
</div> </div>
<div class="col-md-9"> <div class="col-md-9">
<div class="filter-option"> <div class="filter-option">
<div class="btn-group"> <div class="btn-group">
<a class="btn btn-default active issue-open" href="#">27 Open</a> <a class="btn btn-default issue-open{{if not .IsShowClosed}} active{{end}}" href="/issues">{{.OpenIssueCount}} Open</a>
<a class="btn btn-default issue-close" href="#">Close 128</a> <a class="btn btn-default issue-close{{if .IsShowClosed}} active{{end}}" href="/issues?state=closed">{{.ClosedIssueCount}} Close</a>
</div> </div>
</div> </div>
<div class="issues list-group"> <div class="issues list-group">

Loading…
Cancel
Save