Library Panels: Fix refresh when changing to angular library panel (#35048)
Closes #34874
This commit is contained in:
+7
-3
@@ -7,7 +7,7 @@ import { Button, useStyles2, VerticalGroup } from '@grafana/ui';
|
|||||||
import { PanelModel } from 'app/features/dashboard/state';
|
import { PanelModel } from 'app/features/dashboard/state';
|
||||||
import { AddLibraryPanelModal } from '../AddLibraryPanelModal/AddLibraryPanelModal';
|
import { AddLibraryPanelModal } from '../AddLibraryPanelModal/AddLibraryPanelModal';
|
||||||
import { LibraryPanelsView } from '../LibraryPanelsView/LibraryPanelsView';
|
import { LibraryPanelsView } from '../LibraryPanelsView/LibraryPanelsView';
|
||||||
import { PanelOptionsChangedEvent, PanelQueriesChangedEvent } from 'app/types/events';
|
import { PanelDirectiveReadyEvent, PanelOptionsChangedEvent, PanelQueriesChangedEvent } from 'app/types/events';
|
||||||
import { LibraryElementDTO } from '../../types';
|
import { LibraryElementDTO } from '../../types';
|
||||||
import { toPanelModelLibraryPanel } from '../../utils';
|
import { toPanelModelLibraryPanel } from '../../utils';
|
||||||
import { changePanelPlugin } from 'app/features/dashboard/state/actions';
|
import { changePanelPlugin } from 'app/features/dashboard/state/actions';
|
||||||
@@ -55,8 +55,12 @@ export const PanelLibraryOptionsGroup: FC<Props> = ({ panel, searchQuery }) => {
|
|||||||
|
|
||||||
panel.configRev = 0;
|
panel.configRev = 0;
|
||||||
panel.refresh();
|
panel.refresh();
|
||||||
panel.events.publish(new PanelQueriesChangedEvent());
|
const unsubscribeEvent = panel.events.subscribe(PanelDirectiveReadyEvent, () => {
|
||||||
panel.events.publish(new PanelOptionsChangedEvent());
|
panel.refresh();
|
||||||
|
unsubscribeEvent.unsubscribe();
|
||||||
|
});
|
||||||
|
panel.events.publish(PanelQueriesChangedEvent);
|
||||||
|
panel.events.publish(PanelOptionsChangedEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onAddToPanelLibrary = () => {
|
const onAddToPanelLibrary = () => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { PanelEvents } from '@grafana/data';
|
|||||||
import { PanelModel } from '../dashboard/state';
|
import { PanelModel } from '../dashboard/state';
|
||||||
import { PanelCtrl } from './panel_ctrl';
|
import { PanelCtrl } from './panel_ctrl';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { RefreshEvent, RenderEvent } from 'app/types/events';
|
import { PanelDirectiveReadyEvent, RefreshEvent, RenderEvent } from 'app/types/events';
|
||||||
import { coreModule } from 'app/core/core_module';
|
import { coreModule } from 'app/core/core_module';
|
||||||
|
|
||||||
const panelTemplate = `
|
const panelTemplate = `
|
||||||
@@ -113,6 +113,8 @@ coreModule.directive('grafanaPanel', ($rootScope, $document, $timeout) => {
|
|||||||
panelScrollbar.dispose();
|
panelScrollbar.dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
panel.events.publish(PanelDirectiveReadyEvent);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -148,6 +148,10 @@ export class RefreshEvent extends BusEventBase {
|
|||||||
static type = 'refresh';
|
static type = 'refresh';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class PanelDirectiveReadyEvent extends BusEventBase {
|
||||||
|
static type = 'panel-directive-ready';
|
||||||
|
}
|
||||||
|
|
||||||
export class RenderEvent extends BusEventBase {
|
export class RenderEvent extends BusEventBase {
|
||||||
static type = 'render';
|
static type = 'render';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user