Commit 741e5a38 by Torkel Ödegaard

Merge branch 'feat-9887' of https://github.com/alexanderzobnin/grafana into…

Merge branch 'feat-9887' of https://github.com/alexanderzobnin/grafana into alexanderzobnin-feat-9887
parents ccbdb29f 10e3b63d
...@@ -31,6 +31,7 @@ export class PanelCtrl { ...@@ -31,6 +31,7 @@ export class PanelCtrl {
containerHeight: any; containerHeight: any;
events: Emitter; events: Emitter;
timing: any; timing: any;
scrollable: boolean;
constructor($scope, $injector) { constructor($scope, $injector) {
this.$injector = $injector; this.$injector = $injector;
...@@ -39,6 +40,7 @@ export class PanelCtrl { ...@@ -39,6 +40,7 @@ export class PanelCtrl {
this.editorTabIndex = 0; this.editorTabIndex = 0;
this.events = this.panel.events; this.events = this.panel.events;
this.timing = {}; this.timing = {};
this.scrollable = false;
var plugin = config.panels[this.panel.type]; var plugin = config.panels[this.panel.type];
if (plugin) { if (plugin) {
...@@ -64,6 +66,7 @@ export class PanelCtrl { ...@@ -64,6 +66,7 @@ export class PanelCtrl {
} }
refresh() { refresh() {
this.setPanelHeight();
this.events.emit('refresh', null); this.events.emit('refresh', null);
} }
...@@ -72,6 +75,7 @@ export class PanelCtrl { ...@@ -72,6 +75,7 @@ export class PanelCtrl {
} }
changeView(fullscreen, edit) { changeView(fullscreen, edit) {
this.setPanelHeight();
this.publishAppEvent('panel-change-view', { this.publishAppEvent('panel-change-view', {
fullscreen: fullscreen, edit: edit, panelId: this.panel.id fullscreen: fullscreen, edit: edit, panelId: this.panel.id
}); });
...@@ -168,8 +172,15 @@ export class PanelCtrl { ...@@ -168,8 +172,15 @@ export class PanelCtrl {
this.height = this.containerHeight - (PANEL_BORDER + PANEL_PADDING + (this.panel.title ? TITLE_HEIGHT : EMPTY_TITLE_HEIGHT)); this.height = this.containerHeight - (PANEL_BORDER + PANEL_PADDING + (this.panel.title ? TITLE_HEIGHT : EMPTY_TITLE_HEIGHT));
} }
setPanelHeight() {
if (this.scrollable) {
this.$scope.setPanelHeight();
}
}
render(payload?) { render(payload?) {
this.timing.renderStart = new Date().getTime(); this.timing.renderStart = new Date().getTime();
this.setPanelHeight();
this.events.emit('render', payload); this.events.emit('render', payload);
} }
......
...@@ -21,7 +21,12 @@ var panelTemplate = ` ...@@ -21,7 +21,12 @@ var panelTemplate = `
</div> </div>
<div class="panel-content"> <div class="panel-content">
<ng-transclude></ng-transclude> <div gemini-scrollbar ng-if="ctrl.scrollable">
<div class="panel-content--scrollable">
<ng-transclude></ng-transclude>
</div>
</div>
<ng-transclude ng-if="!ctrl.scrollable"></ng-transclude>
</div> </div>
</div> </div>
...@@ -62,6 +67,7 @@ module.directive('grafanaPanel', function($rootScope, $document) { ...@@ -62,6 +67,7 @@ module.directive('grafanaPanel', function($rootScope, $document) {
scope: { ctrl: "=" }, scope: { ctrl: "=" },
link: function(scope, elem) { link: function(scope, elem) {
var panelContainer = elem.find('.panel-container'); var panelContainer = elem.find('.panel-container');
var panelContent = elem.find('.panel-content');
var cornerInfoElem = elem.find('.panel-info-corner'); var cornerInfoElem = elem.find('.panel-info-corner');
var ctrl = scope.ctrl; var ctrl = scope.ctrl;
var infoDrop; var infoDrop;
...@@ -84,6 +90,11 @@ module.directive('grafanaPanel', function($rootScope, $document) { ...@@ -84,6 +90,11 @@ module.directive('grafanaPanel', function($rootScope, $document) {
ctrl.dashboard.setPanelFocus(0); ctrl.dashboard.setPanelFocus(0);
} }
function setPanelHeight() {
panelContent.height(ctrl.height);
}
ctrl.$scope.setPanelHeight = setPanelHeight;
// set initial height // set initial height
if (!ctrl.containerHeight) { if (!ctrl.containerHeight) {
ctrl.calculatePanelHeight(); ctrl.calculatePanelHeight();
......
...@@ -38,6 +38,7 @@ class AlertListPanel extends PanelCtrl { ...@@ -38,6 +38,7 @@ class AlertListPanel extends PanelCtrl {
constructor($scope, $injector, private backendSrv) { constructor($scope, $injector, private backendSrv) {
super($scope, $injector); super($scope, $injector);
_.defaults(this.panel, this.panelDefaults); _.defaults(this.panel, this.panelDefaults);
this.scrollable = true;
this.events.on('init-edit-mode', this.onInitEditMode.bind(this)); this.events.on('init-edit-mode', this.onInitEditMode.bind(this));
this.events.on('refresh', this.onRefresh.bind(this)); this.events.on('refresh', this.onRefresh.bind(this));
......
...@@ -25,6 +25,7 @@ class DashListCtrl extends PanelCtrl { ...@@ -25,6 +25,7 @@ class DashListCtrl extends PanelCtrl {
constructor($scope, $injector, private backendSrv, private dashboardSrv) { constructor($scope, $injector, private backendSrv, private dashboardSrv) {
super($scope, $injector); super($scope, $injector);
_.defaults(this.panel, this.panelDefaults); _.defaults(this.panel, this.panelDefaults);
this.scrollable = true;
if (this.panel.tag) { if (this.panel.tag) {
this.panel.tags = [this.panel.tag]; this.panel.tags = [this.panel.tag];
......
...@@ -19,6 +19,7 @@ export class TextPanelCtrl extends PanelCtrl { ...@@ -19,6 +19,7 @@ export class TextPanelCtrl extends PanelCtrl {
super($scope, $injector); super($scope, $injector);
_.defaults(this.panel, this.panelDefaults); _.defaults(this.panel, this.panelDefaults);
this.scrollable = true;
this.events.on('init-edit-mode', this.onInitEditMode.bind(this)); this.events.on('init-edit-mode', this.onInitEditMode.bind(this));
this.events.on('refresh', this.onRefresh.bind(this)); this.events.on('refresh', this.onRefresh.bind(this));
......
...@@ -27,5 +27,3 @@ ...@@ -27,5 +27,3 @@
background-color: $tight-form-func-bg; background-color: $tight-form-func-bg;
} }
} }
...@@ -39,6 +39,12 @@ div.flot-text { ...@@ -39,6 +39,12 @@ div.flot-text {
.panel-content { .panel-content {
padding: 0px 10px 5px 10px; padding: 0px 10px 5px 10px;
height: 100%; height: 100%;
&--scrollable {
// Add space for scrollbar
padding-right: 10px;
padding-left: 6px;
}
} }
.panel-title-container { .panel-title-container {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment