codecombat/app/views/admin_view.coffee

38 lines
986 B
CoffeeScript
Raw Normal View History

2014-02-26 17:14:43 -05:00
{backboneFailure, genericFailure} = require 'lib/errors'
2014-01-03 13:32:13 -05:00
View = require 'views/kinds/RootView'
template = require 'templates/admin'
module.exports = class AdminView extends View
id: "admin-view"
template: template
2014-02-26 17:14:43 -05:00
events:
'click #enter-espionage-mode': 'enterEspionageMode'
'click #increment-button': 'incrementUserAttribute'
2014-02-26 17:14:43 -05:00
enterEspionageMode: ->
userEmail = $("#user-email").val().toLowerCase()
username = $("#user-username").val().toLowerCase()
2014-02-26 17:14:43 -05:00
postData =
usernameLower: username
emailLower: userEmail
2014-02-26 17:14:43 -05:00
$.ajax
type: "POST",
url: "/auth/spy"
data: postData
success: @espionageSuccess
error: @espionageFailure
2014-02-26 17:14:43 -05:00
espionageSuccess: (model) ->
window.location.reload()
2014-02-26 17:14:43 -05:00
espionageFailure: (jqxhr, status,error)->
console.log "There was an error entering espionage mode: #{error}"
incrementUserAttribute: (e) ->
val = $('#increment-field').val()
me.set(val, me.get(val) + 1)
me.save()