diff --git a/admin_games.go b/admin_games.go index 3d6bbb4..72b6e5f 100644 --- a/admin_games.go +++ b/admin_games.go @@ -15,10 +15,22 @@ func handleAdminGames(w http.ResponseWriter, req *http.Request, page *pageData) teamId := vars["id"] if teamId == "" { // Games List - type gamesPageData struct { - Games []Game + type gamePage struct { + Game *Game + Team *Team } - page.TemplateData = gamesPageData{Games: dbGetAllGames()} + type gamesPageData struct { + Games []gamePage + } + gpd := new(gamesPageData) + allGames := dbGetAllGames() + for _, gm := range allGames { + gamePage := new(gamePage) + gamePage.Game = &gm + gamePage.Team = dbGetTeam(gm.TeamId) + gpd.Games = append(gpd.Games, *gamePage) + } + page.TemplateData = gpd page.SubTitle = "Games" page.show("admin-games.html", w) } else { @@ -39,6 +51,12 @@ func handleAdminGames(w http.ResponseWriter, req *http.Request, page *pageData) page.session.setFlashMessage("Error updating game: "+err.Error(), "error") } redirect("/admin/teams/"+teamId, w, req) + case "screenshotdelete": + ssid := vars["subid"] + if err := dbDeleteTeamGameScreenshot(teamId, ssid); err != nil { + page.session.setFlashMessage("Error deleting screenshot: "+err.Error(), "error") + } + redirect("/admin/teams/"+teamId, w, req) } } } diff --git a/assets/css/admin.css b/assets/css/admin.css index 4033ccf..c40846d 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -5,3 +5,7 @@ div.content { div.bottom-space { margin-bottom: 15px; } + +img.thumbnail { + cursor: pointer; +} diff --git a/assets/css/gjvote.css b/assets/css/gjvote.css index 6b2e344..cc79632 100644 --- a/assets/css/gjvote.css +++ b/assets/css/gjvote.css @@ -78,7 +78,6 @@ div.horizontal-scroll { } img.thumbnail { - width: 100px; height: 100px; } diff --git a/assets/js/gjvote.js b/assets/js/gjvote.js index a1ddb6a..759fd66 100644 --- a/assets/js/gjvote.js +++ b/assets/js/gjvote.js @@ -51,6 +51,7 @@ function showModal(options) { } } modal.style.visibility = 'visible'; + window.scrollTo(0, 0); } function hideModal() { diff --git a/main.go b/main.go index 7d42fd0..ffb369e 100644 --- a/main.go +++ b/main.go @@ -99,6 +99,7 @@ func main() { admin.HandleFunc("/{category}", handleAdmin) admin.HandleFunc("/{category}/{id}", handleAdmin) admin.HandleFunc("/{category}/{id}/{function}", handleAdmin) + admin.HandleFunc("/{category}/{id}/{function}/{subid}", handleAdmin) http.Handle("/", r) diff --git a/model_games.go b/model_games.go index 14a4cd4..4aea97e 100644 --- a/model_games.go +++ b/model_games.go @@ -16,6 +16,7 @@ type Game struct { type Screenshot struct { Description string Image string + UUID string } func dbUpdateTeamGame(teamId, name, desc string) error { @@ -101,6 +102,7 @@ func dbGetTeamGameScreenshot(teamId, ssId string) *Screenshot { var err error ssPath := []string{"teams", teamId, "game", "screenshots", ssId} ret := new(Screenshot) + ret.UUID = ssId if ret.Description, err = db.GetValue(ssPath, "description"); err != nil { return nil } diff --git a/templates/admin-addteam.html b/templates/admin-addteam.html index b202ce2..b9a801a 100644 --- a/templates/admin-addteam.html +++ b/templates/admin-addteam.html @@ -5,45 +5,6 @@ - -

Members

- - - - - - - - - - - - - - - - - -
NameSlack IDTwitterEmail
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
diff --git a/templates/admin-editteam.html b/templates/admin-editteam.html index e26cc8c..885b538 100644 --- a/templates/admin-editteam.html +++ b/templates/admin-editteam.html @@ -23,6 +23,7 @@
+

Team Game

@@ -34,12 +35,12 @@
-
+
{{ if not .TemplateData.Game.Screenshots }} Upload Screenshot {{ else }} {{ range $i, $v := .TemplateData.Game.Screenshots }} - {{ $v.Description }} + {{ $v.Description }} {{ end }} {{ end }}
@@ -122,6 +123,10 @@
+