mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Added a basic framework for kibana
This commit is contained in:
parent
4d49c6303a
commit
6ee366f45d
24 changed files with 142 additions and 78 deletions
|
@ -27,6 +27,18 @@ define(function () {
|
|||
* The default ES index to use for storing Kibana specific object
|
||||
* such as stored dashboards
|
||||
*/
|
||||
kibanaIndex: 'kibana4-int'
|
||||
kibanaIndex: 'kibana4-int',
|
||||
|
||||
/**
|
||||
* A list of apps that can be loaded by Kibana. The id's need to match the
|
||||
* directory name in which the app lives, ie. src/kibana/apps/{{id}}
|
||||
* @type {Array}
|
||||
*/
|
||||
apps: [
|
||||
{ id: 'discover', name: 'Discover' },
|
||||
{ id: 'visualize', name: 'Visualize' },
|
||||
{ id: 'dashboard', name: 'Dashboard' },
|
||||
{ id: 'examples', name: 'Examples' }
|
||||
]
|
||||
};
|
||||
});
|
|
@ -22,6 +22,11 @@ define(function (require) {
|
|||
// Save a reference to this
|
||||
var self = this;
|
||||
|
||||
config = _.defaults(config || {}, {
|
||||
cacheIndex: 'kibana4-int',
|
||||
cacheType: 'mappings'
|
||||
});
|
||||
|
||||
// Store mappings we've already loaded from Elasticsearch
|
||||
var mappings = {};
|
||||
|
||||
|
|
|
@ -10,9 +10,17 @@
|
|||
<script src="bower_components/requirejs/require.js"></script>
|
||||
<script src="kibana/require.config.js"></script>
|
||||
<script>require(['main'], function () {});</script>
|
||||
<link rel="stylesheet" href="kibana/styles/main.css" >
|
||||
</head>
|
||||
<body>
|
||||
<div ng-controller="kibana">
|
||||
<nav class="navbar navbar-default">
|
||||
<ul class="nav navbar-nav">
|
||||
<li ng-repeat="app in apps" ng-class="{active: activeApp == app.id}">
|
||||
<a href="#/{{app.id}}">{{app.name}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div ng-view></div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
0
src/kibana/apps/dashboard/index.css
Normal file
0
src/kibana/apps/dashboard/index.css
Normal file
0
src/kibana/apps/discover/index.css
Normal file
0
src/kibana/apps/discover/index.css
Normal file
1
src/kibana/apps/discover/index.html
Normal file
1
src/kibana/apps/discover/index.html
Normal file
|
@ -0,0 +1 @@
|
|||
<h1>Discover</h1>
|
8
src/kibana/apps/examples/index.html
Normal file
8
src/kibana/apps/examples/index.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
<div ng-controller="examples">
|
||||
<ul class="nav nav-tabs">
|
||||
<li ng-repeat="example in examples" ng-class="{ active: active === example }">
|
||||
<a ng-click="makeActive(example)">{{example}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div ng-include="activeUrl" onload="exampleLoaded()" ></div>
|
||||
</div>
|
|
@ -1,6 +1,27 @@
|
|||
define(function (require) {
|
||||
var angular = require('angular');
|
||||
|
||||
angular
|
||||
.module('kibana/controllers')
|
||||
.controller('examples', function ($scope, $location, courier) {
|
||||
$scope.examples = [
|
||||
'config',
|
||||
'mapper',
|
||||
'courier'
|
||||
];
|
||||
|
||||
$scope.makeActive = function (example) {
|
||||
$scope.active = example;
|
||||
$scope.activeUrl = 'kibana/apps/examples/partials/' + example + '.html';
|
||||
};
|
||||
|
||||
$scope.exampleLoaded = function () {
|
||||
if ($scope.active !== 'config') {
|
||||
courier.fetch();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
angular
|
||||
.module('kibana/directives')
|
||||
.directive('configTest', function () {
|
|
@ -1 +0,0 @@
|
|||
<h1>Explore</h1>
|
0
src/kibana/apps/visualize/index.css
Normal file
0
src/kibana/apps/visualize/index.css
Normal file
|
@ -8,11 +8,14 @@ define(function (require) {
|
|||
|
||||
angular
|
||||
.module('kibana/controllers')
|
||||
.controller('kibana', function ($scope, courier) {
|
||||
.controller('kibana', function ($scope, courier, configFile) {
|
||||
setTimeout(function () {
|
||||
courier.start();
|
||||
}, 15);
|
||||
|
||||
$scope.apps = configFile.apps;
|
||||
$scope.activeApp = '';
|
||||
|
||||
$scope.$on('$routeChangeSuccess', function () {
|
||||
if (courier.running()) courier.fetch();
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ define(function (require) {
|
|||
var scopedRequire = require('require');
|
||||
var enableAsyncModules = require('utils/async_modules');
|
||||
var setup = require('./setup');
|
||||
var configFile = require('../config');
|
||||
|
||||
require('elasticsearch');
|
||||
require('angular-route');
|
||||
|
@ -39,24 +40,50 @@ define(function (require) {
|
|||
});
|
||||
|
||||
app.requires = dependencies;
|
||||
|
||||
app.value('configFile', configFile);
|
||||
app.config(function ($routeProvider) {
|
||||
$routeProvider
|
||||
.when('/', {
|
||||
templateUrl: 'kibana/partials/index.html'
|
||||
})
|
||||
.when('/config-test', {
|
||||
templateUrl: 'courier/tests/config.html',
|
||||
})
|
||||
.when('/mapper-test', {
|
||||
templateUrl: 'courier/tests/mapper.html',
|
||||
})
|
||||
.when('/courier-test', {
|
||||
templateUrl: 'courier/tests/index.html',
|
||||
})
|
||||
.otherwise({
|
||||
redirectTo: '/'
|
||||
redirectTo: '/discover'
|
||||
});
|
||||
|
||||
configFile.apps.forEach(function (app) {
|
||||
var deps = {};
|
||||
deps['app/' + app.id] = function () {
|
||||
return loadApp(app);
|
||||
};
|
||||
|
||||
$routeProvider.when('/' + app.id, {
|
||||
templateUrl: '/kibana/apps/' + app.id + '/index.html',
|
||||
resolve: deps
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var loadApp; // so dumb
|
||||
|
||||
app.run(function ($q) {
|
||||
loadApp = function (app) {
|
||||
var defer = $q.defer();
|
||||
|
||||
require([
|
||||
'apps/' + app.id + '/index'
|
||||
], function () {
|
||||
defer.resolve();
|
||||
delete require.onError;
|
||||
});
|
||||
|
||||
require.onError = function () {
|
||||
defer.reject();
|
||||
};
|
||||
|
||||
// optional dependencies
|
||||
require([
|
||||
'css!apps/' + app.id + '/index.css'
|
||||
]);
|
||||
|
||||
return defer.promise;
|
||||
};
|
||||
});
|
||||
|
||||
setup(app, function (err) {
|
||||
|
@ -64,7 +91,6 @@ define(function (require) {
|
|||
|
||||
// load the elasticsearch service
|
||||
require([
|
||||
'courier/tests/directives',
|
||||
'controllers/kibana',
|
||||
'constants/base'
|
||||
], function () {
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<ul>
|
||||
<li><a ng-href="#/courier-test">Courier Test</a></li>
|
||||
<li><a ng-href="#/config-test">Config Test</a></li>
|
||||
<li><a ng-href="#/mapper-test">Mapper Test</a></li>
|
||||
</ul>
|
|
@ -1,44 +1,27 @@
|
|||
(function () {
|
||||
var config = {
|
||||
baseUrl: 'kibana',
|
||||
paths: {
|
||||
courier: '../courier'
|
||||
require.config({
|
||||
baseUrl: 'kibana',
|
||||
paths: {
|
||||
courier: '../courier',
|
||||
angular: '../bower_components/angular/angular',
|
||||
'angular-route': '../bower_components/angular-route/angular-route',
|
||||
async: '../bower_components/async/lib/async',
|
||||
css: '../bower_components/require-css/css',
|
||||
d3: '../bower_components/d3/d3',
|
||||
elasticsearch: '../bower_components/elasticsearch/elasticsearch.angular',
|
||||
jquery: '../bower_components/jquery/jquery',
|
||||
lodash: '../bower_components/lodash/dist/lodash'
|
||||
},
|
||||
shim: {
|
||||
angular: {
|
||||
deps: ['jquery'],
|
||||
exports: 'angular'
|
||||
},
|
||||
shim: {
|
||||
angular: {
|
||||
deps: ['jquery'],
|
||||
exports: 'angular'
|
||||
}
|
||||
'angular-route': {
|
||||
deps: ['angular']
|
||||
},
|
||||
waitSeconds: 60
|
||||
};
|
||||
|
||||
var bowerComponents = [
|
||||
'angular',
|
||||
'angular-route',
|
||||
['async', 'lib/async'],
|
||||
'd3',
|
||||
['elasticsearch', 'elasticsearch.angular'],
|
||||
'jquery',
|
||||
['lodash', 'dist/lodash']
|
||||
];
|
||||
|
||||
bowerComponents.forEach(function (name) {
|
||||
var path = '../bower_components/';
|
||||
if (typeof name === 'object') {
|
||||
path += name[0] + '/' + name[1];
|
||||
name = name[0];
|
||||
} else {
|
||||
path += name + '/' + name;
|
||||
'elasticsearch': {
|
||||
deps: ['angular']
|
||||
}
|
||||
config.paths[name] = path;
|
||||
|
||||
if (path.match(/angular/) && name !== 'angular') {
|
||||
config.shim[name] = {
|
||||
deps: ['angular']
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
require.config(config);
|
||||
}());
|
||||
},
|
||||
waitSeconds: 60
|
||||
});
|
|
@ -27,23 +27,26 @@ define(function (require) {
|
|||
'kibana/services',
|
||||
'kibana/constants'
|
||||
]);
|
||||
|
||||
var appEl = document.createElement('div');
|
||||
var kibanaIndexExists;
|
||||
|
||||
setup.run(function (es, config) {
|
||||
// init the setup module
|
||||
async.series([
|
||||
async.apply(checkForKibanaIndex, es),
|
||||
async.apply(createKibanaIndex, es),
|
||||
async.apply(checkForCurrentConfigDoc, es),
|
||||
async.apply(initConfig, config)
|
||||
], function (err) {
|
||||
// ready to go, remove the appEl, close services and boot be done
|
||||
appEl.remove();
|
||||
console.log('booting application');
|
||||
return done(err);
|
||||
setup
|
||||
.value('configFile', configFile)
|
||||
.run(function (es, config) {
|
||||
// init the setup module
|
||||
async.series([
|
||||
async.apply(checkForKibanaIndex, es),
|
||||
async.apply(createKibanaIndex, es),
|
||||
async.apply(checkForCurrentConfigDoc, es),
|
||||
async.apply(initConfig, config)
|
||||
], function (err) {
|
||||
// ready to go, remove the appEl, close services and boot be done
|
||||
appEl.remove();
|
||||
console.log('booting application');
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
angular.bootstrap(appEl, ['setup']);
|
||||
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
@import '../../bower_components/bootstrap/less/theme.less';
|
||||
|
||||
body {
|
||||
margin: 25px auto;
|
||||
margin: 25px;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue