user stats
parent
74aa3a5d75
commit
5b0eb71fb1
|
@ -1,9 +1,16 @@
|
||||||
class ProfileBarController
|
class ProfileBarController
|
||||||
@.$inject = [
|
@.$inject = [
|
||||||
"$tgAuth"
|
"$tgAuth",
|
||||||
|
"tgUserService"
|
||||||
]
|
]
|
||||||
|
|
||||||
constructor: (@auth) ->
|
constructor: (@auth, @userService) ->
|
||||||
@.user = @auth.getUser()
|
@.user = @auth.getUser()
|
||||||
|
|
||||||
|
@.loadStats()
|
||||||
|
|
||||||
|
loadStats: () ->
|
||||||
|
return @userService.getStats(@.user.id).then (stats) =>
|
||||||
|
@.stats = stats.toJS()
|
||||||
|
|
||||||
angular.module("taigaProfile").controller("ProfileBar", ProfileBarController)
|
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
|
section.profile-bar
|
||||||
div.profile-image-wrapper
|
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 }}")
|
div.edit-profile(title="{{ 'USER.PROFILE.EDIT' | translate }}")
|
||||||
a.profile-edition(title="{{ 'USER.PROFILE.EDIT' | translate }}", tg-nav="user-settings-user-profile")
|
a.profile-edition(title="{{ 'USER.PROFILE.EDIT' | translate }}", tg-nav="user-settings-user-profile")
|
||||||
span.icon.icon-edit
|
span.icon.icon-edit
|
||||||
|
@ -8,8 +8,8 @@ section.profile-bar
|
||||||
// a.button-green
|
// a.button-green
|
||||||
// span(translate="USER.PROFILE.FOLLOW")
|
// span(translate="USER.PROFILE.FOLLOW")
|
||||||
div.profile-data
|
div.profile-data
|
||||||
h1 {{vm.user.full_name}}
|
h1 {{::vm.user.full_name}}
|
||||||
h2 Backend Developer & Stackeholder
|
h2 {{::vm.stats.roles.join(", ")}}
|
||||||
// div.location
|
// div.location
|
||||||
// include ../../../svg/location.svg
|
// include ../../../svg/location.svg
|
||||||
// span Madrid
|
// span Madrid
|
||||||
|
@ -17,16 +17,16 @@ section.profile-bar
|
||||||
// a.flag(href="", title="{{ 'USER.PROFILE.REPORT' | translate }}")
|
// a.flag(href="", title="{{ 'USER.PROFILE.REPORT' | translate }}")
|
||||||
// include ../../../svg/flag.svg
|
// include ../../../svg/flag.svg
|
||||||
// These values in profile stats are not defined yet in UX. Please ask
|
// These values in profile stats are not defined yet in UX. Please ask
|
||||||
// div.profile-stats
|
div.profile-stats
|
||||||
// div.stat
|
div.stat
|
||||||
// span.stat-number 3
|
span.stat-number {{::vm.stats.projects}}
|
||||||
// span.stat-name(translate="USER.PROFILE.PROJECTS")
|
span.stat-name(translate="USER.PROFILE.PROJECTS")
|
||||||
// div.stat
|
div.stat
|
||||||
// span.stat-number 67
|
span.stat-number {{::vm.stats.closed_userstories}}
|
||||||
// span.stat-name(translate="USER.PROFILE.CLOSED_US")
|
span.stat-name(translate="USER.PROFILE.CLOSED_US")
|
||||||
// div.stat
|
div.stat
|
||||||
// span.stat-number 34
|
span.stat-number {{::vm.stats.contacts}}
|
||||||
// span.stat-name(translate="USER.PROFILE.CONTACTS")
|
span.stat-name(translate="USER.PROFILE.CONTACTS")
|
||||||
// TODO Hide until organizations come
|
// TODO Hide until organizations come
|
||||||
// div.profile-organizations
|
// div.profile-organizations
|
||||||
// h3 Organizations
|
// h3 Organizations
|
||||||
|
|
|
@ -11,6 +11,9 @@ class UserService extends taiga.Service
|
||||||
getContacts: (userId) ->
|
getContacts: (userId) ->
|
||||||
return @rs.users.getContacts(userId)
|
return @rs.users.getContacts(userId)
|
||||||
|
|
||||||
|
getStats: (userId) ->
|
||||||
|
return @rs.users.getStats(userId)
|
||||||
|
|
||||||
attachUserContactsToProjects: (userId, projects) ->
|
attachUserContactsToProjects: (userId, projects) ->
|
||||||
return @.getContacts(userId)
|
return @.getContacts(userId)
|
||||||
.then (contacts) ->
|
.then (contacts) ->
|
||||||
|
|
|
@ -45,6 +45,19 @@ describe "UserService", ->
|
||||||
|
|
||||||
expect(userService.getProjects(userId)).to.be.true
|
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) ->
|
it "attach user contacts to projects", (done) ->
|
||||||
userId = 2
|
userId = 2
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue