Resolved extreme lag on logging in for Owners, added Owner button to retrieve all teams on the server

This commit is contained in:
Deukhoofd 2016-02-28 17:06:27 +01:00
parent a7ee5c24ab
commit f737f48545
7 changed files with 38 additions and 14 deletions

View File

@ -98,13 +98,13 @@ $pokemon-list-height = 50px
margin-left -(@margin-right + @width)
vertical-align middle
cursor pointer
background-image URL('http://91.121.152.74:8000/Sprites/images/noshiny.png')
background-image URL('/Sprites/images/noshiny.png')
background-size cover
&.selected
background-image URL('http://91.121.152.74:8000/Sprites/images/shiny.png')
background-image URL('/Sprites/images/shiny.png')
.teambuilder .happiness-switch
display inline-block
position relative
@ -357,6 +357,9 @@ $pokemon-list-height = 50px
.add-new-team
margin 10px
.get-teams
margin 10px
.team-meta
font-size .75em
text-align right

View File

@ -6,12 +6,13 @@ class @TeambuilderView extends Backbone.View
events:
# Team view
'click .add-new-team': 'addNewTeamEvent'
'click .export-team': 'exportTeam'
'click .clone-team': 'cloneTeam'
'click .delete-team': 'deleteTeamEvent'
'click .go-to-team': 'clickTeam'
'click .import-team': 'renderImportTeamModal'
'click .add-new-team': 'addNewTeamEvent'
'click .export-team' : 'exportTeam'
'click .clone-team' : 'cloneTeam'
'click .delete-team' : 'deleteTeamEvent'
'click .go-to-team' : 'clickTeam'
'click .import-team' : 'renderImportTeamModal'
'click .get-teams' : 'getAllTeamsAdmin'
# Teambuild view
'click .change-format-dropdown a': 'changeTeamFormat'
@ -86,6 +87,10 @@ class @TeambuilderView extends Backbone.View
PokeBattle.TeamStore.add(team)
team.save()
getAllTeamsAdmin: (e) =>
console.log('this')
PokeBattle.primus.send('requestTeams', true)
addNewTeam: (team) =>
@addEmptyPokemon(team) while team.get('pokemon').length < 6
@$('.teambuilder_teams').append @teamTemplate({team, window})

View File

@ -4,3 +4,6 @@ h2 Your teams
!= window.JST['teambuilder/team']({team: team, window: window})
.button.button_blue.add-new-team Add new team
.button.import-team Import
if window.PokeBattle.username == "Deukhoofd" || window.PokeBattle.username == "thesuzerain"
.button.get-teams Get all teams

View File

