-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
92 lines (79 loc) · 2.54 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* Frankenstein Kable 6.x
* Based on Kable + Timelion
* http://qxip.net
*/
import processFunctionDefinition from './server/lib/process_function_definition';
var path = require('path');
var _ = require('lodash');
module.exports = function (kibana) {
return new kibana.Plugin({
name: 'kable',
require: ['kibana', 'elasticsearch', 'timelion'],
uiExports: {
app: {
title: 'Kable',
description: 'Weeeeee',
icon: 'plugins/kable/icon.svg',
main: 'plugins/kable/app',
injectVars: function (server, options) {
var config = server.config();
return {
kbnIndex: config.get('kibana.index'),
esShardTimeout: config.get('elasticsearch.shardTimeout'),
esApiVersion: config.get('elasticsearch.apiVersion'),
esUrl: config.get('elasticsearch.url')
};
}
},
home: [
'plugins/kable/register_feature'
],
uiSettingDefaults: {
'kable:showTutorial': {
value: false,
description: 'Should I show the tutorial by default when entering the kable app?'
},
'kable:es.timefield': {
value: '@timestamp',
description: 'Default field containing a timestamp when using .es()'
},
'kable:es.default_index': {
value: '_all',
description: 'Default elasticsearch index to search with .es()'
},
}
},
config: function (Joi) {
return Joi.object({
enabled: Joi.boolean().default(true),
}).default();
},
init: function (server, options) {
// Add server routes and initalize the plugin here
require('./server/routes/run')(server);
require('./server/routes/functions')(server);
require('./server/routes/legacy')(server);
require('./server/routes/validate_es')(server);
const functions = require('./server/lib/load_functions').getFunctions('functions');
const legacy = require('./server/lib/load_functions').getTypes;
function addFunction(func) {
_.assign(functions, processFunctionDefinition(func));
}
function getFunction(name) {
if (!functions[name]) throw new Error ('No such function: ' + name);
return functions[name];
}
server.plugins.kable = {
functions: functions,
legacy: legacy,
addFunction: addFunction,
getFunction: getFunction
};
if(server.plugins.timelion){
// Inject Kable Timelion
server.plugins.timelion.addFunction(require('./server/timelion_functions/kable'));
}
}
});
};