mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 11:51:02 +00:00
#1533 first cut to show only active repos initially
This commit is contained in:
parent
1f336b456c
commit
b7d537fc5d
5 changed files with 100 additions and 17 deletions
|
@ -30,6 +30,7 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
|
|||
e.Use(token.Refresh)
|
||||
|
||||
e.GET("/", web.ShowIndex)
|
||||
e.GET("/repos", web.ShowAllRepos)
|
||||
e.GET("/login", web.ShowLogin)
|
||||
e.GET("/login/form", web.ShowLoginForm)
|
||||
e.GET("/logout", web.GetLogout)
|
||||
|
@ -163,7 +164,7 @@ func normalize(h http.Handler) http.Handler {
|
|||
|
||||
parts := strings.Split(r.URL.Path, "/")[1:]
|
||||
switch parts[0] {
|
||||
case "settings", "api", "login", "logout", "", "authorize", "hook", "static", "gitlab":
|
||||
case "settings", "repos", "api", "login", "logout", "", "authorize", "hook", "static", "gitlab":
|
||||
// no-op
|
||||
default:
|
||||
|
||||
|
|
46
template/amber/index.amber
Normal file
46
template/amber/index.amber
Normal file
|
@ -0,0 +1,46 @@
|
|||
extends base
|
||||
|
||||
block append head
|
||||
title Active Repositories
|
||||
|
||||
block header
|
||||
ol
|
||||
li Active Repositories
|
||||
|
||||
ul.nav.nav-tabs
|
||||
li.nav-item
|
||||
a.nav-link.active[href="/"] Active Repositories
|
||||
li.nav-item
|
||||
a.nav-link[href="/repos"] My Repositories
|
||||
|
||||
block content
|
||||
div.container
|
||||
if len(Repos) == 0
|
||||
div.alert.alert-info
|
||||
| Your repository list is empty.
|
||||
|
||||
else
|
||||
div.row.repo-row
|
||||
input.repo-search[type="search"][placeholder="Filter..."]
|
||||
div.repo-list
|
||||
each $repo in Repos
|
||||
div.col-sm-4
|
||||
a.card[href="/"+$repo.FullName]
|
||||
div.card-header
|
||||
if $repo.Avatar != ""
|
||||
img.avatar[src=$repo.Avatar]
|
||||
else
|
||||
img.avatar[src="/static/images/dummy.png"]
|
||||
div.card-block
|
||||
h3.login #{$repo.Name}
|
||||
div.full_name.hidden #{$repo.FullName}
|
||||
block append scripts
|
||||
if len(Repos) != 0
|
||||
script
|
||||
$(window).load(function(){
|
||||
$(".repo-list").searcher({
|
||||
itemSelector: ".col-sm-4",
|
||||
textSelector: ".full_name",
|
||||
inputSelector: ".repo-search"
|
||||
});
|
||||
});
|
|
@ -1,11 +1,17 @@
|
|||
extends base
|
||||
|
||||
block append head
|
||||
title Dashboard
|
||||
title All Repositories
|
||||
|
||||
block header
|
||||
ol
|
||||
li Dashboard
|
||||
li All Repositories
|
||||
|
||||
ul.nav.nav-tabs
|
||||
li.nav-item
|
||||
a.nav-link[href="/"] Active Repositories
|
||||
li.nav-item
|
||||
a.nav-link.active[href="/repos"] My Repositories
|
||||
|
||||
block content
|
||||
div.container
|
||||
|
@ -13,20 +19,22 @@ block content
|
|||
div.alert.alert-info
|
||||
| Your repository list is empty.
|
||||
|
||||
div.row.repo-row
|
||||
input.repo-search[type="search"][placeholder="Filter..."]
|
||||
div.repo-list
|
||||
each $repo in Repos
|
||||
div.col-sm-4
|
||||
a.card[href="/"+$repo.FullName]
|
||||
div.card-header
|
||||
if $repo.Avatar != ""
|
||||
img.avatar[src=$repo.Avatar]
|
||||
else
|
||||
img.avatar[src="/static/images/dummy.png"]
|
||||
div.card-block
|
||||
h3.login #{$repo.Name}
|
||||
div.full_name.hidden #{$repo.FullName}
|
||||
else
|
||||
div.row.repo-row
|
||||
input.repo-search[type="search"][placeholder="Filter..."]
|
||||
div.repo-list
|
||||
each $repo in Repos
|
||||
div.col-sm-4
|
||||
a.card[href="/"+$repo.FullName]
|
||||
div.card-header
|
||||
if $repo.Avatar != ""
|
||||
img.avatar[src=$repo.Avatar]
|
||||
else
|
||||
img.avatar[src="/static/images/dummy.png"]
|
||||
div.card-block
|
||||
h3.login #{$repo.Name}
|
||||
div.full_name.hidden #{$repo.FullName}
|
||||
|
||||
block append scripts
|
||||
if len(Repos) != 0
|
||||
script
|
||||
|
|
|
@ -17,6 +17,7 @@ package template
|
|||
//go:generate sh -c "amberc amber/users.amber > amber_gen/users.html"
|
||||
//go:generate sh -c "amberc amber/user.amber > amber_gen/user.html"
|
||||
//go:generate sh -c "amberc amber/nodes.amber > amber_gen/nodes.html"
|
||||
//go:generate sh -c "amberc amber/index.amber > amber_gen/index.html"
|
||||
|
||||
//go:generate go-bindata -pkg template -o template_gen.go amber_gen/
|
||||
|
||||
|
|
27
web/pages.go
27
web/pages.go
|
@ -29,6 +29,33 @@ func ShowIndex(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// filter to only show the currently active ones
|
||||
activeRepos, err := store.GetRepoListOf(c,repos)
|
||||
if err != nil {
|
||||
c.String(400, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.HTML(200, "index.html", gin.H{
|
||||
"User": user,
|
||||
"Repos": activeRepos,
|
||||
})
|
||||
}
|
||||
|
||||
func ShowAllRepos(c *gin.Context) {
|
||||
user := session.User(c)
|
||||
if user == nil {
|
||||
c.Redirect(http.StatusSeeOther, "/login")
|
||||
return
|
||||
}
|
||||
|
||||
// get the repository list from the cache
|
||||
repos, err := cache.GetRepos(c, user)
|
||||
if err != nil {
|
||||
c.String(400, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.HTML(200, "repos.html", gin.H{
|
||||
"User": user,
|
||||
"Repos": repos,
|
||||
|
|
Loading…
Reference in a new issue