9
9
} from '@perun-web-apps/perun/openapi' ;
10
10
import { ActivatedRoute } from '@angular/router' ;
11
11
import { Urns } from '@perun-web-apps/perun/urns' ;
12
+ import { compareFnName } from '@perun-web-apps/perun/utils' ;
12
13
13
14
@Component ( {
14
15
selector : 'app-perun-web-apps-user-accounts' ,
@@ -35,44 +36,44 @@ export class UserAccountsComponent implements OnInit {
35
36
this . initLoading = true ;
36
37
this . route . parent . params . subscribe ( ( params ) => {
37
38
this . userId = Number ( params [ 'userId' ] ) ;
38
- this . usersService . getVosWhereUserIsMember ( this . userId ) . subscribe (
39
- ( vos ) => {
39
+ this . usersService . getVosWhereUserIsMember ( this . userId ) . subscribe ( {
40
+ next : ( vos ) => {
40
41
this . vos = vos ;
41
42
if ( this . vos . length ) {
42
- this . loadMember ( this . vos [ 0 ] ) ;
43
+ this . loadMember ( this . vos . sort ( compareFnName ) [ 0 ] ) ;
43
44
}
44
45
this . initLoading = false ;
45
46
} ,
46
- ( ) => ( this . initLoading = false )
47
- ) ;
47
+ error : ( ) => ( this . initLoading = false ) ,
48
+ } ) ;
48
49
} ) ;
49
50
}
50
51
51
52
loadMember ( vo : Vo ) : void {
52
53
this . loading = true ;
53
54
this . selectedVo = vo ;
54
- this . membersService . getMemberByUser ( this . selectedVo . id , this . userId ) . subscribe (
55
- ( member ) => {
56
- this . membersService . getRichMemberWithAttributes ( member . id ) . subscribe (
57
- ( m ) => {
55
+ this . membersService . getMemberByUser ( this . selectedVo . id , this . userId ) . subscribe ( {
56
+ next : ( member ) => {
57
+ this . membersService . getRichMemberWithAttributes ( member . id ) . subscribe ( {
58
+ next : ( m ) => {
58
59
this . member = m ;
59
60
this . groupService
60
61
. getMemberRichGroupsWithAttributesByNames ( this . member . id , [
61
62
Urns . MEMBER_DEF_GROUP_EXPIRATION ,
62
63
Urns . MEMBER_GROUP_STATUS ,
63
64
] )
64
- . subscribe (
65
- ( groups ) => {
65
+ . subscribe ( {
66
+ next : ( groups ) => {
66
67
this . groups = groups ;
67
68
this . loading = false ;
68
69
} ,
69
- ( ) => ( this . loading = false )
70
- ) ;
70
+ error : ( ) => ( this . loading = false ) ,
71
+ } ) ;
71
72
} ,
72
- ( ) => ( this . loading = false )
73
- ) ;
73
+ error : ( ) => ( this . loading = false ) ,
74
+ } ) ;
74
75
} ,
75
- ( ) => ( this . loading = false )
76
- ) ;
76
+ error : ( ) => ( this . loading = false ) ,
77
+ } ) ;
77
78
}
78
79
}
0 commit comments