Skip to content

Commit

Permalink
Merge pull request #1232 from appirio-tech/dev
Browse files Browse the repository at this point in the history
badge updates and CI update
  • Loading branch information
ajefts authored Oct 3, 2017
2 parents 5fb6e91 + 7513cfd commit 121a132
Show file tree
Hide file tree
Showing 15 changed files with 7,157 additions and 818 deletions.
66 changes: 0 additions & 66 deletions .travis.yml

This file was deleted.

53 changes: 38 additions & 15 deletions app/directives/page-state-header/page-state-header.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import _ from 'lodash'
hideMoney: '=',
defaultState: '@'
},
controller: ['CONSTANTS', '$rootScope', '$scope', 'ProfileService', 'logger', '$state', pageStateHeader],
controller: ['CONSTANTS', '$rootScope', '$scope', 'ProfileService', 'logger', '$state', 'ChallengeService', '$q', 'UserService', 'BadgeService', pageStateHeader],
controllerAs: 'vm'
}
})

function pageStateHeader(CONSTANTS, $rootScope, $scope, ProfileService, logger, $state) {
function pageStateHeader(CONSTANTS, $rootScope, $scope, ProfileService, logger, $state, ChallengeService, $q, UserService, BadgeService) {
var vm = this
vm.backHandler = backHandler

Expand All @@ -35,13 +35,12 @@ import _ from 'lodash'
function activate() {
vm.handle = $scope.handle
vm.profile = null
vm.handleColor = null
$scope.hideMoney = _.get($scope, 'hideMoney', true)
vm.previousStateName = null
vm.previousStateLabel = null
vm.previousState = null
vm.showBackLink = _.get($scope, 'showBackLink', false)
vm.loading = true
vm.dashboardBadgeName = null


// identifies the previous state
if ($scope.$root.previousState && $scope.$root.previousState.name.length > 0) {
Expand All @@ -65,14 +64,32 @@ import _ from 'lodash'
// gets member's profile
ProfileService.getUserProfile(vm.handle).then(function(profile) {
vm.profile = profile
vm.handleColor = ProfileService.getUserHandleColor(vm.profile)

if (!$scope.hideMoney) {
displayMoneyEarned(vm.handle)
} else {
vm.loading = false
}
// get members dashboard badge
UserService.getV2UserProfile(vm.handle).then(function(resp) {

var dashboardAchievement = _filterDashboardAchievement(resp.Achievements || [])[0]
if (dashboardAchievement) {
//Get dashboard badges
vm.dashboardBadge = BadgeService.getAchievementVm(dashboardAchievement)
}
})

})

// get member's challenges to display number of active challenges
$q.all([
ChallengeService.getUserMarathonMatches(vm.handle, { filter: 'status=active' }),
ChallengeService.getUserChallenges(vm.handle, { filter: 'status=active' })
]).then(function(challenges){
var marathonMatches = challenges[0]
var devDesignChallenges = challenges[1]

vm.activeChallenges = marathonMatches.length + devDesignChallenges.length
})

displayMoneyEarned(vm.handle)

}

function backHandler() {
Expand Down Expand Up @@ -100,15 +117,21 @@ import _ from 'lodash'
if (!vm.moneyEarned) {
$scope.hideMoney = true
}

vm.loading = false
})
.catch(function(err) {
$scope.hideMoney = true
vm.loading = false

logger.error('Could not get user financial information', err)
})
}

function _filterDashboardAchievement(achievements) {
//Currently only one batch is shown on the dashboard
vm.dashboardBadgeName = 'SRM Engagement Honor'

return achievements.filter(function(achievement) {
return (achievement.description === vm.dashboardBadgeName)
})
}

}
})()
27 changes: 11 additions & 16 deletions app/directives/page-state-header/page-state-header.jade
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@
div(ng-transclude)

.info
.pic
a(ui-sref="profile.about({userHandle: vm.profile.handle})")
img.profile-circle(ng-if="vm.profile.photoURL", ng-src="{{vm.profile.photoURL}}")

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

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

.money-earned(ng-hide="hideMoney")
.item
.value
p(ng-bind="vm.activeChallenges")
.title
p Active Challenges
.item(ng-if="!hideMoney")
.value
p.number(ng-bind="vm.moneyEarned | currency:'$':0")

p Earned

.back-link(ng-if="showBackLink && vm.previousStateLabel")
a(ng-click="vm.backHandler()") Back to {{vm.previousStateLabel}}

.title
p Won in Prizes
.badgeItem(ng-if="vm.dashboardBadge")
.badge(ng-class="(vm.dashboardBadge.specificClass || vm.dashboardBadge.groupClass) + ' ' + (vm.dashboardBadge.type) + 'Badge'" title='{{vm.dashboardBadgeName}}')
Loading

0 comments on commit 121a132

Please sign in to comment.