2014-02-26 17:14:43 -05:00
|
|
|
{backboneFailure, genericFailure} = require 'lib/errors'
|
2014-07-17 20:16:32 -04:00
|
|
|
RootView = require 'views/kinds/RootView'
|
2014-01-03 13:32:13 -05:00
|
|
|
template = require 'templates/admin'
|
|
|
|
|
2014-07-17 20:16:32 -04:00
|
|
|
module.exports = class AdminView extends RootView
|
2014-06-30 22:16:26 -04:00
|
|
|
id: 'admin-view'
|
2014-01-03 13:32:13 -05:00
|
|
|
template: template
|
2014-04-25 19:57:42 -04:00
|
|
|
|
2014-02-26 17:14:43 -05:00
|
|
|
events:
|
|
|
|
'click #enter-espionage-mode': 'enterEspionageMode'
|
2014-06-09 05:59:27 -04:00
|
|
|
'click #increment-button': 'incrementUserAttribute'
|
2014-04-25 19:57:42 -04:00
|
|
|
|
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-04-25 19:57:42 -04:00
|
|
|
|
2014-02-26 17:14:43 -05:00
|
|
|
postData =
|
|
|
|
usernameLower: username
|
|
|
|
emailLower: userEmail
|
2014-04-25 19:57:42 -04:00
|
|
|
|
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-04-25 19:57:42 -04:00
|
|
|
|
2014-02-26 17:14:43 -05:00
|
|
|
espionageSuccess: (model) ->
|
|
|
|
window.location.reload()
|
2014-04-25 19:57:42 -04:00
|
|
|
|
2014-02-26 17:14:43 -05:00
|
|
|
espionageFailure: (jqxhr, status,error)->
|
|
|
|
console.log "There was an error entering espionage mode: #{error}"
|
2014-06-09 05:59:27 -04:00
|
|
|
|
|
|
|
incrementUserAttribute: (e) ->
|
|
|
|
val = $('#increment-field').val()
|
|
|
|
me.set(val, me.get(val) + 1)
|
|
|
|
me.save()
|