mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 20:31:10 +00:00
Merge pull request #1545 from jeffastorey/active-repos
#1533 first cut to show only active repos initially
This commit is contained in:
commit
51607488cd
5 changed files with 105 additions and 22 deletions
|
@ -30,6 +30,7 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
|
||||||
e.Use(token.Refresh)
|
e.Use(token.Refresh)
|
||||||
|
|
||||||
e.GET("/", web.ShowIndex)
|
e.GET("/", web.ShowIndex)
|
||||||
|
e.GET("/repos", web.ShowAllRepos)
|
||||||
e.GET("/login", web.ShowLogin)
|
e.GET("/login", web.ShowLogin)
|
||||||
e.GET("/login/form", web.ShowLoginForm)
|
e.GET("/login/form", web.ShowLoginForm)
|
||||||
e.GET("/logout", web.GetLogout)
|
e.GET("/logout", web.GetLogout)
|
||||||
|
@ -163,7 +164,7 @@ func normalize(h http.Handler) http.Handler {
|
||||||
|
|
||||||
parts := strings.Split(r.URL.Path, "/")[1:]
|
parts := strings.Split(r.URL.Path, "/")[1:]
|
||||||
switch parts[0] {
|
switch parts[0] {
|
||||||
case "settings", "api", "login", "logout", "", "authorize", "hook", "static", "gitlab":
|
case "settings", "repos", "api", "login", "logout", "", "authorize", "hook", "static", "gitlab":
|
||||||
// no-op
|
// no-op
|
||||||
default:
|
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"] Available 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
|
extends base
|
||||||
|
|
||||||
block append head
|
block append head
|
||||||
title Dashboard
|
title Available Repositories
|
||||||
|
|
||||||
block header
|
block header
|
||||||
ol
|
ol
|
||||||
li Dashboard
|
li Available Repositories
|
||||||
|
|
||||||
|
ul.nav.nav-tabs
|
||||||
|
li.nav-item
|
||||||
|
a.nav-link[href="/"] Active Repositories
|
||||||
|
li.nav-item
|
||||||
|
a.nav-link.active[href="/repos"] Available Repositories
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div.container
|
div.container
|
||||||
|
@ -13,27 +19,29 @@ block content
|
||||||
div.alert.alert-info
|
div.alert.alert-info
|
||||||
| Your repository list is empty.
|
| Your repository list is empty.
|
||||||
|
|
||||||
div.row.repo-row
|
else
|
||||||
input.repo-search[type="search"][placeholder="Filter..."]
|
div.row.repo-row
|
||||||
div.repo-list
|
input.repo-search[type="search"][placeholder="Filter..."]
|
||||||
each $repo in Repos
|
div.repo-list
|
||||||
div.col-sm-4
|
each $repo in Repos
|
||||||
a.card[href="/"+$repo.FullName]
|
div.col-sm-4
|
||||||
div.card-header
|
a.card[href="/"+$repo.FullName]
|
||||||
if $repo.Avatar != ""
|
div.card-header
|
||||||
img.avatar[src=$repo.Avatar]
|
if $repo.Avatar != ""
|
||||||
else
|
img.avatar[src=$repo.Avatar]
|
||||||
img.avatar[src="/static/images/dummy.png"]
|
else
|
||||||
div.card-block
|
img.avatar[src="/static/images/dummy.png"]
|
||||||
h3.login #{$repo.Name}
|
div.card-block
|
||||||
div.full_name.hidden #{$repo.FullName}
|
h3.login #{$repo.Name}
|
||||||
|
div.full_name.hidden #{$repo.FullName}
|
||||||
|
|
||||||
block append scripts
|
block append scripts
|
||||||
if len(Repos) != 0
|
if len(Repos) != 0
|
||||||
script
|
script
|
||||||
$(window).load(function(){
|
$(window).load(function(){
|
||||||
$(".repo-list").searcher({
|
$(".repo-list").searcher({
|
||||||
itemSelector: ".col-sm-4",
|
itemSelector: ".col-sm-4",
|
||||||
textSelector: ".full_name",
|
textSelector: ".full_name",
|
||||||
inputSelector: ".repo-search"
|
inputSelector: ".repo-search"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,6 +17,7 @@ package template
|
||||||
//go:generate sh -c "amberc amber/users.amber > amber_gen/users.html"
|
//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/user.amber > amber_gen/user.html"
|
||||||
//go:generate sh -c "amberc amber/nodes.amber > amber_gen/nodes.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/
|
//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
|
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{
|
c.HTML(200, "repos.html", gin.H{
|
||||||
"User": user,
|
"User": user,
|
||||||
"Repos": repos,
|
"Repos": repos,
|
||||||
|
|
Loading…
Reference in a new issue