-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1952 from spenceralger/breakup-kibana-controller
Breakup kibana controller
- Loading branch information
Showing
24 changed files
with
586 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
define(function (require) { | ||
var _ = require('lodash'); | ||
|
||
require('modules').get('kibana') | ||
.run(function ($rootScope) { | ||
|
||
/** | ||
* Helper that registers an event listener, and removes that listener when | ||
* the $scope is destroyed. | ||
* | ||
* @param {EventEmitter} emitter - the event emitter to listen to | ||
* @param {string} eventName - the event name | ||
* @param {Function} handler - the event handler | ||
* @return {undefined} | ||
*/ | ||
$rootScope.constructor.prototype.$listen = function (emitter, eventName, handler) { | ||
emitter.on(eventName, handler); | ||
this.$on('$destroy', function () { | ||
emitter.off(eventName, handler); | ||
}); | ||
}; | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.truncate-by-height { | ||
max-height: <%= truncateMaxHeight %>; | ||
} | ||
.truncate-by-height::before { | ||
top: <%= truncateGradientTop %>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
define(function (require) { | ||
var _ = require('lodash'); | ||
var $ = require('jquery'); | ||
var $style = $('<style>').appendTo('head').attr('id', 'style-compile'); | ||
|
||
require('modules') | ||
.get('kibana') | ||
.run(function ($rootScope, $compile, config) { | ||
var truncateGradientHeight = 15; | ||
var template = _.template(require('text!components/style_compile/style_compile.css.tmpl')); | ||
var locals = {}; | ||
|
||
$rootScope.$on('$destroy', function () { | ||
$style.remove(); | ||
}); | ||
|
||
// watch the value of the truncate:maxHeight config param | ||
$rootScope.$watch(function () { | ||
return config.get('truncate:maxHeight'); | ||
}, function (maxHeight) { | ||
if (maxHeight > 0) { | ||
locals.truncateMaxHeight = maxHeight + 'px !important'; | ||
locals.truncateGradientTop = maxHeight - truncateGradientHeight + 'px'; | ||
} else { | ||
locals.truncateMaxHeight = 'none'; | ||
locals.truncateGradientTop = '-' + truncateGradientHeight + 'px'; | ||
} | ||
|
||
$style.html(template(locals)); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
define(function (require) { | ||
var html = require('text!components/tooltip/tooltip.html'); | ||
|
||
require('modules').get('kibana') | ||
.config(function ($tooltipProvider) { | ||
$tooltipProvider.options({ | ||
placement: 'bottom', | ||
animation: true, | ||
popupDelay: 150, | ||
appendToBody: false | ||
}); | ||
}) | ||
.directive('kbnTooltip', function () { | ||
return { | ||
restrict: 'E', | ||
template: html, | ||
transclude: true, | ||
replace: true, | ||
scope: true, | ||
link: function ($scope, $el, attr) { | ||
$scope.text = attr.text; | ||
$scope.placement = attr.placement || 'top'; | ||
$scope.delay = attr.delay || 400; | ||
$scope.appendToBody = attr.appendToBody || 0; | ||
} | ||
}; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
define(function (require) { | ||
var _ = require('lodash'); | ||
|
||
require('modules').get('kibana') | ||
.run(function ($rootScope) { | ||
|
||
/** | ||
* Watch multiple expressions with a single callback. Along | ||
* with making code simpler it also merges all of the watcher | ||
* handlers within a single tick. | ||
* | ||
* @param {array[string|function]} expressions - the list of expressions to $watch | ||
* @param {Function} fn - the callback function | ||
* @param {boolean} deep - should the watchers be created as deep watchers? | ||
* @return {undefined} | ||
*/ | ||
$rootScope.constructor.prototype.$watchMulti = function (expressions, fn, deep) { | ||
if (!_.isArray(expressions)) throw new TypeError('expected an array of expressions to watch'); | ||
if (!_.isFunction(fn)) throw new TypeError('expexted a function that is triggered on each watch'); | ||
|
||
var $scope = this; | ||
var initQueue = _.clone(expressions); | ||
var fired = false; | ||
var vals = { | ||
new: new Array(expressions.length), | ||
old: new Array(expressions.length) | ||
}; | ||
|
||
expressions.forEach(function (expr, i) { | ||
$scope.$watch(expr, function (newVal, oldVal) { | ||
vals.new[i] = newVal; | ||
|
||
if (initQueue) { | ||
vals.old[i] = oldVal; | ||
|
||
var qIdx = initQueue.indexOf(expr); | ||
if (qIdx !== -1) initQueue.splice(qIdx, 1); | ||
if (initQueue.length === 0) { | ||
initQueue = false; | ||
if (fn.length) { | ||
fn(vals.new.slice(0), vals.old.slice(0)); | ||
} else { | ||
fn(); | ||
} | ||
} | ||
return; | ||
} | ||
|
||
if (fired) return; | ||
fired = true; | ||
$scope.$evalAsync(function () { | ||
fired = false; | ||
|
||
if (fn.length) { | ||
fn(vals.new.slice(0), vals.old.slice(0)); | ||
} else { | ||
fn(); | ||
} | ||
|
||
for (var i = 0; i < vals.new.length; i++) { | ||
vals.old[i] = vals.new[i]; | ||
} | ||
}); | ||
}); | ||
}); | ||
}; | ||
|
||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.