@ -469,8 +469,8 @@ h1{font-family:"PT Sans Narrow","Helvetica Neue",sans-serif;font-size:2em;font-w
.teambuilder .species{float:left;width:180px;margin-left:-185px;}
.teambuilder .species .species_list{width:100%;}
.teambuilder .species .species_list .pbv{float:right;color:#888}
.teambuilder .shiny-switch{display:inline-block;width:14px;height:14px;margin-right:10px;margin-left:-24px;vertical-align:middle;cursor:pointer;background-image:URL('http://91.121.152.74:8000/Sprites/images/noshiny.png');-webkit-background-size:cover;-moz-background-size:cover;background-size:cover;}
.teambuilder .shiny-switch.selected{background-image:URL('http://91.121.152.74:8000/Sprites/images/shiny.png')}
.teambuilder .shiny-switch{display:inline-block;width:14px;height:14px;margin-right:10px;margin-left:-24px;vertical-align:middle;cursor:pointer;background-image:URL('/Sprites/images/noshiny.png');-webkit-background-size:cover;-moz-background-size:cover;background-size:cover;}
.teambuilder .shiny-switch.selected{background-image:URL('/Sprites/images/shiny.png')}
.teambuilder .happiness-switch{display:inline-block;position:relative;width:14px;height:14px;margin-left:10px;margin-right:-24px;cursor:pointer;vertical-align:middle;}
.teambuilder .happiness-switch:before,.teambuilder .happiness-switch:after{position:absolute;content:"";left:8px;top:0;width:8px;height:13px;background:#ff3c3c;-webkit-border-radius:7px 7px 0 0;border-radius:7px 7px 0 0;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-o-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg);-webkit-transform-origin:0 100%;-moz-transform-origin:0 100%;-o-transform-origin:0 100%;-ms-transform-origin:0 100%;transform-origin:0 100%}
.teambuilder .happiness-switch:after{left:0;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-o-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);-webkit-transform-origin:100% 100%;-moz-transform-origin:100% 100%;-o-transform-origin:100% 100%;-ms-transform-origin:100% 100%;transform-origin:100% 100%}
@ -531,6 +531,7 @@ h1{font-family:"PT Sans Narrow","Helvetica Neue",sans-serif;font-size:2em;font-w
.teambuilder .display_teams h2{margin-left:10px;margin-bottom:0}
.teambuilder .display_teams .select-team h2{-o-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;width:192px;margin:0;font-size:1.5em}
.teambuilder .display_teams .add-new-team{margin:10px}
.teambuilder .display_teams .get-teams{margin:10px}
.teambuilder .display_teams .team-meta{font-size:.75em;text-align:right;margin-top:10px}
.teambuilder .display_teams .team-pbv{margin-top:-5px}
.teambuilder .display_teams .team-tier{margin-top:-5px}

View File

@ -6287,6 +6287,7 @@
this.cloneTeam = __bind(this.cloneTeam, this);
this.resetTeams = __bind(this.resetTeams, this);
this.addNewTeam = __bind(this.addNewTeam, this);
this.getAllTeamsAdmin = __bind(this.getAllTeamsAdmin, this);
this.addNewTeamEvent = __bind(this.addNewTeamEvent, this);
this.addEmptyPokemon = __bind(this.addEmptyPokemon, this);
this.attachEventsToTeam = __bind(this.attachEventsToTeam, this);
@ -6311,6 +6312,7 @@
'click .delete-team': 'deleteTeamEvent',
'click .go-to-team': 'clickTeam',
'click .import-team': 'renderImportTeamModal',
'click .get-teams': 'getAllTeamsAdmin',
'click .change-format-dropdown a': 'changeTeamFormat',
'blur .team_name': 'blurTeamName',
'keypress .team_name': 'keypressTeamName',
@ -6399,6 +6401,11 @@
return team.save();
};
TeambuilderView.prototype.getAllTeamsAdmin = function(e) {
console.log('this');
return PokeBattle.primus.send('requestTeams', true);
};
TeambuilderView.prototype.addNewTeam = function(team) {
while (team.get('pokemon').length < 6) {
this.addEmptyPokemon(team);

View File

@ -1106,7 +1106,11 @@ buf.push(null == (jade.interp = window.JST['teambuilder/team']({team: team, wind
}
}).call(this);
buf.push("</div><div class=\"button button_blue add-new-team\">Add new team</div><div class=\"button import-team\">Import</div>");;return buf.join("");
buf.push("</div><div class=\"button button_blue add-new-team\">Add new team</div><div class=\"button import-team\">Import</div>");
if ( window.PokeBattle.username == "Deukhoofd" || window.PokeBattle.username == "thesuzerain")
{
buf.push("<div class=\"button get-teams\">Get all teams</div>");
};return buf.join("");
};
this["JST"]["user_list"] = function anonymous(locals

View File

@ -235,9 +235,10 @@ CLIENT_VERSION = assets.getVersion()
.save().then (team) ->
callback(team.id)
spark.on 'requestTeams', ->
spark.on 'requestTeams', (fetchall = false) ->
console.log(fetchall)
q = new database.Teams()
if user.authority != auth.levels.OWNER
if !(fetchall && user.authority == auth.levels.OWNER)
q = q.query('where', trainer_id: user.id)
q = q.query('orderBy', 'created_at')
.fetch()