@@ -12,6 +12,9 @@ export class SideMenuCtrl {
12
12
mainLinks : any ;
13
13
orgMenu : any ;
14
14
appSubUrl : string ;
15
+ orgFilter : string ;
16
+ orgItems : any ;
17
+ orgs : any ;
15
18
16
19
/** @ngInject */
17
20
constructor ( private $scope , private $location , private contextSrv , private backendSrv , private $element ) {
@@ -20,6 +23,7 @@ export class SideMenuCtrl {
20
23
this . appSubUrl = config . appSubUrl ;
21
24
this . showSignout = this . contextSrv . isSignedIn && ! config [ 'authProxyEnabled' ] ;
22
25
26
+
23
27
this . mainLinks = config . bootData . mainNavLinks ;
24
28
this . openUserDropdown ( ) ;
25
29
@@ -28,7 +32,7 @@ export class SideMenuCtrl {
28
32
this . contextSrv . sidemenu = false ;
29
33
}
30
34
} ) ;
31
-
35
+ this . orgFilter = '' ;
32
36
}
33
37
34
38
getUrl ( url ) {
@@ -49,38 +53,44 @@ export class SideMenuCtrl {
49
53
this . orgMenu . push ( { section : this . user . orgName , cssClass : 'dropdown-menu-title' } ) ;
50
54
this . orgMenu . push ( {
51
55
text : "Preferences" ,
52
- url : this . getUrl ( "/org" ) ,
56
+ url : this . getUrl ( "/org" )
53
57
} ) ;
54
58
this . orgMenu . push ( {
55
59
text : "Users" ,
56
- url : this . getUrl ( "/org/users" ) ,
60
+ url : this . getUrl ( "/org/users" )
57
61
} ) ;
58
62
this . orgMenu . push ( {
59
63
text : "API Keys" ,
60
- url : this . getUrl ( "/org/apikeys" ) ,
64
+ url : this . getUrl ( "/org/apikeys" )
61
65
} ) ;
62
66
}
63
67
64
68
this . orgMenu . push ( { cssClass : "divider" } ) ;
65
-
66
69
this . backendSrv . get ( '/api/user/orgs' ) . then ( orgs => {
67
- orgs . forEach ( org => {
68
- if ( org . orgId === this . contextSrv . user . orgId ) {
69
- return ;
70
- }
70
+ this . orgs = orgs ;
71
+ this . loadOrgsItems ( ) ;
72
+ } ) ;
73
+ }
71
74
72
- this . orgMenu . push ( {
75
+ loadOrgsItems ( ) {
76
+ this . orgItems = [ ] ;
77
+ this . orgs . forEach ( org => {
78
+ if ( org . orgId === this . contextSrv . user . orgId ) {
79
+ return ;
80
+ }
81
+
82
+ if ( this . orgFilter === '' || org . name . indexOf ( this . orgFilter ) !== - 1 ) {
83
+ this . orgItems . push ( {
73
84
text : "Switch to " + org . name ,
74
85
icon : "fa fa-fw fa-random" ,
75
86
url : this . getUrl ( '/profile/switch-org/' + org . orgId ) ,
76
87
target : '_self'
77
88
} ) ;
78
- } ) ;
79
-
80
- if ( config . allowOrgCreate ) {
81
- this . orgMenu . push ( { text : "New organization" , icon : "fa fa-fw fa-plus" , url : this . getUrl ( '/org/new' ) } ) ;
82
89
}
83
90
} ) ;
91
+ if ( config . allowOrgCreate ) {
92
+ this . orgItems . push ( { text : "New organization" , icon : "fa fa-fw fa-plus" , url : this . getUrl ( '/org/new' ) } ) ;
93
+ }
84
94
}
85
95
}
86
96
0 commit comments