mirror of
https://github.com/grafana/grafana.git
synced 2025-01-10 08:03:58 -06:00
refactor: sidemenu toggle & hiding logic
This commit is contained in:
parent
955dcf2418
commit
68dab71275
@ -79,21 +79,16 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
|||||||
sidemenuOpen = scope.contextSrv.sidemenu;
|
sidemenuOpen = scope.contextSrv.sidemenu;
|
||||||
body.toggleClass('sidemenu-open', sidemenuOpen);
|
body.toggleClass('sidemenu-open', sidemenuOpen);
|
||||||
|
|
||||||
scope.$watch('contextSrv.sidemenu', newVal => {
|
appEvents.on('toggle-sidemenu', () => {
|
||||||
if (sidemenuOpen !== scope.contextSrv.sidemenu) {
|
body.toggleClass('sidemenu-open');
|
||||||
sidemenuOpen = scope.contextSrv.sidemenu;
|
|
||||||
body.toggleClass('sidemenu-open', scope.contextSrv.sidemenu);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let sidemenuOpenSmallBreakpoint = scope.contextSrv.sidemenuSmallBreakpoint;
|
appEvents.on('toggle-sidemenu-mobile', () => {
|
||||||
body.toggleClass('sidemenu-open--xs', sidemenuOpenSmallBreakpoint);
|
body.toggleClass('sidemenu-open--xs');
|
||||||
|
});
|
||||||
|
|
||||||
scope.$watch('contextSrv.sidemenuSmallBreakpoint', newVal => {
|
appEvents.on('toggle-sidemenu-hidden', () => {
|
||||||
if (sidemenuOpenSmallBreakpoint !== scope.contextSrv.sidemenuSmallBreakpoint) {
|
body.toggleClass('sidemenu-hidden');
|
||||||
sidemenuOpenSmallBreakpoint = scope.contextSrv.sidemenuSmallBreakpoint;
|
|
||||||
body.toggleClass('sidemenu-open--xs', scope.contextSrv.sidemenuSmallBreakpoint);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// tooltip removal fix
|
// tooltip removal fix
|
||||||
@ -111,6 +106,9 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear body class sidemenu states
|
||||||
|
body.removeClass('sidemenu-open--xs');
|
||||||
|
|
||||||
$("#tooltip, .tooltip").remove();
|
$("#tooltip, .tooltip").remove();
|
||||||
|
|
||||||
// check for kiosk url param
|
// check for kiosk url param
|
||||||
|
@ -3,11 +3,10 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="sidemenu__logo_small_breakpoint" ng-click="ctrl.toggleSideMenuSmallBreakpoint()">
|
<a class="sidemenu__logo_small_breakpoint" ng-click="ctrl.toggleSideMenuSmallBreakpoint()">
|
||||||
<img src="public/img/grafana_icon.svg"></img>
|
<i class="fa fa-bars"></i>
|
||||||
<p class="sidemenu__close"><i class="fa fa-times"></i> Close</p>
|
<span class="sidemenu__close"><i class="fa fa-times"></i> Close</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
||||||
<div class="sidemenu__top">
|
<div class="sidemenu__top">
|
||||||
<div ng-repeat="item in ::ctrl.mainLinks" class="sidemenu-item dropdown">
|
<div ng-repeat="item in ::ctrl.mainLinks" class="sidemenu-item dropdown">
|
||||||
<a href="{{::item.url}}" class="sidemenu-link" target="{{::item.target}}">
|
<a href="{{::item.url}}" class="sidemenu-link" target="{{::item.target}}">
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
///<reference path="../../../headers/common.d.ts" />
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import coreModule from '../../core_module';
|
import coreModule from '../../core_module';
|
||||||
|
import appEvents from 'app/core/app_events';
|
||||||
|
|
||||||
export class SideMenuCtrl {
|
export class SideMenuCtrl {
|
||||||
user: any;
|
user: any;
|
||||||
@ -11,7 +10,7 @@ export class SideMenuCtrl {
|
|||||||
bottomNav: any;
|
bottomNav: any;
|
||||||
loginUrl: string;
|
loginUrl: string;
|
||||||
isSignedIn: boolean;
|
isSignedIn: boolean;
|
||||||
smallBPSideMenuOpen = false;
|
isOpenMobile: boolean;
|
||||||
|
|
||||||
/** @ngInject */
|
/** @ngInject */
|
||||||
constructor(private $scope, private $rootScope, private $location, private contextSrv, private $timeout) {
|
constructor(private $scope, private $rootScope, private $location, private contextSrv, private $timeout) {
|
||||||
@ -29,24 +28,21 @@ export class SideMenuCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.$scope.$on('$routeChangeSuccess', () => {
|
this.$scope.$on('$routeChangeSuccess', () => {
|
||||||
if (this.smallBPSideMenuOpen) {
|
|
||||||
this.contextSrv.setSideMenuForSmallBreakpoint(false, true);
|
|
||||||
this.smallBPSideMenuOpen = false;
|
|
||||||
}
|
|
||||||
this.loginUrl = 'login?redirect=' + encodeURIComponent(this.$location.path());
|
this.loginUrl = 'login?redirect=' + encodeURIComponent(this.$location.path());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSideMenu() {
|
toggleSideMenu() {
|
||||||
this.contextSrv.toggleSideMenu();
|
this.contextSrv.toggleSideMenu();
|
||||||
|
appEvents.emit('toggle-sidemenu');
|
||||||
|
|
||||||
this.$timeout(() => {
|
this.$timeout(() => {
|
||||||
this.$rootScope.$broadcast('render');
|
this.$rootScope.$broadcast('render');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSideMenuSmallBreakpoint() {
|
toggleSideMenuSmallBreakpoint() {
|
||||||
this.smallBPSideMenuOpen = !this.smallBPSideMenuOpen;
|
appEvents.emit('toggle-sidemenu-mobile');
|
||||||
this.contextSrv.setSideMenuForSmallBreakpoint(this.smallBPSideMenuOpen, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchOrg() {
|
switchOrg() {
|
||||||
@ -75,10 +71,6 @@ export function sideMenuDirective() {
|
|||||||
parent.append(menu);
|
parent.append(menu);
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.$on("$destory", function() {
|
|
||||||
elem.off('click.dropdown');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import coreModule from '../core_module';
|
import coreModule from '../core_module';
|
||||||
|
import appEvents from 'app/core/app_events';
|
||||||
|
|
||||||
export class ErrorCtrl {
|
export class ErrorCtrl {
|
||||||
|
|
||||||
@ -8,11 +9,14 @@ export class ErrorCtrl {
|
|||||||
$scope.navModel = navModelSrv.getNotFoundNav();
|
$scope.navModel = navModelSrv.getNotFoundNav();
|
||||||
$scope.appSubUrl = config.appSubUrl;
|
$scope.appSubUrl = config.appSubUrl;
|
||||||
|
|
||||||
var showSideMenu = contextSrv.sidemenu;
|
if (!contextSrv.isSignedIn) {
|
||||||
contextSrv.sidemenu = false;
|
appEvents.emit('toggle-sidemenu-hidden');
|
||||||
|
}
|
||||||
|
|
||||||
$scope.$on('$destroy', function() {
|
$scope.$on("destroy", () => {
|
||||||
contextSrv.sidemenu = showSideMenu;
|
if (!contextSrv.isSignedIn) {
|
||||||
|
appEvents.emit('toggle-sidemenu-hidden');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,13 +70,15 @@ export class NavModelSrv {
|
|||||||
|
|
||||||
getNotFoundNav() {
|
getNotFoundNav() {
|
||||||
var node = {
|
var node = {
|
||||||
text: "Page not found ",
|
text: "Page not found",
|
||||||
icon: "fa fa-fw fa-warning",
|
icon: "fa fa-fw fa-warning",
|
||||||
|
subTitle: "404 Error"
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
breadcrumbs: [node],
|
breadcrumbs: [node],
|
||||||
node: node
|
node: node,
|
||||||
|
main: node
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,23 +178,27 @@ function setupAngularRoutes($routeProvider, $locationProvider) {
|
|||||||
.when('/login', {
|
.when('/login', {
|
||||||
templateUrl: 'public/app/partials/login.html',
|
templateUrl: 'public/app/partials/login.html',
|
||||||
controller : 'LoginCtrl',
|
controller : 'LoginCtrl',
|
||||||
pageClass: 'page-login',
|
pageClass: 'sidemenu-hidden',
|
||||||
})
|
})
|
||||||
.when('/invite/:code', {
|
.when('/invite/:code', {
|
||||||
templateUrl: 'public/app/partials/signup_invited.html',
|
templateUrl: 'public/app/partials/signup_invited.html',
|
||||||
controller : 'InvitedCtrl',
|
controller : 'InvitedCtrl',
|
||||||
|
pageClass: 'sidemenu-hidden',
|
||||||
})
|
})
|
||||||
.when('/signup', {
|
.when('/signup', {
|
||||||
templateUrl: 'public/app/partials/signup_step2.html',
|
templateUrl: 'public/app/partials/signup_step2.html',
|
||||||
controller : 'SignUpCtrl',
|
controller : 'SignUpCtrl',
|
||||||
|
pageClass: 'sidemenu-hidden',
|
||||||
})
|
})
|
||||||
.when('/user/password/send-reset-email', {
|
.when('/user/password/send-reset-email', {
|
||||||
templateUrl: 'public/app/partials/reset_password.html',
|
templateUrl: 'public/app/partials/reset_password.html',
|
||||||
controller : 'ResetPasswordCtrl',
|
controller : 'ResetPasswordCtrl',
|
||||||
|
pageClass: 'sidemenu-hidden',
|
||||||
})
|
})
|
||||||
.when('/user/password/reset', {
|
.when('/user/password/reset', {
|
||||||
templateUrl: 'public/app/partials/reset_password.html',
|
templateUrl: 'public/app/partials/reset_password.html',
|
||||||
controller : 'ResetPasswordCtrl',
|
controller : 'ResetPasswordCtrl',
|
||||||
|
pageClass: 'sidemenu-hidden',
|
||||||
})
|
})
|
||||||
.when('/dashboard/snapshots', {
|
.when('/dashboard/snapshots', {
|
||||||
templateUrl: 'public/app/features/snapshot/partials/snapshots.html',
|
templateUrl: 'public/app/features/snapshot/partials/snapshots.html',
|
||||||
|
@ -58,10 +58,6 @@ export class ContextSrv {
|
|||||||
this.sidemenu = !this.sidemenu;
|
this.sidemenu = !this.sidemenu;
|
||||||
store.set('grafana.sidemenu', this.sidemenu);
|
store.set('grafana.sidemenu', this.sidemenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
setSideMenuForSmallBreakpoint(show: boolean, persistToggle: boolean) {
|
|
||||||
this.sidemenuSmallBreakpoint = show;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var contextSrv = new ContextSrv();
|
var contextSrv = new ContextSrv();
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
///<reference path="../../../headers/common.d.ts" />
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
@ -18,7 +16,6 @@ export class DashNavCtrl {
|
|||||||
private dashboardSrv,
|
private dashboardSrv,
|
||||||
private $location,
|
private $location,
|
||||||
private backendSrv,
|
private backendSrv,
|
||||||
private contextSrv,
|
|
||||||
public playlistSrv,
|
public playlistSrv,
|
||||||
navModelSrv) {
|
navModelSrv) {
|
||||||
this.navModel = navModelSrv.getDashboardNav(this.dashboard, this);
|
this.navModel = navModelSrv.getDashboardNav(this.dashboard, this);
|
||||||
@ -35,10 +32,6 @@ export class DashNavCtrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSideMenu() {
|
|
||||||
this.contextSrv.toggleSideMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
openEditView(editview) {
|
openEditView(editview) {
|
||||||
var search = _.extend(this.$location.search(), {editview: editview});
|
var search = _.extend(this.$location.search(), {editview: editview});
|
||||||
this.$location.search(search);
|
this.$location.search(search);
|
||||||
|
@ -1,19 +1,6 @@
|
|||||||
<div class="page-container">
|
<page-header model="navModel"></page-header>
|
||||||
<div class="page-header">
|
|
||||||
<div class="page-header__inner">
|
<div class="page-container page-body">
|
||||||
<span class="page-header__logo">
|
|
||||||
<i class="page-header__icon fa fa-fw fa-exclamation-triangle"></i>
|
|
||||||
</span>
|
|
||||||
<div class="page-header__info-block">
|
|
||||||
<h1 class="page-header__title">
|
|
||||||
Page not found
|
|
||||||
</h1>
|
|
||||||
<div class="page-header__sub-title">
|
|
||||||
404 Error
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="panel-container error-container">
|
<div class="panel-container error-container">
|
||||||
<div class="error-column graph-box">
|
<div class="error-column graph-box">
|
||||||
<div class="error-row">
|
<div class="error-row">
|
||||||
|
@ -58,13 +58,14 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row" style="margin-top: 20px">
|
<div style="margin-top: 20px">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<a href="login">Back to login</a>
|
<a href="login">Back to login</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -16,6 +16,14 @@
|
|||||||
.sidemenu__close {
|
.sidemenu__close {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// body class that hides sidemenu
|
||||||
|
.sidemenu-hidden {
|
||||||
|
.sidemenu {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@include media-breakpoint-up(sm) {
|
@include media-breakpoint-up(sm) {
|
||||||
@ -164,7 +172,7 @@ li.sidemenu-org-switcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidemenu__logo, .sidemenu__logo_small_breakpoint {
|
.sidemenu__logo {
|
||||||
display: block;
|
display: block;
|
||||||
padding: 0.4rem 1.0rem 0.4rem 0.65rem;
|
padding: 0.4rem 1.0rem 0.4rem 0.65rem;
|
||||||
min-height: $navbarHeight;
|
min-height: $navbarHeight;
|
||||||
@ -203,6 +211,8 @@ li.sidemenu-org-switcher {
|
|||||||
.sidemenu__close {
|
.sidemenu__close {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: $font-size-md;
|
font-size: $font-size-md;
|
||||||
|
position: relative;
|
||||||
|
top: -3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidemenu__top,
|
.sidemenu__top,
|
||||||
@ -215,14 +225,16 @@ li.sidemenu-org-switcher {
|
|||||||
.sidemenu__logo {
|
.sidemenu__logo {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidemenu__logo_small_breakpoint {
|
.sidemenu__logo_small_breakpoint {
|
||||||
|
padding: 12px 10px 26px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
|
|
||||||
&:hover {
|
.fa-bars {
|
||||||
background: transparent;
|
font-size: 25px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,12 +8,6 @@
|
|||||||
padding-top: $spacer * 5; /* BAD HACK - experiement to see how it looks */
|
padding-top: $spacer * 5; /* BAD HACK - experiement to see how it looks */
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-login {
|
|
||||||
.sidemenu {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-form {
|
.login-form {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
max-width: 24rem;
|
max-width: 24rem;
|
||||||
|
Loading…
Reference in New Issue
Block a user