Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
217 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 15 additions & 24 deletions
39
generators/js-framework/modules/angularjs/controllers/contact.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
(function() { | ||
angular.module('MyApp') | ||
.controller('ContactCtrl', ContactCtrl); | ||
|
||
ContactCtrl.$inject = ['$scope', 'Contact']; | ||
|
||
function ContactCtrl($scope, Contact) { | ||
var ctrl = this; | ||
ctrl.sendContactForm = sendContactForm; | ||
|
||
function sendContactForm() { | ||
Contact.send($scope.contact) | ||
.then(function(response) { | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: Array.isArray(response.data) ? response.data : [response.data] | ||
}; | ||
}); | ||
} | ||
} | ||
})(); | ||
.controller('ContactCtrl', function($scope, Contact) { | ||
$scope.sendContactForm = function() { | ||
Contact.send($scope.contact) | ||
.then(function(response) { | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: Array.isArray(response.data) ? response.data : [response.data] | ||
}; | ||
}); | ||
}; | ||
}); |
39 changes: 15 additions & 24 deletions
39
generators/js-framework/modules/angularjs/controllers/forgot.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
(function() { | ||
angular.module('MyApp') | ||
.controller('ForgotCtrl', ForgotCtrl); | ||
|
||
ForgotCtrl.$inject = ['$scope', 'Account']; | ||
|
||
function ForgotCtrl($scope, Account) { | ||
var ctrl = this; | ||
ctrl.forgotPassword = forgotPassword; | ||
|
||
function forgotPassword() { | ||
Account.forgotPassword($scope.user) | ||
.then(function(response) { | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: Array.isArray(response.data) ? response.data : [response.data] | ||
}; | ||
}); | ||
} | ||
} | ||
})(); | ||
.controller('ForgotCtrl', function($scope, Account) { | ||
$scope.forgotPassword = function() { | ||
Account.forgotPassword($scope.user) | ||
.then(function(response) { | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: Array.isArray(response.data) ? response.data : [response.data] | ||
}; | ||
}); | ||
}; | ||
}); |
43 changes: 16 additions & 27 deletions
43
generators/js-framework/modules/angularjs/controllers/header.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
(function() { | ||
angular.module('MyApp') | ||
.controller('HeaderCtrl', HeaderCtrl); | ||
|
||
HeaderCtrl.$inject = ['$scope', '$location', '$window', '$auth']; | ||
|
||
function HeaderCtrl($scope, $location, $window, $auth) { | ||
var ctrl = this; | ||
ctrl.isActive = isActive; | ||
ctrl.isAuthenticated = isAuthenticated; | ||
ctrl.logout = logout; | ||
|
||
function isActive(viewLocation) { | ||
return viewLocation === $location.path(); | ||
} | ||
|
||
function isAuthenticated() { | ||
return $auth.isAuthenticated(); | ||
} | ||
|
||
function logout() { | ||
$auth.logout(); | ||
delete $window.localStorage.user; | ||
$location.path('/'); | ||
} | ||
|
||
} | ||
})(); | ||
.controller('HeaderCtrl', function($scope, $location, $window, $auth) { | ||
$scope.isActive = function (viewLocation) { | ||
return viewLocation === $location.path(); | ||
}; | ||
|
||
$scope.isAuthenticated = function() { | ||
return $auth.isAuthenticated(); | ||
}; | ||
|
||
$scope.logout = function() { | ||
$auth.logout(); | ||
delete $window.localStorage.user; | ||
$location.path('/'); | ||
}; | ||
//= FOUNDATION_INIT_INDENT2 | ||
}); |
74 changes: 32 additions & 42 deletions
74
generators/js-framework/modules/angularjs/controllers/login.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,36 @@ | ||
(function() { | ||
angular.module('MyApp') | ||
.controller('LoginCtrl', LoginCtrl); | ||
.controller('LoginCtrl', function($scope, $rootScope, $location, $window, $auth) { | ||
$scope.login = function() { | ||
$auth.login($scope.user) | ||
.then(function(response) { | ||
$rootScope.currentUser = response.data.user; | ||
$window.localStorage.user = JSON.stringify(response.data.user); | ||
$location.path('/account'); | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: Array.isArray(response.data) ? response.data : [response.data] | ||
}; | ||
}); | ||
}; | ||
|
||
LoginCtrl.$inject = ['$scope', '$rootScope', '$location', '$window', '$auth']; | ||
|
||
function LoginCtrl($scope, $rootScope, $location, $window, $auth) { | ||
var ctrl = this; | ||
ctrl.login = login; | ||
ctrl.authenticate = authenticate; | ||
|
||
function login() { | ||
$auth.login($scope.user) | ||
.then(function(response) { | ||
$rootScope.currentUser = response.data.user; | ||
$window.localStorage.user = JSON.stringify(response.data.user); | ||
$location.path('/account'); | ||
}) | ||
.catch(function(response) { | ||
$scope.authenticate = function(provider) { | ||
$auth.authenticate(provider) | ||
.then(function(response) { | ||
$rootScope.currentUser = response.data.user; | ||
$window.localStorage.user = JSON.stringify(response.data.user); | ||
$location.path('/'); | ||
}) | ||
.catch(function(response) { | ||
if (response.error) { | ||
$scope.messages = { | ||
error: Array.isArray(response.data) ? response.data : [response.data] | ||
error: [{ msg: response.error }] | ||
}; | ||
}); | ||
} | ||
|
||
function authenticate(provider) { | ||
$auth.authenticate(provider) | ||
.then(function(response) { | ||
$rootScope.currentUser = response.data.user; | ||
$window.localStorage.user = JSON.stringify(response.data.user); | ||
$location.path('/'); | ||
}) | ||
.catch(function(response) { | ||
if (response.error) { | ||
$scope.messages = { | ||
error: [{ msg: response.error }] | ||
}; | ||
} else if (response.data) { | ||
$scope.messages = { | ||
error: [response.data] | ||
}; | ||
} | ||
}); | ||
} | ||
} | ||
})(); | ||
} else if (response.data) { | ||
$scope.messages = { | ||
error: [response.data] | ||
}; | ||
} | ||
}); | ||
}; | ||
}); |
156 changes: 70 additions & 86 deletions
156
generators/js-framework/modules/angularjs/controllers/profile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,76 @@ | ||
(function() { | ||
angular.module('MyApp') | ||
.controller('ContactCtrl', ContactCtrl); | ||
|
||
ContactCtrl.$inject = ['$scope', '$rootScope', '$location', '$window', '$auth', 'Account']; | ||
|
||
function ContactCtrl($scope, $rootScope, $location, $window, $auth, Account) { | ||
var ctrl = this; | ||
ctrl.updateProfile = updateProfile; | ||
ctrl.changePassword = changePassword; | ||
ctrl.link = link; | ||
ctrl.unlink = unlink; | ||
ctrl.deleteAccount = deleteAccount; | ||
ctrl.unlink = unlink; | ||
.controller('ProfileCtrl', function($scope, $rootScope, $location, $window, $auth, Account) { | ||
$scope.profile = $rootScope.currentUser; | ||
|
||
function updateProfile() { | ||
Account.updateProfile($scope.profile) | ||
.then(function(response) { | ||
$rootScope.currentUser = response.data.user; | ||
$window.localStorage.user = JSON.stringify(response.data.user); | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: Array.isArray(response.data) ? response.data : [response.data] | ||
}; | ||
}); | ||
} | ||
|
||
function changePassword() { | ||
Account.changePassword($scope.profile) | ||
.then(function(response) { | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: Array.isArray(response.data) ? response.data : [response.data] | ||
}; | ||
}); | ||
} | ||
$scope.updateProfile = function() { | ||
Account.updateProfile($scope.profile) | ||
.then(function(response) { | ||
$rootScope.currentUser = response.data.user; | ||
$window.localStorage.user = JSON.stringify(response.data.user); | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: Array.isArray(response.data) ? response.data : [response.data] | ||
}; | ||
}); | ||
}; | ||
|
||
function link(provider) { | ||
$auth.link(provider) | ||
.then(function(response) { | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$window.scrollTo(0, 0); | ||
$scope.messages = { | ||
error: [response.data] | ||
}; | ||
}); | ||
} | ||
$scope.changePassword = function() { | ||
Account.changePassword($scope.profile) | ||
.then(function(response) { | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: Array.isArray(response.data) ? response.data : [response.data] | ||
}; | ||
}); | ||
}; | ||
|
||
function unlink(provider) { | ||
$auth.unlink(provider) | ||
.then(function() { | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: [response.data] | ||
}; | ||
}); | ||
} | ||
$scope.link = function(provider) { | ||
$auth.link(provider) | ||
.then(function(response) { | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$window.scrollTo(0, 0); | ||
$scope.messages = { | ||
error: [response.data] | ||
}; | ||
}); | ||
}; | ||
$scope.unlink = function(provider) { | ||
$auth.unlink(provider) | ||
.then(function() { | ||
$scope.messages = { | ||
success: [response.data] | ||
}; | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: [response.data] | ||
}; | ||
}); | ||
}; | ||
|
||
function deleteAccount() { | ||
$scope.deleteAccount = function() { | ||
Account.deleteAccount() | ||
.then(function() { | ||
$auth.logout(); | ||
delete $window.localStorage.user; | ||
$location.path('/'); | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: [response.data] | ||
}; | ||
}); | ||
}; | ||
} | ||
} | ||
})(); | ||
$scope.deleteAccount = function() { | ||
Account.deleteAccount() | ||
.then(function() { | ||
$auth.logout(); | ||
delete $window.localStorage.user; | ||
$location.path('/'); | ||
}) | ||
.catch(function(response) { | ||
$scope.messages = { | ||
error: [response.data] | ||
}; | ||
}); | ||
}; | ||
}); |
Oops, something went wrong.