本文整理汇总了TypeScript中@grafana/ui.PanelPlugin类的典型用法代码示例。如果您正苦于以下问题:TypeScript PanelPlugin类的具体用法?TypeScript PanelPlugin怎么用?TypeScript PanelPlugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PanelPlugin类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: pluginLoaded
pluginLoaded(plugin: PanelPlugin) {
this.plugin = plugin;
if (plugin.panel && plugin.onPanelMigration) {
const version = getPluginVersion(plugin);
if (version !== this.pluginVersion) {
this.options = plugin.onPanelMigration(this);
this.pluginVersion = version;
}
}
}
示例2: changePlugin
changePlugin(newPlugin: PanelPlugin) {
const pluginId = newPlugin.meta.id;
const oldOptions: any = this.getOptionsToRemember();
const oldPluginId = this.type;
// for angular panels we must remove all events and let angular panels do some cleanup
if (this.plugin.angularPanelCtrl) {
this.destroy();
}
// remove panel type specific options
for (const key of _.keys(this)) {
if (mustKeepProps[key]) {
continue;
}
delete (this as any)[key];
}
this.cachedPluginOptions[oldPluginId] = oldOptions;
this.restorePanelOptions(pluginId);
// switch
this.type = pluginId;
this.plugin = newPlugin;
// Let panel plugins inspect options from previous panel and keep any that it can use
if (newPlugin.onPanelTypeChanged) {
this.options = this.options || {};
const old = oldOptions && oldOptions.options ? oldOptions.options : {};
Object.assign(this.options, newPlugin.onPanelTypeChanged(this.options, oldPluginId, old));
}
if (newPlugin.onPanelMigration) {
this.pluginVersion = getPluginVersion(newPlugin);
}
}