All Downloads are FREE. Search and download functionalities are using the official Maven repository.

app.directives.kibanaPanel.js Maven / Gradle / Ivy

The newest version!
define([
  'angular',
  'jquery'
],
function (angular,$) {
  'use strict';

  angular
    .module('kibana.directives')
    .directive('kibanaPanel', function($compile, $rootScope) {
      var container = '
'; var content = '
'; var panelHeader = '
'+ '
' + '
' + '×' + ' Oops! {{panel.error}}' + '
' + '
\n' + '
' + '
' + '' + ''+ ''+ '' + '' + '' + '' + '' + ''+ '' + '' + ''+ ''+ '' + '' + ''+ ''+ '' + '' + ''+ '' + '' + ''+ '' + ''+ '' + '' + '{{panel.title?panel.title:panel.type}}' + ''+ '
'+ '
\n'+ '
'; return { restrict: 'A', replace: true, link: function($scope, elem, attr) { // once we have the template, scan it for controllers and // load the module.js if we have any var newScope = $scope.$new(); elem.parent().parent().parent().resize(function() { $rootScope.$broadcast('render'); }); $scope.refresh = function() { $scope.$broadcast('refresh'); }; $scope.kbnJqUiDraggableOptions = { revert: 'invalid', helper: function() { return $('
'); }, placeholder: 'keep' }; // compile the module and uncloack. We're done function loadModule($module) { $module.appendTo(elem); elem.wrapInner(container); /* jshint indent:false */ $compile(elem.contents())(newScope); elem.removeClass("ng-cloak"); } newScope.$on('$destroy',function(){ elem.unbind(); elem.remove(); }); $scope.$watch(attr.type, function (name) { elem.addClass("ng-cloak"); // load the panels module file, then render it in the dom. var nameAsPath = name.replace(".", "/"); $scope.require([ 'jquery', 'text!panels/'+nameAsPath+'/module.html', 'text!panels/'+nameAsPath+'/editor.html' ], function ($, moduleTemplate) { var $module = $(moduleTemplate); // top level controllers var $controllers = $module.filter('ngcontroller, [ng-controller], .ng-controller'); // add child controllers $controllers = $controllers.add($module.find('ngcontroller, [ng-controller], .ng-controller')); if ($controllers.length) { $controllers.first().prepend(panelHeader); $controllers.first().find('.panel-header').nextAll().wrapAll(content); $scope.require([ 'panels/'+nameAsPath+'/module' ], function() { loadModule($module); }); } else { loadModule($module); } }); }); } }; }); });




© 2015 - 2025 Weber Informatics LLC | Privacy Policy