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

Commit 5cd78c5

Browse files
author
Parth Shah
committed
SUP-2130 fixing header color as well
1 parent 36134a0 commit 5cd78c5

File tree

4 files changed

+17
-50
lines changed

4 files changed

+17
-50
lines changed

app/directives/profile-widget/profile-widget.directive.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(function() {
22
'use strict';
33

4-
angular.module('tcUIComponents').directive('profileWidget', ['CONSTANTS', '$filter', profileWidget]);
4+
angular.module('tcUIComponents').directive('profileWidget', ['CONSTANTS', 'ProfileService', profileWidget]);
55

6-
function profileWidget(CONSTANTS, $filter) {
6+
function profileWidget(CONSTANTS, ProfileService) {
77
return {
88
restrict: 'E',
99
templateUrl: 'directives/profile-widget/profile-widget.html',
@@ -16,9 +16,8 @@
1616
link: function(scope, elem, attrs) {
1717
scope.DOMAIN = CONSTANTS.domain;
1818
scope.ASSET_PREFIX = CONSTANTS.ASSET_PREFIX;
19-
// get max rating or default to 0
20-
var rating = _.get(scope.profile, 'maxRating.rating', 0);
21-
scope.handleColor = $filter('ratingColor')(rating);
19+
20+
scope.handleColor = ProfileService.getUserHandleColor(scope.profile);
2221
scope.$watch('editProfileLink', function(newValue, oldValue, scope) {
2322
if (newValue) {
2423
scope.editProfileLink = newValue;

app/layout/header/header.controller.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
vm.isAuth = TcAuthService.isAuthenticated();
6666
if (vm.isAuth) {
6767
vm.userHandle = UserService.getUserIdentity().handle;
68+
6869
vm.userMenu = [
6970
{ 'sref': 'dashboard', 'text': 'DASHBOARD', 'icon': '/images/nav/dashboard.svg' },
7071
{ 'sref': 'profile.about', 'srefParams': { 'userHandle': vm.userHandle }, 'text': 'MY PROFILE', 'icon': '/images/nav/badge.svg' },
@@ -75,6 +76,7 @@
7576
ProfileService.getUserProfile(vm.userHandle)
7677
.then(function(data) {
7778
vm.profile = data;
79+
vm.userHandleColor = ProfileService.getUserHandleColor(vm.profile);
7880
})
7981
.catch(function(err) {
8082
$log.error("Unable to get user data");

app/layout/header/header.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
span(ui-sref="profile.about({userHandle: vm.userHandle})")
3434
img(class="user-avatar", ng-src="{{vm.profile.photoURL}}")
3535

36-
span.username {{vm.userHandle}}
36+
span.username(style="color:{{vm.userHandleColor}}") {{vm.userHandle}}
3737

3838
a.btn-link.btn-edit-profile.show-small(ui-sref="settings.profile") EDIT
3939

app/services/profile.service.js

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

44
angular.module('tc.services').factory('ProfileService', ProfileService);
55

6-
ProfileService.$inject = ['CONSTANTS', 'ApiService', 'UserService', '$q'];
6+
ProfileService.$inject = ['CONSTANTS', 'ApiService', 'UserService', '$q', '$filter'];
77

8-
function ProfileService(CONSTANTS, ApiService, UserService, $q) {
8+
function ProfileService(CONSTANTS, ApiService, UserService, $q, $filter) {
99

1010
var restangular = ApiService.restangularV3;
1111

@@ -29,8 +29,9 @@
2929
getTracks: getTracks,
3030
getSubTracks: getSubTracks,
3131
getDivisions: getDivisions,
32-
// for profile - to be deprecated
33-
getMockMemberProfile: getMockMemberProfile
32+
33+
getUserHandleColor: getUserHandleColor,
34+
3435
};
3536
return service;
3637

@@ -279,47 +280,12 @@
279280
};
280281
}
281282

282-
function getMockMemberProfile() {
283-
if (!service.memberProfile) {
284-
service.memberProfile = {
285-
"links": [
286-
{
287-
"name": "Github",
288-
"logo": "git-logo.png",
289-
"properties": [
290-
{
291-
"name": "Repos",
292-
"value": 20
293-
},
294-
{
295-
"name": "Followers",
296-
"value": 10
297-
}
298-
]
299-
},
300-
{
301-
"name": "Stack Overflow",
302-
"logo": "stackoverflow-logo.png",
303-
"properties": [
304-
{
305-
"name": "Reputation",
306-
"value": 200
307-
},
308-
{
309-
"name": "Questions",
310-
"value": 102
311-
},
312-
{
313-
"name": "Answers",
314-
"value": 2001
315-
}
316-
]
317-
}
318-
]
319-
};
320-
}
321-
return service.memberProfile;
283+
function getUserHandleColor(profile) {
284+
var rating = _.get(profile, 'maxRating.rating', 0);
285+
return $filter('ratingColor')(rating);
322286
}
287+
288+
323289
}
324290

325291
})();

0 commit comments

Comments
 (0)