|
@@ -13,6 +13,10 @@ export class SideMenuCtrl {
|
|
|
orgMenu: any;
|
|
orgMenu: any;
|
|
|
appSubUrl: string;
|
|
appSubUrl: string;
|
|
|
loginUrl: string;
|
|
loginUrl: string;
|
|
|
|
|
+ orgFilter: string;
|
|
|
|
|
+ orgItems: any;
|
|
|
|
|
+ orgs: any;
|
|
|
|
|
+ maxShownOrgs: number;
|
|
|
|
|
|
|
|
/** @ngInject */
|
|
/** @ngInject */
|
|
|
constructor(private $scope, private $location, private contextSrv, private backendSrv, private $element) {
|
|
constructor(private $scope, private $location, private contextSrv, private backendSrv, private $element) {
|
|
@@ -20,6 +24,7 @@ export class SideMenuCtrl {
|
|
|
this.user = contextSrv.user;
|
|
this.user = contextSrv.user;
|
|
|
this.appSubUrl = config.appSubUrl;
|
|
this.appSubUrl = config.appSubUrl;
|
|
|
this.showSignout = this.contextSrv.isSignedIn && !config['authProxyEnabled'];
|
|
this.showSignout = this.contextSrv.isSignedIn && !config['authProxyEnabled'];
|
|
|
|
|
+ this.maxShownOrgs = 10;
|
|
|
|
|
|
|
|
this.mainLinks = config.bootData.mainNavLinks;
|
|
this.mainLinks = config.bootData.mainNavLinks;
|
|
|
this.openUserDropdown();
|
|
this.openUserDropdown();
|
|
@@ -31,6 +36,8 @@ export class SideMenuCtrl {
|
|
|
}
|
|
}
|
|
|
this.loginUrl = 'login?redirect=' + encodeURIComponent(this.$location.path());
|
|
this.loginUrl = 'login?redirect=' + encodeURIComponent(this.$location.path());
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ this.orgFilter = '';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
getUrl(url) {
|
|
getUrl(url) {
|
|
@@ -51,38 +58,44 @@ export class SideMenuCtrl {
|
|
|
this.orgMenu.push({section: this.user.orgName, cssClass: 'dropdown-menu-title'});
|
|
this.orgMenu.push({section: this.user.orgName, cssClass: 'dropdown-menu-title'});
|
|
|
this.orgMenu.push({
|
|
this.orgMenu.push({
|
|
|
text: "Preferences",
|
|
text: "Preferences",
|
|
|
- url: this.getUrl("/org"),
|
|
|
|
|
|
|
+ url: this.getUrl("/org")
|
|
|
});
|
|
});
|
|
|
this.orgMenu.push({
|
|
this.orgMenu.push({
|
|
|
text: "Users",
|
|
text: "Users",
|
|
|
- url: this.getUrl("/org/users"),
|
|
|
|
|
|
|
+ url: this.getUrl("/org/users")
|
|
|
});
|
|
});
|
|
|
this.orgMenu.push({
|
|
this.orgMenu.push({
|
|
|
text: "API Keys",
|
|
text: "API Keys",
|
|
|
- url: this.getUrl("/org/apikeys"),
|
|
|
|
|
|
|
+ url: this.getUrl("/org/apikeys")
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.orgMenu.push({cssClass: "divider"});
|
|
this.orgMenu.push({cssClass: "divider"});
|
|
|
-
|
|
|
|
|
this.backendSrv.get('/api/user/orgs').then(orgs => {
|
|
this.backendSrv.get('/api/user/orgs').then(orgs => {
|
|
|
- orgs.forEach(org => {
|
|
|
|
|
- if (org.orgId === this.contextSrv.user.orgId) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.orgs = orgs;
|
|
|
|
|
+ this.loadOrgsItems();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- this.orgMenu.push({
|
|
|
|
|
|
|
+ loadOrgsItems(){
|
|
|
|
|
+ this.orgItems = [];
|
|
|
|
|
+ this.orgs.forEach(org => {
|
|
|
|
|
+ if (org.orgId === this.contextSrv.user.orgId) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (this.orgItems.length < this.maxShownOrgs && (this.orgFilter === '' || org.name.indexOf(this.orgFilter) !== -1)){
|
|
|
|
|
+ this.orgItems.push({
|
|
|
text: "Switch to " + org.name,
|
|
text: "Switch to " + org.name,
|
|
|
icon: "fa fa-fw fa-random",
|
|
icon: "fa fa-fw fa-random",
|
|
|
url: this.getUrl('/profile/switch-org/' + org.orgId),
|
|
url: this.getUrl('/profile/switch-org/' + org.orgId),
|
|
|
target: '_self'
|
|
target: '_self'
|
|
|
});
|
|
});
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- if (config.allowOrgCreate) {
|
|
|
|
|
- this.orgMenu.push({text: "New organization", icon: "fa fa-fw fa-plus", url: this.getUrl('/org/new')});
|
|
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ if (config.allowOrgCreate) {
|
|
|
|
|
+ this.orgItems.push({text: "New organization", icon: "fa fa-fw fa-plus", url: this.getUrl('/org/new')});
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|