浏览代码

refactor: minor change to panel json fix PR #10156

Torkel Ödegaard 8 年之前
父节点
当前提交
35c8cdf3a5
共有 1 个文件被更改,包括 7 次插入10 次删除
  1. 7 10
      public/app/features/panel/panel_ctrl.ts

+ 7 - 10
public/app/features/panel/panel_ctrl.ts

@@ -191,9 +191,8 @@ export class PanelCtrl {
 
   duplicate() {
     this.dashboard.duplicatePanel(this.panel);
-    let self = this;
     this.$timeout(() => {
-      self.$scope.$root.$broadcast('render');
+      this.$scope.$root.$broadcast('render');
     });
   }
 
@@ -240,18 +239,16 @@ export class PanelCtrl {
     let index = _.findIndex(dashboard.panels, (panel) => {
       return panel.id === oldPanel.id;
     });
+
     let deletedPanel = dashboard.panels.splice(index, 1);
     this.dashboard.events.emit('panel-removed', deletedPanel);
 
-    // adding it back needs to be done in next digest
-    this.$timeout(() => {
-      newPanel = new PanelModel(newPanel);
-      newPanel.id = oldPanel.id;
+    newPanel = new PanelModel(newPanel);
+    newPanel.id = oldPanel.id;
 
-      dashboard.panels.splice(index, 0, newPanel);
-      dashboard.sortPanelsByGridPos();
-      dashboard.events.emit('panel-added', newPanel);
-    });
+    dashboard.panels.splice(index, 0, newPanel);
+    dashboard.sortPanelsByGridPos();
+    dashboard.events.emit('panel-added', newPanel);
   }
 
   sharePanel() {