Commit 68bd17bd by Torkel Ödegaard

work on scrollable panels

parent 18ca7a53
...@@ -45,16 +45,24 @@ export class PanelCtrl { ...@@ -45,16 +45,24 @@ export class PanelCtrl {
} }
$scope.$on("refresh", () => this.refresh()); $scope.$on("refresh", () => this.refresh());
$scope.$on("component-did-mount", () => this.panelDidMount());
$scope.$on("$destroy", () => { $scope.$on("$destroy", () => {
this.events.emit('panel-teardown'); this.events.emit('panel-teardown');
this.events.removeAllListeners(); this.events.removeAllListeners();
}); });
this.calculatePanelHeight();
} }
init() { init() {
this.events.on('panel-size-changed', this.onSizeChanged.bind(this)); this.events.on('panel-size-changed', this.onSizeChanged.bind(this));
this.publishAppEvent('panel-initialized', {scope: this.$scope});
this.events.emit('panel-initialized'); this.events.emit('panel-initialized');
this.publishAppEvent('panel-initialized', {scope: this.$scope});
}
panelDidMount() {
this.events.emit('component-did-mount');
} }
renderingCompleted() { renderingCompleted() {
...@@ -62,7 +70,6 @@ export class PanelCtrl { ...@@ -62,7 +70,6 @@ export class PanelCtrl {
} }
refresh() { refresh() {
this.setPanelHeight();
this.events.emit('refresh', null); this.events.emit('refresh', null);
} }
...@@ -171,14 +178,14 @@ export class PanelCtrl { ...@@ -171,14 +178,14 @@ export class PanelCtrl {
} }
setPanelHeight() { setPanelHeight() {
if (this.$scope.setPanelHeight) { // console.log('setPanelHeight');
this.$scope.setPanelHeight(); // if (this.$scope.setPanelHeight) {
} // 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);
} }
......
...@@ -73,7 +73,7 @@ module.directive('grafanaPanel', function($rootScope, $document) { ...@@ -73,7 +73,7 @@ module.directive('grafanaPanel', function($rootScope, $document) {
var lastHasAlertRule = false; var lastHasAlertRule = false;
var lastAlertState; var lastAlertState;
var hasAlertRule; var hasAlertRule;
// var lastHeight = 0; var lastHeight = 0;
function mouseEnter() { function mouseEnter() {
panelContainer.toggleClass('panel-hover-highlight', true); panelContainer.toggleClass('panel-hover-highlight', true);
...@@ -85,28 +85,11 @@ module.directive('grafanaPanel', function($rootScope, $document) { ...@@ -85,28 +85,11 @@ module.directive('grafanaPanel', function($rootScope, $document) {
ctrl.dashboard.setPanelFocus(0); ctrl.dashboard.setPanelFocus(0);
} }
// set initial height function panelHeightUpdated() {
if (!ctrl.height) {
ctrl.calculatePanelHeight();
if (ctrl.__proto__.constructor.scrollable) {
panelContent.addClass('panel-content--scrollable');
panelScrollbar = new GeminiScrollbar({
autoshow: false,
element: panelContent[0]
}).create();
}
}
function setPanelHeight() {
panelContent.height(ctrl.height);
if (panelScrollbar) { if (panelScrollbar) {
panelScrollbar.update(); panelScrollbar.update();
} }
} lastHeight = ctrl.height;
if (ctrl.__proto__.constructor.scrollable) {
ctrl.$scope.setPanelHeight = setPanelHeight;
} }
// set initial transparency // set initial transparency
...@@ -115,11 +98,20 @@ module.directive('grafanaPanel', function($rootScope, $document) { ...@@ -115,11 +98,20 @@ module.directive('grafanaPanel', function($rootScope, $document) {
panelContainer.addClass('panel-transparent', true); panelContainer.addClass('panel-transparent', true);
} }
if (ctrl.__proto__.constructor.scrollable) {
panelContent.addClass('panel-content--scrollable');
panelScrollbar = new GeminiScrollbar({ autoshow: false, element: panelContent[0] }).create();
}
// update scrollbar after mounting
ctrl.events.on('component-did-mount', () => {
panelHeightUpdated();
});
ctrl.events.on('render', () => { ctrl.events.on('render', () => {
// if (lastHeight !== ctrl.height) { if (lastHeight !== ctrl.height) {
// panelContent.css({'height': ctrl.height + 'px'}); panelHeightUpdated();
// lastHeight = ctrl.height; }
// }
if (transparentLastState !== ctrl.panel.transparent) { if (transparentLastState !== ctrl.panel.transparent) {
panelContainer.toggleClass('panel-transparent', ctrl.panel.transparent === true); panelContainer.toggleClass('panel-transparent', ctrl.panel.transparent === true);
......
...@@ -221,6 +221,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $ ...@@ -221,6 +221,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
setTimeout(function() { setTimeout(function() {
elem.append(child); elem.append(child);
scope.$applyAsync(function() { scope.$applyAsync(function() {
scope.$broadcast('component-did-mount');
scope.$broadcast('refresh'); scope.$broadcast('refresh');
}); });
}); });
......
///<reference path="../../../headers/common.d.ts" />
import _ from 'lodash'; import _ from 'lodash';
import {PanelCtrl} from 'app/plugins/sdk'; import {PanelCtrl} from 'app/plugins/sdk';
import {impressions} from 'app/features/dashboard/impression_store'; import {impressions} from 'app/features/dashboard/impression_store';
......
///<reference path="../../../headers/common.d.ts" />
import _ from 'lodash'; import _ from 'lodash';
import {PanelCtrl} from '../../../features/panel/panel_ctrl'; import {PanelCtrl} from '../../../features/panel/panel_ctrl';
class PluginListCtrl extends PanelCtrl { class PluginListCtrl extends PanelCtrl {
static templateUrl = 'module.html'; static templateUrl = 'module.html';
static scrollable = true;
pluginList: any[]; pluginList: any[];
viewModel: any; viewModel: any;
...@@ -15,6 +14,7 @@ class PluginListCtrl extends PanelCtrl { ...@@ -15,6 +14,7 @@ class PluginListCtrl extends PanelCtrl {
/** @ngInject */ /** @ngInject */
constructor($scope, $injector, private backendSrv, private $location) { constructor($scope, $injector, private backendSrv, private $location) {
super($scope, $injector); super($scope, $injector);
_.defaults(this.panel, this.panelDefaults); _.defaults(this.panel, this.panelDefaults);
this.events.on('init-edit-mode', this.onInitEditMode.bind(this)); this.events.on('init-edit-mode', this.onInitEditMode.bind(this));
......
...@@ -395,11 +395,6 @@ class SingleStatCtrl extends MetricsPanelCtrl { ...@@ -395,11 +395,6 @@ class SingleStatCtrl extends MetricsPanelCtrl {
var data, linkInfo; var data, linkInfo;
var $panelContainer = elem.find('.panel-container'); var $panelContainer = elem.find('.panel-container');
elem = elem.find('.singlestat-panel'); elem = elem.find('.singlestat-panel');
console.log('singlestat element', elem.length);
function setElementHeight() {
/// elem.css('height', ctrl.height + 'px');
}
function applyColoringThresholds(value, valueString) { function applyColoringThresholds(value, valueString) {
if (!panel.colorValue) { if (!panel.colorValue) {
...@@ -561,8 +556,6 @@ class SingleStatCtrl extends MetricsPanelCtrl { ...@@ -561,8 +556,6 @@ class SingleStatCtrl extends MetricsPanelCtrl {
plotCss.height = Math.floor(height * 0.25) + "px"; plotCss.height = Math.floor(height * 0.25) + "px";
} }
console.log('singlestat height', ctrl.height);
console.log('singlestat plotCss', plotCss.height);
plotCanvas.css(plotCss); plotCanvas.css(plotCss);
var options = { var options = {
...@@ -607,8 +600,6 @@ class SingleStatCtrl extends MetricsPanelCtrl { ...@@ -607,8 +600,6 @@ class SingleStatCtrl extends MetricsPanelCtrl {
}); });
data.colorMap = panel.colors; data.colorMap = panel.colors;
setElementHeight();
var body = panel.gauge.show ? '' : getBigValueHtml(); var body = panel.gauge.show ? '' : getBigValueHtml();
if (panel.colorBackground) { if (panel.colorBackground) {
......
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