mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
building is mostly stable, less is improving, initial cached building added
This commit is contained in:
parent
935bb5e945
commit
522a00ec5d
235 changed files with 1849 additions and 1441 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -3,9 +3,8 @@
|
|||
.node_binaries
|
||||
node_modules
|
||||
bower_components
|
||||
**/*.css
|
||||
trash
|
||||
build
|
||||
bundles
|
||||
target
|
||||
.jruby
|
||||
.idea
|
||||
|
|
1
.jscsrc
1
.jscsrc
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"esprima": "./node_modules/babel-jscs",
|
||||
"maximumLineLength": {
|
||||
"value": 140,
|
||||
"allowComments": true
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"extends": "./.jshintrc",
|
||||
"node": true,
|
||||
"esnext": true,
|
||||
|
||||
"globals": {
|
||||
"Promise": true,
|
||||
|
|
11
bower.json
11
bower.json
|
@ -20,30 +20,21 @@
|
|||
"angular-route": "1.2.28",
|
||||
"angular-ui-ace": "0.2.3",
|
||||
"bluebird": "~2.9.27",
|
||||
"bootstrap": "3.3.4",
|
||||
"d3": "3.5.5",
|
||||
"elasticsearch": "~5.0.0",
|
||||
"Faker": "1.1.0",
|
||||
"FileSaver": "babc6d9d8f",
|
||||
"font-awesome": "4.3.0",
|
||||
"gridster": "0.5.6",
|
||||
"jquery": "2.1.4",
|
||||
"leaflet": "0.7.3",
|
||||
"Leaflet.heat": "Leaflet/Leaflet.heat#627ede7c11bbe43",
|
||||
"lesshat": "3.0.2",
|
||||
"lodash": "3.9.3",
|
||||
"moment": "2.10.3",
|
||||
"moment-timezone": "0.4.0",
|
||||
"ng-clip": "0.2.6",
|
||||
"require-css": "0.1.8",
|
||||
"requirejs": "2.1.18",
|
||||
"requirejs-text": "2.0.14",
|
||||
"marked": "0.3.3",
|
||||
"numeral": "1.5.3",
|
||||
"leaflet-draw": "0.2.4"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"resolutions": {
|
||||
"angular": "1.2.28"
|
||||
}
|
||||
"devDependencies": {}
|
||||
}
|
||||
|
|
25
package.json
25
package.json
|
@ -40,16 +40,23 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"ansicolors": "^0.3.2",
|
||||
"autoprefixer-loader": "^2.0.0",
|
||||
"babel-jscs": "^1.0.3",
|
||||
"bluebird": "^2.9.27",
|
||||
"body-parser": "^1.10.1",
|
||||
"boom": "^2.8.0",
|
||||
"bootstrap": "^3.3.5",
|
||||
"bunyan": "^1.2.3",
|
||||
"commander": "^2.6.0",
|
||||
"compression": "^1.3.0",
|
||||
"cookie-parser": "^1.3.3",
|
||||
"css-loader": "^0.15.1",
|
||||
"debug": "^2.1.1",
|
||||
"elasticsearch": "^5.0.0",
|
||||
"exports-loader": "^0.6.2",
|
||||
"express": "^4.10.6",
|
||||
"file-loader": "^0.8.4",
|
||||
"font-awesome": "^4.3.0",
|
||||
"glob": "^4.3.2",
|
||||
"good": "^5.1.2",
|
||||
"good-console": "^4.1.0",
|
||||
|
@ -57,19 +64,28 @@
|
|||
"good-reporter": "^3.1.0",
|
||||
"hapi": "^8.6.1",
|
||||
"http-auth": "^2.2.5",
|
||||
"imports-loader": "^0.6.4",
|
||||
"joi": "^6.4.3",
|
||||
"js-yaml": "^3.2.5",
|
||||
"json-stringify-safe": "^5.0.1",
|
||||
"lodash": "^3.9.3",
|
||||
"less": "^2.5.1",
|
||||
"less-loader": "^2.2.0",
|
||||
"loader-utils": "^0.2.10",
|
||||
"lodash": "^3.10.0",
|
||||
"minimatch": "^2.0.8",
|
||||
"mkdirp": "^0.5.1",
|
||||
"moment": "^2.10.3",
|
||||
"node-libs-browser": "spalger/node-libs-browser",
|
||||
"numeral": "^1.5.3",
|
||||
"raw-loader": "^0.5.1",
|
||||
"request": "^2.40.0",
|
||||
"requirefrom": "^0.2.0",
|
||||
"rimraf": "^2.4.1",
|
||||
"semver": "^4.3.6",
|
||||
"serve-favicon": "^2.2.0",
|
||||
"style-loader": "^0.12.3",
|
||||
"through": "^2.3.6",
|
||||
"url-loader": "^0.5.6",
|
||||
"webpack": "^1.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -84,8 +100,6 @@
|
|||
"grunt-contrib-copy": "^0.8.0",
|
||||
"grunt-contrib-jade": "^0.14.0",
|
||||
"grunt-contrib-jshint": "^0.11",
|
||||
"grunt-contrib-less": "^1.0.1",
|
||||
"grunt-contrib-requirejs": "^0.4.4",
|
||||
"grunt-contrib-watch": "^0.6.1",
|
||||
"grunt-esvm": "^1.0.1",
|
||||
"grunt-jscs": "^1.8.0",
|
||||
|
@ -112,14 +126,11 @@
|
|||
"path-browserify": "0.0.0",
|
||||
"portscanner": "^1.0.0",
|
||||
"progress": "^1.1.8",
|
||||
"requirejs": "^2.1.14",
|
||||
"rjs-build-analysis": "0.0.3",
|
||||
"simple-git": "^1.3.0",
|
||||
"sinon": "^1.12.2",
|
||||
"tar": "^2.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "~0.10 || ~0.12",
|
||||
"iojs": ">=1.5"
|
||||
"node": ">=2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ for %%I in ("%SCRIPT_DIR%..") do set DIR=%%~dpfI
|
|||
|
||||
set NODE=%DIR%\node\node.exe
|
||||
set SERVER=%DIR%\src\server\cli
|
||||
set NODE_ENV="production"
|
||||
set CONFIG_PATH=%DIR%\config\kibana.yml
|
||||
|
||||
TITLE Kibana Server @@version
|
||||
|
|
|
@ -17,5 +17,5 @@ DIR=$(dirname "${SCRIPT}")/..
|
|||
NODE=${DIR}/node/bin/node
|
||||
SERVER=${DIR}/src/server/cli
|
||||
|
||||
CONFIG_PATH="${DIR}/config/kibana.yml" NODE_ENV="production" exec "${NODE}" ${SERVER} ${@}
|
||||
CONFIG_PATH="${DIR}/config/kibana.yml" exec "${NODE}" ${SERVER} ${@}
|
||||
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
module.exports = function (kibana) {
|
||||
var path = require('path');
|
||||
var glob = require('glob');
|
||||
var join = path.join;
|
||||
var rel = join.bind(null, __dirname);
|
||||
|
||||
var ROOT = rel('../../../');
|
||||
var SRC = join(ROOT, 'src');
|
||||
var NODE_MODULES = join(ROOT, 'node_modules');
|
||||
var APP = join(SRC, 'kibana');
|
||||
var TEST = join(ROOT, 'test');
|
||||
var istanbul = require('./lib/istanbul');
|
||||
var amdWrapper = require('./lib/amd_wrapper');
|
||||
var kibanaSrcFilter = require('./lib/kibana_src_filter');
|
||||
|
||||
return new kibana.Plugin({
|
||||
require: ['marvel'],
|
||||
init: function (server, options) {
|
||||
server.ext('onPreHandler', istanbul({ root: SRC, displayRoot: SRC, filter: kibanaSrcFilter }));
|
||||
server.ext('onPreHandler', istanbul({ root: APP, displayRoot: SRC, filter: kibanaSrcFilter }));
|
||||
|
||||
server.route({
|
||||
path: '/test/{paths*}',
|
||||
method: 'GET',
|
||||
handler: {
|
||||
directory: {
|
||||
path: TEST
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
path: '/amd-wrap/{paths*}',
|
||||
method: 'GET',
|
||||
handler: amdWrapper({ root: ROOT })
|
||||
});
|
||||
|
||||
server.route({
|
||||
path: '/src/{paths*}',
|
||||
method: 'GET',
|
||||
handler: {
|
||||
directory: {
|
||||
path: SRC
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
path: '/node_modules/{paths*}',
|
||||
method: 'GET',
|
||||
handler: {
|
||||
directory: {
|
||||
path: NODE_MODULES
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
path: '/specs',
|
||||
method: 'GET',
|
||||
handler: function (request, reply) {
|
||||
var unit = join(ROOT, '/test/unit/');
|
||||
glob(join(unit, 'specs/**/*.js'), function (er, files) {
|
||||
var moduleIds = files
|
||||
.filter(function (filename) {
|
||||
return path.basename(filename).charAt(0) !== '_';
|
||||
})
|
||||
.map(function (filename) {
|
||||
return path.relative(unit, filename).replace(/\\/g, '/').replace(/\.js$/, '');
|
||||
});
|
||||
|
||||
return reply(moduleIds);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
};
|
|
@ -1,24 +1,101 @@
|
|||
var _ = require('lodash');
|
||||
var join = require('path').join;
|
||||
|
||||
var resolve = require('path').resolve.bind(null, __dirname, '..', '..');
|
||||
var KbnServer = require('../server/KbnServer');
|
||||
|
||||
function kibanaPlugin(kibana) {
|
||||
var path = require('path');
|
||||
var glob = require('glob');
|
||||
var join = path.join;
|
||||
var rel = join.bind(null, __dirname);
|
||||
|
||||
var ROOT = rel('../../../');
|
||||
var SRC = join(ROOT, 'src');
|
||||
var NODE_MODULES = join(ROOT, 'node_modules');
|
||||
var APP = join(SRC, 'kibana');
|
||||
var TEST = join(ROOT, 'test');
|
||||
var istanbul = require('./lib/istanbul');
|
||||
var amdWrapper = require('./lib/amd_wrapper');
|
||||
var kibanaSrcFilter = require('./lib/kibana_src_filter');
|
||||
|
||||
return new kibana.Plugin({
|
||||
init: function (server, options) {
|
||||
server.ext('onPreHandler', istanbul({ root: SRC, displayRoot: SRC, filter: kibanaSrcFilter }));
|
||||
server.ext('onPreHandler', istanbul({ root: APP, displayRoot: SRC, filter: kibanaSrcFilter }));
|
||||
|
||||
server.route({
|
||||
path: '/test/{paths*}',
|
||||
method: 'GET',
|
||||
handler: {
|
||||
directory: {
|
||||
path: TEST
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
path: '/amd-wrap/{paths*}',
|
||||
method: 'GET',
|
||||
handler: amdWrapper({ root: ROOT })
|
||||
});
|
||||
|
||||
server.route({
|
||||
path: '/src/{paths*}',
|
||||
method: 'GET',
|
||||
handler: {
|
||||
directory: {
|
||||
path: SRC
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
path: '/node_modules/{paths*}',
|
||||
method: 'GET',
|
||||
handler: {
|
||||
directory: {
|
||||
path: NODE_MODULES
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
path: '/specs',
|
||||
method: 'GET',
|
||||
handler: function (request, reply) {
|
||||
var unit = join(ROOT, '/test/unit/');
|
||||
glob(join(unit, 'specs/**/*.js'), function (er, files) {
|
||||
var moduleIds = files
|
||||
.filter(function (filename) {
|
||||
return path.basename(filename).charAt(0) !== '_';
|
||||
})
|
||||
.map(function (filename) {
|
||||
return path.relative(unit, filename).replace(/\\/g, '/').replace(/\.js$/, '');
|
||||
});
|
||||
|
||||
return reply(moduleIds);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function run(port, quiet) {
|
||||
return (new KbnServer({
|
||||
'env': 'development',
|
||||
|
||||
'logging.quiet': quiet,
|
||||
'kibana.server.port': port || 5601,
|
||||
'plugins.paths': [
|
||||
join(__dirname, 'dev_statics_plugin')
|
||||
],
|
||||
'plugins.scanDirs': [
|
||||
join(__dirname, '..', 'plugins')
|
||||
]
|
||||
'plugins.paths': [ __dirname ],
|
||||
'plugins.scanDirs': [ resolve('src/plugins') ],
|
||||
'optimize.bundleDir': resolve('bundles'),
|
||||
}))
|
||||
.listen();
|
||||
}
|
||||
|
||||
module.exports = kibanaPlugin;
|
||||
module.exports.run = run;
|
||||
|
||||
if (require.main === module) {
|
||||
run().done();
|
||||
} else {
|
||||
module.exports = run;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"name": "dev_statics",
|
||||
"name": "dev_server",
|
||||
"version": "1.0.0"
|
||||
}
|
|
@ -68,7 +68,7 @@ module.exports = function (kibana) {
|
|||
// of modules that this plugin provides to other plugins.
|
||||
// For now this only describes the modules exported for
|
||||
// the front-end
|
||||
exports: {
|
||||
uiExports: {
|
||||
|
||||
// an app is the highest level ui-component that a plugin
|
||||
// can export. apps get an icon on the app page and the option
|
||||
|
@ -148,7 +148,7 @@ require('chrome')
|
|||
})
|
||||
|
||||
require('routes').when('/', {
|
||||
view: requrie('text!plugins/my-kibana-plugin/home.awesome.html')
|
||||
view: requrie('plugins/my-kibana-plugin/home.awesome.html')
|
||||
})
|
||||
.otherwise({
|
||||
redirect: '/'
|
||||
|
|
19
src/plugins/appSwitcher/index.js
Normal file
19
src/plugins/appSwitcher/index.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
module.exports = function (kibana) {
|
||||
return new kibana.Plugin({
|
||||
uiExports: {
|
||||
app: {
|
||||
id: 'switcher',
|
||||
main: 'plugins/appSwitcher/appSwitcher',
|
||||
hidden: true,
|
||||
defaultModules: {
|
||||
angular: [],
|
||||
require: [
|
||||
'chrome',
|
||||
'angular-bootstrap'
|
||||
]
|
||||
.concat(kibana.autoload.styles)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
4
src/plugins/appSwitcher/package.json
Normal file
4
src/plugins/appSwitcher/package.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "appSwitcher",
|
||||
"version": "1.0.0"
|
||||
}
|
35
src/plugins/appSwitcher/public/appSwitcher.css
Normal file
35
src/plugins/appSwitcher/public/appSwitcher.css
Normal file
|
@ -0,0 +1,35 @@
|
|||
.application {
|
||||
background-color: #ecf0f1;
|
||||
}
|
||||
.app-links {
|
||||
width: 700px;
|
||||
margin: 25px auto;
|
||||
text-align: justify;
|
||||
}
|
||||
.app-links .app-link {
|
||||
display: inline-block;
|
||||
background: white;
|
||||
width: 200px;
|
||||
margin: 0 30px 30px 0;
|
||||
}
|
||||
.app-links .app-link .app-icon {
|
||||
display: block;
|
||||
height: 200px;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
.app-links .app-link .app-info {
|
||||
display: block;
|
||||
padding: 15px;
|
||||
}
|
||||
.app-links .app-link .app-title {
|
||||
margin: 0 0 10px;
|
||||
color: #444444;
|
||||
}
|
||||
.app-links .app-link .app-description {
|
||||
font-size: 1em;
|
||||
color: #95a5a6;
|
||||
text-align: left;
|
||||
margin: 0;
|
||||
}
|
||||
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi8vVXNlcnMvc3BlbmNlci9kZXYvZXMva2liYW5hL3NyYy91aS9hcHBTd2l0Y2hlci9hcHBTd2l0Y2hlci5sZXNzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBO0VBQ0UseUJBQUE7O0FBR0Y7RUFDRSxZQUFBO0VBQ0EsaUJBQUE7RUFDQSxtQkFBQTs7QUFIRixVQUtFO0VBQ0UscUJBQUE7RUFDQSxpQkFBQTtFQUNBLFlBQUE7RUFDQSxxQkFBQTs7QUFUSixVQUtFLFVBTUU7RUFDRSxjQUFBO0VBQ0EsYUFBQTtFQUNBLHNCQUFBO0VBQ0EsMkJBQUE7O0FBZk4sVUFLRSxVQWFFO0VBQ0UsY0FBQTtFQUNBLGFBQUE7O0FBcEJOLFVBS0UsVUFrQkU7RUFDRSxnQkFBQTtFQUNBLGNBQUE7O0FBekJOLFVBS0UsVUF1QkU7RUFDRSxjQUFBO0VBQ0EsY0FBQTtFQUNBLGdCQUFBO0VBQ0EsU0FBQSJ9 */
|
24
src/plugins/appSwitcher/public/appSwitcher.js
Normal file
24
src/plugins/appSwitcher/public/appSwitcher.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
require('plugins/appSwitcher/appSwitcher.less');
|
||||
|
||||
require('chrome')
|
||||
.setLogo('url(/images/kibana.png) left no-repeat', true)
|
||||
.setTabs([
|
||||
{
|
||||
id: '',
|
||||
title: 'Apps'
|
||||
}
|
||||
])
|
||||
.setRootTemplate(require('plugins/appSwitcher/appSwitcher.html'))
|
||||
.setRootController('switcher', function SwitcherController($http) {
|
||||
var switcher = {
|
||||
loading: true
|
||||
};
|
||||
|
||||
$http.get('/api/apps')
|
||||
.then(function (resp) {
|
||||
switcher.loading = false;
|
||||
switcher.apps = resp.data;
|
||||
});
|
||||
|
||||
return switcher;
|
||||
});
|
|
@ -1,5 +1,4 @@
|
|||
@import (reference) "lesshat";
|
||||
@import (reference) "ui-styles/theme/_variables";
|
||||
@import (reference) "~ui-styles/variables";
|
||||
|
||||
.application {
|
||||
background-color: @gray-lighter;
|
|
@ -35,7 +35,7 @@ module.exports = function (kibana) {
|
|||
);
|
||||
|
||||
// Set up the health check service and start it.
|
||||
healthCheck(this, server).start();
|
||||
// healthCheck(this, server).start();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function (kibana) {
|
|||
|
||||
return new kibana.Plugin({
|
||||
|
||||
exports: {
|
||||
uiExports: {
|
||||
visTypes: [
|
||||
'plugins/kbn_vislib_vis_types/kbn_vislib_vis_types'
|
||||
]
|
||||
|
|
|
@ -28,7 +28,7 @@ define(function (require) {
|
|||
},
|
||||
scales: ['linear', 'log', 'square root'],
|
||||
modes: ['stacked', 'overlap', 'percentage', 'wiggle', 'silhouette'],
|
||||
editor: require('text!plugins/kbn_vislib_vis_types/editors/area.html')
|
||||
editor: require('plugins/kbn_vislib_vis_types/editors/area.html')
|
||||
},
|
||||
schemas: new Schemas([
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ define(function (require) {
|
|||
module.directive('lineInterpolationOption', function ($parse, $compile) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kbn_vislib_vis_types/controls/line_interpolation_option.html'),
|
||||
template: require('plugins/kbn_vislib_vis_types/controls/line_interpolation_option.html'),
|
||||
replace: true
|
||||
};
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ define(function (require) {
|
|||
module.directive('pointSeriesOptions', function ($parse, $compile) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kbn_vislib_vis_types/controls/point_series_options.html'),
|
||||
template: require('plugins/kbn_vislib_vis_types/controls/point_series_options.html'),
|
||||
replace: true
|
||||
};
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ define(function (require) {
|
|||
module.directive('vislibBasicOptions', function ($parse, $compile) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kbn_vislib_vis_types/controls/vislib_basic_options.html'),
|
||||
template: require('plugins/kbn_vislib_vis_types/controls/vislib_basic_options.html'),
|
||||
replace: true
|
||||
};
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ define(function (require) {
|
|||
},
|
||||
scales: ['linear', 'log', 'square root'],
|
||||
modes: ['stacked', 'percentage', 'grouped'],
|
||||
editor: require('text!plugins/kbn_vislib_vis_types/editors/histogram.html')
|
||||
editor: require('plugins/kbn_vislib_vis_types/editors/histogram.html')
|
||||
},
|
||||
schemas: new Schemas([
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ define(function (require) {
|
|||
yAxis: {}
|
||||
},
|
||||
scales: ['linear', 'log', 'square root'],
|
||||
editor: require('text!plugins/kbn_vislib_vis_types/editors/line.html')
|
||||
editor: require('plugins/kbn_vislib_vis_types/editors/line.html')
|
||||
},
|
||||
schemas: new Schemas([
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ define(function (require) {
|
|||
addLegend: true,
|
||||
isDonut: false
|
||||
},
|
||||
editor: require('text!plugins/kbn_vislib_vis_types/editors/pie.html')
|
||||
editor: require('plugins/kbn_vislib_vis_types/editors/pie.html')
|
||||
},
|
||||
responseConverter: false,
|
||||
hierarchicalData: true,
|
||||
|
|
|
@ -25,7 +25,7 @@ define(function (require) {
|
|||
},
|
||||
mapTypes: ['Scaled Circle Markers', 'Shaded Circle Markers', 'Shaded Geohash Grid', 'Heatmap'],
|
||||
canDesaturate: !!supports.cssFilters,
|
||||
editor: require('text!plugins/kbn_vislib_vis_types/editors/tile_map.html')
|
||||
editor: require('plugins/kbn_vislib_vis_types/editors/tile_map.html')
|
||||
},
|
||||
listeners: {
|
||||
rectangle: function (event) {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
module.exports = function (kibana) {
|
||||
var jq = ['$=jquery'];
|
||||
var ng = jq.concat('angular');
|
||||
|
||||
return new kibana.Plugin({
|
||||
exports: {
|
||||
uiExports: {
|
||||
app: {
|
||||
title: 'Kibana',
|
||||
description: 'the kibana you know and love',
|
||||
|
@ -11,6 +13,54 @@ module.exports = function (kibana) {
|
|||
'visTypes',
|
||||
'spyModes'
|
||||
]
|
||||
},
|
||||
|
||||
modules: {
|
||||
'chrome$': 'chrome/chrome',
|
||||
'lodash': 'utils/lodash-mixins/index',
|
||||
'errors': 'components/errors',
|
||||
'modules': 'components/modules',
|
||||
'routes': 'components/routes/index',
|
||||
|
||||
// bower_components
|
||||
'angular': ['bower_components/angular/angular', jq, 'window.angular'],
|
||||
|
||||
// angular deps
|
||||
'angular-bindonce': ['bower_components/angular-bindonce/bindonce', ng],
|
||||
'angular-bootstrap': ['bower_components/angular-bootstrap/ui-bootstrap-tpls', ng],
|
||||
'angular-elastic': ['bower_components/angular-elastic/elastic', ng],
|
||||
'angular-route': ['bower_components/angular-route/angular-route', ng],
|
||||
'ng-clip': ['bower_components/ng-clip/src/ngClip', ng.concat('zeroclipboard')],
|
||||
'elasticsearch': ['meta-modules/elasticsearch'],
|
||||
'elasticsearch-src': {
|
||||
path: 'bower_components/elasticsearch/elasticsearch.angular.min',
|
||||
parse: false
|
||||
},
|
||||
|
||||
// ace editor
|
||||
'ace': {
|
||||
path: 'bower_components/ace-builds/src-noconflict/ace',
|
||||
parse: false,
|
||||
exports: 'ace'
|
||||
},
|
||||
'angular-ui-ace': ['bower_components/angular-ui-ace/ui-ace', ng.concat('ace', 'aceJson=ace-json')],
|
||||
'ace-json': ['bower_components/ace-builds/src-noconflict/mode-json', 'ace'],
|
||||
'd3': ['bower_components/d3/d3'],
|
||||
'faker': ['bower_components/Faker/faker'],
|
||||
'file_saver': ['bower_components/FileSaver/FileSaver', null, 'saveAs'],
|
||||
'gridster': ['bower_components/gridster/dist/jquery.gridster', 'jquery,gs=gridster-styles'],
|
||||
'gridster-styles': ['bower_components/gridster/dist/jquery.gridster.css'],
|
||||
'jquery': ['bower_components/jquery/dist/jquery'],
|
||||
'leaflet': ['bower_components/leaflet/dist/leaflet', 'ls=leaflet-styles'],
|
||||
'leaflet-styles': ['bower_components/leaflet-draw/dist/leaflet.draw.css'],
|
||||
'leaflet-heat': ['bower_components/Leaflet.heat/dist/leaflet-heat', 'leaflet'],
|
||||
'leaflet-draw': ['bower_components/leaflet-draw/dist/leaflet.draw', 'leaflet,lds=leaflet-draw-styles'],
|
||||
'leaflet-draw-styles': ['bower_components/leaflet/dist/leaflet.css'],
|
||||
'lodash_src': ['bower_components/lodash/lodash'],
|
||||
'moment': ['bower_components/moment/moment'],
|
||||
'zeroclipboard': ['bower_components/zeroclipboard/dist/ZeroClipboard'],
|
||||
'marked': ['bower_components/marked/lib/marked'],
|
||||
'numeral': ['bower_components/numeral/numeral']
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ define(function (require) {
|
|||
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kibana/dashboard/components/panel/panel.html'),
|
||||
template: require('plugins/kibana/dashboard/components/panel/panel.html'),
|
||||
requires: '^dashboardGrid',
|
||||
link: function ($scope, $el) {
|
||||
// using $scope inheritance, panels are available in AppState
|
||||
|
|
|
@ -14,7 +14,7 @@ define(function (require) {
|
|||
require('plugins/kibana/dashboard/directives/grid');
|
||||
require('plugins/kibana/dashboard/components/panel/panel');
|
||||
require('plugins/kibana/dashboard/services/saved_dashboards');
|
||||
require('css!plugins/kibana/dashboard/styles/main.css');
|
||||
require('plugins/kibana/dashboard/styles/main.less');
|
||||
|
||||
var app = require('modules').get('app/dashboard', [
|
||||
'elasticsearch',
|
||||
|
@ -27,7 +27,7 @@ define(function (require) {
|
|||
|
||||
require('routes')
|
||||
.when('/dashboard', {
|
||||
template: require('text!plugins/kibana/dashboard/index.html'),
|
||||
template: require('plugins/kibana/dashboard/index.html'),
|
||||
resolve: {
|
||||
dash: function (savedDashboards) {
|
||||
return savedDashboards.get();
|
||||
|
@ -35,7 +35,7 @@ define(function (require) {
|
|||
}
|
||||
})
|
||||
.when('/dashboard/:id', {
|
||||
template: require('text!plugins/kibana/dashboard/index.html'),
|
||||
template: require('plugins/kibana/dashboard/index.html'),
|
||||
resolve: {
|
||||
dash: function (savedDashboards, Notifier, $route, $location, courier) {
|
||||
return savedDashboards.get($route.current.params.id)
|
||||
|
@ -83,10 +83,10 @@ define(function (require) {
|
|||
var $state = $scope.state = new AppState(stateDefaults);
|
||||
|
||||
$scope.configTemplate = new ConfigTemplate({
|
||||
save: require('text!plugins/kibana/dashboard/partials/save_dashboard.html'),
|
||||
load: require('text!plugins/kibana/dashboard/partials/load_dashboard.html'),
|
||||
share: require('text!plugins/kibana/dashboard/partials/share.html'),
|
||||
pickVis: require('text!plugins/kibana/dashboard/partials/pick_visualization.html')
|
||||
save: require('plugins/kibana/dashboard/partials/save_dashboard.html'),
|
||||
load: require('plugins/kibana/dashboard/partials/load_dashboard.html'),
|
||||
share: require('plugins/kibana/dashboard/partials/share.html'),
|
||||
pickVis: require('plugins/kibana/dashboard/partials/pick_visualization.html')
|
||||
});
|
||||
|
||||
$scope.refresh = _.bindKey(courier, 'fetch');
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
@import (reference) "ui-styles/_bootstrap.less";
|
||||
@import (reference) "ui-styles/theme/_theme.less";
|
||||
@import (reference) "ui-styles/_mixins.less";
|
||||
@import (reference) "lesshat.less";
|
||||
|
||||
@import (reference) "~ui-styles/variables";
|
||||
@import (reference) "~ui-styles/mixins";
|
||||
@dashboard-background: @gray-lighter;
|
||||
|
||||
.tab-dashboard {
|
||||
|
@ -56,24 +53,24 @@ dashboard-grid {
|
|||
height: 100%;
|
||||
|
||||
// flex layout allows us to define the visualize element as "fill available space"
|
||||
.display(flex);
|
||||
.flex-direction(column);
|
||||
.justify-content(flex-start);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
|
||||
.panel-heading {
|
||||
.flex(0 0 auto);
|
||||
flex: 0 0 auto;
|
||||
white-space: nowrap;
|
||||
display: flex;
|
||||
|
||||
div.btn-group {
|
||||
white-space: nowrap;
|
||||
.flex(0 0 auto);
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.panel-title {
|
||||
font-size: inherit;
|
||||
.ellipsis();
|
||||
.flex(1 1 0);
|
||||
flex: 1 1 0;
|
||||
}
|
||||
|
||||
a {
|
||||
|
@ -90,10 +87,10 @@ dashboard-grid {
|
|||
.load-error {
|
||||
text-align: center;
|
||||
font-size: 1em;
|
||||
.display(flex);
|
||||
.flex(1 0 auto);
|
||||
.justify-content(center);
|
||||
.flex-direction(column);
|
||||
display: flex;
|
||||
flex: 1 0 auto;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
|
||||
.fa-exclamation-triangle {
|
||||
font-size: 2em;
|
||||
|
@ -103,7 +100,7 @@ dashboard-grid {
|
|||
|
||||
.panel-content {
|
||||
display: flex;
|
||||
.flex(1, 1, 100%);
|
||||
flex: 1 1 100%;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
define(function (require) {
|
||||
var $ = require('jquery');
|
||||
var app = require('modules').get('apps/discover');
|
||||
var html = require('text!plugins/kibana/discover/components/field_chooser/discover_field.html');
|
||||
var html = require('plugins/kibana/discover/components/field_chooser/discover_field.html');
|
||||
var _ = require('lodash');
|
||||
|
||||
require('directives/css_truncate');
|
||||
|
@ -17,7 +17,7 @@ define(function (require) {
|
|||
var detailsElem;
|
||||
var detailScope = $scope.$new();
|
||||
|
||||
var detailsHtml = require('text!plugins/kibana/discover/components/field_chooser/lib/detail_views/string.html');
|
||||
var detailsHtml = require('plugins/kibana/discover/components/field_chooser/lib/detail_views/string.html');
|
||||
|
||||
var init = function () {
|
||||
if ($scope.field.details) {
|
||||
|
|
|
@ -23,7 +23,7 @@ define(function (require) {
|
|||
indexPatternList: '=',
|
||||
updateFilterInQuery: '=filter'
|
||||
},
|
||||
template: require('text!plugins/kibana/discover/components/field_chooser/field_chooser.html'),
|
||||
template: require('plugins/kibana/discover/components/field_chooser/field_chooser.html'),
|
||||
link: function ($scope) {
|
||||
$scope.setIndexPattern = function (id) {
|
||||
$scope.state.index = id;
|
||||
|
|
|
@ -30,7 +30,7 @@ define(function (require) {
|
|||
|
||||
require('routes')
|
||||
.when('/discover/:id?', {
|
||||
template: require('text!plugins/kibana/discover/index.html'),
|
||||
template: require('plugins/kibana/discover/index.html'),
|
||||
reloadOnSearch: false,
|
||||
resolve: {
|
||||
ip: function (Promise, courier, config, $location) {
|
||||
|
@ -90,8 +90,8 @@ define(function (require) {
|
|||
|
||||
// config panel templates
|
||||
$scope.configTemplate = new ConfigTemplate({
|
||||
load: require('text!plugins/kibana/discover/partials/load_search.html'),
|
||||
save: require('text!plugins/kibana/discover/partials/save_search.html')
|
||||
load: require('plugins/kibana/discover/partials/load_search.html'),
|
||||
save: require('plugins/kibana/discover/partials/save_search.html')
|
||||
});
|
||||
|
||||
$scope.timefilter = timefilter;
|
||||
|
|
|
@ -4,5 +4,5 @@ define(function (require, module, exports) {
|
|||
require('components/collapsible_sidebar/collapsible_sidebar');
|
||||
require('plugins/kibana/discover/components/field_chooser/field_chooser');
|
||||
require('plugins/kibana/discover/controllers/discover');
|
||||
require('css!plugins/kibana/discover/styles/main.css');
|
||||
require('plugins/kibana/discover/styles/main.less');
|
||||
});
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
@import (reference) "ui-styles/_bootstrap.less";
|
||||
@import (reference) "ui-styles/theme/_theme.less";
|
||||
@import (reference) "ui-styles/_variables.less";
|
||||
@import (reference) "~ui-styles/variables";
|
||||
|
||||
.tab-discover {
|
||||
overflow-x: hidden;
|
||||
|
@ -256,7 +254,7 @@ disc-field-chooser {
|
|||
|
||||
&-interval {
|
||||
a {
|
||||
text-decoration: underline;;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
select {
|
||||
|
|
|
@ -13,7 +13,7 @@ define(function (require) {
|
|||
'kibana/index_patterns'
|
||||
]);
|
||||
|
||||
var html = require('text!plugins/kibana/doc/index.html');
|
||||
var html = require('plugins/kibana/doc/index.html');
|
||||
|
||||
var resolveIndexPattern = {
|
||||
indexPattern: function (courier, savedSearches, $route) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
define(function (require, module, exports) {
|
||||
var _ = require('lodash');
|
||||
|
||||
require('css!plugins/kibana/settings/styles/main.css');
|
||||
require('plugins/kibana/settings/styles/main.less');
|
||||
require('filters/start_from');
|
||||
|
||||
require('routes')
|
||||
|
@ -13,7 +13,7 @@ define(function (require, module, exports) {
|
|||
.directive('kbnSettingsApp', function (Private, $route, timefilter) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kibana/settings/app.html'),
|
||||
template: require('plugins/kibana/settings/app.html'),
|
||||
transclude: true,
|
||||
scope: {
|
||||
sectionName: '@section'
|
||||
|
|
|
@ -3,7 +3,7 @@ define(function (require) {
|
|||
|
||||
require('routes')
|
||||
.when('/settings/about', {
|
||||
template: require('text!plugins/kibana/settings/sections/about/index.html')
|
||||
template: require('plugins/kibana/settings/sections/about/index.html')
|
||||
});
|
||||
|
||||
require('modules').get('apps/settings')
|
||||
|
|
|
@ -7,7 +7,7 @@ define(function (require) {
|
|||
return {
|
||||
restrict: 'A',
|
||||
replace: true,
|
||||
template: require('text!plugins/kibana/settings/sections/advanced/advanced_row.html'),
|
||||
template: require('plugins/kibana/settings/sections/advanced/advanced_row.html'),
|
||||
scope: {
|
||||
conf: '=advancedRow',
|
||||
configs: '='
|
||||
|
|
|
@ -7,7 +7,7 @@ define(function (require) {
|
|||
|
||||
require('routes')
|
||||
.when('/settings/advanced', {
|
||||
template: require('text!plugins/kibana/settings/sections/advanced/index.html')
|
||||
template: require('plugins/kibana/settings/sections/advanced/index.html')
|
||||
});
|
||||
|
||||
require('modules').get('apps/settings')
|
||||
|
|
|
@ -8,7 +8,7 @@ define(function (require) {
|
|||
|
||||
require('routes')
|
||||
.when('/settings/indices/', {
|
||||
template: require('text!plugins/kibana/settings/sections/indices/_create.html')
|
||||
template: require('plugins/kibana/settings/sections/indices/_create.html')
|
||||
});
|
||||
|
||||
require('modules').get('apps/settings')
|
||||
|
|
|
@ -6,7 +6,7 @@ define(function (require) {
|
|||
|
||||
require('routes')
|
||||
.when('/settings/indices/:indexPatternId', {
|
||||
template: require('text!plugins/kibana/settings/sections/indices/_edit.html'),
|
||||
template: require('plugins/kibana/settings/sections/indices/_edit.html'),
|
||||
resolve: {
|
||||
indexPattern: function ($route, courier) {
|
||||
return courier.indexPatterns.get($route.current.params.indexPatternId)
|
||||
|
|
|
@ -6,7 +6,7 @@ define(function (require) {
|
|||
.when('/settings/indices/:indexPatternId/field/:fieldName', { mode: 'edit' })
|
||||
.when('/settings/indices/:indexPatternId/create-field/', { mode: 'create' })
|
||||
.defaults(/settings\/indices\/[^\/]+\/(field|create-field)(\/|$)/, {
|
||||
template: require('text!plugins/kibana/settings/sections/indices/_field_editor.html'),
|
||||
template: require('plugins/kibana/settings/sections/indices/_field_editor.html'),
|
||||
resolve: {
|
||||
indexPattern: function ($route, courier) {
|
||||
return courier.indexPatterns.get($route.current.params.indexPatternId)
|
||||
|
|
|
@ -4,7 +4,7 @@ define(function (require) {
|
|||
.directive('kbnSettingsIndexHeader', function (config) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kibana/settings/sections/indices/_index_header.html'),
|
||||
template: require('plugins/kibana/settings/sections/indices/_index_header.html'),
|
||||
scope: {
|
||||
indexPattern: '=',
|
||||
setDefault: '&',
|
||||
|
|
|
@ -6,13 +6,13 @@ define(function (require) {
|
|||
.directive('indexedFields', function () {
|
||||
var yesTemplate = '<i class="fa fa-check" aria-label="yes"></i>';
|
||||
var noTemplate = '';
|
||||
var nameHtml = require('text!plugins/kibana/settings/sections/indices/_field_name.html');
|
||||
var typeHtml = require('text!plugins/kibana/settings/sections/indices/_field_type.html');
|
||||
var controlsHtml = require('text!plugins/kibana/settings/sections/indices/_field_controls.html');
|
||||
var nameHtml = require('plugins/kibana/settings/sections/indices/_field_name.html');
|
||||
var typeHtml = require('plugins/kibana/settings/sections/indices/_field_type.html');
|
||||
var controlsHtml = require('plugins/kibana/settings/sections/indices/_field_controls.html');
|
||||
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kibana/settings/sections/indices/_indexed_fields.html'),
|
||||
template: require('plugins/kibana/settings/sections/indices/_indexed_fields.html'),
|
||||
scope: true,
|
||||
link: function ($scope) {
|
||||
var rowScopes = []; // track row scopes, so they can be destroyed as needed
|
||||
|
|
|
@ -5,13 +5,13 @@ define(function (require) {
|
|||
require('modules').get('apps/settings')
|
||||
.directive('scriptedFields', function (kbnUrl, Notifier) {
|
||||
var rowScopes = []; // track row scopes, so they can be destroyed as needed
|
||||
var controlsHtml = require('text!plugins/kibana/settings/sections/indices/_field_controls.html');
|
||||
var controlsHtml = require('plugins/kibana/settings/sections/indices/_field_controls.html');
|
||||
|
||||
var notify = new Notifier();
|
||||
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kibana/settings/sections/indices/_scripted_fields.html'),
|
||||
template: require('plugins/kibana/settings/sections/indices/_scripted_fields.html'),
|
||||
scope: true,
|
||||
link: function ($scope) {
|
||||
var dateScripts = require('plugins/kibana/settings/sections/indices/_date_scripts');
|
||||
|
|
|
@ -21,7 +21,7 @@ define(function (require) {
|
|||
return {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
template: require('text!plugins/kibana/settings/sections/indices/index.html'),
|
||||
template: require('plugins/kibana/settings/sections/indices/index.html'),
|
||||
link: function ($scope) {
|
||||
$scope.edittingId = $route.current.params.indexPatternId;
|
||||
config.$bind($scope, 'defaultIndex');
|
||||
|
|
|
@ -3,7 +3,7 @@ define(function (require) {
|
|||
var angular = require('angular');
|
||||
var saveAs = require('file_saver');
|
||||
var registry = require('plugins/kibana/settings/saved_object_registry');
|
||||
var objectIndexHTML = require('text!plugins/kibana/settings/sections/objects/_objects.html');
|
||||
var objectIndexHTML = require('plugins/kibana/settings/sections/objects/_objects.html');
|
||||
|
||||
require('directives/file_upload');
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ define(function (require) {
|
|||
var angular = require('angular');
|
||||
var rison = require('utils/rison');
|
||||
var registry = require('plugins/kibana/settings/saved_object_registry');
|
||||
var objectViewHTML = require('text!plugins/kibana/settings/sections/objects/_view.html');
|
||||
var objectViewHTML = require('plugins/kibana/settings/sections/objects/_view.html');
|
||||
|
||||
require('routes')
|
||||
.when('/settings/objects/:service/:id', {
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
@import (reference) "lesshat.less";
|
||||
@import (reference) "ui-styles/_bootstrap.less";
|
||||
@import (reference) "ui-styles/theme/_theme.less";
|
||||
@import (reference) "ui-styles/_variables.less";
|
||||
@import (reference) "ui-styles/_mixins.less";
|
||||
@import (reference) "~ui-styles/theme";
|
||||
@import (reference) "~ui-styles/variables";
|
||||
|
||||
kibana-settings-app,
|
||||
kbn-settings-indices,
|
||||
|
@ -144,15 +141,15 @@ kbn-settings-objects-view {
|
|||
}
|
||||
|
||||
.index-pattern-name {
|
||||
.display(flex);
|
||||
.align-items(center);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.title {
|
||||
.flex(1, 1, auto);
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.controls {
|
||||
.flex(4, 0, auto);
|
||||
flex: 4 0 auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ define(function (require) {
|
|||
var _ = require('lodash');
|
||||
var $ = require('jquery');
|
||||
var aggTypes = Private(require('components/agg_types/index'));
|
||||
var advancedToggleHtml = require('text!plugins/kibana/visualize/editor/advanced_toggle.html');
|
||||
var advancedToggleHtml = require('plugins/kibana/visualize/editor/advanced_toggle.html');
|
||||
|
||||
var notify = new Notifier({
|
||||
location: 'visAggGroup'
|
||||
|
@ -16,7 +16,7 @@ define(function (require) {
|
|||
|
||||
return {
|
||||
restrict: 'A',
|
||||
template: require('text!plugins/kibana/visualize/editor/agg.html'),
|
||||
template: require('plugins/kibana/visualize/editor/agg.html'),
|
||||
require: 'form',
|
||||
link: function ($scope, $el, attrs, kbnForm) {
|
||||
$scope.$bind('outputAgg', 'outputVis.aggs.byId[agg.id]', $scope);
|
||||
|
|
|
@ -6,7 +6,7 @@ define(function (require) {
|
|||
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kibana/visualize/editor/agg_add.html'),
|
||||
template: require('plugins/kibana/visualize/editor/agg_add.html'),
|
||||
controllerAs: 'add',
|
||||
controller: function ($scope) {
|
||||
var self = this;
|
||||
|
|
|
@ -8,7 +8,7 @@ define(function (require) {
|
|||
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kibana/visualize/editor/agg_group.html'),
|
||||
template: require('plugins/kibana/visualize/editor/agg_group.html'),
|
||||
scope: true,
|
||||
link: function ($scope, $el, attr) {
|
||||
$scope.groupName = attr.groupName;
|
||||
|
|
|
@ -7,8 +7,8 @@ define(function (require) {
|
|||
var _ = require('lodash');
|
||||
var $ = require('jquery');
|
||||
var aggTypes = Private(require('components/agg_types/index'));
|
||||
var aggSelectHtml = require('text!plugins/kibana/visualize/editor/agg_select.html');
|
||||
var advancedToggleHtml = require('text!plugins/kibana/visualize/editor/advanced_toggle.html');
|
||||
var aggSelectHtml = require('plugins/kibana/visualize/editor/agg_select.html');
|
||||
var advancedToggleHtml = require('plugins/kibana/visualize/editor/advanced_toggle.html');
|
||||
require('filters/match_any');
|
||||
require('plugins/kibana/visualize/editor/agg_param');
|
||||
|
||||
|
@ -18,7 +18,7 @@ define(function (require) {
|
|||
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kibana/visualize/editor/agg_params.html'),
|
||||
template: require('plugins/kibana/visualize/editor/agg_params.html'),
|
||||
scope: true,
|
||||
link: function ($scope, $el, attr) {
|
||||
$scope.$bind('agg', attr.agg);
|
||||
|
|
|
@ -9,7 +9,7 @@ define(function (require) {
|
|||
|
||||
require('routes')
|
||||
.when('/visualize/create', {
|
||||
template: require('text!plugins/kibana/visualize/editor/editor.html'),
|
||||
template: require('plugins/kibana/visualize/editor/editor.html'),
|
||||
resolve: {
|
||||
savedVis: function (savedVisualizations, courier, $route, Private) {
|
||||
var visTypes = Private(require('registry/vis_types'));
|
||||
|
@ -26,7 +26,7 @@ define(function (require) {
|
|||
}
|
||||
})
|
||||
.when('/visualize/edit/:id', {
|
||||
template: require('text!plugins/kibana/visualize/editor/editor.html'),
|
||||
template: require('plugins/kibana/visualize/editor/editor.html'),
|
||||
resolve: {
|
||||
savedVis: function (savedVisualizations, courier, $route) {
|
||||
return savedVisualizations.get($route.current.params.id)
|
||||
|
@ -74,9 +74,9 @@ define(function (require) {
|
|||
|
||||
// config panel templates
|
||||
var configTemplate = new ConfigTemplate({
|
||||
save: require('text!plugins/kibana/visualize/editor/panels/save.html'),
|
||||
load: require('text!plugins/kibana/visualize/editor/panels/load.html'),
|
||||
share: require('text!plugins/kibana/visualize/editor/panels/share.html'),
|
||||
save: require('plugins/kibana/visualize/editor/panels/save.html'),
|
||||
load: require('plugins/kibana/visualize/editor/panels/load.html'),
|
||||
share: require('plugins/kibana/visualize/editor/panels/share.html'),
|
||||
});
|
||||
|
||||
if (savedVis.id) {
|
||||
|
|
|
@ -9,7 +9,7 @@ define(function (require) {
|
|||
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kibana/visualize/editor/sidebar.html'),
|
||||
template: require('plugins/kibana/visualize/editor/sidebar.html'),
|
||||
scope: true,
|
||||
controllerAs: 'sidebar',
|
||||
controller: function ($scope) {
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
.user-select(none);
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
a {
|
||||
|
@ -60,7 +60,7 @@
|
|||
|
||||
// overrides for tablet and desktop
|
||||
@media (min-width: @screen-md-min) {
|
||||
.flex-direction(row);
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@
|
|||
|
||||
// overrided for tablet and desktop
|
||||
@media (min-width: @screen-md-min) {
|
||||
.flex-basis(@vis-editor-sidebar-basis);
|
||||
flex-basis: @vis-editor-sidebar-basis;
|
||||
min-width: @vis-editor-sidebar-min-width;
|
||||
max-width: @vis-editor-sidebar-min-width;
|
||||
// margin-bottom: (@input-height-base * 2) - 3;
|
||||
|
@ -104,7 +104,7 @@
|
|||
}
|
||||
|
||||
> .vis-edit-sidebar-buttons {
|
||||
.flex(0, 0, auto)
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
label {
|
||||
|
@ -133,7 +133,7 @@
|
|||
}
|
||||
|
||||
label {
|
||||
.flex(2 0 0);
|
||||
flex: 2 0 0;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
|
@ -153,8 +153,8 @@
|
|||
}
|
||||
|
||||
nesting-indicator {
|
||||
.display(flex);
|
||||
.flex(0 0 auto);
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
|
||||
> span {
|
||||
width: @vis-editor-nesting-width;
|
||||
|
@ -169,7 +169,7 @@
|
|||
|
||||
// wraps the .vis-editor-agg and nesting-indicator ^^
|
||||
&-wrapper {
|
||||
.display(flex);
|
||||
display: flex;
|
||||
}
|
||||
|
||||
&-group {
|
||||
|
@ -178,23 +178,23 @@
|
|||
}
|
||||
|
||||
&-header {
|
||||
.display(flex);
|
||||
.align-items(center);
|
||||
.flex(1, 0, auto);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 1 0 auto;
|
||||
margin-bottom: @vis-editor-agg-editor-spacing;
|
||||
|
||||
&-toggle {
|
||||
.flex(0, 0, auto);
|
||||
flex: 0 0 auto;
|
||||
margin-right: @vis-editor-agg-editor-spacing;
|
||||
}
|
||||
|
||||
&-subagg-icon {
|
||||
.flex(0, 1, auto);
|
||||
flex: 0 1 auto;
|
||||
padding-right: @padding-base-vertical;
|
||||
}
|
||||
|
||||
&-title {
|
||||
.flex(1, 1, auto);
|
||||
flex: 1 1 auto;
|
||||
.ellipsis();
|
||||
font-weight: bold;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@
|
|||
}
|
||||
|
||||
&-controls {
|
||||
.flex(0, 0, auto);
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,10 +248,10 @@
|
|||
}
|
||||
|
||||
&-form-row {
|
||||
.display(flex);
|
||||
display: flex;
|
||||
|
||||
> * {
|
||||
.flex(1, 1, auto);
|
||||
flex: 1 1 auto;
|
||||
margin-right: @vis-editor-agg-editor-spacing;
|
||||
|
||||
&:last-child {
|
||||
|
@ -260,18 +260,18 @@
|
|||
}
|
||||
|
||||
> .btn {
|
||||
.align-self(center);
|
||||
align-self: center;
|
||||
}
|
||||
}
|
||||
|
||||
&-form-value {
|
||||
.align-self(center);
|
||||
align-self: center;
|
||||
margin: 0 0 0 @vis-editor-agg-editor-spacing;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
&-wide-btn {
|
||||
.border-radius(0);
|
||||
border-radius: 0;
|
||||
border-top: 2px solid @gray-lighter;
|
||||
|
||||
&-add {
|
||||
|
@ -319,20 +319,20 @@
|
|||
}
|
||||
|
||||
&-canvas {
|
||||
.flex(1, 0, @screen-md-min - @vis-editor-sidebar-basis);
|
||||
.display(flex);
|
||||
.flex-direction(column);
|
||||
flex: 1 0 (@screen-md-min - @vis-editor-sidebar-basis);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: auto;
|
||||
|
||||
&.embedded {
|
||||
.flex-shrink(1);
|
||||
.flex-basis(100%);
|
||||
flex-shrink: 1;
|
||||
flex-basis: 100%;
|
||||
}
|
||||
|
||||
// overrided for tablet and desktop
|
||||
@media (min-width: @screen-md-min) {
|
||||
.flex-shrink(1);
|
||||
.flex-basis(100%);
|
||||
flex-shrink: 1;
|
||||
flex-basis: 100%;
|
||||
}
|
||||
|
||||
&-title {
|
||||
|
@ -342,11 +342,11 @@
|
|||
|
||||
visualize {
|
||||
.flex-parent();
|
||||
.flex(1, 1, 100%);
|
||||
flex: 1 1 100%;
|
||||
}
|
||||
|
||||
.visualize-chart {
|
||||
.flex(1, 1, 100%);
|
||||
flex: 1 1 100%;
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ define(function (require) {
|
|||
.directive('visEditorVisOptions', function (Private, $timeout, $compile) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/kibana/visualize/editor/vis_options.html'),
|
||||
template: require('plugins/kibana/visualize/editor/vis_options.html'),
|
||||
scope: {
|
||||
vis: '=',
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
define(function (require) {
|
||||
require('css!plugins/kibana/visualize/styles/main.css');
|
||||
require('plugins/kibana/visualize/styles/main.less');
|
||||
|
||||
require('plugins/kibana/visualize/editor/editor');
|
||||
require('plugins/kibana/visualize/wizard/wizard');
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
@import (reference) "ui-styles/main.less";
|
||||
@import (reference) "~ui-styles/variables";
|
||||
@import (reference) "~bootstrap/less/list-group";
|
||||
@import (reference) "~ui-styles/list-group-menu";
|
||||
|
||||
.vis-wizard {
|
||||
h1 {
|
||||
|
@ -12,30 +14,30 @@
|
|||
|
||||
// overrided for tablet and desktop
|
||||
@media (min-width: @screen-md-min) {
|
||||
.display(flex);
|
||||
.align-items(flex-start);
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
&-heading {
|
||||
.flex(0 0 200px);
|
||||
.display(flex);
|
||||
.align-items(center);
|
||||
flex: 0 0 200px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 1.2em;
|
||||
|
||||
.fa {
|
||||
.flex(0 0 auto);
|
||||
flex: 0 0 auto;
|
||||
margin-right: @padding-base-horizontal;
|
||||
font-size: 1.5em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h4 {
|
||||
.flex(1 0 auto);
|
||||
flex: 1 0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
&-description {
|
||||
.flex(1 1 auto);
|
||||
flex: 1 1 auto;
|
||||
color: @brand-primary;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ define(function (require) {
|
|||
/** Wizard Step 1
|
||||
/********/
|
||||
routes.when('/visualize/step/1', {
|
||||
template: templateStep(1, require('text!plugins/kibana/visualize/wizard/step_1.html'))
|
||||
template: templateStep(1, require('plugins/kibana/visualize/wizard/step_1.html'))
|
||||
});
|
||||
|
||||
module.controller('VisualizeWizardStep1', function ($scope, $route, $location, timefilter, Private) {
|
||||
|
@ -33,7 +33,7 @@ define(function (require) {
|
|||
/** Wizard Step 2
|
||||
/********/
|
||||
routes.when('/visualize/step/2', {
|
||||
template: templateStep(2, require('text!plugins/kibana/visualize/wizard/step_2.html')),
|
||||
template: templateStep(2, require('plugins/kibana/visualize/wizard/step_2.html')),
|
||||
resolve: {
|
||||
indexPatternIds: function (courier) {
|
||||
return courier.indexPatterns.getIds();
|
||||
|
|
|
@ -2,9 +2,9 @@ module.exports = function (kibana) {
|
|||
|
||||
return new kibana.Plugin({
|
||||
|
||||
exports: {
|
||||
uiExports: {
|
||||
visTypes: [
|
||||
'plugins/markdown_vis/index'
|
||||
'plugins/markdown_vis/markdown_vis'
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
define(function (require) {
|
||||
// we need to load the css ourselves
|
||||
require('css!plugins/markdown_vis/markdown_vis.css');
|
||||
require('plugins/markdown_vis/markdown_vis.less');
|
||||
|
||||
// we also need to load the controller and used by the template
|
||||
require('plugins/markdown_vis/markdown_vis_controller');
|
||||
|
@ -18,9 +18,9 @@ define(function (require) {
|
|||
title: 'Markdown widget',
|
||||
icon: 'fa-code',
|
||||
description: 'Useful for displaying explanations or instructions for dashboards.',
|
||||
template: require('text!plugins/markdown_vis/markdown_vis.html'),
|
||||
template: require('plugins/markdown_vis/markdown_vis.html'),
|
||||
params: {
|
||||
editor: require('text!plugins/markdown_vis/markdown_vis_params.html')
|
||||
editor: require('plugins/markdown_vis/markdown_vis_params.html')
|
||||
},
|
||||
requiresSearch: false
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
@import (reference) "ui-styles/_mixins.less";
|
||||
@import (reference) "lesshat.less";
|
||||
@import (reference) "~ui-styles/mixins.less";
|
||||
|
||||
.markdown-vis {
|
||||
padding: 1em;
|
||||
|
@ -12,15 +11,15 @@
|
|||
|
||||
.visualization-options {
|
||||
.flex-parent();
|
||||
.flex(1, 1, auto);
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.markdown-vis-options {
|
||||
.flex-parent();
|
||||
.flex(1, 1, auto);
|
||||
flex: 1 1 auto;
|
||||
|
||||
textarea {
|
||||
.flex(1, 1, auto);
|
||||
flex: 1 1 auto;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ module.exports = function (kibana) {
|
|||
|
||||
return new kibana.Plugin({
|
||||
|
||||
exports: {
|
||||
uiExports: {
|
||||
visTypes: [
|
||||
'plugins/metric_vis/index'
|
||||
'plugins/metric_vis/metric_vis'
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
<div class="metric-value" ng-style="{'font-size': vis.params.fontSize+'pt'}">{{metric.value}}</div>
|
||||
<div>{{metric.label}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
define(function (require) {
|
||||
// we need to load the css ourselves
|
||||
require('css!plugins/metric_vis/metric_vis.css');
|
||||
require('plugins/metric_vis/metric_vis.less');
|
||||
|
||||
// we also need to load the controller and used by the template
|
||||
require('plugins/metric_vis/metric_vis_controller');
|
||||
|
@ -20,12 +20,12 @@ define(function (require) {
|
|||
description: 'One big number for all of your one big number needs. Perfect for show ' +
|
||||
'a count of hits, or the exact average a numeric field.',
|
||||
icon: 'fa-calculator',
|
||||
template: require('text!plugins/metric_vis/metric_vis.html'),
|
||||
template: require('plugins/metric_vis/metric_vis.html'),
|
||||
params: {
|
||||
defaults: {
|
||||
fontSize: 60
|
||||
},
|
||||
editor: require('text!plugins/metric_vis/metric_vis_params.html')
|
||||
editor: require('plugins/metric_vis/metric_vis_params.html')
|
||||
},
|
||||
schemas: new Schemas([
|
||||
{
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
@import (reference) "ui-styles/_mixins.less";
|
||||
@import (reference) "lesshat.less";
|
||||
@import (reference) "~ui-styles/mixins.less";
|
||||
|
||||
.metric-vis {
|
||||
width: 100%;
|
||||
.display(flex);
|
||||
.flex-direction(row);
|
||||
.flex-wrap(wrap);
|
||||
.justify-content(space-around);
|
||||
.align-items(center);
|
||||
.align-content(space-around);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
align-content: space-around;
|
||||
|
||||
.metric-value {
|
||||
font-weight: bold;
|
||||
|
@ -18,6 +17,5 @@
|
|||
.metric-container {
|
||||
text-align: center;
|
||||
padding: 1em;
|
||||
.flex();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,4 +27,4 @@ define(function (require) {
|
|||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = function (kibana) {
|
||||
return new kibana.Plugin({
|
||||
exports: {
|
||||
uiExports: {
|
||||
app: {
|
||||
title: 'Sense',
|
||||
description: 'like cURL, but for elasticsearch and helpfull',
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
module.exports = function (kibana) {
|
||||
|
||||
return new kibana.Plugin({
|
||||
exports: {
|
||||
uiExports: {
|
||||
visTypes: [
|
||||
'plugins/table_vis/index'
|
||||
'plugins/table_vis/table_vis'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
define(function (require) {
|
||||
// we need to load the css ourselves
|
||||
require('css!plugins/table_vis/table_vis.css');
|
||||
require('plugins/table_vis/table_vis.less');
|
||||
|
||||
// we also need to load the controller and used by the template
|
||||
require('plugins/table_vis/table_vis_controller');
|
||||
|
@ -31,7 +31,7 @@ define(function (require) {
|
|||
icon: 'fa-table',
|
||||
description: 'The data table provides a detailed breakdown, in tabular format, of the results of a composed ' +
|
||||
'aggregation. Tip, a data table is available from many other charts by clicking grey bar at the bottom of the chart.',
|
||||
template: require('text!plugins/table_vis/table_vis.html'),
|
||||
template: require('plugins/table_vis/table_vis.html'),
|
||||
params: {
|
||||
defaults: {
|
||||
perPage: 10,
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
@import (reference) "lesshat.less";
|
||||
|
||||
.table-vis {
|
||||
.display(flex);
|
||||
.flex-direction(column);
|
||||
.flex(1 0 100%);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1 0 100%;
|
||||
|
||||
&-error {
|
||||
.display(flex);
|
||||
.flex-direction(column);
|
||||
.justify-content(center);
|
||||
.flex(1 0 100%);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
flex: 1 0 100%;
|
||||
|
||||
text-align: center;
|
||||
}
|
||||
|
@ -20,11 +18,11 @@
|
|||
}
|
||||
|
||||
.pagination-other-pages {
|
||||
.justify-content(flex-end);
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.pagination-size {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ define(function (require) {
|
|||
.directive('tableVisParams', function () {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: require('text!plugins/table_vis/table_vis_params.html'),
|
||||
template: require('plugins/table_vis/table_vis_params.html'),
|
||||
link: function ($scope) {
|
||||
$scope.$watchMulti([
|
||||
'vis.params.showPartialRows',
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module.exports = function (kibana) {
|
||||
return new kibana.Plugin({
|
||||
exports: {
|
||||
uiExports: {
|
||||
spyModes: [
|
||||
'plugins/vis_debug_spy/index'
|
||||
'plugins/vis_debug_spy/vis_debug_spy'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ define(function (require) {
|
|||
return {
|
||||
name: 'debug',
|
||||
display: 'Debug',
|
||||
template: require('text!plugins/vis_debug_spy/vis_debug.html'),
|
||||
template: require('plugins/vis_debug_spy/vis_debug_spy.html'),
|
||||
order: 5,
|
||||
link: function ($scope, $el) {
|
||||
$scope.$watch('vis.getState() | json', function (json) {
|
||||
|
|
|
@ -15,13 +15,14 @@ function KbnServer(settings) {
|
|||
|
||||
this.server = new Hapi.Server();
|
||||
|
||||
// mixin server modules
|
||||
this.ready = _.constant(this.mixin(
|
||||
require('./config'),
|
||||
require('./logging'),
|
||||
require('./http'),
|
||||
require('./ui'),
|
||||
require('./status'),
|
||||
require('./plugins'),
|
||||
require('./ui'), // sets this.uiExports
|
||||
require('./status'), // sets this.status
|
||||
require('./plugins'), // sets this.plugins
|
||||
require('./optimize')
|
||||
));
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ var override = require('./override');
|
|||
function Config(schema, defaults) {
|
||||
this.schema = schema || Joi.object({}).default();
|
||||
this.config = {};
|
||||
this.set(defaults || {});
|
||||
this.set(defaults);
|
||||
|
||||
console.log(this.get('env'));
|
||||
}
|
||||
|
||||
Config.prototype.extendSchema = function (key, schema) {
|
||||
|
@ -19,24 +21,48 @@ Config.prototype.extendSchema = function (key, schema) {
|
|||
};
|
||||
|
||||
Config.prototype.reset = function (obj) {
|
||||
var results = Joi.validate(obj, this.schema);
|
||||
if (results.error) {
|
||||
throw results.error;
|
||||
}
|
||||
this.config = results.value;
|
||||
this._commit(obj);
|
||||
};
|
||||
|
||||
Config.prototype.set = function (key, value) {
|
||||
// clone and modify the config
|
||||
var config = _.cloneDeep(this.config);
|
||||
if (_.isPlainObject(key)) {
|
||||
config = override(config, key);
|
||||
} else {
|
||||
_.set(config, key, value);
|
||||
}
|
||||
var results = Joi.validate(config, this.schema);
|
||||
|
||||
// attempt to validate the config value
|
||||
this._commit(config);
|
||||
};
|
||||
|
||||
Config.prototype._commit = function (newConfig) {
|
||||
// resolve the current environment
|
||||
var env = newConfig.env;
|
||||
delete newConfig.env;
|
||||
if (_.isObject(env)) env = env.name;
|
||||
if (!env) env = process.env.NODE_ENV || 'production';
|
||||
|
||||
// pass the environment as context so that it can be refed in config
|
||||
var context = {
|
||||
env: env,
|
||||
prod: env === 'production',
|
||||
dev: env === 'development',
|
||||
};
|
||||
|
||||
if (!context.dev && !context.prod) {
|
||||
throw new TypeError(`Unexpected environment "${env}", expected one of "development" or "production"`);
|
||||
}
|
||||
|
||||
var results = Joi.validate(newConfig, this.schema, {
|
||||
context: context
|
||||
});
|
||||
|
||||
if (results.error) {
|
||||
throw results.error;
|
||||
}
|
||||
|
||||
this.config = results.value;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,9 +2,30 @@ var Joi = require('joi');
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var package = require('../utils/closestPackageJson').getSync();
|
||||
var prod = process.env.NODE_ENV === 'production';
|
||||
var fromRoot = require('../utils/fromRoot');
|
||||
|
||||
var env = (function () {
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'production':
|
||||
case 'prod':
|
||||
case undefined:
|
||||
return 'production';
|
||||
case 'development':
|
||||
case 'dev':
|
||||
return 'development';
|
||||
default:
|
||||
throw new TypeError(`Unexpected NODE_ENV "${process.env.NODE_ENV}", expected production or development.`);
|
||||
}
|
||||
}());
|
||||
var dev = env === 'development';
|
||||
var prod = env === 'production';
|
||||
|
||||
module.exports = Joi.object({
|
||||
env: Joi.object({
|
||||
name: Joi.string().default(Joi.ref('$env')),
|
||||
dev: Joi.boolean().default(Joi.ref('$dev')),
|
||||
prod: Joi.boolean().default(Joi.ref('$prod'))
|
||||
}).default(),
|
||||
|
||||
kibana: Joi.object({
|
||||
package: Joi.any().default(package),
|
||||
|
@ -56,11 +77,17 @@ module.exports = Joi.object({
|
|||
}).default()
|
||||
}).default(),
|
||||
|
||||
plugins: {
|
||||
plugins: Joi.object({
|
||||
paths: Joi.array().items(Joi.string()).default([]),
|
||||
scanDirs: Joi.array().items(Joi.string()).default([]),
|
||||
optimize: Joi.boolean().default(prod)
|
||||
}
|
||||
scanDirs: Joi.array().items(Joi.string()).default([])
|
||||
}),
|
||||
|
||||
optimize: Joi.object({
|
||||
bundleDir: Joi.string().default(fromRoot('src/server/optimize/bundles')),
|
||||
viewCaching: Joi.boolean().default(Joi.ref('$prod')),
|
||||
watch: Joi.boolean().default(Joi.ref('$dev')),
|
||||
sourceMaps: Joi.boolean().default(Joi.ref('$dev'))
|
||||
})
|
||||
|
||||
}).default();
|
||||
|
||||
|
|
41
src/server/optimize/DirectoryNameAsDefaultFile.js
Normal file
41
src/server/optimize/DirectoryNameAsDefaultFile.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*****
|
||||
* Modified clone of https://github.com/webpack/enhanced-resolve/blob/3b88905ad3cb6392f48f7bc57d351891774fd93b/lib/DirectoryDefaultFilePlugin.js
|
||||
*****
|
||||
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
var _ = require('lodash');
|
||||
var basename = require('path').basename;
|
||||
|
||||
function DirectoryDefaultFilePlugin(files) {}
|
||||
module.exports = DirectoryDefaultFilePlugin;
|
||||
|
||||
DirectoryDefaultFilePlugin.prototype.apply = function (resolver) {
|
||||
resolver.plugin('directory', function (request, done) {
|
||||
handle(request).then(function (result) {
|
||||
done(null, result);
|
||||
}, done);
|
||||
});
|
||||
|
||||
var handle = _.memoize(function (req) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var directory = resolver.join(req.path, req.request);
|
||||
resolver.fileSystem.stat(directory, function (err, stat) {
|
||||
if (err || !stat) return resolve();
|
||||
if (!stat.isDirectory()) return resolve();
|
||||
|
||||
resolver.doResolve('file', {
|
||||
path: req.path,
|
||||
query: req.query,
|
||||
request: resolver.join(directory, basename(directory))
|
||||
}, function (err, result) {
|
||||
return resolve(result || undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
}, function (req) {
|
||||
return `${req.path}!${req.request}!${req.query}`;
|
||||
});
|
||||
};
|
108
src/server/optimize/Optimizer.js
Normal file
108
src/server/optimize/Optimizer.js
Normal file
|
@ -0,0 +1,108 @@
|
|||
'use strict';
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var inherits = require('util').inherits;
|
||||
var _ = require('lodash');
|
||||
var join = require('path').join;
|
||||
var write = require('fs').writeFileSync;
|
||||
var webpack = require('webpack');
|
||||
|
||||
var assets = require('../ui/assets');
|
||||
var fromRoot = require('../utils/fromRoot');
|
||||
var OptmzBundles = require('./OptmzBundles');
|
||||
var OptmzUiModules = require('./OptmzUiModules');
|
||||
var DirectoryNameAsDefaultFile = require('./DirectoryNameAsDefaultFile');
|
||||
|
||||
class Optimizer extends EventEmitter {
|
||||
constructor(opts) {
|
||||
super();
|
||||
|
||||
this.watch = opts.watch || false;
|
||||
this.sourceMaps = opts.sourceMaps || false;
|
||||
this.modules = new OptmzUiModules(opts.plugins);
|
||||
this.bundles = new OptmzBundles(opts.bundleDir, opts.apps);
|
||||
}
|
||||
|
||||
init() {
|
||||
return this.bundles.init(this.watch).then(_.bindKey(this, 'startCompiler'));
|
||||
}
|
||||
|
||||
startCompiler() {
|
||||
var self = this;
|
||||
var modules = self.modules;
|
||||
var bundles = self.bundles;
|
||||
|
||||
var compiler = webpack({
|
||||
entry: bundles.getEntriesToCompile(),
|
||||
|
||||
devtool: this.sourceMaps ? 'inline-source-map' : false,
|
||||
|
||||
output: {
|
||||
path: this.bundles.dir,
|
||||
publicPath: '/bundles/',
|
||||
filename: '[name].js'
|
||||
},
|
||||
|
||||
plugins: [
|
||||
new webpack.NoErrorsPlugin(),
|
||||
new webpack.optimize.DedupePlugin(),
|
||||
new webpack.optimize.OccurenceOrderPlugin(),
|
||||
new webpack.ResolverPlugin([
|
||||
new DirectoryNameAsDefaultFile()
|
||||
])
|
||||
],
|
||||
|
||||
module: {
|
||||
noParse: modules.noParse,
|
||||
loaders: modules.loaders
|
||||
},
|
||||
|
||||
resolve: {
|
||||
extensions: ['', '.js', '.less'],
|
||||
packageMains: [],
|
||||
modulesDirectories: [ fromRoot('node_modules'), assets.root ],
|
||||
root: fromRoot(),
|
||||
alias: modules.aliases
|
||||
}
|
||||
});
|
||||
|
||||
compiler.plugin('watch-run', function (compiler, cb) {
|
||||
self.emit('watch-run');
|
||||
cb();
|
||||
});
|
||||
|
||||
compiler.plugin('done', function (stats) {
|
||||
var errCount = _.size(stats.compilation.errors);
|
||||
|
||||
if (errCount) {
|
||||
console.log(stats.toString({ colors: true }));
|
||||
self.emit('error', new Error('Failed to compile bundle'));
|
||||
return;
|
||||
}
|
||||
|
||||
self.emit('done');
|
||||
});
|
||||
|
||||
compiler.plugin('failed', onFail);
|
||||
function onFail(err) {
|
||||
self.emit('error', err);
|
||||
}
|
||||
|
||||
process.nextTick(function () {
|
||||
if (self.watch) {
|
||||
compiler.watch({
|
||||
aggregateTimeout: 300
|
||||
}, _.noop);
|
||||
} else {
|
||||
self.emit('build-start');
|
||||
compiler.run(function (err) {
|
||||
err && onFail(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return compiler;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Optimizer;
|
20
src/server/optimize/OptmzAppEntry.js.tmpl
Normal file
20
src/server/optimize/OptmzAppEntry.js.tmpl
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* Optimized application entry file
|
||||
*
|
||||
* This is programatically created and updated, do not modify
|
||||
*
|
||||
* built using: Kibana <%= kbnVersion %>
|
||||
* includes code from:
|
||||
<%
|
||||
deps.sort().forEach(function (plugin) {
|
||||
print(` * - ${plugin}\n`);
|
||||
})
|
||||
%> *
|
||||
*/
|
||||
|
||||
require('chrome');
|
||||
<%
|
||||
modules.require.forEach(function (id) {
|
||||
if (id !== 'chrome') print(`require('${id}');\n`);
|
||||
});
|
||||
%>require('chrome').bootstrap(<%= JSON.stringify(modules.angular) %>);
|
141
src/server/optimize/OptmzBundles.js
Normal file
141
src/server/optimize/OptmzBundles.js
Normal file
|
@ -0,0 +1,141 @@
|
|||
'use strict';
|
||||
|
||||
let _ = require('lodash');
|
||||
let join = require('path').join;
|
||||
let resolve = require('bluebird').resolve;
|
||||
let promify = require('bluebird').promisify;
|
||||
let rimraf = promify(require('rimraf'));
|
||||
let mkdirp = promify(require('mkdirp'));
|
||||
|
||||
let stat = promify(require('fs').stat);
|
||||
let read = promify(require('fs').readFile);
|
||||
let write = promify(require('fs').writeFile);
|
||||
let unlink = promify(require('fs').unlink);
|
||||
let readdir = promify(require('fs').readdir);
|
||||
let readSync = require('fs').readFileSync;
|
||||
|
||||
let appEntryTmpl = _.template(readSync(join(__dirname, 'OptmzAppEntry.js.tmpl')));
|
||||
let kbnVersion = require('../utils/closestPackageJson').getSync().version;
|
||||
|
||||
class OptmzBundles {
|
||||
constructor(dir, apps) {
|
||||
this.dir = dir;
|
||||
if (!_.isString(this.dir)) {
|
||||
throw new TypeError('Optimizer requires a working directory');
|
||||
}
|
||||
|
||||
this.entries = _.map(apps, function (app) {
|
||||
let entry = {
|
||||
id: app.id,
|
||||
app: app,
|
||||
modules: app.getModules(),
|
||||
deps: app.relatedPlugins(),
|
||||
path: join(dir, app.id + '.entry.js'),
|
||||
bundlePath: join(dir, app.id + '.js')
|
||||
};
|
||||
|
||||
entry.content = appEntryTmpl(_.defaults({ kbnVersion: kbnVersion }, entry));
|
||||
|
||||
return entry;
|
||||
});
|
||||
|
||||
_.bindAll(this, [
|
||||
'init',
|
||||
'cleanBundles',
|
||||
'ensureBundleDir',
|
||||
'syncBundleDir',
|
||||
'syncBundle',
|
||||
'clean',
|
||||
'dirContents',
|
||||
'getUnkownBundleFiles',
|
||||
'getEntriesToCompile'
|
||||
]);
|
||||
}
|
||||
|
||||
init(fresh) {
|
||||
return resolve()
|
||||
.then(fresh && this.cleanBundles)
|
||||
.then(this.ensureBundleDir)
|
||||
.then(this.syncBundleDir);
|
||||
}
|
||||
|
||||
cleanBundles() {
|
||||
return rimraf(this.dir);
|
||||
}
|
||||
|
||||
ensureBundleDir() {
|
||||
return mkdirp(this.dir);
|
||||
}
|
||||
|
||||
syncBundleDir() {
|
||||
let ensure = this.entries.map(this.syncBundle);
|
||||
let collectGarbage = this.getUnkownBundleFiles().then(this.clean);
|
||||
return resolve(ensure.concat(collectGarbage)).all().then(_.noop);
|
||||
}
|
||||
|
||||
syncBundle(entry) {
|
||||
let clean = this.clean;
|
||||
|
||||
return resolve([
|
||||
read(entry.path),
|
||||
stat(entry.bundlePath)
|
||||
])
|
||||
.settle()
|
||||
.spread(function (readEntry, statBundle) {
|
||||
if (readEntry.isFulfilled() && statBundle.isFulfilled()) {
|
||||
entry.exists = (readEntry.value() !== entry.content);
|
||||
} else {
|
||||
entry.exists = false;
|
||||
}
|
||||
|
||||
if (entry.exists) return;
|
||||
|
||||
return clean([entry.path, entry.bundlePath])
|
||||
.then(function () {
|
||||
return write(entry.path, entry.content, { encoding: 'utf8' });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// unlinks files, swallows missing file errors
|
||||
clean(paths) {
|
||||
return resolve(
|
||||
_.flatten([paths]).map(function (path) {
|
||||
return rimraf(path);
|
||||
})
|
||||
)
|
||||
.settle()
|
||||
.then(_.noop);
|
||||
}
|
||||
|
||||
dirContents() {
|
||||
let dir = this.dir;
|
||||
|
||||
return readdir(dir).map(function (name) {
|
||||
// skip '.', '..', and dot-prefixed files
|
||||
if (name.charAt(0) === '.') return false;
|
||||
return join(dir, name);
|
||||
})
|
||||
.then(_.compact);
|
||||
}
|
||||
|
||||
getUnkownBundleFiles() {
|
||||
let entriesByPath = _.indexBy(this.entries, 'path');
|
||||
let entriesByBundlePath = _.indexBy(this.entries, 'bundlePath');
|
||||
|
||||
return this.dirContents()
|
||||
.map(function (path) {
|
||||
return entriesByPath[path] || entriesByBundlePath[path];
|
||||
})
|
||||
.then(_.compact)
|
||||
.then(this.clean);
|
||||
}
|
||||
|
||||
getEntriesToCompile() {
|
||||
return _.transform(this.entries, function (map, entry) {
|
||||
if (!entry.exists) map[entry.id] = entry.path;
|
||||
}, {});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = OptmzBundles;
|
96
src/server/optimize/OptmzUiModules.js
Normal file
96
src/server/optimize/OptmzUiModules.js
Normal file
|
@ -0,0 +1,96 @@
|
|||
var _ = require('lodash');
|
||||
var join = require('path').join;
|
||||
|
||||
var assets = require('../ui/assets');
|
||||
var asRegExp = _.flow(
|
||||
_.escapeRegExp,
|
||||
function (path) {
|
||||
return path + '(?:\\.js)?$';
|
||||
},
|
||||
RegExp
|
||||
);
|
||||
|
||||
function OptmzUiExports(plugins) {
|
||||
// regular expressions which will prevent webpack from parsing the file
|
||||
var noParse = this.noParse = [];
|
||||
|
||||
// webpack aliases, like require paths, mapping a prefix to a directory
|
||||
var aliases = this.aliases = {};
|
||||
|
||||
// webpack loaders map loader configuration to regexps
|
||||
var loaders = this.loaders = [
|
||||
{ test: /\.less$/, loader: 'style!css!less' },
|
||||
{ test: /\.css$/, loader: 'style!css' },
|
||||
{ test: /\.html$/, loader: 'raw' },
|
||||
{
|
||||
test: /\.(woff|woff2|png)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
||||
loader: 'url-loader?limit=10000&minetype=application/font-woff'
|
||||
},
|
||||
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file-loader' },
|
||||
];
|
||||
|
||||
var claimedModuleIds = {};
|
||||
_.each(plugins, function (plugin) {
|
||||
var exports = plugin.uiExportSpecs;
|
||||
|
||||
// add an alias for this plugins public directory
|
||||
if (plugin.publicDir) {
|
||||
aliases[`plugins/${plugin.id}`] = plugin.publicDir;
|
||||
}
|
||||
|
||||
// consume the plugin's "modules" exports
|
||||
_.forOwn(exports.modules, function (spec, id) {
|
||||
if (claimedModuleIds[id]) {
|
||||
throw new TypeError(`Plugin ${plugin.id} attempted to override export "${id}" from ${claimedModuleIds[id]}`);
|
||||
} else {
|
||||
claimedModuleIds[id] = plugin.id;
|
||||
}
|
||||
|
||||
// configurable via spec
|
||||
var path;
|
||||
var parse = true;
|
||||
var imports = null;
|
||||
var exports = null;
|
||||
|
||||
// basic style, just a path
|
||||
if (_.isString(spec)) path = spec;
|
||||
|
||||
if (_.isArray(spec)) {
|
||||
path = spec[0];
|
||||
imports = spec[1];
|
||||
exports = spec[2];
|
||||
}
|
||||
|
||||
if (_.isPlainObject(spec)) {
|
||||
path = spec.path;
|
||||
parse = _.get(spec, 'parse', parse);
|
||||
imports = _.get(spec, 'imports', imports);
|
||||
exports = _.get(spec, 'exports', exports);
|
||||
}
|
||||
|
||||
if (!path) {
|
||||
throw new TypeError('Invalid spec definition, unable to identify path');
|
||||
}
|
||||
|
||||
aliases[id] = path;
|
||||
|
||||
var loader = [];
|
||||
if (imports) {
|
||||
loader.push(`imports?${imports}`);
|
||||
}
|
||||
|
||||
if (exports) loader.push(`exports?${exports}`);
|
||||
if (loader.length) loaders.push({ test: asRegExp(path), loader: loader.join('!') });
|
||||
|
||||
if (!parse) noParse.push(asRegExp(path));
|
||||
});
|
||||
|
||||
// consume the plugin's "loaders" exports
|
||||
_.each(exports.loaders, function (loader) {
|
||||
loaders.push(loader);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = OptmzUiExports;
|
|
@ -1,112 +1,39 @@
|
|||
module.exports = function (kbnServer, server, config) {
|
||||
var _ = require('lodash');
|
||||
var extname = require('path').extname;
|
||||
var basename = require('path').basename;
|
||||
var dirname = require('path').dirname;
|
||||
var relative = require('path').relative;
|
||||
var resolve = require('path').resolve;
|
||||
var join = require('path').join;
|
||||
var webpack = require('webpack');
|
||||
var Promise = require('bluebird');
|
||||
|
||||
var apps = kbnServer.uiExports.apps;
|
||||
var uiDir = require('../ui/assetsDir');
|
||||
var glob = _.wrap(Promise.promisify(require('glob')), function (gb, dir) {
|
||||
return gb('**/*', {
|
||||
cwd: dir,
|
||||
silent: true,
|
||||
strict: true,
|
||||
nodir: true,
|
||||
follow: false
|
||||
});
|
||||
});
|
||||
|
||||
var Optimizer = require('./Optimizer');
|
||||
var bundleDir = resolve(config.get('optimize.bundleDir'));
|
||||
var status = kbnServer.status.create('optimize');
|
||||
status.yellow('Optimizing and caching browser bundles');
|
||||
|
||||
// don't return promise !!
|
||||
// use status api
|
||||
_(server.plugins)
|
||||
.pluck('plugin')
|
||||
.filter('publicDir')
|
||||
.map(function (plugin) {
|
||||
return glob(plugin.publicDir).then(function (matches) {
|
||||
return {
|
||||
id: plugin.id,
|
||||
dir: plugin.publicDir,
|
||||
files: matches
|
||||
};
|
||||
});
|
||||
server.exposeStaticDir('/bundles/{path*}', bundleDir);
|
||||
|
||||
return (new Optimizer({
|
||||
watch: config.get('optimize.watch'),
|
||||
sourceMaps: config.get('optimize.sourceMaps'),
|
||||
bundleDir: bundleDir,
|
||||
apps: [].concat(
|
||||
kbnServer.uiExports.apps,
|
||||
kbnServer.uiExports.apps.hidden
|
||||
),
|
||||
plugins: kbnServer.plugins
|
||||
}))
|
||||
.on('build-start', function () {
|
||||
status.yellow('Optimizing and caching application source files');
|
||||
})
|
||||
.concat([
|
||||
glob(uiDir).then(function (files) {
|
||||
return {
|
||||
id: 'ui',
|
||||
dir: uiDir,
|
||||
files: files
|
||||
};
|
||||
})
|
||||
])
|
||||
.thru(Promise.all)
|
||||
.value()
|
||||
.reduce(function (aliases, match) {
|
||||
match.files.forEach(function (file) {
|
||||
var path = join(match.dir, file);
|
||||
var ext = extname(file);
|
||||
var name = basename(file, ext === '.js' ? ext : '');
|
||||
var folders = dirname(file); // switch to / for moduleids/urls
|
||||
var base = match.id === 'ui' ? '' : 'plugins/' + match.id;
|
||||
|
||||
// filter out less files
|
||||
if (ext === '.less') return;
|
||||
|
||||
// prevent './module' style paths
|
||||
if (folders === '.') folders = '';
|
||||
|
||||
var alias = _.compact([base, folders, name]).join('/').replace(/\\/g, '/');
|
||||
aliases[alias + '$'] = path;
|
||||
});
|
||||
|
||||
return aliases;
|
||||
}, {})
|
||||
.then(function (aliases) {
|
||||
var compiler = webpack({
|
||||
entry: _.mapValues(apps, 'main'),
|
||||
|
||||
output: {
|
||||
path: join(__dirname, '..', 'bundles'),
|
||||
filename: '[name].bundle.js'
|
||||
},
|
||||
|
||||
plugins: [
|
||||
new webpack.NoErrorsPlugin(),
|
||||
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
BROWSER: JSON.stringify(true),
|
||||
NODE_ENV: JSON.stringify('development')
|
||||
}
|
||||
}),
|
||||
|
||||
new webpack.optimize.DedupePlugin(),
|
||||
new webpack.optimize.OccurenceOrderPlugin()
|
||||
],
|
||||
|
||||
resolve: {
|
||||
extensions: ['.js'],
|
||||
packageMains: [],
|
||||
modulesDirectories: [],
|
||||
root: [],
|
||||
aliases: aliases
|
||||
}
|
||||
});
|
||||
|
||||
return Promise.fromNode(compiler.run.bind(compiler));
|
||||
.on('watch-run', _.before(2, function () {
|
||||
status.yellow('Optimizing and watching application source files');
|
||||
}))
|
||||
.on('watch-run', _.after(2, function () {
|
||||
status.yellow('Source file change detected, reoptimizing source files');
|
||||
}))
|
||||
.on('done', function () {
|
||||
status.green('Optimization complete');
|
||||
})
|
||||
.then(
|
||||
function () { status.green('Optimization complete'); },
|
||||
function (err) {
|
||||
status.red('Optimization failure! ' + err.message);
|
||||
server.log(['fatal'], err);
|
||||
}
|
||||
);
|
||||
.on('error', function (err) {
|
||||
server.log(['fatal'], err);
|
||||
status.red('Optimization failure! ' + err.message);
|
||||
})
|
||||
.init();
|
||||
};
|
||||
|
|
|
@ -4,27 +4,24 @@ var Joi = require('joi');
|
|||
var Promise = require('bluebird');
|
||||
var join = require('path').join;
|
||||
|
||||
function Plugin(kibana, path, package, opts) {
|
||||
this._kibana = kibana;
|
||||
function Plugin(kbnServer, path, package, opts) {
|
||||
this.kbnServer = kbnServer;
|
||||
this.package = package;
|
||||
this.path = path;
|
||||
|
||||
this.id = opts.id || package.name;
|
||||
this.uiExportSpecs = opts.uiExports || {};
|
||||
this.requiredIds = opts.require || [];
|
||||
this.version = opts.version || package.version;
|
||||
this.publicDir = _.get(opts, 'publicDir', join(path, 'public'));
|
||||
this.externalInit = opts.init || _.noop;
|
||||
this.getConfig = opts.config || _.noop;
|
||||
|
||||
kibana.uiExports.add(this, opts.exports);
|
||||
|
||||
var readyCb;
|
||||
var readyPromise = Promise.fromNode(function (cb) { readyCb = cb; });
|
||||
this.ready = _.constant(readyPromise);
|
||||
this.init = _.once(this.init);
|
||||
}
|
||||
|
||||
Plugin.scoped = function (kibana, path, package) {
|
||||
Plugin.scoped = function (kbnServer, path, package) {
|
||||
function ScopedPlugin(opts) {
|
||||
ScopedPlugin.super_.call(this, kibana, path, package, opts || {});
|
||||
ScopedPlugin.super_.call(this, kbnServer, path, package, opts || {});
|
||||
}
|
||||
inherits(ScopedPlugin, Plugin);
|
||||
return ScopedPlugin;
|
||||
|
@ -32,12 +29,17 @@ Plugin.scoped = function (kibana, path, package) {
|
|||
|
||||
Plugin.prototype.init = function () {
|
||||
var self = this;
|
||||
|
||||
var id = self.id;
|
||||
var version = self.version;
|
||||
var server = this._kibana.server;
|
||||
var status = this._kibana.status;
|
||||
var server = self.kbnServer.server;
|
||||
var status = self.kbnServer.status;
|
||||
|
||||
var config = server.config();
|
||||
server.log(['plugin', 'init', 'debug'], {
|
||||
message: 'initializing plugin <%= plugin.id %>',
|
||||
plugin: self
|
||||
});
|
||||
|
||||
return Promise.try(function () {
|
||||
return self.getConfig(Joi);
|
||||
|
@ -48,10 +50,13 @@ Plugin.prototype.init = function () {
|
|||
.then(function () {
|
||||
return status.decoratePlugin(self);
|
||||
})
|
||||
.then(function () {
|
||||
return self.kbnServer.uiExports.consumePlugin(self);
|
||||
})
|
||||
.then(function () {
|
||||
|
||||
var register = function (server, options, next) {
|
||||
server.expose('plugin', self);
|
||||
|
||||
Promise.try(self.externalInit, [server, options], self).nodeify(next);
|
||||
};
|
||||
|
||||
|
@ -68,10 +73,14 @@ Plugin.prototype.init = function () {
|
|||
.then(function () {
|
||||
// Only change the plugin status to green if the
|
||||
// intial status has not been updated
|
||||
if (self.status.state === undefined) {
|
||||
if (self.status.state === 'uninitialized') {
|
||||
self.status.green('Ready');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Plugin.prototype.toString = function () {
|
||||
return `${this.id}@${this.version}`;
|
||||
};
|
||||
|
||||
module.exports = Plugin;
|
||||
|
|
|
@ -5,6 +5,7 @@ var join = require('path').join;
|
|||
function PluginApi(kibana, pluginPath) {
|
||||
this.rootDir = kibana.rootDir;
|
||||
this.package = require(join(pluginPath, 'package.json'));
|
||||
this.autoload = require('../ui/autoload');
|
||||
this.Plugin = Plugin.scoped(kibana, pluginPath, this.package);
|
||||
}
|
||||
|
||||
|
|
33
src/server/plugins/Plugins.js
Normal file
33
src/server/plugins/Plugins.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
let _ = require('lodash');
|
||||
let inspect = require('util').inspect;
|
||||
let PluginApi = require('./PluginApi');
|
||||
|
||||
module.exports = class Plugins extends Array {
|
||||
|
||||
constructor(kbnServer) {
|
||||
super();
|
||||
this.kbnServer = kbnServer;
|
||||
}
|
||||
|
||||
load(path) {
|
||||
var self = this;
|
||||
var api = new PluginApi(this.kbnServer, path);
|
||||
|
||||
[].concat(require(path)(api) || [])
|
||||
.forEach(function (out) {
|
||||
if (out instanceof api.Plugin) {
|
||||
self._byId = null;
|
||||
self.push(out);
|
||||
} else {
|
||||
throw new TypeError('unexpected plugin export ' + inspect(out));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
get byId() {
|
||||
return this._byId || (this._byId = _.indexBy(this, 'id'));
|
||||
}
|
||||
|
||||
};
|
|
@ -4,28 +4,14 @@ module.exports = function (kbnServer, server, config) {
|
|||
var Boom = require('boom');
|
||||
var join = require('path').join;
|
||||
|
||||
var scan = require('./scan');
|
||||
var load = require('./load');
|
||||
|
||||
var scanDirs = [].concat(config.get('plugins.scanDirs'));
|
||||
var absolutePaths = [].concat(config.get('plugins.paths'));
|
||||
|
||||
return Promise.try(scan, [server, scanDirs])
|
||||
.then(function (foundPaths) {
|
||||
return load(kbnServer, _.union(foundPaths, absolutePaths));
|
||||
})
|
||||
.then(function () {
|
||||
|
||||
if (config.get('plugins.optimize')) {
|
||||
kbnServer.mixin(require('./optimize'));
|
||||
server.exposeStaticDir('/plugins/{path*}', join(__dirname, 'bundles'));
|
||||
} else {
|
||||
server.exposeStaticDir('/plugins/{id}/{path*}', function (req) {
|
||||
var id = req.params.id;
|
||||
var plugin = _.get(server.plugins, [id, 'plugin']);
|
||||
return (plugin && plugin.publicDir) ? plugin.publicDir : Boom.notFound();
|
||||
});
|
||||
}
|
||||
|
||||
server.exposeStaticDir('/plugins/{id}/{path*}', function (req) {
|
||||
var id = req.params.id;
|
||||
var plugin = kbnServer.plugins.byId[id];
|
||||
return (plugin && plugin.publicDir) ? plugin.publicDir : Boom.notFound();
|
||||
});
|
||||
|
||||
return kbnServer.mixin(
|
||||
require('./scan'),
|
||||
require('./load')
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,8 +1,35 @@
|
|||
var Promise = require('bluebird');
|
||||
var PluginApi = require('./PluginApi');
|
||||
module.exports = function (kbnServer, server, config) {
|
||||
var _ = require('lodash');
|
||||
var resolve = require('bluebird').resolve;
|
||||
var inspect = require('util').inspect;
|
||||
|
||||
module.exports = function (kbnServer, pluginPaths) {
|
||||
return Promise.map(pluginPaths, function (pluginPath) {
|
||||
return require(pluginPath)(new PluginApi(kbnServer, pluginPath)).init();
|
||||
var Plugins = require('./Plugins');
|
||||
var plugins = kbnServer.plugins = new Plugins(kbnServer);
|
||||
var path = [];
|
||||
|
||||
return resolve(kbnServer.pluginPaths)
|
||||
.map(function (path) {
|
||||
return plugins.load(path);
|
||||
})
|
||||
.then(function () {
|
||||
var others = _.indexBy(plugins, 'id');
|
||||
|
||||
return Promise.all(plugins.map(function recurse(plugin) {
|
||||
if (_.includes(path, plugin.id)) {
|
||||
throw new Error(`circular dependencies found: "${path.concat(plugin.id).join(' -> ')}"`);
|
||||
}
|
||||
|
||||
path.push(plugin.id);
|
||||
|
||||
var preInits = _.map(plugin.requiredIds, function (id) {
|
||||
if (!others[id]) throw new Error(`Unmet requirement "${id}" for plugin "${plugin.id}"`);
|
||||
return recurse(others[id]);
|
||||
});
|
||||
var promise = Promise.all(preInits).then(_.bindKey(plugin, 'init'));
|
||||
|
||||
path.pop();
|
||||
|
||||
return promise;
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
var _ = require('lodash');
|
||||
var Promise = require('bluebird');
|
||||
var readdir = Promise.promisify(require('fs').readdir);
|
||||
var stat = Promise.promisify(require('fs').stat);
|
||||
var join = require('path').join;
|
||||
module.exports = function (kbnServer, server, config) {
|
||||
var _ = require('lodash');
|
||||
var Promise = require('bluebird');
|
||||
var readdir = Promise.promisify(require('fs').readdir);
|
||||
var stat = Promise.promisify(require('fs').stat);
|
||||
var join = require('path').join;
|
||||
|
||||
module.exports = function (server, includeDirs) {
|
||||
return Promise.map(includeDirs, function (dir) {
|
||||
var scanDirs = [].concat(config.get('plugins.scanDirs'));
|
||||
var absolutePaths = [].concat(config.get('plugins.paths'));
|
||||
|
||||
return Promise.map(scanDirs, function (dir) {
|
||||
server.log('plugin-scan', 'Scanning ' + dir + ' for plugins');
|
||||
|
||||
return readdir(dir).map(function (file) {
|
||||
|
@ -18,8 +21,13 @@ module.exports = function (server, includeDirs) {
|
|||
});
|
||||
});
|
||||
})
|
||||
.then(_.flatten)
|
||||
.then(_.compact)
|
||||
.then(function (dirs) {
|
||||
return _(dirs)
|
||||
.flatten()
|
||||
.compact()
|
||||
.union(absolutePaths)
|
||||
.value();
|
||||
})
|
||||
.filter(function (dir) {
|
||||
try {
|
||||
require(dir);
|
||||
|
@ -29,5 +37,8 @@ module.exports = function (server, includeDirs) {
|
|||
server.log('plugin-scan', 'Skipping non-plugin directory at ' + dir);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.then(function (pluginPaths) {
|
||||
kbnServer.pluginPaths = pluginPaths;
|
||||
});
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ function Status(name, server) {
|
|||
Status.super_.call(this);
|
||||
|
||||
this.name = name;
|
||||
this.state = undefined;
|
||||
this.state = 'uninitialized';
|
||||
this.message = 'uninitialized';
|
||||
|
||||
this.on('change', function (current, previous) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue