@ -14,7 +14,7 @@ export class KeybindingSrv {
timepickerOpen = false ;
/** @ngInject */
constructor ( private $rootScope , private $location , private datasourceSrv , private timeSrv ) {
constructor ( private $rootScope , private $location , private datasourceSrv , private timeSrv , private contextSrv ) {
// clear out all shortcuts on route change
$rootScope . $on ( '$routeChangeSuccess' , ( ) = > {
Mousetrap . reset ( ) ;
@ -177,21 +177,24 @@ export class KeybindingSrv {
}
} ) ;
this . bind ( 'x' , async ( ) = > {
if ( dashboard . meta . focusPanelId ) {
const panel = dashboard . getPanelById ( dashboard . meta . focusPanelId ) ;
const datasource = await this . datasourceSrv . get ( panel . datasource ) ;
if ( datasource && datasource . supportsExplore ) {
const range = this . timeSrv . timeRangeForUrl ( ) ;
const state = {
. . . datasource . getExploreState ( panel ) ,
range ,
} ;
const exploreState = encodePathComponent ( JSON . stringify ( state ) ) ;
this . $location . url ( ` /explore/ ${ exploreState } ` ) ;
// jump to explore if permissions allow
if ( this . contextSrv . isEditor ) {
this . bind ( 'x' , async ( ) = > {
if ( dashboard . meta . focusPanelId ) {
const panel = dashboard . getPanelById ( dashboard . meta . focusPanelId ) ;
const datasource = await this . datasourceSrv . get ( panel . datasource ) ;
if ( datasource && datasource . supportsExplore ) {
const range = this . timeSrv . timeRangeForUrl ( ) ;
const state = {
. . . datasource . getExploreState ( panel ) ,
range ,
} ;
const exploreState = encodePathComponent ( JSON . stringify ( state ) ) ;
this . $location . url ( ` /explore/ ${ exploreState } ` ) ;
}
}
}
} ) ;
} ) ;
}
// delete panel
this . bind ( 'p r' , ( ) = > {