mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ux: making org visibile in profile view
This commit is contained in:
@@ -36,7 +36,16 @@
|
||||
<img ng-src="{{::item.img}}" ng-show="::item.img">
|
||||
</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu--sidemenu" role="menu" ng-if="::item.children">
|
||||
<ul class="dropdown-menu dropdown-menu--sidemenu" role="menu">
|
||||
<li ng-if="item.showOrgSwitcher" class="sidemenu-org-switcher">
|
||||
<a ng-click="ctrl.switchOrg()">
|
||||
<div>
|
||||
<div class="sidemenu-org-switcher__org-name">{{ctrl.contextSrv.user.orgName}}</div>
|
||||
<div class="sidemenu-org-switcher__org-current">Current Org:</div>
|
||||
</div>
|
||||
<div class="sidemenu-org-switcher__switch"><i class="fa fa-fw fa-random"></i>Switch</div>
|
||||
</a>
|
||||
</li>
|
||||
<li ng-repeat="child in ::item.children" ng-class="{divider: child.divider}" ng-hide="::child.hideFromMenu">
|
||||
<a href="{{::child.url}}" target="{{::child.target}}">
|
||||
<i class="{{::child.icon}}" ng-show="::child.icon"></i>
|
||||
|
||||
@@ -6,7 +6,6 @@ import $ from 'jquery';
|
||||
import coreModule from '../../core_module';
|
||||
|
||||
export class SideMenuCtrl {
|
||||
isSignedIn: boolean;
|
||||
user: any;
|
||||
mainLinks: any;
|
||||
bottomNav: any;
|
||||
@@ -19,7 +18,6 @@ export class SideMenuCtrl {
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private $scope, private $rootScope, private $location, private contextSrv, private backendSrv, private $element) {
|
||||
this.isSignedIn = contextSrv.isSignedIn;
|
||||
this.user = contextSrv.user;
|
||||
this.appSubUrl = config.appSubUrl;
|
||||
this.maxShownOrgs = 10;
|
||||
@@ -27,6 +25,13 @@ export class SideMenuCtrl {
|
||||
this.bottomNav = _.filter(config.bootData.navTree, item => item.hideFromMenu);
|
||||
this.loginUrl = 'login?redirect=' + encodeURIComponent(this.$location.path());
|
||||
|
||||
if (contextSrv.user.orgCount > 1) {
|
||||
let profileNode = _.find(this.bottomNav, {id: 'profile'});
|
||||
if (profileNode) {
|
||||
profileNode.showOrgSwitcher = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.$scope.$on('$routeChangeSuccess', () => {
|
||||
if (!this.contextSrv.pinned) {
|
||||
this.contextSrv.sidemenu = false;
|
||||
@@ -44,60 +49,6 @@ export class SideMenuCtrl {
|
||||
search() {
|
||||
this.$rootScope.appEvent('show-dash-search');
|
||||
}
|
||||
|
||||
openUserDropdown() {
|
||||
|
||||
// if (this.contextSrv.hasRole('Admin')) {
|
||||
// this.orgMenu.push({section: this.user.orgName, cssClass: 'dropdown-menu-title'});
|
||||
// this.orgMenu.push({
|
||||
// text: "Preferences",
|
||||
// url: this.getUrl("/org")
|
||||
// });
|
||||
// this.orgMenu.push({
|
||||
// text: "Users",
|
||||
// url: this.getUrl("/org/users")
|
||||
// });
|
||||
// this.orgMenu.push({
|
||||
// text: "User Groups",
|
||||
// url: this.getUrl("/org/user-groups")
|
||||
// });
|
||||
// this.orgMenu.push({
|
||||
// text: "API Keys",
|
||||
// url: this.getUrl("/org/apikeys")
|
||||
// });
|
||||
// }
|
||||
|
||||
// this.orgMenu.push({cssClass: "divider"});
|
||||
// this.backendSrv.get('/api/user/orgs').then(orgs => {
|
||||
// this.orgs = orgs;
|
||||
// this.loadOrgsItems();
|
||||
// });
|
||||
}
|
||||
|
||||
loadOrgsItems(){
|
||||
this.orgItems = [];
|
||||
this.orgs.forEach(org => {
|
||||
if (org.orgId === this.contextSrv.user.orgId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.orgItems.length === this.maxShownOrgs) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.orgFilter === '' || (org.name.toLowerCase().indexOf(this.orgFilter.toLowerCase()) !== -1)) {
|
||||
this.orgItems.push({
|
||||
text: "Switch to " + org.name,
|
||||
icon: "fa fa-fw fa-random",
|
||||
url: this.getUrl('/profile/switch-org/' + org.orgId),
|
||||
target: '_self'
|
||||
});
|
||||
}
|
||||
});
|
||||
if (config.allowOrgCreate) {
|
||||
this.orgItems.push({text: "New organization", icon: "fa fa-fw fa-plus", url: this.getUrl('/org/new')});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function sideMenuDirective() {
|
||||
|
||||
Reference in New Issue
Block a user