Merge branch 'master' of ssh://git.bullercodeworks.com:2200/brian/gjvote
This commit is contained in:
commit
153b869a98
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,3 +5,7 @@ div.content {
|
||||
div.bottom-space {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
img.thumbnail {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ div.horizontal-scroll {
|
||||
}
|
||||
|
||||
img.thumbnail {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ function showModal(options) {
|
||||
}
|
||||
}
|
||||
modal.style.visibility = 'visible';
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
function hideModal() {
|
||||
|
1
main.go
1
main.go
@ -103,6 +103,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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
<form class="pure-form pure-form-aligned" action="/admin/games/{{ $uuid }}/save" method="POST">
|
||||
<fieldset>
|
||||
<div class="left big-space">
|
||||
<a name="game" />
|
||||
<h3>Team Game</h3>
|
||||
<div class="pure-control-group">
|
||||
<label class="control-label" for="gamename">Game Name</label>
|
||||
@ -34,12 +35,12 @@
|
||||
</div>
|
||||
<div class="pure-control-group">
|
||||
<label class="control-label">Screenshots</label>
|
||||
<div class="center-all horizontal-scroll thumbnail-container">
|
||||
<div class="center-all horizontal-scroll thumbnail-container" id="thumbnail-container">
|
||||
{{ if not .TemplateData.Game.Screenshots }}
|
||||
<a style="margin-top:40px;" class="center-all pure-button pure-button-primary" href="javascript:toggleUploadSSForm();">Upload Screenshot</a>
|
||||
{{ else }}
|
||||
{{ range $i, $v := .TemplateData.Game.Screenshots }}
|
||||
<img class="thumbnail" alt="{{ $v.Description }}" src="{{ $v.Image }}" />
|
||||
<img data-teamid="{{ $uuid }}" data-ssid="{{ $v.UUID }}" class="thumbnail" alt="{{ $v.Description }}" src="data:image/png;base64,{{ $v.Image }}" />
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
@ -122,6 +123,10 @@
|
||||
<button type="submit" class="pull-right space-sides pure-button pure-button-primary">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
<div id="editscreenshotform" style="display:none;">
|
||||
<div id="editss-container" class="pure-control-group" style="margin-bottom:50px;">
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
snack.listener(
|
||||
{node:document.getElementById('btnDeleteTeam'),event:'click'},
|
||||
@ -143,6 +148,43 @@
|
||||
});
|
||||
}
|
||||
);
|
||||
snack.listener(
|
||||
{
|
||||
node:document.getElementById('thumbnail-container'),
|
||||
event:'click',
|
||||
delegate: function(node) {
|
||||
return node.getElementsByTagName('img');
|
||||
}
|
||||
},
|
||||
function() {
|
||||
showEditScreenShotModal(snack.wrap(this)[0]);
|
||||
}
|
||||
);
|
||||
|
||||
function showEditScreenShotModal(img) {
|
||||
var newImg = img.cloneNode();
|
||||
var editSSForm = document.getElementById('editscreenshotform');
|
||||
var cont = document.getElementById('editss-container');
|
||||
while(cont.hasChildNodes()) {
|
||||
cont.removeChild(cont.lastChild);
|
||||
}
|
||||
cont.appendChild(newImg);
|
||||
showModal({
|
||||
title: 'Edit Screenshot',
|
||||
bodyNode: editSSForm,
|
||||
buttons: [
|
||||
{ title: 'Delete', class: 'pure-button-error', position: 'right',
|
||||
click: function() {
|
||||
window.location = "/admin/games/{{ $uuid }}/screenshotdelete/"+img.dataset.ssid;
|
||||
}
|
||||
},
|
||||
{ title: 'Cancel', class: 'pure-button', position: 'right', click: hideModal }
|
||||
]
|
||||
});
|
||||
editSSForm.style.display="block";
|
||||
editSSForm.style.height="200px";
|
||||
}
|
||||
|
||||
function toggleUploadSSForm() {
|
||||
var uploadForm = document.getElementById('uploadscreenshotform');
|
||||
showModal({
|
||||
|
Loading…
Reference in New Issue
Block a user