Advertisement
Guest User

appcoffee.coffee

a guest
Apr 13th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict'
  2.  
  3. UsrAdmApp = angular.module 'UsrAdmApp', ['ngAnimate', 'ui.bootstrap']
  4.  
  5. UsrAdmApp.controller 'UsrAdmCtrl', class
  6.  
  7.     constructor: (@$scope, @$http, @$timeout) ->
  8.         # Init scope
  9.         @$scope.show_form = true
  10.         @$scope.show_ok = false
  11.         @$scope.show_invalid = false
  12.         @$scope.uploading = false
  13.         @$scope.user = {
  14.             name: username,
  15.             token: token
  16.         }
  17.    
  18.         # Alert Handling
  19.         @$scope.alerts = []
  20.         @$scope.closeAlert = (index) ->
  21.             @$scope.alerts.splice(index, 1)
  22.    
  23.         # Update password to server
  24.         @$scope.update = (user) ->
  25.             @$scope.uploading = true
  26.             @$http.post("changePassword", user).success(
  27.                 (data, status, headers, config) ->
  28.                     @$scope.uploading = false
  29.                     if data["errors"].length > 0
  30.                         @$scope.alerts = $scope.alerts.concat(data["errors"])
  31.                         if data["can_retry"] is 0
  32.                             @$scope.show_form = false
  33.                             @$scope.show_ok = false
  34.                             @$scope.show_invalid = true
  35.                     else
  36.                         @$scope.show_form = false
  37.                         @$scope.show_ok = true
  38.                         @$scope.show_invalid = false
  39.             ).error(
  40.                 (data, status, headers, config) ->
  41.                     @$scope.uploading = false
  42.                     @$scope.alerts.push({
  43.                         type: "danger",
  44.                         msg: "Error during communication with server, you may try later"
  45.                     })
  46.             )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement