@@ -14,6 +14,7 @@ import {
14
14
NotificatorService ,
15
15
} from '@perun-web-apps/perun/services' ;
16
16
import { Urns } from '@perun-web-apps/perun/urns' ;
17
+ import { addRecentlyVisited , addRecentlyVisitedObject } from '@perun-web-apps/perun/utils' ;
17
18
18
19
@Component ( {
19
20
selector : 'app-group-overview' ,
@@ -42,18 +43,47 @@ export class GroupOverviewComponent implements OnInit {
42
43
43
44
ngOnInit ( ) {
44
45
this . loading = true ;
45
- this . group = this . entityStorageService . getEntity ( ) ;
46
- if ( this . group . parentGroupId !== null ) {
47
- this . loadParentGroupData ( ) ;
48
- } else {
49
- this . parentGroup = null ;
50
- this . initNavItems ( ) ;
51
- this . loading = false ;
52
- }
46
+ this . loadData ( ) ;
47
+ }
48
+
49
+ loadData ( ) {
50
+ this . loading = true ;
51
+ this . route . params . subscribe ( ( params ) => {
52
+ const voId = params [ 'voId' ] ;
53
+ const groupId = params [ 'groupId' ] ;
54
+ this . voService . getVoById ( voId ) . subscribe (
55
+ ( vo ) => {
56
+ this . groupService . getGroupById ( groupId ) . subscribe (
57
+ ( group ) => {
58
+ this . group = group ;
59
+ this . entityStorageService . setEntity ( {
60
+ id : group . id ,
61
+ voId : vo . id ,
62
+ parentGroupId : group . parentGroupId ,
63
+ beanName : group . beanName ,
64
+ } ) ;
65
+ addRecentlyVisited ( 'groups' , this . group ) ;
66
+ addRecentlyVisitedObject ( this . group , vo . name ) ;
67
+ this . loadParentGroupData ( this . group . parentGroupId ) ;
68
+ if ( this . group . parentGroupId == null ) {
69
+ this . parentGroup = null ;
70
+ this . initNavItems ( ) ;
71
+ this . loading = false ;
72
+ return ;
73
+ }
74
+ this . loading = false ;
75
+ } ,
76
+ ( ) => ( this . loading = false )
77
+ ) ;
78
+ } ,
79
+ ( ) => ( this . loading = false )
80
+ ) ;
81
+ } ) ;
53
82
}
54
83
55
- private loadParentGroupData ( ) {
56
- this . groupService . getGroupById ( this . group . parentGroupId ) . subscribe (
84
+ private loadParentGroupData ( id ?: number ) {
85
+ if ( id == null ) return ;
86
+ this . groupService . getGroupById ( id ) . subscribe (
57
87
( parentGroup ) => {
58
88
this . parentGroup = parentGroup ;
59
89
this . initNavItems ( ) ;
0 commit comments