55 Facility ,
66 Member ,
77 Resource ,
8+ ResourcesManagerService ,
9+ UsersManagerService ,
810} from '@perun-web-apps/perun/openapi' ;
911import { compareFnName } from '@perun-web-apps/perun/utils' ;
1012
@@ -21,7 +23,12 @@ export class UserAssignmentsComponent implements OnInit {
2123 member : Member = null ;
2224 resources : Resource [ ] = [ ] ;
2325 userId : number ;
24- constructor ( private route : ActivatedRoute , private facilityService : FacilitiesManagerService ) { }
26+ constructor (
27+ private route : ActivatedRoute ,
28+ private facilityService : FacilitiesManagerService ,
29+ private usersService : UsersManagerService ,
30+ private resourcesService : ResourcesManagerService
31+ ) { }
2532
2633 ngOnInit ( ) : void {
2734 this . initLoading = true ;
@@ -43,12 +50,21 @@ export class UserAssignmentsComponent implements OnInit {
4350 loadFacility ( facility : Facility ) : void {
4451 this . loading = true ;
4552 this . selectedFacility = facility ;
46- this . facilityService . getAssignedRichResourcesForFacility ( facility . id ) . subscribe ( {
47- next : ( resources ) => {
48- this . resources = resources ;
49- this . loading = false ;
50- } ,
51- error : ( ) => ( this . loading = false ) ,
52- } ) ;
53+ this . usersService
54+ . getAssociatedResourcesForUser ( this . selectedFacility . id , this . userId )
55+ . subscribe ( {
56+ next : ( resources ) => {
57+ this . resourcesService
58+ . getRichResourcesByIds ( resources . map ( ( resource ) => resource . id ) )
59+ . subscribe ( {
60+ next : ( richResources ) => {
61+ this . resources = richResources ;
62+ this . loading = false ;
63+ } ,
64+ error : ( ) => ( this . loading = false ) ,
65+ } ) ;
66+ } ,
67+ error : ( ) => ( this . loading = false ) ,
68+ } ) ;
5369 }
5470}
0 commit comments