[kibana] create some defaultInjectedVars
This commit is contained in:
parent
b2ae7987c7
commit
6eff5c5380
2 changed files with 10 additions and 6 deletions
|
@ -38,10 +38,7 @@ module.exports = function (kibana) {
|
||||||
let config = server.config();
|
let config = server.config();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
kbnIndex: config.get('kibana.index'),
|
kbnDefaultAppId: config.get('kibana.defaultAppId')
|
||||||
kbnDefaultAppId: config.get('kibana.defaultAppId'),
|
|
||||||
esShardTimeout: config.get('elasticsearch.shardTimeout'),
|
|
||||||
esApiVersion: config.get('elasticsearch.apiVersion'),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = async (kbnServer, server, config) => {
|
module.exports = async (kbnServer, server, config) => {
|
||||||
let _ = require('lodash');
|
let { defaults } = require('lodash');
|
||||||
let Boom = require('boom');
|
let Boom = require('boom');
|
||||||
let formatUrl = require('url').format;
|
let formatUrl = require('url').format;
|
||||||
let { resolve } = require('path');
|
let { resolve } = require('path');
|
||||||
|
@ -56,6 +56,13 @@ module.exports = async (kbnServer, server, config) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const defaultInjectedVars = {};
|
||||||
|
if (config.has('kibana')) defaultInjectedVars.kbnIndex = config.get('kibana.index');
|
||||||
|
if (config.has('elasticsearch')) {
|
||||||
|
defaultInjectedVars.esShardTimeout = config.get('elasticsearch.shardTimeout');
|
||||||
|
defaultInjectedVars.esApiVersion = config.get('elasticsearch.apiVersion');
|
||||||
|
}
|
||||||
|
|
||||||
server.decorate('reply', 'renderApp', function (app) {
|
server.decorate('reply', 'renderApp', function (app) {
|
||||||
let payload = {
|
let payload = {
|
||||||
app: app,
|
app: app,
|
||||||
|
@ -63,7 +70,7 @@ module.exports = async (kbnServer, server, config) => {
|
||||||
version: kbnServer.version,
|
version: kbnServer.version,
|
||||||
buildNum: config.get('pkg.buildNum'),
|
buildNum: config.get('pkg.buildNum'),
|
||||||
buildSha: config.get('pkg.buildSha'),
|
buildSha: config.get('pkg.buildSha'),
|
||||||
vars: app.getInjectedVars()
|
vars: defaults(app.getInjectedVars(), defaultInjectedVars),
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.view(app.templateName, {
|
return this.view(app.templateName, {
|
||||||
|
|
Loading…
Reference in a new issue