diff --git a/public/app/core/services/keybindingSrv.ts b/public/app/core/services/keybindingSrv.ts index d0e74698e3f..64aeeddb522 100644 --- a/public/app/core/services/keybindingSrv.ts +++ b/public/app/core/services/keybindingSrv.ts @@ -213,16 +213,12 @@ export class KeybindingSrv { // collapse all rows this.bind('d shift+c', () => { - for (let row of dashboard.rows) { - row.collapse = true; - } + dashboard.collapseRows(); }); // expand all rows this.bind('d shift+e', () => { - for (let row of dashboard.rows) { - row.collapse = false; - } + dashboard.expandRows(); }); this.bind('d n', e => { diff --git a/public/app/features/dashboard/dashboard_model.ts b/public/app/features/dashboard/dashboard_model.ts index e35f8f0d430..3fa8ed9973a 100644 --- a/public/app/features/dashboard/dashboard_model.ts +++ b/public/app/features/dashboard/dashboard_model.ts @@ -524,6 +524,34 @@ export class DashboardModel { this.removePanel(row); } + expandRows() { + for (let i = 0; i < this.panels.length; i++) { + var panel = this.panels[i]; + + if (panel.type !== 'row') { + continue; + } + + if (panel.collapsed) { + this.toggleRow(panel); + } + } + } + + collapseRows() { + for (let i = 0; i < this.panels.length; i++) { + var panel = this.panels[i]; + + if (panel.type !== 'row') { + continue; + } + + if (!panel.collapsed) { + this.toggleRow(panel); + } + } + } + setPanelFocus(id) { this.meta.focusPanelId = id; }