wip: fixed issues now things are starting to work as before for angular panels

This commit is contained in:
Torkel Ödegaard
2018-10-09 17:07:13 +02:00
parent 2f84101fe7
commit d2bdf8cff1
7 changed files with 19 additions and 14 deletions

View File

@@ -57,7 +57,7 @@ class MetricsPanelCtrl extends PanelCtrl {
}
private onInitMetricsPanelEditMode() {
this.addEditorTab('Queries', metricsTabDirective, 1, 'fa fa-database');
this.addEditorTab('Metrics', metricsTabDirective, 1, 'fa fa-database');
this.addEditorTab('Time range', 'public/app/features/panel/partials/panelTime.html');
}

View File

@@ -220,8 +220,8 @@ export class PanelCtrl {
calculatePanelHeight() {
if (this.panel.fullscreen) {
const docHeight = $(window).height();
const editHeight = Math.floor(docHeight * 0.4);
const docHeight = $('.react-grid-layout').height();
const editHeight = Math.floor(docHeight * 0.35);
const fullscreenHeight = Math.floor(docHeight * 0.8);
this.containerHeight = this.panel.isEditing ? editHeight : fullscreenHeight;
} else {

View File

@@ -90,10 +90,6 @@ module.directive('grafanaPanel', ($rootScope, $document, $timeout) => {
ctrl.dashboard.setPanelFocus(0);
}
function panelHeightUpdated() {
// panelContent.css({ height: ctrl.height + 'px' });
}
function resizeScrollableContent() {
if (panelScrollbar) {
panelScrollbar.update();
@@ -138,7 +134,6 @@ module.directive('grafanaPanel', ($rootScope, $document, $timeout) => {
ctrl.events.on('panel-size-changed', () => {
ctrl.calculatePanelHeight();
panelHeightUpdated();
$timeout(() => {
console.log('panel directive panel size changed, render');
resizeScrollableContent();
@@ -148,7 +143,6 @@ module.directive('grafanaPanel', ($rootScope, $document, $timeout) => {
// set initial height
ctrl.calculatePanelHeight();
panelHeightUpdated();
ctrl.events.on('render', () => {
console.log('panel_directive: render', ctrl.panel.id);

View File

@@ -8,7 +8,7 @@ import { importPluginModule } from './plugin_loader';
import { UnknownPanelCtrl } from 'app/plugins/panel/unknown/module';
/** @ngInject */
function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $templateCache) {
function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $templateCache, $timeout) {
function getTemplate(component) {
if (component.template) {
return $q.when(component.template);
@@ -207,10 +207,14 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
// let a binding digest cycle complete before adding to dom
setTimeout(() => {
elem.append(child);
scope.$applyAsync(() => {
console.log('post appendAndCompile, broadcast refresh', scope.panel);
scope.$broadcast('component-did-mount');
elem.append(child);
setTimeout(() => {
scope.$applyAsync(() => {
console.log('post appendAndCompile, broadcast refresh', scope.panel);
scope.$broadcast('component-did-mount');
});
});
});
});
}