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

Commit 212110a

Browse files
committed
Merge branch 'dev' of github.com:appirio-tech/topcoder-app into dev
2 parents 665af8a + a1c4fdb commit 212110a

20 files changed

+455
-35
lines changed

app/blocks/logger/logger.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ import angular from 'angular'
3333
$log.error(message)
3434

3535
if (window.NREUM) {
36-
var err = new Error(message)
37-
38-
window.NREUM.noticeError(err)
36+
window.NREUM.noticeError(message)
3937
}
4038
}
4139

app/community/members.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import angular from 'angular'
1212
ctrl.notSearch = true
1313
ctrl.showing = 'list'
1414
ctrl.domain = CONSTANTS.domain
15-
ctrl.currentMonth = 'March 2016'
15+
ctrl.currentMonth = 'April 2016'
1616
ctrl.memberLeaderboard = []
1717
ctrl.copilots = []
1818
CommunityDataService.getMembersData()

app/community/members.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
.platform-stats-container
1414
.stat
1515
p.statVal {{ctrl.platformStats.memberCount | number : 0}}
16-
p.statLabel ACTIVE MEMBER
16+
p.statLabel ACTIVE MEMBERS
1717
.stat
1818
p.statVal {{ctrl.platformStats.activeMembersCount | number : 0}}
1919
p.statLabel COMPETING TODAY
2020
.stat
2121
p.statVal {{ctrl.platformStats.prizePurse | currency:undefined:0}}
22-
p.statLabel AVAILABLE PRIZE
22+
p.statLabel AVAILABLE PRIZES
2323
.stat
2424
p.statVal {{ctrl.platformStats.activeContestsCount | number : 0}}
2525
p.statLabel ACTIVE CHALLENGES

app/directives/page-state-header/page-state-header.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
img.profile-circle(ng-if="!vm.profile.photoURL", src=require("../../../assets/images/ico-user-default.svg"))
1414

15-
.user-stats(id="metrics", ng-hide="vm.loading")
15+
.user-metrics(id="metrics", ng-hide="vm.loading")
1616
a.handle(style="color:{{vm.handleColor}};", ui-sref="profile.about({userHandle: vm.profile.handle})") {{vm.profile.handle}}
1717

1818
.money-earned(ng-hide="hideMoney")

app/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ require('../assets/css/sitemap/sitemap.scss')
6363
require('../assets/css/settings/update-password.scss')
6464
require('../assets/css/settings/settings.scss')
6565
require('../assets/css/settings/preferences.scss')
66+
require('../assets/css/settings/email.scss')
6667
require('../assets/css/settings/edit-profile.scss')
6768
require('../assets/css/settings/account-info.scss')
6869
require('../assets/css/profile/subtrack.scss')

