Commit 1618b095 by Tobias Skarhed Committed by Torkel Ödegaard

Use and add keybard shortcut

parent 63fa9fdc
...@@ -15,7 +15,14 @@ export class KeybindingSrv { ...@@ -15,7 +15,14 @@ export class KeybindingSrv {
timepickerOpen = false; timepickerOpen = false;
/** @ngInject */ /** @ngInject */
constructor(private $rootScope, private $location, private datasourceSrv, private timeSrv, private contextSrv) { constructor(
private $rootScope,
private $location,
private datasourceSrv,
private timeSrv,
private contextSrv,
private $window
) {
// clear out all shortcuts on route change // clear out all shortcuts on route change
$rootScope.$on('$routeChangeSuccess', () => { $rootScope.$on('$routeChangeSuccess', () => {
Mousetrap.reset(); Mousetrap.reset();
...@@ -259,6 +266,13 @@ export class KeybindingSrv { ...@@ -259,6 +266,13 @@ export class KeybindingSrv {
this.bind('d v', () => { this.bind('d v', () => {
appEvents.emit('toggle-view-mode'); appEvents.emit('toggle-view-mode');
}); });
//Autofit panels
this.bind('d a', () => {
this.$location.search('autofitpanels', this.$location.search().autofitpanels ? null : true);
//Force reload
this.$window.location.href = this.$location.absUrl();
});
} }
} }
......
...@@ -24,7 +24,8 @@ export class DashboardCtrl implements PanelContainer { ...@@ -24,7 +24,8 @@ export class DashboardCtrl implements PanelContainer {
private unsavedChangesSrv, private unsavedChangesSrv,
private dashboardViewStateSrv, private dashboardViewStateSrv,
public playlistSrv, public playlistSrv,
private panelLoader private panelLoader,
private $location
) { ) {
// temp hack due to way dashboards are loaded // temp hack due to way dashboards are loaded
// can't use controllerAs on route yet // can't use controllerAs on route yet
...@@ -64,7 +65,7 @@ export class DashboardCtrl implements PanelContainer { ...@@ -64,7 +65,7 @@ export class DashboardCtrl implements PanelContainer {
this.dashboard = dashboard; this.dashboard = dashboard;
this.dashboard.processRepeats(); this.dashboard.processRepeats();
if (window.location.search.search('autofitpanels') !== -1) { if (this.$location.search().autofitpanels) {
let maxRows = Math.max( let maxRows = Math.max(
...this.dashboard.panels.map(panel => { ...this.dashboard.panels.map(panel => {
return panel.gridPos.h + panel.gridPos.y; return panel.gridPos.h + panel.gridPos.y;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment