mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Panel: plugins panels can now reside outsude the app/panels directory, added example plugin panel
This commit is contained in:
parent
920689b80e
commit
1330488e13
@ -3,8 +3,10 @@
|
|||||||
**UI Improvements*
|
**UI Improvements*
|
||||||
- [Issue #770](https://github.com/grafana/grafana/issues/770). UI: Panel dropdown menu replaced with a new panel menu
|
- [Issue #770](https://github.com/grafana/grafana/issues/770). UI: Panel dropdown menu replaced with a new panel menu
|
||||||
|
|
||||||
|
**Misc**
|
||||||
- [Issue #877](https://github.com/grafana/grafana/issues/877). Graph: Smart auto decimal precision when using scaled unit formats
|
- [Issue #877](https://github.com/grafana/grafana/issues/877). Graph: Smart auto decimal precision when using scaled unit formats
|
||||||
- [Issue #850](https://github.com/grafana/grafana/issues/850). Graph: Shared tooltip that shows multiple series & crosshair line, thx @toni-moreno
|
- [Issue #850](https://github.com/grafana/grafana/issues/850). Graph: Shared tooltip that shows multiple series & crosshair line, thx @toni-moreno
|
||||||
|
- [Issue #938](https://github.com/grafana/grafana/issues/938). Panel: Plugin panels now reside outside of app/panels directory
|
||||||
|
|
||||||
**Fixes**
|
**Fixes**
|
||||||
- [Issue #925](https://github.com/grafana/grafana/issues/925). Graph: bar width calculation fix for some edge cases (bars would render on top of each other)
|
- [Issue #925](https://github.com/grafana/grafana/issues/925). Graph: bar width calculation fix for some edge cases (bars would render on top of each other)
|
||||||
|
@ -57,7 +57,6 @@ function (angular, $, _, appLevelRequire, config) {
|
|||||||
register_fns.factory = $provide.factory;
|
register_fns.factory = $provide.factory;
|
||||||
register_fns.service = $provide.service;
|
register_fns.service = $provide.service;
|
||||||
register_fns.filter = $filterProvider.register;
|
register_fns.filter = $filterProvider.register;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var apps_deps = [
|
var apps_deps = [
|
||||||
|
@ -15,7 +15,10 @@ function (_, crypto) {
|
|||||||
var defaults = {
|
var defaults = {
|
||||||
datasources : {},
|
datasources : {},
|
||||||
window_title_prefix : 'Grafana - ',
|
window_title_prefix : 'Grafana - ',
|
||||||
panels : ['graph', 'text'],
|
panels : {
|
||||||
|
'graph': { path: 'panels/graph' },
|
||||||
|
'text': { path: 'panels/text' }
|
||||||
|
},
|
||||||
plugins : {},
|
plugins : {},
|
||||||
default_route : '/dashboard/file/default.json',
|
default_route : '/dashboard/file/default.json',
|
||||||
playlist_timespan : "1m",
|
playlist_timespan : "1m",
|
||||||
@ -76,7 +79,7 @@ function (_, crypto) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (settings.plugins.panels) {
|
if (settings.plugins.panels) {
|
||||||
settings.panels = _.union(settings.panels, settings.plugins.panels);
|
_.extend(settings.panels, settings.plugins.panels);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!settings.plugins.dependencies) {
|
if (!settings.plugins.dependencies) {
|
||||||
|
@ -21,7 +21,7 @@ function (angular, $, config, _) {
|
|||||||
$timeout) {
|
$timeout) {
|
||||||
|
|
||||||
$scope.editor = { index: 0 };
|
$scope.editor = { index: 0 };
|
||||||
$scope.panelNames = config.panels;
|
$scope.panelNames = _.map(config.panels, function(value, key) { return key; });
|
||||||
var resizeEventTimeout;
|
var resizeEventTimeout;
|
||||||
|
|
||||||
this.init = function(dashboardData) {
|
this.init = function(dashboardData) {
|
||||||
@ -90,21 +90,12 @@ function (angular, $, config, _) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.edit_path = function(type) {
|
$scope.panelEditorPath = function(type) {
|
||||||
var p = $scope.panel_path(type);
|
return 'app/' + config.panels[type].path + '/editor.html';
|
||||||
if(p) {
|
|
||||||
return p+'/editor.html';
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.panel_path =function(type) {
|
$scope.pulldownEditorPath = function(type) {
|
||||||
if(type) {
|
return 'app/panels/'+type+'/editor.html';
|
||||||
return 'app/panels/'+type.replace(".","/");
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.showJsonEditor = function(evt, options) {
|
$scope.showJsonEditor = function(evt, options) {
|
||||||
|
@ -201,7 +201,7 @@ function (angular, _, config, gfunc, Parser) {
|
|||||||
|
|
||||||
$scope.targetTextChanged = function() {
|
$scope.targetTextChanged = function() {
|
||||||
parseTarget();
|
parseTarget();
|
||||||
$scope.$parent.get_data();
|
$scope.get_data();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.targetChanged = function() {
|
$scope.targetChanged = function() {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
define([
|
define([
|
||||||
'angular',
|
'angular',
|
||||||
'jquery',
|
'jquery',
|
||||||
|
'config',
|
||||||
'./panelMenu',
|
'./panelMenu',
|
||||||
],
|
],
|
||||||
function (angular, $) {
|
function (angular, $, config) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular
|
angular
|
||||||
@ -68,10 +69,12 @@ function (angular, $) {
|
|||||||
|
|
||||||
elem.addClass('ng-cloak');
|
elem.addClass('ng-cloak');
|
||||||
|
|
||||||
|
var panelPath = config.panels[panelType].path;
|
||||||
|
|
||||||
$scope.require([
|
$scope.require([
|
||||||
'jquery',
|
'jquery',
|
||||||
'text!panels/'+panelType+'/module.html',
|
'text!'+panelPath+'/module.html',
|
||||||
'panels/' + panelType + "/module",
|
panelPath + "/module",
|
||||||
], function ($, moduleTemplate) {
|
], function ($, moduleTemplate) {
|
||||||
var $module = $(moduleTemplate);
|
var $module = $(moduleTemplate);
|
||||||
$module.prepend(panelHeader);
|
$module.prepend(panelHeader);
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-repeat="pulldown in dashboard.nav" ng-controller="SubmenuCtrl" ng-show="editor.index == 4+$index">
|
<div ng-repeat="pulldown in dashboard.nav" ng-controller="SubmenuCtrl" ng-show="editor.index == 4+$index">
|
||||||
<ng-include ng-show="pulldown.enable" src="edit_path(pulldown.type)"></ng-include>
|
<ng-include ng-show="pulldown.enable" src="pulldownEditorPath(pulldown.type)"></ng-include>
|
||||||
<button ng-hide="pulldown.enable" class="btn" ng-click="pulldown.enable = true">Enable the {{pulldown.type}}</button>
|
<button ng-hide="pulldown.enable" class="btn" ng-click="pulldown.enable = true">Enable the {{pulldown.type}}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show="editorTabs[editor.index] == 'Panel'">
|
<div ng-show="editorTabs[editor.index] == 'Panel'">
|
||||||
<div ng-include src="edit_path(panel.type)"></div>
|
<div ng-include src="panelEditorPath(panel.type)"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-repeat="tab in panelMeta.editorTabs" ng-show="editorTabs[editor.index] == tab.title">
|
<div ng-repeat="tab in panelMeta.editorTabs" ng-show="editorTabs[editor.index] == tab.title">
|
||||||
|
10
src/plugins/custom.panel.example/editor.html
Normal file
10
src/plugins/custom.panel.example/editor.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<div>
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span4">
|
||||||
|
<label class="small">Mode</label> <select class="input-medium" ng-model="panel.mode" ng-options="f for f in ['html','markdown','text']"></select>
|
||||||
|
</div>
|
||||||
|
<div class="span2" ng-show="panel.mode == 'text'">
|
||||||
|
<label class="small">Font Size</label> <select class="input-mini" ng-model="panel.style['font-size']" ng-options="f for f in ['6pt','7pt','8pt','10pt','12pt','14pt','16pt','18pt','20pt','24pt','28pt','32pt','36pt','42pt','48pt','52pt','60pt','72pt']"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
3
src/plugins/custom.panel.example/module.html
Normal file
3
src/plugins/custom.panel.example/module.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<div ng-controller='CustomPanelCtrl'>
|
||||||
|
<h2>Custom panel</h2>
|
||||||
|
</div>
|
31
src/plugins/custom.panel.example/module.js
Normal file
31
src/plugins/custom.panel.example/module.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
define([
|
||||||
|
'angular',
|
||||||
|
'app',
|
||||||
|
'lodash',
|
||||||
|
'require',
|
||||||
|
],
|
||||||
|
function (angular, app, _) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var module = angular.module('grafana.panels.custom', []);
|
||||||
|
app.useModule(module);
|
||||||
|
|
||||||
|
module.controller('CustomPanelCtrl', function($scope, panelSrv) {
|
||||||
|
|
||||||
|
$scope.panelMeta = {
|
||||||
|
description : "Example plugin panel",
|
||||||
|
};
|
||||||
|
|
||||||
|
// set and populate defaults
|
||||||
|
var _d = {
|
||||||
|
};
|
||||||
|
|
||||||
|
_.defaults($scope.panel, _d);
|
||||||
|
|
||||||
|
$scope.init = function() {
|
||||||
|
panelSrv.init($scope);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.init();
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user