app/services/api.service.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ import _ from 'lodash'
7474
case 'SUBMISSIONS':
7575
case 'USER':
7676
return _getRestangularV3(CONSTANTS.AUTH_API_URL)
77+
case 'MAILCHIMP':
78+
return _getRestangularV3(CONSTANTS.INTERNAL_API_URL)
7779
default:
7880
return _getRestangularV3()
7981
}
@@ -93,6 +95,10 @@ import _ from 'lodash'
9395
})
9496
.setDefaultHeaders({ 'Content-Type': 'application/json' })
9597
.addRequestInterceptor(function(element, operation, what, url) {
98+
// for mailchimp api, don't add param field in the body
99+
if (url.indexOf('mailchimp') > -1) {
100+
return element
101+
}
96102
if (url.indexOf('members') > -1 || (operation.toLowerCase() === 'post' && url.indexOf('profiles') > -1)) {
97103
return {
98104
param: element

app/services/communityData.service.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,29 @@ import angular from 'angular'
2121
var data = {
2222
'memberLeaderboard': [
2323
{
24-
'avatar': '//www.topcoder.com/wp-content/uploads/2015/05/universo_march2016.png',
25-
'name': 'universo',
24+
'avatar': '//www.topcoder.com/wp-content/uploads/2015/05/toxicpixel_apr2016.png',
25+
'name': 'ToxicPixel',
2626
'contestType': 'Design',
27-
'description': 'Won $4,500 in design challenges',
27+
'description': 'Won $4,200 with top prizes in LUX and Idea Gen!',
2828
'class': 'design'
2929
}, {
30-
'avatar': '//www.topcoder.com/wp-content/uploads/2015/05/sdgun_march2016.png',
31-
'name': 'sdgun',
30+
'avatar': '//www.topcoder.com/wp-content/uploads/2015/05/monicamuranyi_apr2016.png',
31+
'name': 'MonicaMuranyi',
3232
'contestType': 'Development',
33-
'description': 'Nine wins for $2,076',
33+
'description': 'Won $8,300 across 12 competitions',
3434
'class': 'develop'
3535
}, {
36-
'avatar': '//www.topcoder.com/wp-content/uploads/2015/05/BSBandme_march2016.png',
37-
'name': 'BSBandme',
36+
'avatar': '//www.topcoder.com/wp-content/uploads/2015/05/sugina_apr2016.png',
37+
'name': 'Sugina',
3838
'contestType': 'Data Science',
39-
'description': 'Gained 285 rating points within all 3 January SRMs',
39+
'description': 'Total increase of 175 points, with a jump from Div 2 to Div 1',
4040
'class': 'data-science'
4141
}, {
42-
'avatar': '//www.topcoder.com/wp-content/uploads/2015/05/johan_92_march2016.png',
43-
'name': 'johan_92',
44-
'contestType': 'Design Rookie',
45-
'description': 'Joined end of December and has had 4 1st place wins!',
46-
'class': 'design'
42+
'avatar': '//www.topcoder.com/wp-content/uploads/2015/05/tritias_apr2016.png',
43+
'name': 'TiTrias',
44+
'contestType': 'Development Rookie',
45+
'description': 'Won first challenge within a month of joining!',
46+
'class': 'develop'
4747
}
4848
],
4949
'copilots': [{

app/services/mailchimp.service.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import angular from 'angular'
2+
3+
(function() {
4+
'use strict'
5+
6+
angular.module('tc.services').factory('MailchimpService', MailchimpService)
7+
8+
MailchimpService.$inject = ['$http', 'logger', 'Restangular', 'CONSTANTS', 'ApiService', '$q']
9+
10+
function MailchimpService($http, logger, Restangular, CONSTANTS, ApiService, $q) {
11+
var mailchimpApi = ApiService.getApiServiceProvider('MAILCHIMP')
12+
var service = {
13+
getMemberSubscription: getMemberSubscription,
14+
addSubscription: addSubscription
15+
}
16+
return service
17+
18+
function getMemberSubscription(user) {
19+
return $q(function(resolve, reject) {
20+
mailchimpApi.one('mailchimp/lists', CONSTANTS.MAILCHIMP_LIST_ID)
21+
.one('members', user.userId).get()
22+
.then(function(resp) {
23+
resolve(resp)
24+
})
25+
.catch(function(err) {
26+
if (err.status === 404) {
27+
logger.debug('Member subscription not found')
28+
resolve()
29+
return
30+
}
31+
logger.error('Error getting member to subscription list', err)
32+
33+
var errorStatus = 'FATAL_ERROR'
34+
reject({
35+
status: errorStatus,
36+
msg: err.errorMessage
37+
})
38+
})
39+
})
40+
}
41+
42+
43+
function addSubscription(user, preferences) {
44+
var subscription = {
45+
userId: user.userId,
46+
firstName: user.firstName,
47+
lastName: user.lastName,
48+
interests: {}
49+
}
50+
if (!preferences) {
51+
subscription.interests[CONSTANTS.MAILCHIMP_NL_GEN] = true
52+
} else {
53+
subscription.interests = preferences
54+
}
55+
return $q(function(resolve, reject) {
56+
mailchimpApi.one('mailchimp/lists', CONSTANTS.MAILCHIMP_LIST_ID)
57+
.customPUT(subscription, 'members')
58+
.then(function(resp) {
59+
resolve(resp)
60+
})
61+
.catch(function(err) {
62+
logger.error('Error adding member to subscription list', err)
63+
64+
var errorStatus = 'FATAL_ERROR'
65+
66+
reject({
67+
status: errorStatus,
68+
msg: err.errorMessage
69+
})
70+
})
71+
})
72+
}
73+
}
74+
})()

app/services/tcAuth.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ import angular from 'angular'
127127
resolve(result)
128128
} else {
129129
if (resp.reasonCode === 'ALREADY_IN_USE') {
130-
logger.error('Social handle exist')
130+
logger.error('Social handle already exists')
131131
reject({
132132
status: 'SOCIAL_PROFILE_ALREADY_EXISTS'
133133
})
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import angular from 'angular'
2+
3+
(function () {
4+
'use strict'
5+
6+
angular.module('tc.settings').controller('EmailSettingsController', EmailSettingsController)
7+
8+
EmailSettingsController.$inject = ['$rootScope', 'userProfile', 'ProfileService', 'MailchimpService', 'logger', 'CONSTANTS', 'toaster', '$q', '$scope']
9+
10+
function EmailSettingsController($rootScope, userProfile, ProfileService, MailchimpService, logger, CONSTANTS, toaster, $q, $scope) {
11+
var vm = this
12+
vm.loading = false
13+
vm.saving = false
14+
vm.isDirty = isDirty
15+
vm.save = save
16+
17+
activate()
18+
19+
function activate() {
20+
vm.newsletters = [
21+
{
22+
id: CONSTANTS.MAILCHIMP_NL_GEN,
23+
name: 'General Newsletter',
24+
desc: 'News summary from all tracks and programs',
25+
enabled: false,
26+
dirty: false
27+
},
28+
{
29+
id: CONSTANTS.MAILCHIMP_NL_DESIGN,
30+
name: 'Design Newsletter',
31+
desc: 'Website, mobile, and product design; UI and UX',
32+
enabled: false,
33+
dirty: false
34+
},
35+
{
36+
id: CONSTANTS.MAILCHIMP_NL_DEV,
37+
name: 'Developer Newsletter',
38+
desc: 'Software architecture, component assembly, application development, and bug hunting',
39+
enabled: false,
40+
dirty: false
41+
},
42+
{
43+
id: CONSTANTS.MAILCHIMP_NL_DATA,
44+
name: 'Data Science Newsletter',
45+
desc: 'Algorithm and data structures, statistical analysis',
46+
enabled: false,
47+
dirty: false
48+
},
49+
{
50+
id: CONSTANTS.MAILCHIMP_NL_IOS,
51+
name: 'iOS Community Newsletter',
52+
desc: 'Mobile app design and development for iOS, with Swift emphasis',
53+
enabled: false,
54+
dirty: false
55+
},
56+
{
57+
id: CONSTANTS.MAILCHIMP_NL_TCO,
58+
name: 'TCO Newsletter',
59+
desc: 'Our annual online and onsite tournament to celebrate and reward the community',
60+
enabled: false,
61+
dirty: false
62+
}
63+
]
64+
65+
vm.loading = true
66+
return MailchimpService.getMemberSubscription(userProfile).then(function(subscription) {
67+
vm.loading = false
68+
if (!subscription) {
69+
// add member to the list with empty preferences
70+
MailchimpService.addSubscription(userProfile, {}).then(function(resp) {
71+
logger.debug(resp)
72+
}).catch(function(err) {
73+
// no error to user
74+
//TODO some error alert to community admin
75+
logger.debug('error in adding user to member list')
76+
})
77+
} else {
78+
if (subscription.interests) {
79+
vm.newsletters.forEach(function(newsletter) {
80+
if (subscription.interests[newsletter.id]) {
81+
newsletter.enabled = true
82+
}
83+
})
84+
}
85+
}
86+
})
87+
}
88+
89+
function isDirty() {
90+
var dirty = false
91+
vm.newsletters.forEach(function(newsletter) {
92+
if (newsletter.dirty){
93+
dirty = true
94+
}
95+
})
96+
return dirty
97+
}
98+
99+
function save() {
100+
vm.saving = true
101+
var preferences = {}
102+
vm.newsletters.forEach(function(newsletter) {
103+
preferences[newsletter.id] = newsletter.enabled
104+
})
105+
MailchimpService.addSubscription(userProfile, preferences).then(function(resp) {
106+
vm.loading = false
107+
vm.saving = false
108+
// reset dirty state for all newsletter options
109+
vm.newsletters.forEach(function(newsletter) {
110+
newsletter.dirty = false
111+
})
112+
toaster.pop('success', 'Success!', 'Preferences updated.')
113+
}).catch(function(err) {
114+
logger.error('Could not update email preferences', err)
115+
vm.loading = false
116+
vm.saving = false
117+
118+
toaster.pop('error', 'Whoops!', 'Something went wrong. Please try again later.')
119+
})
120+
}
121+
}
122+
})()

app/settings/email/email.jade

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.email-preferences-container
2+
.settings-section.newsletters
3+
.section-info
4+
h2 Email Preferences
5+
.description Choose the community newsletters that you would like to receive. They are sent about once a week and have the latest news on challenges, events, and special programs.
6+
7+
.section-fields
8+
.processing(ng-show="vm.loading")
9+
i.fa.fa-spinner.fa-spin
10+
.newsletters(ng-hide="vm.loading")
11+
.newsletter(ng-repeat="newsletter in vm.newsletters")
12+
13+
.content(ng-class="{ disabled: !newsletter.enabled }")
14+
.newsletter-details
15+
.text
16+
span.title {{newsletter.name}}
17+
.description
18+
span(ng-bind="newsletter.desc")
19+
20+
.onoffswitch
21+
input.onoffswitch-checkbox(type='checkbox', name='onoffswitch', checked='', ng-model="newsletter.enabled", id="{{newsletter.name}}-onoffswitch", ng-change="newsletter.dirty = !newsletter.dirty")
22+
label.onoffswitch-label(for='{{newsletter.name}}-onoffswitch')
23+
span.onoffswitch-inner
24+
span.onoffswitch-switch
25+
.save-section
26+
button.tc-btn.tc-btn-l.done-button(
27+
type="button",
28+
tc-busy-button, tc-busy-when="vm.saving",
29+
ng-click="vm.save()",
30+
ng-disabled="!vm.isDirty()") Save

app/settings/preferences/preferences.jade

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
.preferences-container
22
ul
3-
li
4-
a(href="http://thecloud.appirio.com/email_prefs_request.html", target="_blank")
5-
.icon
6-
i.fa.fa-envelope
7-
span Email Preferences
8-
.description Specify what kind of email you would like to receive from us
9-
103
li
114
a(href="https://apps.{{DOMAIN}}/forums/?module=Settings", target="_blank")
125
.icon

app/settings/settings.jade

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
li
1111
a(ui-sref="settings.account", ui-sref-active="active-tab") Account
1212

13+
li
14+
a(ui-sref="settings.email", ui-sref-active="active-tab") Email
15+
1316
li
1417
a(ui-sref="settings.preferences", ui-sref-active="active-tab") Preferences
1518

0 commit comments

Comments
 (0)