mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[registry] use registrys to access objects
This commit is contained in:
parent
8634c7228e
commit
cda9517c6b
26 changed files with 71 additions and 48 deletions
|
@ -8,6 +8,7 @@ module.exports = function (grunt) {
|
|||
src: __dirname + '/src', // unbuild version of build
|
||||
build: __dirname + '/build', // copy of source, but optimized
|
||||
app: __dirname + '/src/kibana', // source directory for the app
|
||||
plugins: __dirname + '/src/plugins', // source directory for the app
|
||||
server: __dirname + '/src/server', // source directory for the server
|
||||
target: __dirname + '/target', // location of the compressed build targets
|
||||
buildApp: __dirname + '/build/kibana', // build directory for the app
|
||||
|
|
|
@ -23,7 +23,7 @@ $scope.onChangeFormat = function (field, format) {
|
|||
```
|
||||
|
||||
### Passing the formats to a chart
|
||||
Currently, the [histogram formatter](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/visualize/saved_visualizations/resp_converters/histogram.js) passes the formatting function as the `xAxisFormatter` and `yAxisFormatter` function.
|
||||
Currently, the [histogram formatter](https://github.com/elasticsearch/kibana4/blob/master/src/plugins/visualize/saved_visualizations/resp_converters/histogram.js) passes the formatting function as the `xAxisFormatter` and `yAxisFormatter` function.
|
||||
|
||||
*/
|
||||
/* jshint ignore:end */
|
||||
|
|
|
@ -75,7 +75,7 @@ define(function (require) {
|
|||
});
|
||||
};
|
||||
})
|
||||
.controller('kibana', function ($rootScope, $location, $scope, Notifier, $injector, $q, $http, config, kbnSetup) {
|
||||
.controller('kibana', function ($rootScope, $location, $scope, Notifier, $injector, $q, $http, config, kbnSetup, Private) {
|
||||
var notify = new Notifier();
|
||||
|
||||
$scope.appEmbedded = $location.search().embed;
|
||||
|
@ -108,7 +108,7 @@ define(function (require) {
|
|||
}
|
||||
};
|
||||
|
||||
$scope.apps = configFile.apps;
|
||||
$scope.apps = Private(require('registry/apps'));
|
||||
// initialize each apps lastPath (fetch it from storage)
|
||||
$scope.apps.forEach(function (app) { lastPathFor(app); });
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<!-- Full navbar -->
|
||||
<div collapse="!showCollapsed" class="navbar-collapse" id="kibana-primary-navbar">
|
||||
<ul class="nav navbar-nav">
|
||||
<li ng-repeat="app in apps" ng-class="{active: activeApp == app.id}">
|
||||
<li ng-repeat="app in apps.inOrderOrder" ng-class="{active: activeApp == app.id}">
|
||||
<a ng-href="#{{app.lastPath}}" bo-text="app.name"></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
var IndexedArray = require('utils/indexed_array/index');
|
||||
|
||||
function Registry() {
|
||||
this._modules = [];
|
||||
}
|
||||
return function createRegistry(name, indexedArrayOpts) {
|
||||
var modules = [];
|
||||
indexedArrayOpts = indexedArrayOpts || { index: ['name'] };
|
||||
|
||||
Registry.prototype.register = function (privateModule) {
|
||||
this._modules.push(privateModule);
|
||||
var registry = function (Private) {
|
||||
var opts = _.cloneDeep(indexedArrayOpts);
|
||||
opts.initialSet = modules.map(Private);
|
||||
return new IndexedArray(opts);
|
||||
};
|
||||
|
||||
registry.name = name + 'Registry';
|
||||
registry.register = function (privateModule) {
|
||||
modules.push(privateModule);
|
||||
};
|
||||
|
||||
return registry;
|
||||
};
|
||||
|
||||
Registry.prototype.load = function (Private) {
|
||||
return this._modules.map(Private);
|
||||
};
|
||||
|
||||
return Registry;
|
||||
});
|
|
@ -1,4 +1,6 @@
|
|||
define(function (require) {
|
||||
var Registry = require('registry/_registry');
|
||||
return new Registry();
|
||||
return require('registry/_registry')('apps', {
|
||||
index: ['name'],
|
||||
order: ['order']
|
||||
});
|
||||
});
|
|
@ -1,4 +1,3 @@
|
|||
define(function (require) {
|
||||
var Registry = require('registry/_registry');
|
||||
return new Registry();
|
||||
return require('registry/_registry')('visTypes');
|
||||
});
|
|
@ -164,8 +164,9 @@ define(function (require) {
|
|||
var apps = require('registry/apps');
|
||||
apps.register(function DashboardAppModule() {
|
||||
return {
|
||||
id: 'dashboard',
|
||||
name: 'Dashboard',
|
||||
route: '/dashboard'
|
||||
order: 2
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,8 +9,9 @@ define(function (require, module, exports) {
|
|||
var apps = require('registry/apps');
|
||||
apps.register(function DiscoverAppModule() {
|
||||
return {
|
||||
id: 'discover',
|
||||
name: 'Discover',
|
||||
route: '/discover'
|
||||
order: 0
|
||||
};
|
||||
});
|
||||
});
|
|
@ -4,6 +4,11 @@ define(function (require, module, exports) {
|
|||
require('css!plugins/settings/styles/main.css');
|
||||
require('filters/start_from');
|
||||
|
||||
require('routes')
|
||||
.when('/settings', {
|
||||
redirectTo: '/settings/indices'
|
||||
});
|
||||
|
||||
require('modules').get('apps/settings')
|
||||
.directive('kbnSettingsApp', function (Private, $route, timefilter) {
|
||||
return {
|
||||
|
@ -28,8 +33,9 @@ define(function (require, module, exports) {
|
|||
var apps = require('registry/apps');
|
||||
apps.register(function SettingsAppModule() {
|
||||
return {
|
||||
id: 'settings',
|
||||
name: 'Settings',
|
||||
route: '/settings/indices'
|
||||
order: 3
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="kbn-settings-about container" ng-controller="settingsAbout">
|
||||
<div class="col-md-4 col-md-offset-4 jumbotron">
|
||||
<center>
|
||||
<img src='apps/settings/sections/about/elk.png'><br>
|
||||
<img src='plugins/settings/sections/about/elk.png'><br>
|
||||
<h1>Kibana</h1>
|
||||
<p>
|
||||
<table class="table table-condensed kbn-settings-about-versions">
|
||||
|
|
|
@ -18,7 +18,7 @@ define(function (require) {
|
|||
default: true
|
||||
}
|
||||
];
|
||||
schema.editor = require('text!components/vis_types/controls/rows_or_columns.html');
|
||||
schema.editor = require('text!plugins/vis_types/controls/rows_or_columns.html');
|
||||
}
|
||||
|
||||
_.defaults(schema, {
|
|
@ -2,8 +2,8 @@ define(function (require) {
|
|||
return function VisTypeFactory(Private) {
|
||||
var _ = require('lodash');
|
||||
|
||||
var VisTypeSchemas = Private(require('components/vis_types/_schemas'));
|
||||
var HistogramConverter = Private(require('components/vis_types/converters/histogram'));
|
||||
var VisTypeSchemas = Private(require('plugins/vis_types/_schemas'));
|
||||
var HistogramConverter = Private(require('plugins/vis_types/converters/histogram'));
|
||||
|
||||
function VisType(opts) {
|
||||
opts = opts || {};
|
|
@ -6,7 +6,7 @@ define(function (require) {
|
|||
var interval = require('utils/interval');
|
||||
|
||||
var $tooltipScope = $rootScope.$new();
|
||||
var $tooltip = $(require('text!components/vis_types/tooltips/histogram.html'));
|
||||
var $tooltip = $(require('text!plugins/vis_types/tooltips/histogram.html'));
|
||||
$compile($tooltip)($tooltipScope);
|
||||
|
||||
return function (chart, columns, rows) {
|
|
@ -5,7 +5,7 @@ define(function (require) {
|
|||
var moment = require('moment');
|
||||
var interval = require('utils/interval');
|
||||
|
||||
var $tooltip = $(require('text!components/vis_types/tooltips/pie.html'));
|
||||
var $tooltip = $(require('text!plugins/vis_types/tooltips/pie.html'));
|
||||
var $tooltipScope = $rootScope.$new();
|
||||
$compile($tooltip)($tooltipScope);
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
define(function (require) {
|
||||
return function HistogramVisType(Private) {
|
||||
var VisType = Private(require('components/vis_types/_vis_type'));
|
||||
var Schemas = Private(require('components/vis_types/_schemas'));
|
||||
var VisType = Private(require('plugins/vis_types/_vis_type'));
|
||||
var Schemas = Private(require('plugins/vis_types/_schemas'));
|
||||
|
||||
return new VisType({
|
||||
name: 'histogram',
|
|
@ -1,7 +1,7 @@
|
|||
define(function (require) {
|
||||
return function HistogramVisType(Private) {
|
||||
var VisType = Private(require('components/vis_types/_vis_type'));
|
||||
var Schemas = Private(require('components/vis_types/_schemas'));
|
||||
var VisType = Private(require('plugins/vis_types/_vis_type'));
|
||||
var Schemas = Private(require('plugins/vis_types/_schemas'));
|
||||
|
||||
return new VisType({
|
||||
name: 'line',
|
|
@ -1,8 +1,8 @@
|
|||
define(function (require) {
|
||||
return function HistogramVisType(Private) {
|
||||
var VisType = Private(require('components/vis_types/_vis_type'));
|
||||
var Schemas = Private(require('components/vis_types/_schemas'));
|
||||
var PieConverter = Private(require('components/vis_types/converters/pie'));
|
||||
var VisType = Private(require('plugins/vis_types/_vis_type'));
|
||||
var Schemas = Private(require('plugins/vis_types/_schemas'));
|
||||
var PieConverter = Private(require('plugins/vis_types/converters/pie'));
|
||||
|
||||
return new VisType({
|
||||
name: 'pie',
|
|
@ -4,11 +4,17 @@ define(function (require) {
|
|||
require('plugins/visualize/editor/editor');
|
||||
require('plugins/visualize/wizard/wizard');
|
||||
|
||||
require('routes')
|
||||
.when('/visualize', {
|
||||
redirectTo: '/visualize/step/1'
|
||||
});
|
||||
|
||||
var apps = require('registry/apps');
|
||||
apps.register(function VisualizeAppModule() {
|
||||
return {
|
||||
id: 'visualize',
|
||||
name: 'Visualize',
|
||||
route: '/visualize/step/1'
|
||||
order: 1
|
||||
};
|
||||
});
|
||||
});
|
|
@ -4,15 +4,15 @@ module.exports = {
|
|||
src: {
|
||||
src: [
|
||||
'<%= src %>/kibana/components/*/*.less',
|
||||
'<%= src %>/kibana/plugins/dashboard/styles/main.less',
|
||||
'<%= src %>/kibana/apps/discover/styles/main.less',
|
||||
'<%= src %>/kibana/apps/settings/styles/main.less',
|
||||
'<%= src %>/kibana/apps/visualize/styles/main.less',
|
||||
'<%= src %>/kibana/apps/visualize/styles/visualization.less',
|
||||
'<%= src %>/kibana/apps/visualize/styles/main.less',
|
||||
'<%= src %>/kibana/styles/main.less',
|
||||
'<%= src %>/kibana/components/vislib/styles/main.less',
|
||||
'<%= src %>/kibana/components/**/*.less'
|
||||
'<%= src %>/kibana/components/**/*.less',
|
||||
'<%= plugins %>/dashboard/styles/main.less',
|
||||
'<%= plugins %>/discover/styles/main.less',
|
||||
'<%= plugins %>/settings/styles/main.less',
|
||||
'<%= plugins %>/visualize/styles/main.less',
|
||||
'<%= plugins %>/visualize/styles/visualization.less',
|
||||
'<%= plugins %>/visualize/styles/main.less'
|
||||
],
|
||||
expand: true,
|
||||
ext: '.css',
|
||||
|
|
|
@ -61,11 +61,11 @@ module.exports = function (grunt) {
|
|||
|
||||
// include each app
|
||||
var main = config.build.options.modules[0];
|
||||
// TODO: load files as plugins
|
||||
// var configFile = grunt.file.readYAML(grunt.config.get('configFile'));
|
||||
// configFile.apps.forEach(function (app) {
|
||||
// main.include.push('apps/' + app.id + '/index');
|
||||
// });
|
||||
var dirname = require('path').dirname;
|
||||
grunt.file.expand({ cwd: '<%= plugins %>' }, '*/index.js').forEach(function (fileName) {
|
||||
var pluginName = dirname(fileName);
|
||||
main.include.push('plugins/' + pluginName + '/index');
|
||||
});
|
||||
|
||||
return config;
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ define(function (require) {
|
|||
AggConfigs = Private(require('components/vis/_agg_configs'));
|
||||
IndexedArray = require('utils/indexed_array/index');
|
||||
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
|
||||
Schemas = Private(require('components/vis_types/_schemas'));
|
||||
Schemas = Private(require('plugins/vis_types/_schemas'));
|
||||
}));
|
||||
|
||||
it('extends IndexedArray', function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue