user stats
parent
74aa3a5d75
commit
5b0eb71fb1
|
@ -1,9 +1,16 @@
|
|||
class ProfileBarController
|
||||
@.$inject = [
|
||||
"$tgAuth"
|
||||
"$tgAuth",
|
||||
"tgUserService"
|
||||
]
|
||||
|
||||
constructor: (@auth) ->
|
||||
constructor: (@auth, @userService) ->
|
||||
@.user = @auth.getUser()
|
||||
|
||||
@.loadStats()
|
||||
|
||||
loadStats: () ->
|
||||
return @userService.getStats(@.user.id).then (stats) =>
|
||||
@.stats = stats.toJS()
|
||||
|
||||
angular.module("taigaProfile").controller("ProfileBar", ProfileBarController)
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
describe "ProfileBar", ->
|
||||
$controller = null
|
||||
$q = null
|
||||
provide = null
|
||||
$rootScope = null
|
||||
mocks = {}
|
||||
|
||||
_mockUserService = () ->
|
||||
mocks.userService = {
|
||||
getStats: sinon.stub()
|
||||
}
|
||||
|
||||
provide.value "tgUserService", mocks.userService
|
||||
|
||||
_mockAuthService = () ->
|
||||
stub = sinon.stub()
|
||||
|
||||
stub.returns({id: 2})
|
||||
|
||||
provide.value "$tgAuth", {
|
||||
getUser: stub
|
||||
}
|
||||
|
||||
_mocks = () ->
|
||||
module ($provide) ->
|
||||
provide = $provide
|
||||
_mockUserService()
|
||||
_mockAuthService()
|
||||
|
||||
return null
|
||||
|
||||
_inject = (callback) ->
|
||||
inject (_$controller_, _$q_, _$rootScope_) ->
|
||||
$q = _$q_
|
||||
$rootScope = _$rootScope_
|
||||
$controller = _$controller_
|
||||
|
||||
beforeEach ->
|
||||
module "taigaProfile"
|
||||
_mocks()
|
||||
_inject()
|
||||
|
||||
it "user stats filled", () ->
|
||||
userId = 2
|
||||
stats = Immutable.fromJS([
|
||||
{id: 1},
|
||||
{id: 2},
|
||||
{id: 3}
|
||||
])
|
||||
|
||||
mocks.userService.getStats = (userId) ->
|
||||
expect(userId).to.be.equal(userId)
|
||||
|
||||
return $q (resolve, reject) ->
|
||||
resolve(stats)
|
||||
|
||||
ctrl = $controller("ProfileBar")
|
||||
|
||||
$rootScope.$apply()
|
||||
|
||||
expect(ctrl.stats).to.be.eql(stats.toJS())
|
|
@ -1,6 +1,6 @@
|
|||
section.profile-bar
|
||||
div.profile-image-wrapper
|
||||
img.profile-img(ng-src="{{user.big_photo}}", alt="{{ user.full_name }}")
|
||||
img.profile-img(ng-src="{{::vm.user.big_photo}}", alt="{{::vm.user.full_name}}")
|
||||
div.edit-profile(title="{{ 'USER.PROFILE.EDIT' | translate }}")
|
||||
a.profile-edition(title="{{ 'USER.PROFILE.EDIT' | translate }}", tg-nav="user-settings-user-profile")
|
||||
span.icon.icon-edit
|
||||
|
@ -8,8 +8,8 @@ section.profile-bar
|
|||
// a.button-green
|
||||
// span(translate="USER.PROFILE.FOLLOW")
|
||||
div.profile-data
|
||||
h1 {{vm.user.full_name}}
|
||||
h2 Backend Developer & Stackeholder
|
||||
h1 {{::vm.user.full_name}}
|
||||
h2 {{::vm.stats.roles.join(", ")}}
|
||||
// div.location
|
||||
// include ../../../svg/location.svg
|
||||
// span Madrid
|
||||
|
@ -17,16 +17,16 @@ section.profile-bar
|
|||
// a.flag(href="", title="{{ 'USER.PROFILE.REPORT' | translate }}")
|
||||
// include ../../../svg/flag.svg
|
||||
// These values in profile stats are not defined yet in UX. Please ask
|
||||
// div.profile-stats
|
||||
// div.stat
|
||||
// span.stat-number 3
|
||||
// span.stat-name(translate="USER.PROFILE.PROJECTS")
|
||||
// div.stat
|
||||
// span.stat-number 67
|
||||
// span.stat-name(translate="USER.PROFILE.CLOSED_US")
|
||||
// div.stat
|
||||
// span.stat-number 34
|
||||
// span.stat-name(translate="USER.PROFILE.CONTACTS")
|
||||
div.profile-stats
|
||||
div.stat
|
||||
span.stat-number {{::vm.stats.projects}}
|
||||
span.stat-name(translate="USER.PROFILE.PROJECTS")
|
||||
div.stat
|
||||
span.stat-number {{::vm.stats.closed_userstories}}
|
||||
span.stat-name(translate="USER.PROFILE.CLOSED_US")
|
||||
div.stat
|
||||
span.stat-number {{::vm.stats.contacts}}
|
||||
span.stat-name(translate="USER.PROFILE.CONTACTS")
|
||||
// TODO Hide until organizations come
|
||||
// div.profile-organizations
|
||||
// h3 Organizations
|
||||
|
|
|
@ -11,6 +11,9 @@ class UserService extends taiga.Service
|
|||
getContacts: (userId) ->
|
||||
return @rs.users.getContacts(userId)
|
||||
|
||||
getStats: (userId) ->
|
||||
return @rs.users.getStats(userId)
|
||||
|
||||
attachUserContactsToProjects: (userId, projects) ->
|
||||
return @.getContacts(userId)
|
||||
.then (contacts) ->
|
||||
|
|
|
@ -45,6 +45,19 @@ describe "UserService", ->
|
|||
|
||||
expect(userService.getProjects(userId)).to.be.true
|
||||
|
||||
it "get user contacts", () ->
|
||||
userId = 2
|
||||
|
||||
contacts = [
|
||||
{id: 1},
|
||||
{id: 2},
|
||||
{id: 3}
|
||||
]
|
||||
|
||||
mocks.resources.users.getContacts.withArgs(userId).returns(true)
|
||||
|
||||
expect(userService.getContacts(userId)).to.be.true
|
||||
|
||||
it "attach user contacts to projects", (done) ->
|
||||
userId = 2
|
||||
|
||||
|
|
Loading…
Reference in New Issue