mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* panel container menu gets new Explore entry (between Edit and Share) * entry only shows if datasource has `supportsExplore` set to true (set for Prometheus only for now) * click on Explore entry changes url to `/explore/state` via location provider * `state` is a JSON representation of the panel queries * datasources implement `getExploreState()` how to turn a panel config into explore initial state * Explore can parse the state and initialize its query expressions * ReactContainer now forwards route parameters as props to component * `pluginlist` and `singlestat` panel subclasses needed to be adapted because `panel_ctrl` now has the location provider as a property already
75 lines
2.0 KiB
TypeScript
75 lines
2.0 KiB
TypeScript
import _ from 'lodash';
|
|
import { PanelCtrl } from '../../../features/panel/panel_ctrl';
|
|
|
|
class PluginListCtrl extends PanelCtrl {
|
|
static templateUrl = 'module.html';
|
|
static scrollable = true;
|
|
|
|
pluginList: any[];
|
|
viewModel: any;
|
|
|
|
// Set and populate defaults
|
|
panelDefaults = {};
|
|
|
|
/** @ngInject */
|
|
constructor($scope, $injector, private backendSrv) {
|
|
super($scope, $injector);
|
|
|
|
_.defaults(this.panel, this.panelDefaults);
|
|
|
|
this.events.on('init-edit-mode', this.onInitEditMode.bind(this));
|
|
this.pluginList = [];
|
|
this.viewModel = [
|
|
{ header: 'Installed Apps', list: [], type: 'app' },
|
|
{ header: 'Installed Panels', list: [], type: 'panel' },
|
|
{ header: 'Installed Datasources', list: [], type: 'datasource' },
|
|
];
|
|
|
|
this.update();
|
|
}
|
|
|
|
onInitEditMode() {
|
|
this.editorTabIndex = 1;
|
|
this.addEditorTab('Options', 'public/app/plugins/panel/pluginlist/editor.html');
|
|
}
|
|
|
|
gotoPlugin(plugin, evt) {
|
|
if (evt) {
|
|
evt.stopPropagation();
|
|
}
|
|
this.$location.url(`plugins/${plugin.id}/edit`);
|
|
}
|
|
|
|
updateAvailable(plugin, $event) {
|
|
$event.stopPropagation();
|
|
$event.preventDefault();
|
|
|
|
var modalScope = this.$scope.$new(true);
|
|
modalScope.plugin = plugin;
|
|
|
|
this.publishAppEvent('show-modal', {
|
|
src: 'public/app/features/plugins/partials/update_instructions.html',
|
|
scope: modalScope,
|
|
});
|
|
}
|
|
|
|
update() {
|
|
this.backendSrv.get('api/plugins', { embedded: 0, core: 0 }).then(plugins => {
|
|
this.pluginList = plugins;
|
|
this.viewModel[0].list = _.filter(plugins, { type: 'app' });
|
|
this.viewModel[1].list = _.filter(plugins, { type: 'panel' });
|
|
this.viewModel[2].list = _.filter(plugins, { type: 'datasource' });
|
|
|
|
for (let plugin of this.pluginList) {
|
|
if (plugin.hasUpdate) {
|
|
plugin.state = 'has-update';
|
|
} else if (!plugin.enabled) {
|
|
plugin.state = 'not-enabled';
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
export { PluginListCtrl, PluginListCtrl as PanelCtrl };
|