Merge pull request #1545 from jeffastorey/active-repos

#1533 first cut to show only active repos initially
This commit is contained in:
Brad Rydzewski 2016-03-31 17:48:32 -07:00
commit 51607488cd
5 changed files with 105 additions and 22 deletions

View file

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

View 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"
});
});

View file

@ -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,6 +19,7 @@ block content
div.alert.alert-info div.alert.alert-info
| Your repository list is empty. | Your repository list is empty.
else
div.row.repo-row div.row.repo-row
input.repo-search[type="search"][placeholder="Filter..."] input.repo-search[type="search"][placeholder="Filter..."]
div.repo-list div.repo-list
@ -27,6 +34,7 @@ block content
div.card-block div.card-block
h3.login #{$repo.Name} h3.login #{$repo.Name}
div.full_name.hidden #{$repo.FullName} div.full_name.hidden #{$repo.FullName}
block append scripts block append scripts
if len(Repos) != 0 if len(Repos) != 0
script script

View file

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

View file

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