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

Latest Listings #1015

Merged
merged 5 commits into from
Feb 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 71 additions & 3 deletions app/listings/listings.controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'lodash'
import angular from 'angular'
import { loadUser } from '../services/userv3.service.js'

Expand All @@ -13,24 +14,91 @@ import { loadUser } from '../services/userv3.service.js'

function ListingsCtrl(CONSTANTS, logger, $q, TcAuthService, UserService, UserStatsService, ProfileService,
ChallengeService, ExternalAccountService, ngDialog, $anchorScroll, $scope) {
var vm = this
var handle
vm.neverParticipated = false
vm.loading = true
vm.userHasChallenges = true
vm.challengeView = 'tile'

activate()

function activate() {
$scope.myChallenges = []
$scope.userProps = { isAuth: false }
$scope.userProps = { isAuth: false, myChallenges: [] }
logger.debug('Calling ListingsController activate()')

vm.myChallenges = []
loadUser().then(function(token) {
handle = UserService.getUserIdentity().handle
// mock current user have this challenges
vm.myChallenges.push({'id':30056409})
vm.myChallenges.push({'id':30056067})
vm.myChallenges.push({'id':16870})

// update auth flag
if(TcAuthService.isAuthenticated()) {
$scope.userProps = { isAuth: true }
getChallenges(handle)
$scope.userProps = { isAuth: true, myChallenges: vm.myChallenges }
}
}, function(error) {
// do nothing, just show non logged in state of navigation bar
})
}

function getChallenges(handle) {
var marathonMatchParams = {
limit: 8,
filter: 'status=active'
}

var challengeParams = {
limit: 8,
orderBy: 'submissionEndDate',
filter: 'status=active'
}

$q.all([
ChallengeService.getUserMarathonMatches(handle, marathonMatchParams),
ChallengeService.getUserChallenges(handle, challengeParams)
]).then(function(challenges){
var marathonMatches = challenges[0]
var devDesignChallenges = challenges[1]

if (!marathonMatches.length && !devDesignChallenges.length) {
vm.userHasChallenges = false
_checkForParticipation().then(function() {
vm.loading = false
})
} else {
ChallengeService.processActiveDevDesignChallenges(devDesignChallenges)
ChallengeService.processActiveMarathonMatches(marathonMatches)
var userChallenges = marathonMatches.concat(devDesignChallenges)

userChallenges = _.sortBy(userChallenges, function(n) {
return n.registrationEndDate
})
vm.myChallenges = userChallenges.reverse().slice(0, 8)

// update myChallenges
$scope.userProps = { isAuth: true, myChallenges: vm.myChallenges }

vm.userHasChallenges = true
vm.loading = false
}
})
.catch(function(err) {
logger.error('Error getting challenges and marathon matches', err)

vm.userHasChallenges = true
vm.loading = false
})
}

function _checkForParticipation() {
return ChallengeService.checkChallengeParticipation(handle, function(participated) {
vm.neverParticipated = !participated
})
}
}

})()
2 changes: 1 addition & 1 deletion assets/css/directives/badge-tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@
background-position: 0px -672px;
}
.Predix-Community {
background-position: -50px -672px;
background-position: -47px -672px;
}
.iOS-Community {
background-position: -95px -672px;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"appirio-styles": "0.x.x",
"appirio-tech-ng-iso-constants": "^1.0.6",
"appirio-tech-ng-ui-components": "^2.1.2",
"appirio-tech-react-components": "nomo-kazza/react-components.git#challenge-listings",
"appirio-tech-react-components": "appirio-tech/react-components.git#cl-misc-fixes-2",
"auth0-angular": "^4.1.0",
"auth0-js": "^6.8.0",
"d3": "^3.5.14",
Expand Down