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

Commit d3de5aa

Browse files
committed
Merge pull request #593 from appirio-tech/qa-integration
Qa integration
2 parents 3b3c918 + 95cbe4f commit d3de5aa

File tree

138 files changed

+2090
-2333
lines changed

Some content is hidden

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

138 files changed

+2090
-2333
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.0.16
1+
v1.0.17

app/account/login/login.controller.js

Lines changed: 63 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,96 +3,116 @@
33

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

6-
LoginController.$inject = ['$log', '$state', '$stateParams', '$location', '$scope', 'TcAuthService', 'AuthTokenService', 'UserService', 'NotificationService', 'Helpers', 'CONSTANTS'];
6+
LoginController.$inject = ['$log', '$state', '$stateParams', '$location', '$scope', 'TcAuthService', 'UserService', 'NotificationService', 'Helpers', 'CONSTANTS'];
77

8-
function LoginController($log, $state, $stateParams, $location, $scope, TcAuthService, AuthTokenService, UserService, NotificationService, Helpers, CONSTANTS) {
9-
$log = $log.getInstance("LoginController");
8+
function LoginController($log, $state, $stateParams, $location, $scope, TcAuthService, UserService, NotificationService, Helpers, CONSTANTS) {
109
var vm = this;
10+
$log = $log.getInstance("LoginController");
1111
vm.$stateParams = $stateParams;
1212
vm.passwordReset = false;
13-
vm.usernameExists = true;
1413
vm.currentPasswordDefaultPlaceholder = "Password";
14+
vm.loginErrors = {
15+
USERNAME_NONEXISTANT: false,
16+
WRONG_PASSWORD: false,
17+
SOCIAL_LOGIN_ERROR: false
18+
};
19+
20+
vm.login = login;
21+
vm.socialLogin = socialLogin;
22+
1523
// reference for main vm
1624
var mainVm = $scope.$parent.main;
1725

18-
if ($stateParams.notifyReset) {
19-
NotificationService.inform('Your new password has been set. Please log in. If you have any trouble, please contact [email protected].');
20-
}
26+
activate();
2127

22-
function _doLogin(usernameOrEmail, password) {
23-
return TcAuthService.login(usernameOrEmail, password).then(
24-
function(data) {
25-
// success
26-
$log.debug('logged in');
27-
// setup login event for analytics tracking
28-
Helpers.setupLoginEventMetrices(usernameOrEmail);
29-
return Helpers.redirectPostLogin($stateParams.next);
30-
})
31-
.catch(function(resp) {
32-
$log.warn(resp);
33-
switch (resp.status) {
34-
case "ACCOUNT_INACTIVE":
35-
$state.go('registeredSuccessfully');
36-
// user should already be redirected
37-
break;
38-
case "UNKNOWN_ERROR":
39-
default:
40-
vm.wrongPassword = true;
41-
vm.password = '';
42-
}
43-
});
28+
function activate() {
29+
if ($stateParams.notifyReset) {
30+
NotificationService.inform('Your new password has been set. Please log in. If you have any trouble, please contact [email protected].');
31+
}
4432
}
4533

46-
vm.login = function() {
47-
vm.usernameExists = true;
48-
vm.wrongPassword = false;
34+
function login() {
35+
vm.loginErrors.USERNAME_NONEXISTANT = false;
36+
vm.loginErrors.WRONG_PASSWORD = false;
37+
4938
// TODO ideally it should be done by dedicated directive to handle all outside clicks
5039
mainVm.menuVisible = false;
5140

5241
if (Helpers.isEmail(vm.username)) {
42+
// the user is loggin in using email
5343
vm.emailOrUsername = 'email';
44+
5445
// ensure email exists
46+
// uses same validity check as registration
47+
// valid => email isn't already used by someone
5548
UserService.validateUserEmail(vm.username).then(function(data) {
5649
if (data.valid) {
5750
// email doesn't exist
58-
vm.usernameExists = false;
51+
vm.loginErrors.USERNAME_NONEXISTANT = true;
5952
} else {
60-
vm.usernameExists = true;
6153
_doLogin(vm.username, vm.currentPassword);
6254
}
6355
}).catch(function(resp) {
6456
// TODO handle error
6557
// assume email exists, login would in any case if it didn't
66-
vm.usernameExists = true;
58+
vm.loginErrors.USERNAME_NONEXISTANT = false;
6759
_doLogin(vm.username, vm.currentPassword);
6860
});
6961
} else {
62+
// the user is logging in using a username
7063
vm.emailOrUsername = 'username';
64+
7165
// username - make sure it exists
7266
UserService.validateUserHandle(vm.username).then(function(data) {
7367
if (data.valid) {
7468
// username doesn't exist
75-
vm.usernameExists = false;
69+
vm.loginErrors.USERNAME_NONEXISTANT = true;
7670
} else {
77-
vm.usernameExists = true;
7871
_doLogin(vm.username, vm.currentPassword);
7972
}
8073
}).catch(function(resp) {
8174
// TODO handle error
8275
// assume email exists, login would in any case if it didn't
83-
vm.usernameExists = true;
8476
_doLogin(vm.username, vm.currentPassword);
8577
});
8678
}
8779
};
8880

89-
vm.socialLogin = function(backend) {
90-
var params = {}, callbackUrl;
81+
function _doLogin(usernameOrEmail, password) {
82+
return TcAuthService.login(usernameOrEmail, password).then(function(data) {
83+
// success
84+
$log.debug('logged in');
85+
86+
// setup login event for analytics tracking
87+
Helpers.setupLoginEventMetrics(usernameOrEmail);
88+
return Helpers.redirectPostLogin($stateParams.next);
89+
90+
}).catch(function(resp) {
91+
$log.warn(resp);
92+
switch (resp.status) {
93+
case "ACCOUNT_INACTIVE":
94+
$state.go('registeredSuccessfully');
95+
// user should already be redirected
96+
break;
97+
case "UNKNOWN_ERROR":
98+
default:
99+
vm.loginErrors.WRONG_PASSWORD = true;
100+
vm.password = '';
101+
}
102+
});
103+
}
104+
105+
function socialLogin(platform) {
106+
// we need to pass on the 'next' param if we have one
107+
var params = {};
91108
if ($stateParams.next) {
92109
params = {next: $stateParams.next};
93110
}
94-
callbackUrl = $state.href('login', params, {absolute: true});
95-
TcAuthService.socialLogin(backend, callbackUrl)
111+
112+
// redirect back to login
113+
var callbackUrl = $state.href('login', params, {absolute: true});
114+
115+
TcAuthService.socialLogin(platform, callbackUrl)
96116
.then(function() {
97117
$log.debug('logged in');
98118
return Helpers.redirectPostLogin($stateParams.next);
@@ -104,6 +124,7 @@
104124
case "USER_NOT_REGISTERED":
105125
default:
106126
vm.socialLoginError = 401;
127+
vm.loginErrors.SOCIAL_LOGIN_ERROR = true;
107128
break;
108129
}
109130
});

app/account/login/login.jade

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
h1 LOG IN TO TOPCODER
77

88
form(name="vm.loginForm", role="form", ng-submit="vm.loginForm.$valid && vm.login()", novalidate)
9-
.form-errors
10-
p.form-error(ng-hide="vm.usernameExists") We couldn't find a member with that {{vm.emailOrUsername || "username"}}. Please check that you entered it correctly.
9+
.form-errors(ng-messages="vm.loginErrors")
10+
p.form-error(ng-message="USERNAME_NONEXISTANT") We couldn't find a member with that {{vm.emailOrUsername || "username"}}. Please check that you entered it correctly.
1111

12-
p.form-error(ng-show="vm.wrongPassword") That password is incorrect. Please check that you entered the right one.
12+
p.form-error(ng-message="WRONG_PASSWORD") That password is incorrect. Please check that you entered the right one.
1313

14-
p.form-error(ng-show="vm.socialLoginError === 401") User with that profile is not registered.
14+
p.form-error(ng-message="SOCIAL_LOGIN_ERROR") User with that profile is not registered.
1515

16-
div.validation-bar(ng-class="{'error-bar': !vm.usernameExists}")
16+
div.validation-bar(ng-class="{'error-bar': vm.loginErrors.USERNAME_NONEXISTANT}")
1717
input(ng-model="vm.username", name="username", placeholder="Username or Email", type="text", required)
1818

1919
toggle-password

app/directives/account/toggle-password/toggle-password.directive.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
if (relatedTarget.attr('type') === 'checkbox' && relatedTarget.attr('id') === 'currentPasswordCheckbox') {
4141
vm.currentPasswordFocus = true;
4242
vm.currentPasswordPlaceholder = '';
43+
currentPasswordInput.focus();
4344
} else {
4445
// If you are blurring from the password input and clicking anywhere but the checkbox
4546
vm.currentPasswordFocus = false;

app/directives/account/toggle-password/toggle-password.jade

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ input#current-password-input(
22
ng-model="vm.currentPassword",
33
ng-model-options="{allowInvalid: true}",
44

5-
focus-on="focusOnCurrentPasswordInput",
65
ng-focus="vm.onCPFocus($event)",
76
ng-blur="vm.onCPBlur($event)",
87

app/directives/badges/badge-tooltip.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* jshint -W117, -W030 */
2-
describe('Badge Tooltiop Directive', function() {
2+
describe('Badge Tooltip Directive', function() {
33
var scope;
44
var element;
55
var badge = mockData.getMockBadge();

app/directives/challenge-tile/challenge-tile.directive.jade

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
// Only show if not data science track
3333
p.roles
3434
span(ng-hide="challenge.track === 'DATA_SCIENCE'")
35-
#[span Role: ] #[span {{challenge.userDetails.roles | listRoles}}]
35+
span Role:  
36+
span {{challenge.userDetails.roles | listRoles}}
3637

3738
.completed-challenge(
3839
ng-show="challenge.status === 'COMPLETED' || challenge.status === 'PAST'",
@@ -66,7 +67,8 @@
6667
// Only show if not data science track
6768
p.roles
6869
span(ng-hide="challenge.track === 'DATA_SCIENCE'")
69-
#[span Role: ] #[span {{challenge.userDetails.roles | listRoles}}]
70+
span Role:  
71+
span {{challenge.userDetails.roles | listRoles}}
7072

7173
.challenge.list-view(ng-show="view=='list'", ng-class="challenge.track")
7274
.active-challenge(ng-show="challenge.status === 'ACTIVE'")

app/directives/distribution-graph/distribution-graph.directive.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,31 @@
178178
})
179179
.attr('fill', function(d) {
180180
return ratingToColor($scope.colors, d.start);
181+
});
182+
183+
svg.selectAll('rect.hover')
184+
.data(ranges)
185+
.enter()
186+
.append('rect')
187+
.attr('class', 'hover')
188+
.attr('fill', 'transparent')
189+
.attr('x', function(d, i) {
190+
return xScale(i);
191+
})
192+
.attr('y', function(d) {
193+
return padding.top;
194+
})
195+
.attr('width', xScale.rangeBand())
196+
.attr('height', function(d) {
197+
return totalH - padding.bottom - padding.top;
181198
})
182199
.on('mouseover', function(d) {
183-
d3.select(this)
184-
.attr('fill', ratingToDarkerColor($scope.colors, d.start));
185200
$scope.highlightedRating = d.start;
186201
$scope.displayCoders = true;
187202
$scope.numCoders = d.number;
188203
$scope.$digest();
189204
})
190205
.on('mouseout', function(d) {
191-
d3.select(this)
192-
.attr('fill', ratingToColor($scope.colors, d.start));
193206
$scope.displayCoders = false;
194207
$scope.highlightedRating = false;
195208
$scope.$digest();

0 commit comments

Comments
 (0)