diff --git a/package.json b/package.json index 8488f7b1b0b..e96f9bd78a5 100644 --- a/package.json +++ b/package.json @@ -117,14 +117,16 @@ "brace": "^0.10.0", "classnames": "^2.2.5", "clipboard": "^1.7.1", + "d3": "^4.11.0", + "d3-scale-chromatic": "^1.1.1", "eventemitter3": "^2.0.2", "file-saver": "^1.3.3", - "gemini-scrollbar": "https://github.com/grafana/gemini-scrollbar#grafana", "jquery": "^3.2.1", "lodash": "^4.17.4", "moment": "^2.18.1", "mousetrap": "^1.6.0", "ngreact": "^0.4.1", + "perfect-scrollbar": "^1.2.0", "prop-types": "^15.6.0", "react": "^16.0.0", "react-dom": "^16.0.0", @@ -134,8 +136,6 @@ "rxjs": "^5.4.3", "tether": "^1.4.0", "tether-drop": "https://github.com/torkelo/drop", - "tinycolor2": "^1.4.1", - "d3": "^4.11.0", - "d3-scale-chromatic": "^1.1.1" + "tinycolor2": "^1.4.1" } } diff --git a/public/app/core/components/scroll/scroll.ts b/public/app/core/components/scroll/scroll.ts index 02e43bc76d9..a43ef59ec84 100644 --- a/public/app/core/components/scroll/scroll.ts +++ b/public/app/core/components/scroll/scroll.ts @@ -1,22 +1,20 @@ -/// - -import GeminiScrollbar from 'gemini-scrollbar'; +import PerfectScrollbar from 'perfect-scrollbar'; import coreModule from 'app/core/core_module'; export function geminiScrollbar() { return { restrict: 'A', link: function(scope, elem, attrs) { - var myScrollbar = new GeminiScrollbar({ - autoshow: false, - element: elem[0] - }).create(); + + let scrollbar = new PerfectScrollbar(elem[0]); + console.log('scrllbar!'); scope.$on('$destroy', () => { - myScrollbar.destroy(); + scrollbar.destroy(); }); + } }; } -coreModule.directive('geminiScrollbar', geminiScrollbar); +coreModule.directive('grafanaScrollbar', geminiScrollbar); diff --git a/public/app/core/components/search/search.html b/public/app/core/components/search/search.html index 7cd7628282f..cbdd3a94b1b 100644 --- a/public/app/core/components/search/search.html +++ b/public/app/core/components/search/search.html @@ -40,51 +40,49 @@
-
- diff --git a/public/app/features/admin/partials/configuration_home.html b/public/app/features/admin/partials/configuration_home.html index 0d56497cdde..19f6cae770f 100644 --- a/public/app/features/admin/partials/configuration_home.html +++ b/public/app/features/admin/partials/configuration_home.html @@ -1,35 +1,33 @@ -
-
- - diff --git a/public/app/features/dashboard/dashgrid/DashboardPanel.tsx b/public/app/features/dashboard/dashgrid/DashboardPanel.tsx index 18c124d63e2..27fe64d4660 100644 --- a/public/app/features/dashboard/dashgrid/DashboardPanel.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardPanel.tsx @@ -47,7 +47,7 @@ export class DashboardPanel extends React.Component { } return ( -
this.element = element} /> +
this.element = element} className="panel-height-helper" /> ); } } diff --git a/public/app/features/dashboard/dashgrid/PanelLoader.ts b/public/app/features/dashboard/dashgrid/PanelLoader.ts index 2e9302537af..567043584a5 100644 --- a/public/app/features/dashboard/dashgrid/PanelLoader.ts +++ b/public/app/features/dashboard/dashgrid/PanelLoader.ts @@ -12,7 +12,7 @@ export class PanelLoader { } load(elem, panel, dashboard): AttachedPanel { - var template = ''; + var template = ''; var panelScope = this.$rootScope.$new(); panelScope.panel = panel; panelScope.dashboard = dashboard; diff --git a/public/app/features/panel/panel_ctrl.ts b/public/app/features/panel/panel_ctrl.ts index a81b8d56faa..b6cae5c7ece 100644 --- a/public/app/features/panel/panel_ctrl.ts +++ b/public/app/features/panel/panel_ctrl.ts @@ -5,9 +5,7 @@ import {appEvents, profiler} from 'app/core/core'; import Remarkable from 'remarkable'; import {GRID_CELL_HEIGHT, GRID_CELL_VMARGIN} from 'app/core/constants'; -const TITLE_HEIGHT = 25; -const EMPTY_TITLE_HEIGHT = 9; -const PANEL_PADDING = 5; +const TITLE_HEIGHT = 27; const PANEL_BORDER = 2; import {Emitter} from 'app/core/core'; @@ -48,16 +46,24 @@ export class PanelCtrl { } $scope.$on("refresh", () => this.refresh()); + $scope.$on("component-did-mount", () => this.panelDidMount()); + $scope.$on("$destroy", () => { this.events.emit('panel-teardown'); this.events.removeAllListeners(); }); + + this.calculatePanelHeight(); } init() { this.events.on('panel-size-changed', this.onSizeChanged.bind(this)); - this.publishAppEvent('panel-initialized', {scope: this.$scope}); this.events.emit('panel-initialized'); + this.publishAppEvent('panel-initialized', {scope: this.$scope}); + } + + panelDidMount() { + this.events.emit('component-did-mount'); } renderingCompleted() { @@ -166,7 +172,7 @@ export class PanelCtrl { this.containerHeight = this.panel.gridPos.h * GRID_CELL_HEIGHT + ((this.panel.gridPos.h-1) * GRID_CELL_VMARGIN); } - this.height = this.containerHeight - (PANEL_BORDER + PANEL_PADDING + (this.panel.title ? TITLE_HEIGHT : EMPTY_TITLE_HEIGHT)); + this.height = this.containerHeight - (PANEL_BORDER + TITLE_HEIGHT); } render(payload?) { diff --git a/public/app/features/panel/panel_directive.ts b/public/app/features/panel/panel_directive.ts index f1ffff2e6d4..2e183e70b4a 100644 --- a/public/app/features/panel/panel_directive.ts +++ b/public/app/features/panel/panel_directive.ts @@ -1,7 +1,6 @@ -/// - import angular from 'angular'; import Drop from 'tether-drop'; +import PerfectScrollbar from 'perfect-scrollbar'; var module = angular.module('grafana.directives'); @@ -62,9 +61,11 @@ module.directive('grafanaPanel', function($rootScope, $document) { scope: { ctrl: "=" }, link: function(scope, elem) { var panelContainer = elem.find('.panel-container'); + var panelContent = elem.find('.panel-content'); var cornerInfoElem = elem.find('.panel-info-corner'); var ctrl = scope.ctrl; var infoDrop; + var panelScrollbar; // the reason for handling these classes this way is for performance // limit the watchers on panels etc @@ -84,11 +85,12 @@ module.directive('grafanaPanel', function($rootScope, $document) { ctrl.dashboard.setPanelFocus(0); } - // set initial height - if (!ctrl.containerHeight) { - ctrl.calculatePanelHeight(); - panelContainer.css({minHeight: ctrl.containerHeight}); - lastHeight = ctrl.containerHeight; + function panelHeightUpdated() { + panelContent.height(ctrl.height); + if (panelScrollbar) { + panelScrollbar.update(); + } + lastHeight = ctrl.height; } // set initial transparency @@ -97,10 +99,16 @@ module.directive('grafanaPanel', function($rootScope, $document) { panelContainer.addClass('panel-transparent', true); } + // update scrollbar after mounting + ctrl.events.on('component-did-mount', () => { + if (ctrl.__proto__.constructor.scrollable) { + panelScrollbar = new PerfectScrollbar(panelContent[0]); + } + }); + ctrl.events.on('render', () => { - if (lastHeight !== ctrl.containerHeight) { - panelContainer.css({minHeight: ctrl.containerHeight}); - lastHeight = ctrl.containerHeight; + if (lastHeight !== ctrl.height) { + panelHeightUpdated(); } if (transparentLastState !== ctrl.panel.transparent) { @@ -181,6 +189,10 @@ module.directive('grafanaPanel', function($rootScope, $document) { if (infoDrop) { infoDrop.destroy(); } + + if (panelScrollbar) { + panelScrollbar.update(); + } }); } }; @@ -190,11 +202,11 @@ module.directive('panelHelpCorner', function($rootScope) { return { restrict: 'E', template: ` - - - - - + + + + + `, link: function(scope, elem) { } diff --git a/public/app/features/plugins/partials/ds_edit.html b/public/app/features/plugins/partials/ds_edit.html index e039fbd83ae..58396e816b3 100644 --- a/public/app/features/plugins/partials/ds_edit.html +++ b/public/app/features/plugins/partials/ds_edit.html @@ -1,90 +1,88 @@ -
-
- -
-