codecombat/app/views/admin/MainAdminView.coffee

38 lines
998 B
CoffeeScript
Raw Normal View History

2014-02-26 17:14:43 -05:00
{backboneFailure, genericFailure} = require 'lib/errors'
RootView = require 'views/kinds/RootView'
2014-01-03 13:32:13 -05:00
template = require 'templates/admin'
module.exports = class MainAdminView extends RootView
2014-06-30 22:16:26 -04:00
id: 'admin-view'
2014-01-03 13:32:13 -05:00
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: ->
2014-06-30 22:16:26 -04:00
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
2014-06-30 22:16:26 -04:00
type: 'POST',
url: '/auth/spy'
2014-02-26 17:14:43 -05:00
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()