-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #351 from chester1000/client-coffee-clenup
style(app:client:coffee) client-side cleanup of .coffee files
- Loading branch information
Showing
16 changed files
with
186 additions
and
170 deletions.
There are no files selected for viewing
66 changes: 33 additions & 33 deletions
66
app/templates/client/app/account(auth)/account(coffee).coffee
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,35 +1,35 @@ | ||
'use strict' | ||
|
||
angular.module('<%= scriptAppName %>') | ||
<% if(filters.ngroute) { %>.config ($routeProvider) -> | ||
$routeProvider | ||
.when('/login', | ||
templateUrl: 'app/account/login/login.html' | ||
controller: 'LoginCtrl' | ||
) | ||
.when('/signup', | ||
templateUrl: 'app/account/signup/signup.html' | ||
controller: 'SignupCtrl' | ||
) | ||
.when('/settings', | ||
templateUrl: 'app/account/settings/settings.html' | ||
controller: 'SettingsCtrl', | ||
authenticate: true | ||
)<% } %><% if(filters.uirouter) { %>.config ($stateProvider) -> | ||
$stateProvider | ||
.state('login', | ||
url: '/login', | ||
templateUrl: 'app/account/login/login.html' | ||
controller: 'LoginCtrl' | ||
) | ||
.state('signup', | ||
url: '/signup', | ||
templateUrl: 'app/account/signup/signup.html' | ||
controller: 'SignupCtrl' | ||
) | ||
.state('settings', | ||
url: '/settings', | ||
templateUrl: 'app/account/settings/settings.html' | ||
controller: 'SettingsCtrl', | ||
authenticate: true | ||
)<% } %> | ||
angular.module '<%= scriptAppName %>' | ||
<% if(filters.ngroute) { %>.config ($routeProvider) -> | ||
$routeProvider | ||
.when '/login', | ||
templateUrl: 'app/account/login/login.html' | ||
controller: 'LoginCtrl' | ||
|
||
.when '/signup', | ||
templateUrl: 'app/account/signup/signup.html' | ||
controller: 'SignupCtrl' | ||
|
||
.when '/settings', | ||
templateUrl: 'app/account/settings/settings.html' | ||
controller: 'SettingsCtrl' | ||
authenticate: true | ||
<% } %><% if(filters.uirouter) { %>.config ($stateProvider) -> | ||
$stateProvider | ||
.state 'login', | ||
url: '/login' | ||
templateUrl: 'app/account/login/login.html' | ||
controller: 'LoginCtrl' | ||
|
||
.state 'signup', | ||
url: '/signup' | ||
templateUrl: 'app/account/signup/signup.html' | ||
controller: 'SignupCtrl' | ||
|
||
.state 'settings', | ||
url: '/settings' | ||
templateUrl: 'app/account/settings/settings.html' | ||
controller: 'SettingsCtrl' | ||
authenticate: true | ||
<% } %> |
11 changes: 7 additions & 4 deletions
11
app/templates/client/app/account(auth)/login/login.controller(coffee).coffee
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
9 changes: 6 additions & 3 deletions
9
app/templates/client/app/account(auth)/settings/settings.controller(coffee).coffee
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,14 +1,17 @@ | ||
'use strict' | ||
|
||
angular.module('<%= scriptAppName %>').controller 'SettingsCtrl', ($scope, User, Auth) -> | ||
angular.module '<%= scriptAppName %>' | ||
.controller 'SettingsCtrl', ($scope, User, Auth) -> | ||
$scope.errors = {} | ||
$scope.changePassword = (form) -> | ||
$scope.submitted = true | ||
|
||
if form.$valid | ||
Auth.changePassword($scope.user.oldPassword, $scope.user.newPassword).then(-> | ||
Auth.changePassword $scope.user.oldPassword, $scope.user.newPassword | ||
.then -> | ||
$scope.message = 'Password successfully changed.' | ||
).catch -> | ||
|
||
.catch -> | ||
form.password.$setValidity 'mongoose', false | ||
$scope.errors.other = 'Incorrect password' | ||
$scope.message = '' |
10 changes: 6 additions & 4 deletions
10
app/templates/client/app/account(auth)/signup/signup.controller(coffee).coffee
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
26 changes: 13 additions & 13 deletions
26
app/templates/client/app/admin(auth)/admin(coffee).coffee
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,15 +1,15 @@ | ||
'use strict' | ||
|
||
angular.module('<%= scriptAppName %>') | ||
<% if(filters.ngroute) { %>.config ($routeProvider) -> | ||
$routeProvider | ||
.when('/admin', | ||
templateUrl: 'app/admin/admin.html' | ||
controller: 'AdminCtrl' | ||
)<% } %><% if(filters.uirouter) { %>.config ($stateProvider) -> | ||
$stateProvider | ||
.state('admin', | ||
url: '/admin', | ||
templateUrl: 'app/admin/admin.html' | ||
controller: 'AdminCtrl' | ||
)<% } %> | ||
angular.module '<%= scriptAppName %>' | ||
<% if(filters.ngroute) { %>.config ($routeProvider) -> | ||
$routeProvider | ||
.when '/admin', | ||
templateUrl: 'app/admin/admin.html' | ||
controller: 'AdminCtrl' | ||
<% } %><% if(filters.uirouter) { %>.config ($stateProvider) -> | ||
$stateProvider | ||
.state 'admin', | ||
url: '/admin' | ||
templateUrl: 'app/admin/admin.html' | ||
controller: 'AdminCtrl' | ||
<% } %> |
9 changes: 6 additions & 3 deletions
9
app/templates/client/app/admin(auth)/admin.controller(coffee).coffee
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,10 +1,13 @@ | ||
'use strict' | ||
|
||
angular.module('<%= scriptAppName %>').controller 'AdminCtrl', ($scope, $http, Auth, User) -> | ||
$http.get('/api/users').success (users) -> | ||
angular.module '<%= scriptAppName %>' | ||
.controller 'AdminCtrl', ($scope, $http, Auth, User) -> | ||
|
||
$http.get '/api/users' | ||
.success (users) -> | ||
$scope.users = users | ||
|
||
$scope.delete = (user) -> | ||
User.remove id: user._id | ||
angular.forEach $scope.users, (u, i) -> | ||
$scope.users.splice i, 1 if u is user | ||
$scope.users.splice i, 1 if u is user |
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,40 +1,39 @@ | ||
'use strict' | ||
|
||
angular.module('<%= scriptAppName %>', [<%= angularModules %>]) | ||
<% if(filters.ngroute) { %>.config (($routeProvider, $locationProvider<% if(filters.auth) { %>, $httpProvider<% } %>) -> | ||
$routeProvider | ||
.otherwise | ||
redirectTo: '/' | ||
angular.module '<%= scriptAppName %>', [<%= angularModules %>] | ||
<% if(filters.ngroute) { %>.config ($routeProvider, $locationProvider<% if(filters.auth) { %>, $httpProvider<% } %>) -> | ||
$routeProvider | ||
.otherwise | ||
redirectTo: '/' | ||
|
||
$locationProvider.html5Mode true<% if(filters.auth) { %> | ||
$httpProvider.interceptors.push 'authInterceptor'<% } %> | ||
)<% } %><% if(filters.uirouter) { %>.config (($stateProvider, $urlRouterProvider, $locationProvider<% if(filters.auth) { %>, $httpProvider<% } %>) -> | ||
$urlRouterProvider | ||
.otherwise('/') | ||
$locationProvider.html5Mode true<% if(filters.auth) { %> | ||
$httpProvider.interceptors.push 'authInterceptor'<% } %> | ||
<% } %><% if(filters.uirouter) { %>.config ($stateProvider, $urlRouterProvider, $locationProvider<% if(filters.auth) { %>, $httpProvider<% } %>) -> | ||
$urlRouterProvider | ||
.otherwise '/' | ||
|
||
$locationProvider.html5Mode true<% if(filters.auth) { %> | ||
$httpProvider.interceptors.push 'authInterceptor'<% } %> | ||
)<% } %><% if(filters.auth) { %> | ||
.factory('authInterceptor', ($rootScope, $q, $cookieStore, $location) -> | ||
# Add authorization token to headers | ||
request: (config) -> | ||
config.headers = config.headers or {} | ||
config.headers.Authorization = 'Bearer ' + $cookieStore.get('token') if $cookieStore.get('token') | ||
config | ||
$locationProvider.html5Mode true<% if(filters.auth) { %> | ||
$httpProvider.interceptors.push 'authInterceptor'<% } %> | ||
<% } %><% if(filters.auth) { %> | ||
.factory 'authInterceptor', ($rootScope, $q, $cookieStore, $location) -> | ||
# Add authorization token to headers | ||
request: (config) -> | ||
config.headers = config.headers or {} | ||
config.headers.Authorization = 'Bearer ' + $cookieStore.get 'token' if $cookieStore.get 'token' | ||
config | ||
|
||
# Intercept 401s and redirect you to login | ||
responseError: (response) -> | ||
if response.status is 401 | ||
$location.path '/login' | ||
# remove any stale tokens | ||
$cookieStore.remove 'token' | ||
$q.reject response | ||
else | ||
$q.reject response | ||
) | ||
.run (($rootScope, $location, Auth) -> | ||
# Redirect to login if route requires auth and you're not logged in | ||
$rootScope.$on <% if(filters.ngroute) { %>'$routeChangeStart'<% } %><% if(filters.uirouter) { %>'$stateChangeStart'<% } %>, (event, next) -> | ||
Auth.isLoggedInAsync (loggedIn) -> | ||
$location.path "/login" if next.authenticate and not loggedIn | ||
)<% } %> | ||
# Intercept 401s and redirect you to login | ||
responseError: (response) -> | ||
if response.status is 401 | ||
$location.path '/login' | ||
# remove any stale tokens | ||
$cookieStore.remove 'token' | ||
|
||
$q.reject response | ||
|
||
.run ($rootScope, $location, Auth) -> | ||
# Redirect to login if route requires auth and you're not logged in | ||
$rootScope.$on <% if(filters.ngroute) { %>'$routeChangeStart'<% } %><% if(filters.uirouter) { %>'$stateChangeStart'<% } %>, (event, next) -> | ||
Auth.isLoggedInAsync (loggedIn) -> | ||
$location.path "/login" if next.authenticate and not loggedIn | ||
<% } %> |
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,15 +1,15 @@ | ||
'use strict' | ||
|
||
angular.module('<%= scriptAppName %>') | ||
<% if(filters.ngroute) { %>.config ($routeProvider) -> | ||
$routeProvider | ||
.when('/', | ||
templateUrl: 'app/main/main.html' | ||
controller: 'MainCtrl' | ||
)<% } %><% if(filters.uirouter) { %>.config ($stateProvider) -> | ||
$stateProvider | ||
.state('main', | ||
url: '/', | ||
templateUrl: 'app/main/main.html' | ||
controller: 'MainCtrl' | ||
)<% } %> | ||
angular.module '<%= scriptAppName %>' | ||
<% if(filters.ngroute) { %>.config ($routeProvider) -> | ||
$routeProvider | ||
.when '/', | ||
templateUrl: 'app/main/main.html' | ||
controller: 'MainCtrl' | ||
<% } %><% if(filters.uirouter) { %>.config ($stateProvider) -> | ||
$stateProvider | ||
.state 'main', | ||
url: '/' | ||
templateUrl: 'app/main/main.html' | ||
controller: 'MainCtrl' | ||
<% } %> |
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
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
Oops, something went wrong.