Implemented groups
This commit is contained in:
25
pages/groups/groups.go
Normal file
25
pages/groups/groups.go
Normal file
@ -0,0 +1,25 @@
|
||||
package groups
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
groups, err := arn.FilterGroups(func(group *arn.Group) bool {
|
||||
return !group.IsDraft
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Error fetching groups", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Groups(groups, user))
|
||||
}
|
21
pages/groups/groups.pixy
Normal file
21
pages/groups/groups.pixy
Normal file
@ -0,0 +1,21 @@
|
||||
component Groups(groups []*arn.Group, user *arn.User)
|
||||
.tabs
|
||||
Tab("Groups", "users", "/groups")
|
||||
|
||||
h1.page-title Groups
|
||||
|
||||
.buttons
|
||||
if user != nil
|
||||
if user.DraftIndex().GroupID == ""
|
||||
button.action(data-action="newObject", data-trigger="click", data-type="group")
|
||||
Icon("plus")
|
||||
span New group
|
||||
else
|
||||
a.button.ajax(href="/group/" + user.DraftIndex().GroupID + "/edit")
|
||||
Icon("pencil")
|
||||
span Edit draft
|
||||
|
||||
.groups
|
||||
each group in groups
|
||||
.group
|
||||
h3= group.Name
|
Reference in New Issue
Block a user