Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 3283e71

Browse files
author
Nick Litwin
committed
Renamed services, fixed review API call
1 parent 2e8c8ab commit 3283e71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+351
-628
lines changed

app/account/account.routes.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
var states = {
1212
'auth': {
1313
parent: 'root',
14-
onEnter: ['$state', '$stateParams', 'tcAuth', function($state, $stateParams, tcAuth) {
15-
if (tcAuth.isAuthenticated()) {
14+
onEnter: ['$state', '$stateParams', 'TcAuthService', function($state, $stateParams, TcAuthService) {
15+
if (TcAuthService.isAuthenticated()) {
1616
// redirect to next if exists else dashboard
1717
if ($stateParams.next) {
1818
$log.debug('Redirecting: ' + $stateParams.next);
@@ -127,8 +127,8 @@
127127
},
128128
logout: {
129129
url: '/logout',
130-
controller: ['tcAuth', function(tcAuth) {
131-
tcAuth.logout();
130+
controller: ['TcAuthService', function(TcAuthService) {
131+
TcAuthService.logout();
132132
}]
133133
}
134134
};

app/account/login/login.controller.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44
angular.module('tc.account').controller('LoginController', LoginController);
55

6-
LoginController.$inject = ['$log', '$state', '$stateParams', 'tcAuth', 'authtoken', 'UserService'];
6+
LoginController.$inject = ['$log', '$state', '$stateParams', 'TcAuthService', 'AuthTokenService', 'UserService'];
77

8-
function LoginController($log, $state, $stateParams, tcAuth, authtoken, UserService) {
8+
function LoginController($log, $state, $stateParams, TcAuthService, AuthTokenService, UserService) {
99
var vm = this;
1010
vm.passwordReset = false;
1111
vm.usernameExists = true;
1212

1313
var redirect = function() {
1414
// check if the user is already logged in
15-
if (tcAuth.isAuthenticated()) {
15+
if (TcAuthService.isAuthenticated()) {
1616
// redirect to next if exists else dashboard
1717
if ($stateParams.next) {
1818
$log.debug('Redirecting: ' + $stateParams.next);
@@ -26,23 +26,23 @@
2626
// Handling social login stuff
2727
if ($stateParams.userJWTToken) {
2828
// user logged in
29-
authtoken.setV3Token($stateParams.userJWTToken);
29+
AuthTokenService.setV3Token($stateParams.userJWTToken);
3030
redirect();
3131
}
3232
if ($stateParams.status) {
3333
// handle social login callback
3434
var status = parseInt($stateParams.status);
3535
switch(status) {
3636
case 200:
37-
authtoken.getTokenFromAuth0Code($stateParams.code);
37+
AuthTokenService.getTokenFromAuth0Code($stateParams.code);
3838
break;
3939
case 401:
4040
default:
4141
vm.socialLoginError = status;
4242
break;
4343
}
4444
} else if ($stateParams.code && $stateParams.state) {
45-
authtoken.getTokenFromAuth0Code($stateParams.code).then(
45+
AuthTokenService.getTokenFromAuth0Code($stateParams.code).then(
4646
function(v3Token) {
4747
$log.debug('looged in using social');
4848
redirect();
@@ -59,7 +59,7 @@
5959
.catch(function() {
6060
// User exists
6161
vm.usernameExists = true;
62-
tcAuth.login(vm.username, vm.password).then(
62+
TcAuthService.login(vm.username, vm.password).then(
6363
function(data) {
6464
// success
6565
$log.debug('logged in');
@@ -82,7 +82,7 @@
8282
params = {next: $stateParams.next};
8383
}
8484
callbackUrl = $state.href('login', params, {absolute: true});
85-
tcAuth.socialLogin(backend, callbackUrl);
85+
TcAuthService.socialLogin(backend, callbackUrl);
8686
};
8787

8888
}

app/account/register/register.controller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
angular.module('tc.account').controller('RegisterController', RegisterController);
55

6-
RegisterController.$inject = ['$log', 'tcAuth', '$state'];
6+
RegisterController.$inject = ['$log', 'TcAuthService', '$state'];
77

8-
function RegisterController($log, tcAuth, $state) {
8+
function RegisterController($log, TcAuthService, $state) {
99
var vm = this;
1010

1111
vm.register = function() {
@@ -27,7 +27,7 @@
2727
}
2828
};
2929

30-
tcAuth.register(userInfo)
30+
TcAuthService.register(userInfo)
3131
.then(function(data) {
3232
$log.debug('registered successfully');
3333

app/account/reset-password-sent.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.reset-password-container
22
h1 Back on Track!
3-
3+
44
p We have sent you an email with a link to reset your password.
55

66
p Didn't receive an email? a(ui-sref="resetPasswordLink").Resend

app/account/reset-password/reset-password.controller.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33

44
angular.module('tc.account').controller('ResetPasswordController', ResetPasswordController);
55

6-
ResetPasswordController.$inject = ['$log', 'auth'];
6+
ResetPasswordController.$inject = ['$log'];
77

88
function ResetPasswordController($log) {
99
var vm = this;
1010

1111
vm.sendLink = function() {
1212
if (vm.resetPasswordForm.$valid) {
1313
// send link
14-
auth.initiateResetPassword(vm.email).then(
15-
function() {
16-
// success
17-
$state.go('resetPasswordLinkConfirmation');
18-
},
19-
function(err) {
20-
$log.error(err);
21-
}
22-
);
14+
// auth.initiateResetPassword(vm.email).then(
15+
// function() {
16+
// // success
17+
// $state.go('resetPasswordLinkConfirmation');
18+
// },
19+
// function(err) {
20+
// $log.error(err);
21+
// }
22+
// );
2323
}
2424
}
2525

app/index.jade

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ html
102102
script(src="account/reset-password/reset-password.controller.js")
103103
script(src="account/register/register.controller.js")
104104
script(src="account/login/login.controller.js")
105-
script(src="topcoder.module.js")
105+
script(src="services/services.module.js")
106106
script(src="services/user.service.js")
107107
script(src="services/tcAuth.service.js")
108108
script(src="services/srm.service.js")
@@ -117,6 +117,7 @@ html
117117
script(src="services/api.service.js")
118118
script(src="sample/sample.module.js")
119119
script(src="sample/sample.routes.js")
120+
script(src="topcoder.module.js")
120121
script(src="sample/sample.controller.js")
121122
script(src="peer-review/slideable.directive.js")
122123
script(src="peer-review/peer-review.routes.js")

app/layout/header/header.controller.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33

44
angular.module('tc.layout').controller('HeaderController', HeaderController);
55

6-
HeaderController.$inject = ['$window', '$state', '$stateParams', 'tcAuth', 'CONSTANTS', '$log', '$rootScope'];
6+
HeaderController.$inject = ['$window', '$state', '$stateParams', 'TcAuthService', 'CONSTANTS', '$log', '$rootScope'];
77

8-
function HeaderController($window, $state, $stateParams, tcAuth, CONSTANTS, $log, $rootScope) {
8+
function HeaderController($window, $state, $stateParams, TcAuthService, CONSTANTS, $log, $rootScope) {
99
var vm = this;
1010
vm.domain = CONSTANTS.domain;
11-
vm.login = tcAuth.login;
11+
vm.login = TcAuthService.login;
1212
vm.logout = logout;
1313

1414

1515
function initHeaderProps(event) {
1616
$log.debug(event + ' triggered header update.');
17-
vm.isAuth = tcAuth.isAuthenticated();
17+
vm.isAuth = TcAuthService.isAuthenticated();
1818
}
1919
// init props default
2020
initHeaderProps('default');
2121

2222
function logout() {
23-
tcAuth.logout().then(
23+
TcAuthService.logout().then(
2424
function() {
2525
// success
2626
$state.go('home');

app/layout/layout.module.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
var dependencies = [];
55

6-
angular
7-
.module('tc.layout', dependencies);
6+
angular.module('tc.layout', dependencies);
87

98
})();

app/member-dashboard/.Rhistory

Whitespace-only changes.

app/member-dashboard/blog-post/.Rhistory

Whitespace-only changes.

app/member-dashboard/blog-post/blog-feed.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div ng-controller="BlogPostCtrl as vm" class="widget container-fluid panel panel-default">
1+
<div ng-controller="BlogPostController as vm" class="widget container-fluid panel panel-default">
22
<div class="panel-heading">
33
<span class="panel-title">Featured Blogs</span>
44
</div>
@@ -11,4 +11,4 @@
1111
<div class="clearfix"></div>
1212
</div>
1313
</div>
14-
</div>
14+
</div>
Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,26 @@
1-
/**
2-
* Copyright (C) 2014 TopCoder Inc., All Rights Reserved.
3-
* @author mdesiderio
4-
* @version 1.0
5-
*
6-
* Controller for the blog post widget
7-
*/
81
(function () {
2+
'use strict';
93

10-
/**
11-
* Create blog post controller controller
12-
*/
13-
angular
14-
.module('tc.myDashboard')
15-
.controller('BlogPostCtrl', BlogPostCtrl);
4+
angular.module('tc.myDashboard').controller('BlogPostController', BlogPostController);
165

17-
/**
18-
* Inject dependencies
19-
* @type {string[]}
20-
*/
21-
BlogPostCtrl.$inject = ['$scope', 'tcAuth', 'blog'];
6+
BlogPostController.$inject = ['TcAuthService', 'BlogService'];
227

23-
/**
24-
* BlogPost Controller implementation
25-
*
26-
* @param $scope
27-
* @param blog service to access and parse blog RSS feed
28-
* @constructor
29-
*/
30-
function BlogPostCtrl($scope, tcAuth, blog) {
8+
// Accesss and parses the blog RSS feed
9+
function BlogPostController(TcAuthService, BlogService) {
3110
var vm = this;
3211

33-
// activate controller
34-
if (tcAuth.isAuthenticated() === true) {
12+
if (TcAuthService.isAuthenticated() === true) {
3513
activate();
3614
} else {
3715
return false;
3816
}
3917

4018
function activate() {
41-
return blog.getBlogFeed()
19+
return BlogService.getBlogFeed()
4220
.then(function(data) {
4321
vm.blogPosts = data;
4422
});
4523
}
4624
}
4725

48-
})();
26+
})();

app/member-dashboard/blog-post/blog-post.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ describe('Blog Post Controller', function() {
66

77
beforeEach(function() {
88
bard.appModule('topcoder');
9-
bard.inject(this, '$controller', '$rootScope', '$q', 'tcAuth', 'blog');
9+
bard.inject(this, '$controller', '$rootScope', '$q', 'TcAuthService', 'BlogService');
1010

11-
blogService = blog;
12-
authService = tcAuth;
11+
blogService = BlogService;
12+
authService = TcAuthService;
1313

1414
sinon.stub(blogService, 'getBlogFeed', function() {
1515
var deferred = $q.defer();
@@ -22,7 +22,7 @@ describe('Blog Post Controller', function() {
2222

2323
describe('before login activation', function() {
2424
beforeEach(function() {
25-
controller = $controller('BlogPostCtrl', {
25+
controller = $controller('BlogPostController', {
2626
$scope: $rootScope.$new(),
2727
auth: authService,
2828
blog: blogService
@@ -48,7 +48,7 @@ describe('Blog Post Controller', function() {
4848
sinon.stub(authService, 'isAuthenticated', function() {
4949
return true;
5050
});
51-
controller = $controller('BlogPostCtrl', {
51+
controller = $controller('BlogPostController', {
5252
$scope: $rootScope.$new(),
5353
auth: authService,
5454
blog: blogService

app/member-dashboard/helpful-links/helpful-links.controller.js

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
1-
/**
2-
* Copyright (C) 2014 TopCoder Inc., All Rights Reserved.
3-
* @author mdesiderio
4-
* @version 1.0
5-
*
6-
* Controller for the helpful links widget
7-
*/
8-
(function () {
1+
(function () {
2+
'use strict';
93

10-
/**
11-
* Create helpful links controller
12-
*/
13-
angular
14-
.module('tc.myDashboard')
15-
.controller('HelpfulLinksCtrl', HelpfulLinksCtrl);
4+
angular.module('tc.myDashboard').controller('HelpfulLinksController', HelpfulLinksController);
165

17-
/**
18-
* Inject dependencies
19-
* @type {string[]}
20-
*/
21-
HelpfulLinksCtrl.$inject = ['$scope', '$location', 'CONSTANTS'];
6+
HelpfulLinksController.$inject = ['$location', 'CONSTANTS'];
227

23-
/**
24-
* Helpful links controller implementation
25-
*
26-
* @param $scope
27-
* @constructor
28-
*/
29-
function HelpfulLinksCtrl($scope, $location, CONSTANTS) {
8+
function HelpfulLinksController($location, CONSTANTS) {
309
var vm = this;
3110
vm.communityBaseUrl = $location.protocol() + ":" + CONSTANTS.COMMUNITY_URL;
3211
vm.mainUrl = CONSTANTS.MAIN_URL;
@@ -41,8 +20,7 @@
4120
vm.changeVisibleLinks = changeVisibleLinks;
4221
vm.showPreviousLinks = showPreviousLinks;
4322
vm.hasChildren = hasChildren;
44-
45-
//activate controller
23+
4624
activate();
4725

4826
function activate() {
@@ -697,4 +675,4 @@
697675
}
698676

699677

700-
})();
678+
})();

app/member-dashboard/helpful-links/helpful-links.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div ng-controller="HelpfulLinksCtrl as vm" class="panel panel-default">
1+
<div ng-controller="HelpfulLinksController as vm" class="panel panel-default">
22
<div class="panel-heading">
33
<span class="panel-title">{{vm.visibleNode.name}}</span>
44
<a href="#" ng-show="vm.breadcrumb.length > 0" ng-click="vm.showPreviousLinks()" class="pull-right">Back</a>
@@ -17,4 +17,4 @@
1717
</li>
1818
</ul>
1919
</div>
20-
</div>
20+
</div>

0 commit comments

Comments
 (0)