mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
reorganized the projects a tad, included grunt tasks for testing and running the server. Includes incomplete Courier code for now.
This commit is contained in:
parent
587786b2b5
commit
a1336836b3
38 changed files with 1266 additions and 46 deletions
35
.jshintrc
Normal file
35
.jshintrc
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"unused": false,
|
||||
"browser": true,
|
||||
"node": false,
|
||||
|
||||
"globals": {
|
||||
"define": true,
|
||||
"require": true
|
||||
},
|
||||
|
||||
"white": true,
|
||||
"bitwise": false,
|
||||
"eqnull": true,
|
||||
"eqeqeq": true,
|
||||
"forin": true,
|
||||
"immed": true,
|
||||
"expr": true,
|
||||
"indent": 2,
|
||||
"latedef": "nofunc",
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"undef": true,
|
||||
"quotmark": "single",
|
||||
"plusplus": false,
|
||||
"boss": true,
|
||||
"trailing": true,
|
||||
"laxbreak": true,
|
||||
"laxcomma": true,
|
||||
"validthis": true,
|
||||
"sub": true,
|
||||
"maxlen": 140,
|
||||
"-W084": true,
|
||||
"maxerr": 10
|
||||
}
|
24
Gruntfile.js
Normal file
24
Gruntfile.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* jshint node:true */
|
||||
module.exports = function (grunt) {
|
||||
// load plugins
|
||||
require('load-grunt-config')(grunt, {
|
||||
configPath: __dirname + '/tasks/config',
|
||||
init: true,
|
||||
config: {
|
||||
root: __dirname,
|
||||
src: __dirname + '/src',
|
||||
app: __dirname + '/src/kibana',
|
||||
unitTestDir: __dirname + '/test/unit',
|
||||
meta: {
|
||||
banner: '/*! <%= package.name %> - v<%= package.version %> - ' +
|
||||
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
|
||||
'<%= package.homepage ? " * " + package.homepage + "\\n" : "" %>' +
|
||||
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= package.author.company %>;' +
|
||||
' Licensed <%= package.license %> */\n'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// load task definitions
|
||||
grunt.loadTasks('tasks');
|
||||
};
|
16
Gulpfile.js
16
Gulpfile.js
|
@ -1,16 +0,0 @@
|
|||
var gulp = require('gulp');
|
||||
var connect = require('connect');
|
||||
|
||||
var paths = {
|
||||
webroot: 'src/'
|
||||
};
|
||||
|
||||
gulp.task('server', function() {
|
||||
var app = connect()
|
||||
// .use(connect.logger('dev'))
|
||||
.use(connect.static(paths.webroot));
|
||||
|
||||
var server = require('http').createServer(app).listen(0, function () {
|
||||
console.log('server listeing at http://localhost:%d', server.address().port);
|
||||
});
|
||||
});
|
|
@ -23,6 +23,9 @@
|
|||
"requirejs": "~2.1.10",
|
||||
"elasticsearch": "~1.4.0",
|
||||
"angular": "~1.2.10",
|
||||
"lodash": "~2.4.1"
|
||||
"lodash": "~2.4.1",
|
||||
"eventEmitter": "~4.2.7",
|
||||
"inherits": "~0.0.1",
|
||||
"d3": "~3.4.1"
|
||||
}
|
||||
}
|
||||
|
|
19
package.json
19
package.json
|
@ -4,13 +4,24 @@
|
|||
"version": "0.0.0",
|
||||
"description": "Kibana TNG",
|
||||
"main": "Gulpfile.js",
|
||||
"dependencies": {
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"connect": "~2.12.0",
|
||||
"gulp": "~3.5.2"
|
||||
"gulp": "~3.5.2",
|
||||
"lodash": "~2.4.1",
|
||||
"expect.js": "~0.2.0",
|
||||
"gulp-jshint": "git://github.com/spenceralger/gulp-jshint.git#relative_jshintrc",
|
||||
"jshint-stylish": "~0.1.5",
|
||||
"grunt": "~0.4.2",
|
||||
"grunt-contrib-connect": "~0.6.0",
|
||||
"grunt-contrib-jshint": "~0.8.0",
|
||||
"mocha": "~1.17.1",
|
||||
"load-grunt-config": "~0.7.0",
|
||||
"grunt-mocha": "~0.4.10"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"test": "gulp test"
|
||||
"test": "gulp test",
|
||||
"server": "gulp server"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
define(function (require) {
|
||||
document.body.innerHTML = 'this is the future';
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
/**
|
||||
* Bootstrap require with the needed config, then load the app.js module.
|
||||
*/
|
||||
require.config({
|
||||
baseUrl: 'app',
|
||||
paths: {
|
||||
angular: '../bower_components/angular/angular',
|
||||
lodash: '../bower_components/lodash/lodash',
|
||||
jquery: '../bower_components/jquery/jquery',
|
||||
d3: '../bower_components/d3/d3'
|
||||
},
|
||||
shim: {
|
||||
angular: {
|
||||
deps: ['jquery'],
|
||||
exports: 'angular'
|
||||
}
|
||||
},
|
||||
waitSeconds: 60
|
||||
});
|
40
src/bower_components/eventEmitter/.bower.json
vendored
Normal file
40
src/bower_components/eventEmitter/.bower.json
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "eventEmitter",
|
||||
"description": "Event based JavaScript for the browser",
|
||||
"version": "4.2.7",
|
||||
"main": [
|
||||
"./EventEmitter.js"
|
||||
],
|
||||
"author": {
|
||||
"name": "Oliver Caldwell",
|
||||
"web": "http://oli.me.uk/"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/Wolfy87/EventEmitter#license-mit"
|
||||
}
|
||||
],
|
||||
"keywords": [
|
||||
"events",
|
||||
"structure"
|
||||
],
|
||||
"ignore": [
|
||||
"docs",
|
||||
"tests",
|
||||
"tools",
|
||||
".gitignore",
|
||||
"package.json"
|
||||
],
|
||||
"homepage": "https://github.com/Wolfy87/EventEmitter",
|
||||
"_release": "4.2.7",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v4.2.7",
|
||||
"commit": "5cba254c056a143df1c4f5505bfa8c3531ebd56c"
|
||||
},
|
||||
"_source": "git://github.com/Wolfy87/EventEmitter.git",
|
||||
"_target": "~4.2.7",
|
||||
"_originalSource": "eventEmitter",
|
||||
"_direct": true
|
||||
}
|
472
src/bower_components/eventEmitter/EventEmitter.js
vendored
Normal file
472
src/bower_components/eventEmitter/EventEmitter.js
vendored
Normal file
|
@ -0,0 +1,472 @@
|
|||
/*!
|
||||
* EventEmitter v4.2.7 - git.io/ee
|
||||
* Oliver Caldwell
|
||||
* MIT license
|
||||
* @preserve
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Class for managing events.
|
||||
* Can be extended to provide event functionality in other classes.
|
||||
*
|
||||
* @class EventEmitter Manages event registering and emitting.
|
||||
*/
|
||||
function EventEmitter() {}
|
||||
|
||||
// Shortcuts to improve speed and size
|
||||
var proto = EventEmitter.prototype;
|
||||
var exports = this;
|
||||
var originalGlobalValue = exports.EventEmitter;
|
||||
|
||||
/**
|
||||
* Finds the index of the listener for the event in it's storage array.
|
||||
*
|
||||
* @param {Function[]} listeners Array of listeners to search through.
|
||||
* @param {Function} listener Method to look for.
|
||||
* @return {Number} Index of the specified listener, -1 if not found
|
||||
* @api private
|
||||
*/
|
||||
function indexOfListener(listeners, listener) {
|
||||
var i = listeners.length;
|
||||
while (i--) {
|
||||
if (listeners[i].listener === listener) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias a method while keeping the context correct, to allow for overwriting of target method.
|
||||
*
|
||||
* @param {String} name The name of the target method.
|
||||
* @return {Function} The aliased method
|
||||
* @api private
|
||||
*/
|
||||
function alias(name) {
|
||||
return function aliasClosure() {
|
||||
return this[name].apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the listener array for the specified event.
|
||||
* Will initialise the event object and listener arrays if required.
|
||||
* Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
|
||||
* Each property in the object response is an array of listener functions.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to return the listeners from.
|
||||
* @return {Function[]|Object} All listener functions for the event.
|
||||
*/
|
||||
proto.getListeners = function getListeners(evt) {
|
||||
var events = this._getEvents();
|
||||
var response;
|
||||
var key;
|
||||
|
||||
// Return a concatenated array of all matching events if
|
||||
// the selector is a regular expression.
|
||||
if (evt instanceof RegExp) {
|
||||
response = {};
|
||||
for (key in events) {
|
||||
if (events.hasOwnProperty(key) && evt.test(key)) {
|
||||
response[key] = events[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
response = events[evt] || (events[evt] = []);
|
||||
}
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Takes a list of listener objects and flattens it into a list of listener functions.
|
||||
*
|
||||
* @param {Object[]} listeners Raw listener objects.
|
||||
* @return {Function[]} Just the listener functions.
|
||||
*/
|
||||
proto.flattenListeners = function flattenListeners(listeners) {
|
||||
var flatListeners = [];
|
||||
var i;
|
||||
|
||||
for (i = 0; i < listeners.length; i += 1) {
|
||||
flatListeners.push(listeners[i].listener);
|
||||
}
|
||||
|
||||
return flatListeners;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to return the listeners from.
|
||||
* @return {Object} All listener functions for an event in an object.
|
||||
*/
|
||||
proto.getListenersAsObject = function getListenersAsObject(evt) {
|
||||
var listeners = this.getListeners(evt);
|
||||
var response;
|
||||
|
||||
if (listeners instanceof Array) {
|
||||
response = {};
|
||||
response[evt] = listeners;
|
||||
}
|
||||
|
||||
return response || listeners;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a listener function to the specified event.
|
||||
* The listener will not be added if it is a duplicate.
|
||||
* If the listener returns true then it will be removed after it is called.
|
||||
* If you pass a regular expression as the event name then the listener will be added to all events that match it.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to attach the listener to.
|
||||
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.addListener = function addListener(evt, listener) {
|
||||
var listeners = this.getListenersAsObject(evt);
|
||||
var listenerIsWrapped = typeof listener === 'object';
|
||||
var key;
|
||||
|
||||
for (key in listeners) {
|
||||
if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
|
||||
listeners[key].push(listenerIsWrapped ? listener : {
|
||||
listener: listener,
|
||||
once: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias of addListener
|
||||
*/
|
||||
proto.on = alias('addListener');
|
||||
|
||||
/**
|
||||
* Semi-alias of addListener. It will add a listener that will be
|
||||
* automatically removed after it's first execution.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to attach the listener to.
|
||||
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.addOnceListener = function addOnceListener(evt, listener) {
|
||||
return this.addListener(evt, {
|
||||
listener: listener,
|
||||
once: true
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias of addOnceListener.
|
||||
*/
|
||||
proto.once = alias('addOnceListener');
|
||||
|
||||
/**
|
||||
* Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
|
||||
* You need to tell it what event names should be matched by a regex.
|
||||
*
|
||||
* @param {String} evt Name of the event to create.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.defineEvent = function defineEvent(evt) {
|
||||
this.getListeners(evt);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Uses defineEvent to define multiple events.
|
||||
*
|
||||
* @param {String[]} evts An array of event names to define.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.defineEvents = function defineEvents(evts) {
|
||||
for (var i = 0; i < evts.length; i += 1) {
|
||||
this.defineEvent(evts[i]);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a listener function from the specified event.
|
||||
* When passed a regular expression as the event name, it will remove the listener from all events that match it.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to remove the listener from.
|
||||
* @param {Function} listener Method to remove from the event.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.removeListener = function removeListener(evt, listener) {
|
||||
var listeners = this.getListenersAsObject(evt);
|
||||
var index;
|
||||
var key;
|
||||
|
||||
for (key in listeners) {
|
||||
if (listeners.hasOwnProperty(key)) {
|
||||
index = indexOfListener(listeners[key], listener);
|
||||
|
||||
if (index !== -1) {
|
||||
listeners[key].splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias of removeListener
|
||||
*/
|
||||
proto.off = alias('removeListener');
|
||||
|
||||
/**
|
||||
* Adds listeners in bulk using the manipulateListeners method.
|
||||
* If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
|
||||
* You can also pass it a regular expression to add the array of listeners to all events that match it.
|
||||
* Yeah, this function does quite a bit. That's probably a bad thing.
|
||||
*
|
||||
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
|
||||
* @param {Function[]} [listeners] An optional array of listener functions to add.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.addListeners = function addListeners(evt, listeners) {
|
||||
// Pass through to manipulateListeners
|
||||
return this.manipulateListeners(false, evt, listeners);
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes listeners in bulk using the manipulateListeners method.
|
||||
* If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
|
||||
* You can also pass it an event name and an array of listeners to be removed.
|
||||
* You can also pass it a regular expression to remove the listeners from all events that match it.
|
||||
*
|
||||
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
|
||||
* @param {Function[]} [listeners] An optional array of listener functions to remove.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.removeListeners = function removeListeners(evt, listeners) {
|
||||
// Pass through to manipulateListeners
|
||||
return this.manipulateListeners(true, evt, listeners);
|
||||
};
|
||||
|
||||
/**
|
||||
* Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
|
||||
* The first argument will determine if the listeners are removed (true) or added (false).
|
||||
* If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
|
||||
* You can also pass it an event name and an array of listeners to be added/removed.
|
||||
* You can also pass it a regular expression to manipulate the listeners of all events that match it.
|
||||
*
|
||||
* @param {Boolean} remove True if you want to remove listeners, false if you want to add.
|
||||
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
|
||||
* @param {Function[]} [listeners] An optional array of listener functions to add/remove.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
|
||||
var i;
|
||||
var value;
|
||||
var single = remove ? this.removeListener : this.addListener;
|
||||
var multiple = remove ? this.removeListeners : this.addListeners;
|
||||
|
||||
// If evt is an object then pass each of it's properties to this method
|
||||
if (typeof evt === 'object' && !(evt instanceof RegExp)) {
|
||||
for (i in evt) {
|
||||
if (evt.hasOwnProperty(i) && (value = evt[i])) {
|
||||
// Pass the single listener straight through to the singular method
|
||||
if (typeof value === 'function') {
|
||||
single.call(this, i, value);
|
||||
}
|
||||
else {
|
||||
// Otherwise pass back to the multiple function
|
||||
multiple.call(this, i, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// So evt must be a string
|
||||
// And listeners must be an array of listeners
|
||||
// Loop over it and pass each one to the multiple method
|
||||
i = listeners.length;
|
||||
while (i--) {
|
||||
single.call(this, evt, listeners[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes all listeners from a specified event.
|
||||
* If you do not specify an event then all listeners will be removed.
|
||||
* That means every event will be emptied.
|
||||
* You can also pass a regex to remove all events that match it.
|
||||
*
|
||||
* @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.removeEvent = function removeEvent(evt) {
|
||||
var type = typeof evt;
|
||||
var events = this._getEvents();
|
||||
var key;
|
||||
|
||||
// Remove different things depending on the state of evt
|
||||
if (type === 'string') {
|
||||
// Remove all listeners for the specified event
|
||||
delete events[evt];
|
||||
}
|
||||
else if (evt instanceof RegExp) {
|
||||
// Remove all events matching the regex.
|
||||
for (key in events) {
|
||||
if (events.hasOwnProperty(key) && evt.test(key)) {
|
||||
delete events[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Remove all listeners in all events
|
||||
delete this._events;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias of removeEvent.
|
||||
*
|
||||
* Added to mirror the node API.
|
||||
*/
|
||||
proto.removeAllListeners = alias('removeEvent');
|
||||
|
||||
/**
|
||||
* Emits an event of your choice.
|
||||
* When emitted, every listener attached to that event will be executed.
|
||||
* If you pass the optional argument array then those arguments will be passed to every listener upon execution.
|
||||
* Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
|
||||
* So they will not arrive within the array on the other side, they will be separate.
|
||||
* You can also pass a regular expression to emit to all events that match it.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
|
||||
* @param {Array} [args] Optional array of arguments to be passed to each listener.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.emitEvent = function emitEvent(evt, args) {
|
||||
var listeners = this.getListenersAsObject(evt);
|
||||
var listener;
|
||||
var i;
|
||||
var key;
|
||||
var response;
|
||||
|
||||
for (key in listeners) {
|
||||
if (listeners.hasOwnProperty(key)) {
|
||||
i = listeners[key].length;
|
||||
|
||||
while (i--) {
|
||||
// If the listener returns true then it shall be removed from the event
|
||||
// The function is executed either with a basic call or an apply if there is an args array
|
||||
listener = listeners[key][i];
|
||||
|
||||
if (listener.once === true) {
|
||||
this.removeListener(evt, listener.listener);
|
||||
}
|
||||
|
||||
response = listener.listener.apply(this, args || []);
|
||||
|
||||
if (response === this._getOnceReturnValue()) {
|
||||
this.removeListener(evt, listener.listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias of emitEvent
|
||||
*/
|
||||
proto.trigger = alias('emitEvent');
|
||||
|
||||
/**
|
||||
* Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
|
||||
* As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
|
||||
*
|
||||
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
|
||||
* @param {...*} Optional additional arguments to be passed to each listener.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.emit = function emit(evt) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
return this.emitEvent(evt, args);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the current value to check against when executing listeners. If a
|
||||
* listeners return value matches the one set here then it will be removed
|
||||
* after execution. This value defaults to true.
|
||||
*
|
||||
* @param {*} value The new value to check for when executing listeners.
|
||||
* @return {Object} Current instance of EventEmitter for chaining.
|
||||
*/
|
||||
proto.setOnceReturnValue = function setOnceReturnValue(value) {
|
||||
this._onceReturnValue = value;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches the current value to check against when executing listeners. If
|
||||
* the listeners return value matches this one then it should be removed
|
||||
* automatically. It will return true by default.
|
||||
*
|
||||
* @return {*|Boolean} The current value to check for or the default, true.
|
||||
* @api private
|
||||
*/
|
||||
proto._getOnceReturnValue = function _getOnceReturnValue() {
|
||||
if (this.hasOwnProperty('_onceReturnValue')) {
|
||||
return this._onceReturnValue;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches the events object and creates one if required.
|
||||
*
|
||||
* @return {Object} The events storage object.
|
||||
* @api private
|
||||
*/
|
||||
proto._getEvents = function _getEvents() {
|
||||
return this._events || (this._events = {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
|
||||
*
|
||||
* @return {Function} Non conflicting EventEmitter class.
|
||||
*/
|
||||
EventEmitter.noConflict = function noConflict() {
|
||||
exports.EventEmitter = originalGlobalValue;
|
||||
return EventEmitter;
|
||||
};
|
||||
|
||||
// Expose the class either via AMD, CommonJS or the global object
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(function () {
|
||||
return EventEmitter;
|
||||
});
|
||||
}
|
||||
else if (typeof module === 'object' && module.exports){
|
||||
module.exports = EventEmitter;
|
||||
}
|
||||
else {
|
||||
this.EventEmitter = EventEmitter;
|
||||
}
|
||||
}.call(this));
|
7
src/bower_components/eventEmitter/EventEmitter.min.js
vendored
Normal file
7
src/bower_components/eventEmitter/EventEmitter.min.js
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/*!
|
||||
* EventEmitter v4.2.7 - git.io/ee
|
||||
* Oliver Caldwell
|
||||
* MIT license
|
||||
* @preserve
|
||||
*/
|
||||
(function(){"use strict";function t(){}function r(t,n){for(var e=t.length;e--;)if(t[e].listener===n)return e;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var e=t.prototype,i=this,s=i.EventEmitter;e.getListeners=function(n){var r,e,t=this._getEvents();if(n instanceof RegExp){r={};for(e in t)t.hasOwnProperty(e)&&n.test(e)&&(r[e]=t[e])}else r=t[n]||(t[n]=[]);return r},e.flattenListeners=function(t){var e,n=[];for(e=0;e<t.length;e+=1)n.push(t[e].listener);return n},e.getListenersAsObject=function(n){var e,t=this.getListeners(n);return t instanceof Array&&(e={},e[n]=t),e||t},e.addListener=function(i,e){var t,n=this.getListenersAsObject(i),s="object"==typeof e;for(t in n)n.hasOwnProperty(t)&&-1===r(n[t],e)&&n[t].push(s?e:{listener:e,once:!1});return this},e.on=n("addListener"),e.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},e.once=n("addOnceListener"),e.defineEvent=function(e){return this.getListeners(e),this},e.defineEvents=function(t){for(var e=0;e<t.length;e+=1)this.defineEvent(t[e]);return this},e.removeListener=function(i,s){var n,e,t=this.getListenersAsObject(i);for(e in t)t.hasOwnProperty(e)&&(n=r(t[e],s),-1!==n&&t[e].splice(n,1));return this},e.off=n("removeListener"),e.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},e.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},e.manipulateListeners=function(r,t,i){var e,n,s=r?this.removeListener:this.addListener,o=r?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(e=i.length;e--;)s.call(this,t,i[e]);else for(e in t)t.hasOwnProperty(e)&&(n=t[e])&&("function"==typeof n?s.call(this,e,n):o.call(this,e,n));return this},e.removeEvent=function(e){var t,r=typeof e,n=this._getEvents();if("string"===r)delete n[e];else if(e instanceof RegExp)for(t in n)n.hasOwnProperty(t)&&e.test(t)&&delete n[t];else delete this._events;return this},e.removeAllListeners=n("removeEvent"),e.emitEvent=function(r,o){var e,i,t,s,n=this.getListenersAsObject(r);for(t in n)if(n.hasOwnProperty(t))for(i=n[t].length;i--;)e=n[t][i],e.once===!0&&this.removeListener(r,e.listener),s=e.listener.apply(this,o||[]),s===this._getOnceReturnValue()&&this.removeListener(r,e.listener);return this},e.trigger=n("emitEvent"),e.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},e.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},e._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},e._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return i.EventEmitter=s,t},"function"==typeof define&&define.amd?define(function(){return t}):"object"==typeof module&&module.exports?module.exports=t:this.EventEmitter=t}).call(this);
|
82
src/bower_components/eventEmitter/README.md
vendored
Normal file
82
src/bower_components/eventEmitter/README.md
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
# EventEmitter
|
||||
|
||||
## Event based JavaScript for the browser
|
||||
|
||||
As the subtitle suggests, this script brings the power of events from platforms such as [node.js](http://nodejs.org/) to your browser. Although it can be used on any other platform, I just built it with browsers in mind.
|
||||
|
||||
This is actually the fourth full rewrite of EventEmitter, my aim is for it to be faster and lighter than ever before. It also has a remapped API which just makes a lot more sense. Because the methods now have more descriptive names it is friendlier to extension into other classes. You will be able to distinguish event method from your own methods.
|
||||
|
||||
I have been working on it for over ~~a year~~ two years so far and in that time my skills in JavaScript have come a long way. This script is a culmination of my learnings which you can hopefully find very useful.
|
||||
|
||||
## Dependencies
|
||||
|
||||
There are no hard dependencies. The only reason you will want to run `npm install` to grab the development dependencies is to build the documentation or minify the source code. No other scripts are required to actually use EventEmitter.
|
||||
|
||||
## Documentation
|
||||
|
||||
* [Guide](https://github.com/Wolfy87/EventEmitter/blob/master/docs/guide.md)
|
||||
* [API](https://github.com/Wolfy87/EventEmitter/blob/master/docs/api.md)
|
||||
|
||||
### Examples
|
||||
|
||||
* [Simple](http://jsfiddle.net/Wolfy87/qXQu9/)
|
||||
* [RegExp DOM caster](http://jsfiddle.net/Wolfy87/JqRvS/)
|
||||
|
||||
### Building the documentation
|
||||
|
||||
You can run `tools/doc.sh` to build from the JSDoc comments found within the source code. The built documentation will be placed in `docs/api.md`. I actually keep this inside the repository so each version will have it's documentation stored with it.
|
||||
|
||||
## Minifying
|
||||
|
||||
You can grab minified versions of EventEmitter from inside this repository, every version is tagged. If you need to build a custom version then you can run `tools/dist.sh`.
|
||||
|
||||
## Cloning
|
||||
|
||||
You can clone the repository with your generic clone commands as a standalone repository or submodule.
|
||||
|
||||
```bash
|
||||
# Full repository
|
||||
git clone git://github.com/Wolfy87/EventEmitter.git
|
||||
|
||||
# Or submodule
|
||||
git submodule add git://github.com/Wolfy87/EventEmitter.git assets/js/EventEmitter
|
||||
```
|
||||
|
||||
### Package managers
|
||||
|
||||
You can also get a copy of EventEmitter through the following package managers:
|
||||
* [NPM](https://npmjs.org/) (wolfy87-eventemitter)
|
||||
* [Bower](http://bower.io/) (eventEmitter)
|
||||
* [Component](http://github.com/component/component) (Wolfy87/EventEmitter)
|
||||
|
||||
## Testing
|
||||
|
||||
Tests are performed using [Mocha](http://visionmedia.github.io/mocha/) and [Chai](http://chaijs.com/) in the following browsers.
|
||||
|
||||
* Firefox
|
||||
* Chrome
|
||||
* Opera
|
||||
* Safari
|
||||
* IE9+
|
||||
|
||||
When testing in the more modern browsers, I run it through the very early versions, some midrange versions and the very latest ones too. I don't just do the latest version.
|
||||
|
||||
EventEmitter will always be tested and working perfectly in all of them before a release. I will not release anything I think is riddled with bugs. However, if you do spot one, please [submit it as an issue](https://github.com/Wolfy87/EventEmitter/issues) and I will get right on it.
|
||||
|
||||
I had to stop testing in IE<9. This is because Jasmine no longer seems to work in old IE. I converted all of my tests to Mocha/Chai and then realised Chai doesn't work in IE<9 either. I know it works, I just can't run the tests anymore, I still recommend using it in older IE versions. However, if you do encounter problems, all you have to do is roll back before v4.1.0, the first IE9+ only tested version.
|
||||
|
||||
As consolation for the lack of legacy browser testing, I have made sure the examples listed above run perfectly in IE6+. So the unit tests might not be able to run, but I am **very** confident that it works absolutely perfectly.
|
||||
|
||||
## Contributing
|
||||
|
||||
If you wish to contribute to the project then please commit your changes into the `develop` branch. All pull requests should contain a failing test which is then resolved by your additions. [A perfect example](https://github.com/Wolfy87/EventEmitter/pull/46) was submitted by [nathggns](https://github.com/nathggns).
|
||||
|
||||
## License (MIT)
|
||||
|
||||
Copyright (c) 2011-2013 Oliver Caldwell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
29
src/bower_components/eventEmitter/bower.json
vendored
Normal file
29
src/bower_components/eventEmitter/bower.json
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "eventEmitter",
|
||||
"description": "Event based JavaScript for the browser",
|
||||
"version": "4.2.7",
|
||||
"main": [
|
||||
"./EventEmitter.js"
|
||||
],
|
||||
"author": {
|
||||
"name": "Oliver Caldwell",
|
||||
"web": "http://oli.me.uk/"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/Wolfy87/EventEmitter#license-mit"
|
||||
}
|
||||
],
|
||||
"keywords": [
|
||||
"events",
|
||||
"structure"
|
||||
],
|
||||
"ignore": [
|
||||
"docs",
|
||||
"tests",
|
||||
"tools",
|
||||
".gitignore",
|
||||
"package.json"
|
||||
]
|
||||
}
|
9
src/bower_components/eventEmitter/component.json
vendored
Normal file
9
src/bower_components/eventEmitter/component.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "eventEmitter",
|
||||
"repo": "Wolfy87/EventEmitter",
|
||||
"description": "Event based JavaScript for the browser.",
|
||||
"version": "4.2.7",
|
||||
"scripts": ["EventEmitter.js"],
|
||||
"main": "EventEmitter.js",
|
||||
"license": "MIT"
|
||||
}
|
|
@ -8,10 +8,9 @@
|
|||
<title>Kibana 4</title>
|
||||
<!-- load the root require context -->
|
||||
<script src="bower_components/requirejs/require.js"></script>
|
||||
<script src="app/require.config.js"></script>
|
||||
<script>require(['app'], function () {})</script>
|
||||
<script src="kibana/require.config.js"></script>
|
||||
<script>require(['main'], function () {});</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
1
src/kibana/apps/dashboard/main.html
Normal file
1
src/kibana/apps/dashboard/main.html
Normal file
|
@ -0,0 +1 @@
|
|||
<h1>Dashboard</h1>
|
3
src/kibana/apps/dashboard/main.js
Normal file
3
src/kibana/apps/dashboard/main.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
define(function (require) {
|
||||
|
||||
});
|
1
src/kibana/apps/explore/main.html
Normal file
1
src/kibana/apps/explore/main.html
Normal file
|
@ -0,0 +1 @@
|
|||
<h1>Explore</h1>
|
3
src/kibana/apps/explore/main.js
Normal file
3
src/kibana/apps/explore/main.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
define(function (require) {
|
||||
|
||||
});
|
1
src/kibana/apps/visualize/main.html
Normal file
1
src/kibana/apps/visualize/main.html
Normal file
|
@ -0,0 +1 @@
|
|||
<h1>Visualize</h1>
|
3
src/kibana/apps/visualize/main.js
Normal file
3
src/kibana/apps/visualize/main.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
define(function (require) {
|
||||
|
||||
});
|
174
src/kibana/courier/courier.js
Normal file
174
src/kibana/courier/courier.js
Normal file
|
@ -0,0 +1,174 @@
|
|||
define(function (require) {
|
||||
|
||||
var DataSource = require('courier/data_source');
|
||||
var _ = require('lodash');
|
||||
|
||||
var optionNames = [
|
||||
'fetchInterval',
|
||||
'client'
|
||||
];
|
||||
|
||||
function Courier(config) {
|
||||
config = config || {};
|
||||
|
||||
var opts = {};
|
||||
var fetchTimer;
|
||||
var activeRequest;
|
||||
|
||||
var sources = [];
|
||||
|
||||
var mergeInheritance = function (source) {
|
||||
var state = {
|
||||
body: {}
|
||||
};
|
||||
|
||||
// all of the filters from the source chain,
|
||||
// no particular order
|
||||
var filters = [];
|
||||
|
||||
var mergeProp = function (val, key) {
|
||||
switch (key) {
|
||||
case 'filters':
|
||||
filters.push(val);
|
||||
break;
|
||||
case 'index':
|
||||
case 'type':
|
||||
if (key && state[key] == null) {
|
||||
state[key] = val;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (key && state.body[key] == null) {
|
||||
state.body[key] = val;
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// walk the chain and merge each property
|
||||
var current = source;
|
||||
while (current) {
|
||||
_.forOwn(current, mergeProp);
|
||||
current = current.inherits;
|
||||
}
|
||||
|
||||
_.forOwn({
|
||||
query: {
|
||||
match_all: {}
|
||||
},
|
||||
index: '_all',
|
||||
type: '_all'
|
||||
}, mergeProp);
|
||||
|
||||
if (filters.length) {
|
||||
state.body.query = {
|
||||
filtered: {
|
||||
query: state.body.query,
|
||||
filter: {
|
||||
bool: {
|
||||
must: filters
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return state;
|
||||
};
|
||||
|
||||
var writeSourceRequest = function (source) {
|
||||
var state = mergeInheritance(source.state());
|
||||
return JSON.stringify({
|
||||
index: state.index,
|
||||
type: state.type
|
||||
}) +
|
||||
'\n' +
|
||||
JSON.stringify(state.body);
|
||||
};
|
||||
|
||||
var onSourceUpdate = _.bind(function (source) {
|
||||
var existing = _.find(sources, { source: source });
|
||||
if (!existing) {
|
||||
this.stopFetchingSource(source);
|
||||
}
|
||||
existing.req = writeSourceRequest(source);
|
||||
}, this);
|
||||
|
||||
var setFetchTimeout = function () {
|
||||
clearTimeout(fetchTimer);
|
||||
if (opts.fetchInterval) {
|
||||
fetchTimer = setTimeout(onFetch, opts.fetchInterval);
|
||||
} else {
|
||||
fetchTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
var stopFetching = function () {
|
||||
clearTimeout(fetchTimer);
|
||||
return this;
|
||||
};
|
||||
|
||||
var onFetch = _.bind(function () {
|
||||
if (!opts.client) {
|
||||
throw new Error('Courier does not have a client yet, unable to fetch queries');
|
||||
}
|
||||
|
||||
var requests = _.pluck(sources, 'req');
|
||||
|
||||
activeRequest = opts.client.msearch({
|
||||
body: requests
|
||||
});
|
||||
}, this);
|
||||
|
||||
var startFetchingSource = function (source) {
|
||||
var existing = _.find(sources, { source: source });
|
||||
if (existing) return false;
|
||||
|
||||
sources.push({
|
||||
source: source,
|
||||
req: writeSourceRequest(source)
|
||||
});
|
||||
source.on('change', onSourceUpdate);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
var stopFetchingSource = function (source) {
|
||||
source.removeListener('change', onSourceUpdate);
|
||||
_.remove(sources, { source: source });
|
||||
if (sources.length === 0) clearTimeout(fetchTimer);
|
||||
};
|
||||
|
||||
// public api
|
||||
this.start = setFetchTimeout;
|
||||
this.startFetchingSource = startFetchingSource;
|
||||
this.stop = stopFetching;
|
||||
this.stopFetchingSource = stopFetchingSource;
|
||||
this.close = _.partial(_.each, sources, stopFetchingSource);
|
||||
this.define = function (state) {
|
||||
return new DataSource(this, state);
|
||||
};
|
||||
|
||||
// chainable settings/getters for state stuff
|
||||
optionNames.forEach(function chainableOptions(name) {
|
||||
this[name] = function (val) {
|
||||
if (val === void 0) {
|
||||
return opts[name];
|
||||
}
|
||||
opts[name] = val;
|
||||
switch (name) {
|
||||
case 'fetchInterval':
|
||||
if (fetchTimer) setFetchTimeout();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
}, this);
|
||||
|
||||
// private api, exposed for testing
|
||||
this._state = function () { return opts; };
|
||||
this._writeSourceRequest = writeSourceRequest;
|
||||
}
|
||||
|
||||
|
||||
return Courier;
|
||||
});
|
99
src/kibana/courier/data_source.js
Normal file
99
src/kibana/courier/data_source.js
Normal file
|
@ -0,0 +1,99 @@
|
|||
define(function (require) {
|
||||
var inherits = require('utils/inherits');
|
||||
var _ = require('lodash');
|
||||
var EventEmitter = require('utils/event_emitter');
|
||||
var Mapper = require('courier/mapper');
|
||||
|
||||
// polyfill for older versions of node
|
||||
function listenerCount(emitter, event) {
|
||||
if (EventEmitter.listenerCount) {
|
||||
return EventEmitter.listenerCount(emitter, event);
|
||||
} else {
|
||||
return this.listeners(event).length;
|
||||
}
|
||||
}
|
||||
|
||||
var optionNames = [
|
||||
'index',
|
||||
'indexPattern',
|
||||
'type',
|
||||
'query',
|
||||
'filter',
|
||||
'sort',
|
||||
'highlight',
|
||||
'aggs',
|
||||
'from',
|
||||
'size',
|
||||
'inherits'
|
||||
];
|
||||
|
||||
function DataSource(courier, initialState) {
|
||||
var state;
|
||||
|
||||
if (initialState) {
|
||||
// state can be serialized as JSON, and passed back in to restore
|
||||
if (typeof initialState === 'string') {
|
||||
state = JSON.parse(state);
|
||||
} else {
|
||||
state = _.cloneDeep(initialState);
|
||||
}
|
||||
} else {
|
||||
state = {};
|
||||
}
|
||||
|
||||
var mapper = new Mapper();
|
||||
|
||||
var makeActive = _.bind(function () {
|
||||
if (listenerCount(this, 'results') === 0) return;
|
||||
courier.startFetchingSource(this);
|
||||
this.removeListener('newListener', makeActive);
|
||||
this.on('removeListener', makeInactive);
|
||||
}, this);
|
||||
|
||||
var makeInactive = _.bind(function () {
|
||||
if (listenerCount(this, 'results') > 0) return;
|
||||
courier.stopFetchingSource(this);
|
||||
this.removeListener('removeListener', makeInactive);
|
||||
this.on('newListener', makeActive);
|
||||
}, this);
|
||||
|
||||
this.on('newListener', makeActive);
|
||||
|
||||
/**
|
||||
* Used to flatten a chain of DataSources
|
||||
* @return {object} - simple object containing all of the
|
||||
* sources internal state
|
||||
*/
|
||||
this._state = function () {
|
||||
return state;
|
||||
};
|
||||
|
||||
// public api
|
||||
this.toJSON = function () {
|
||||
return JSON.stringify(_.omit(state, 'inherits'));
|
||||
};
|
||||
|
||||
this.getFieldNames = function (cb) {
|
||||
mapper.getMapping(state.index, state.type, function (mapping) {
|
||||
return _.keys(mapping);
|
||||
});
|
||||
};
|
||||
|
||||
// get/set internal state values
|
||||
optionNames.forEach(function chainableOptions(name) {
|
||||
this[name] = function (val) {
|
||||
if (val === void 0) {
|
||||
return state[name];
|
||||
}
|
||||
if (state[name] !== val) {
|
||||
state[name] = val;
|
||||
this.emit('change', this, name);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
}, this);
|
||||
}
|
||||
inherits(DataSource, EventEmitter);
|
||||
|
||||
return DataSource;
|
||||
});
|
13
src/kibana/courier/mapper.js
Normal file
13
src/kibana/courier/mapper.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
define(function (require) {
|
||||
/**
|
||||
* Fetches mappings from elasticsearch and casts result objects
|
||||
* based on those mappings
|
||||
*
|
||||
* @class Mapper
|
||||
*/
|
||||
function Mapper() {
|
||||
|
||||
}
|
||||
|
||||
return Mapper;
|
||||
});
|
9
src/kibana/main.js
Normal file
9
src/kibana/main.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
define(function (require) {
|
||||
|
||||
/**
|
||||
* Bootstrap require with the needed config, then setup routing and bootstrap the app
|
||||
*/
|
||||
|
||||
return {};
|
||||
|
||||
});
|
21
src/kibana/require.config.js
Normal file
21
src/kibana/require.config.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
(function () {
|
||||
function bower(p) { return '../bower_components/' + p; }
|
||||
|
||||
require.config({
|
||||
baseUrl: 'kibana',
|
||||
paths: {
|
||||
d3: bower('d3/d3'),
|
||||
lodash: bower('lodash/dist/lodash'),
|
||||
jquery: bower('jquery/jquery'),
|
||||
angular: bower('angular/angular'),
|
||||
'utils/event_emitter': bower('eventEmitter/EventEmitter')
|
||||
},
|
||||
shim: {
|
||||
angular: {
|
||||
deps: ['jquery'],
|
||||
exports: 'angular'
|
||||
}
|
||||
},
|
||||
waitSeconds: 60
|
||||
});
|
||||
}());
|
7
src/kibana/utils/inherits.js
Normal file
7
src/kibana/utils/inherits.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
|
||||
return function (Child, Parent) {
|
||||
Child.prototype = _.create(Parent.prototype, { 'constructor': Parent });
|
||||
};
|
||||
});
|
4
tasks/.jshintrc
Normal file
4
tasks/.jshintrc
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"extends": "../.jshintrc",
|
||||
"node": true
|
||||
}
|
17
tasks/config/connect.js
Normal file
17
tasks/config/connect.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
module.exports = {
|
||||
dev: {
|
||||
options: {
|
||||
base: '<%= src %>'
|
||||
}
|
||||
},
|
||||
test: {
|
||||
options: {
|
||||
base: [
|
||||
'<%= unitTestDir %>',
|
||||
'<%= src %>',
|
||||
'<%= root %>/node_modules/mocha',
|
||||
'<%= root %>/node_modules/expect.js'
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
12
tasks/config/mocha.js
Normal file
12
tasks/config/mocha.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
module.exports = {
|
||||
unit: {
|
||||
options: {
|
||||
log: true,
|
||||
logErrors: true,
|
||||
urls: [
|
||||
'http://localhost:8000/'
|
||||
],
|
||||
run: false
|
||||
}
|
||||
}
|
||||
};
|
4
tasks/server.js
Normal file
4
tasks/server.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
module.exports = function (grunt) {
|
||||
grunt.registerTask('server', ['connect:dev:keepalive']);
|
||||
grunt.registerTask('test_server', ['connect:test:keepalive']);
|
||||
};
|
7
tasks/test.js
Normal file
7
tasks/test.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = function (grunt) {
|
||||
/* jshint scripturl:true */
|
||||
grunt.registerTask('test', [
|
||||
'connect:test',
|
||||
'mocha:unit'
|
||||
]);
|
||||
};
|
14
test/.jshintrc
Normal file
14
test/.jshintrc
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"extends": "../.jshintrc",
|
||||
|
||||
"globals": {
|
||||
"describe": true,
|
||||
"it": true,
|
||||
"beforeEach": true,
|
||||
"afterEach": true,
|
||||
"before": true,
|
||||
"after": true,
|
||||
"expect": true,
|
||||
"define": true
|
||||
}
|
||||
}
|
35
test/unit/index.html
Normal file
35
test/unit/index.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Kibana4 Tests</title>
|
||||
<link rel="stylesheet" href="mocha.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="expect.js"></script>
|
||||
<script src="mocha.js"></script>
|
||||
<script>
|
||||
mocha.setup('bdd');
|
||||
// sauce labs & selenium inject global variables that break this
|
||||
// mocha.checkLeaks();
|
||||
// mocha.globals(['mochaRunner', 'angular']);
|
||||
</script>
|
||||
<!-- libs -->
|
||||
<script src="bower_components/requirejs/require.js"></script>
|
||||
<script src="kibana/require.config.js"></script>
|
||||
<!-- <script src="angular.js"></script> -->
|
||||
|
||||
<!-- tests -->
|
||||
<script>
|
||||
require([
|
||||
'/specs/courier.js',
|
||||
'/specs/data_source.js'
|
||||
], function () {
|
||||
window.mochaRunner = mocha.run().on('end', function(){
|
||||
window.mochaResults = this.stats;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
60
test/unit/specs/courier.js
Normal file
60
test/unit/specs/courier.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
define(function (require) {
|
||||
var Courier = require('courier/courier');
|
||||
|
||||
describe('Courier Module', function () {
|
||||
|
||||
it('provides a constructor for the Courier classs', function () {
|
||||
var courier = new Courier();
|
||||
expect(courier).to.be.a(Courier);
|
||||
});
|
||||
|
||||
it('knows when a DataSource object has event listeners for the results event');
|
||||
it('executes queries on the interval for searches that have listeners for results');
|
||||
|
||||
describe('::new', function () {
|
||||
it('requires a config object which will be passed to the .');
|
||||
});
|
||||
|
||||
describe('events', function () {
|
||||
describe('error', function () {
|
||||
it('emits when any request comes back with an error');
|
||||
it('emits multiple times when multiple requests error');
|
||||
it('hander is called with the client error object, and the DataSource object to which the error relates');
|
||||
});
|
||||
});
|
||||
|
||||
describe('sync API', function () {
|
||||
var courier;
|
||||
beforeEach(function () {
|
||||
courier = new Courier();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
courier.close();
|
||||
});
|
||||
|
||||
describe('#fetchInterval', function () {
|
||||
it('sets the interval in milliseconds that queries will be fetched', function () {
|
||||
courier.fetchInterval(1000);
|
||||
expect(courier._state()).to.have.property('fetchInterval', 1000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#define', function () {
|
||||
it('creates an empty (match all) DataSource object', function () {
|
||||
var source = courier.define();
|
||||
expect(source._state()).to.eql({});
|
||||
});
|
||||
it('optionally accepts a json object/string that will populate the DataSource object with settings');
|
||||
});
|
||||
});
|
||||
|
||||
describe('async API', function () {
|
||||
describe('#fetch', function () {
|
||||
it('crawls the DataSource objects which are listening for results.');
|
||||
it('uses aggregated filter/aggs/etc to create serialized es-DSL request');
|
||||
it('sends the serialized es-dsl requests in a single /msearch request.');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
59
test/unit/specs/data_source.js
Normal file
59
test/unit/specs/data_source.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
define(function (require) {
|
||||
describe('DataSource class', function () {
|
||||
describe('events', function () {
|
||||
describe('results', function () {
|
||||
it('emits when a new result is available');
|
||||
it('emits null when an error occurs');
|
||||
});
|
||||
});
|
||||
|
||||
describe('chainable and synch API', function () {
|
||||
describe('#query', function () {
|
||||
it('sets the query of a DataSource');
|
||||
});
|
||||
|
||||
describe('#filters', function () {
|
||||
it('converts the query to a filtered_query and sets the filters in that query');
|
||||
});
|
||||
|
||||
describe('#sort', function () {
|
||||
it('adds a sort to the DataSource');
|
||||
});
|
||||
|
||||
describe('#highlight', function () {
|
||||
it('sets the highlight fields for a DataSource');
|
||||
});
|
||||
|
||||
describe('#aggs', function () {
|
||||
it('sets the aggs for the DataSource');
|
||||
});
|
||||
|
||||
describe('#from', function () {
|
||||
it('sets the from property of the DataSource');
|
||||
});
|
||||
|
||||
describe('#size', function () {
|
||||
it('sets the size property of the DataSource');
|
||||
});
|
||||
|
||||
describe('#inherits', function () {
|
||||
it('sets the parent of a DataSource, meaning it will absorb it\'s filters/aggregations/etc.');
|
||||
});
|
||||
|
||||
describe('#toJSON', function () {
|
||||
it('serializes the own properties of this DataSource to a JSON string');
|
||||
});
|
||||
});
|
||||
|
||||
describe('async API', function () {
|
||||
describe('#fetch', function () {
|
||||
it('initiates a fetch at the Courier');
|
||||
});
|
||||
|
||||
describe('#fields', function () {
|
||||
it('fetches the fields available for the given query, including the types possible for each field');
|
||||
it('returns types as an array, possibly containing multiple types or multi-index queries');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue