|
|
@@ -1,14 +1,15 @@
|
|
|
define([
|
|
|
'angular',
|
|
|
'jquery',
|
|
|
- 'underscore'
|
|
|
+ 'underscore',
|
|
|
+ '../controllers/PanelBaseCtrl'
|
|
|
],
|
|
|
-function (angular, $, _) {
|
|
|
+function (angular, $, _, PanelBaseCtrl) {
|
|
|
'use strict';
|
|
|
|
|
|
angular
|
|
|
.module('kibana.directives')
|
|
|
- .directive('kibanaPanel', function($compile, $timeout, $rootScope) {
|
|
|
+ .directive('kibanaPanel', function($compile, $timeout, $rootScope, $injector) {
|
|
|
|
|
|
var container = '<div class="panel-container"></div>';
|
|
|
var content = '<div class="panel-content"></div>';
|
|
|
@@ -23,7 +24,7 @@ function (angular, $, _) {
|
|
|
'</div>' +
|
|
|
'</div>\n' +
|
|
|
|
|
|
- '<div class="row-fluid panel-extra">' +
|
|
|
+ '<div class="row-fluid panel-extra" ng-hide="panel.hide_title">' +
|
|
|
'<div class="panel-extra-container">' +
|
|
|
|
|
|
'<span class="panel-loading" ng-show="panelMeta.loading == true">' +
|
|
|
@@ -79,6 +80,10 @@ function (angular, $, _) {
|
|
|
elem.remove();
|
|
|
});
|
|
|
|
|
|
+ newScope.initBaseController = function(self, scope) {
|
|
|
+ $injector.invoke(PanelBaseCtrl, self, { $scope: scope });
|
|
|
+ };
|
|
|
+
|
|
|
$scope.$watch(attr.type, function (name) {
|
|
|
elem.addClass("ng-cloak");
|
|
|
// load the panels module file, then render it in the dom.
|
|
|
@@ -107,125 +112,6 @@ function (angular, $, _) {
|
|
|
});
|
|
|
|
|
|
|
|
|
- /*
|
|
|
- /* Panel base functionality
|
|
|
- /* */
|
|
|
- newScope.initPanel = function(scope) {
|
|
|
-
|
|
|
- scope.updateColumnSpan = function(span) {
|
|
|
- scope.panel.span = span;
|
|
|
-
|
|
|
- $timeout(function() {
|
|
|
- scope.$emit('render');
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- function enterFullscreenMode(options) {
|
|
|
- var docHeight = $(window).height();
|
|
|
- var editHeight = Math.floor(docHeight * 0.3);
|
|
|
- var fullscreenHeight = Math.floor(docHeight * 0.7);
|
|
|
- var oldTimeRange = scope.range;
|
|
|
-
|
|
|
- scope.height = options.edit ? editHeight : fullscreenHeight;
|
|
|
- scope.editMode = options.edit;
|
|
|
-
|
|
|
- if (!scope.fullscreen) {
|
|
|
- var closeEditMode = $rootScope.$on('panel-fullscreen-exit', function() {
|
|
|
- scope.editMode = false;
|
|
|
- scope.fullscreen = false;
|
|
|
- delete scope.height;
|
|
|
-
|
|
|
- closeEditMode();
|
|
|
-
|
|
|
- $timeout(function() {
|
|
|
- if (oldTimeRange !== $scope.range) {
|
|
|
- scope.dashboard.refresh();
|
|
|
- }
|
|
|
- else {
|
|
|
- scope.$emit('render');
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- $(window).scrollTop(0);
|
|
|
-
|
|
|
- scope.fullscreen = true;
|
|
|
-
|
|
|
- $rootScope.$emit('panel-fullscreen-enter');
|
|
|
-
|
|
|
- $timeout(function() {
|
|
|
- scope.$emit('render');
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- scope.toggleFullscreenEdit = function() {
|
|
|
- if (scope.editMode) {
|
|
|
- $rootScope.$emit('panel-fullscreen-exit');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- enterFullscreenMode({edit: true});
|
|
|
- };
|
|
|
-
|
|
|
- $scope.toggleFullscreen = function() {
|
|
|
- if (scope.fullscreen && !scope.editMode) {
|
|
|
- $rootScope.$emit('panel-fullscreen-exit');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- enterFullscreenMode({ edit: false });
|
|
|
- };
|
|
|
-
|
|
|
- var menu = [
|
|
|
- {
|
|
|
- text: 'Edit',
|
|
|
- configModal: "app/partials/paneleditor.html",
|
|
|
- condition: !scope.panelMeta.fullscreenEdit
|
|
|
- },
|
|
|
- {
|
|
|
- text: 'Edit',
|
|
|
- click: "toggleFullscreenEdit()",
|
|
|
- condition: scope.panelMeta.fullscreenEdit
|
|
|
- },
|
|
|
- {
|
|
|
- text: "Fullscreen",
|
|
|
- click: 'toggleFullscreen()',
|
|
|
- condition: scope.panelMeta.fullscreenView
|
|
|
- },
|
|
|
- {
|
|
|
- text: 'Duplicate',
|
|
|
- click: 'duplicatePanel(panel)',
|
|
|
- condition: true
|
|
|
- },
|
|
|
- {
|
|
|
- text: 'Span',
|
|
|
- submenu: [
|
|
|
- { text: '1', click: 'updateColumnSpan(1)' },
|
|
|
- { text: '2', click: 'updateColumnSpan(2)' },
|
|
|
- { text: '3', click: 'updateColumnSpan(3)' },
|
|
|
- { text: '4', click: 'updateColumnSpan(4)' },
|
|
|
- { text: '5', click: 'updateColumnSpan(5)' },
|
|
|
- { text: '6', click: 'updateColumnSpan(6)' },
|
|
|
- { text: '7', click: 'updateColumnSpan(7)' },
|
|
|
- { text: '8', click: 'updateColumnSpan(8)' },
|
|
|
- { text: '9', click: 'updateColumnSpan(9)' },
|
|
|
- { text: '10', click: 'updateColumnSpan(10)' },
|
|
|
- { text: '11', click: 'updateColumnSpan(11)' },
|
|
|
- { text: '12', click: 'updateColumnSpan(12)' },
|
|
|
- ],
|
|
|
- condition: true
|
|
|
- },
|
|
|
- {
|
|
|
- text: 'Remove',
|
|
|
- click: 'remove_panel_from_row(row, panel)',
|
|
|
- condition: true
|
|
|
- }
|
|
|
- ];
|
|
|
-
|
|
|
- scope.inspector = {};
|
|
|
- scope.panelMeta.menu = _.where(menu, { condition: true });
|
|
|
- };
|
|
|
}
|
|
|
};
|
|
|
});
|