From 7cb6093dba91097ab81a7f3b5cd43b8f185fa111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 10 Aug 2017 15:08:53 +0200 Subject: [PATCH] new-grid: fixed destory issues --- .../app/features/dashboard/dashgrid/dashgrid.ts | 17 +++++++++++++++-- public/app/features/dashboard/model.ts | 1 - 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/public/app/features/dashboard/dashgrid/dashgrid.ts b/public/app/features/dashboard/dashgrid/dashgrid.ts index ec2b51cf628..6b9c6c360b8 100644 --- a/public/app/features/dashboard/dashgrid/dashgrid.ts +++ b/public/app/features/dashboard/dashgrid/dashgrid.ts @@ -58,11 +58,20 @@ export class GridCtrl { } bindItem(element) { - this.gridstack.makeWidget(element); + if (this.gridstack) { + this.gridstack.makeWidget(element); + } } removeItem(element) { - this.gridstack.removeWidget(element, false); + if (this.gridstack) { + this.gridstack.removeWidget(element, false); + } + } + + destroy() { + this.gridstack.destroy(); + this.gridstack = null; } } @@ -81,6 +90,10 @@ export function dashGrid($timeout) { $timeout(function() { ctrl.init(); }); + + scope.$on('$destroy', () => { + ctrl.destroy(); + }); } }; } diff --git a/public/app/features/dashboard/model.ts b/public/app/features/dashboard/model.ts index 96faff0395d..635485952d1 100644 --- a/public/app/features/dashboard/model.ts +++ b/public/app/features/dashboard/model.ts @@ -653,7 +653,6 @@ export class DashboardModel { if (oldVersion < 15) { this.upgradeToGridLayout(); - console.log(this.panels); } if (panelUpgrades.length === 0) {