mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
fixed some references that I missed
This commit is contained in:
parent
93a44f2668
commit
a8588eaec1
12 changed files with 186 additions and 173 deletions
|
@ -1,5 +1,5 @@
|
|||
define(function (require) {
|
||||
var app = require('angular').module('app/discover');
|
||||
var app = require('modules').get('app/discover');
|
||||
var html = require('text!./field_chooser.html');
|
||||
|
||||
app.directive('discFieldChooser', function () {
|
||||
|
|
15
src/kibana/constants/base.js
Normal file
15
src/kibana/constants/base.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
define(function (require) {
|
||||
/**
|
||||
* broke this out so that it could be loaded before the application is
|
||||
*/
|
||||
require('modules')
|
||||
.get('kibana/constants')
|
||||
|
||||
// This stores the Kibana revision number, @REV@ is replaced by grunt.
|
||||
.constant('kbnVersion', '@REV@')
|
||||
|
||||
// Use this for cache busting partials
|
||||
.constant('cacheBust', 'cache-bust=' + Date.now())
|
||||
|
||||
;
|
||||
});
|
|
@ -1,5 +1,4 @@
|
|||
define(function (require) {
|
||||
var angular = require('angular');
|
||||
var _ = require('lodash');
|
||||
var $ = require('jquery');
|
||||
var moment = require('moment');
|
||||
|
@ -8,15 +7,15 @@ define(function (require) {
|
|||
require('services/courier');
|
||||
require('directives/view');
|
||||
|
||||
angular
|
||||
.module('kibana/controllers')
|
||||
require('modules')
|
||||
.get('kibana/controllers')
|
||||
.controller('kibana', function ($scope, courier, config, configFile) {
|
||||
$scope.apps = configFile.apps;
|
||||
$scope.activeApp = '';
|
||||
|
||||
$scope.$on('$locationChangeSuccess', function (event, uri) {
|
||||
if (!uri) return;
|
||||
$scope.activeApp = uri.split('#')[1].split('/')[1];
|
||||
var route = uri.split('#/').slice(1);
|
||||
$scope.activeApp = route ? route[0] : null;
|
||||
});
|
||||
|
||||
$scope.opts = {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
define(function (require) {
|
||||
var module = require('angular').module('kibana/directives');
|
||||
var module = require('modules').get('kibana/directives');
|
||||
var $ = require('jquery');
|
||||
|
||||
module.directive('kbnInfiniteScroll', function () {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
define(function (require) {
|
||||
var module = require('angular').module('kibana/directives');
|
||||
var module = require('modules').get('kibana/directives');
|
||||
var $ = require('jquery');
|
||||
|
||||
module.directive('kbnTruncated', function ($compile) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
define(function (require) {
|
||||
var angular = require('angular');
|
||||
|
||||
angular
|
||||
.module('kibana/directives')
|
||||
require('modules')
|
||||
.get('kibana/directives')
|
||||
/******
|
||||
****** COPIED directive from angular-router
|
||||
****** https://github.com/angular/angular.js/blob/6f0503514f/src/ngRoute/directive/ngView.js#L183
|
||||
|
|
|
@ -14,10 +14,10 @@ define(function (require) {
|
|||
require('angular-route');
|
||||
|
||||
var kibana = angular.module('kibana', [
|
||||
// external requirements
|
||||
// list external requirements here (modules created
|
||||
// by the modules util are added automatically)
|
||||
'elasticsearch',
|
||||
'ngRoute'
|
||||
// internale requirements are added by the modules.js util
|
||||
]);
|
||||
|
||||
// proceed once setup is complete
|
||||
|
@ -25,10 +25,6 @@ define(function (require) {
|
|||
kibana
|
||||
// config.js in the root
|
||||
.value('configFile', configFile)
|
||||
// This stores the Kibana revision number, @REV@ is replaced by grunt.
|
||||
.constant('kbnVersion', '@REV@')
|
||||
// Use this for cache busting partials
|
||||
.constant('cacheBust', 'cache-bust=' + Date.now())
|
||||
// setup default routes
|
||||
.config(function ($routeProvider) {
|
||||
$routeProvider
|
||||
|
@ -38,7 +34,7 @@ define(function (require) {
|
|||
|
||||
configFile.apps.forEach(function (app) {
|
||||
$routeProvider.when('/' + app.id, {
|
||||
templateUrl: '/kibana/apps/' + app.id + '/index.html'
|
||||
templateUrl: 'kibana/apps/' + app.id + '/index.html'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -49,7 +45,7 @@ define(function (require) {
|
|||
return 'apps/' + app.id + '/index';
|
||||
})), function bootstrap() {
|
||||
$(function () {
|
||||
angular.bootstrap(document, 'kibana');
|
||||
angular.bootstrap(document, ['kibana']);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require.config({
|
||||
baseUrl: 'kibana',
|
||||
baseUrl: './kibana',
|
||||
paths: {
|
||||
kibana: './index',
|
||||
courier: '../courier',
|
||||
|
@ -15,7 +15,7 @@ require.config({
|
|||
lodash: '../bower_components/lodash/dist/lodash',
|
||||
moment: '../bower_components/moment/moment',
|
||||
gridster: '../bower_components/gridster/dist/jquery.gridster',
|
||||
configFile: '../config',
|
||||
modules: 'utils/modules',
|
||||
bower_components: '../bower_components'
|
||||
},
|
||||
shim: {
|
||||
|
|
|
@ -4,164 +4,165 @@ define(function (require) {
|
|||
|
||||
require('services/courier');
|
||||
|
||||
var module = require('modules').get('kibana/services');
|
||||
// share doc and val cache between apps
|
||||
var doc;
|
||||
var vals = {};
|
||||
|
||||
module.service('config', function ($q, $rootScope, courier, kbnVersion, configFile) {
|
||||
var watchers = {};
|
||||
var unwatchers = [];
|
||||
require('modules')
|
||||
.get('kibana/services')
|
||||
.service('config', function ($q, $rootScope, courier, kbnVersion, configFile) {
|
||||
var watchers = {};
|
||||
var unwatchers = [];
|
||||
|
||||
if (!doc) {
|
||||
doc = courier.createSource('doc')
|
||||
.index(configFile.kibanaIndex)
|
||||
.type('config')
|
||||
.id(kbnVersion);
|
||||
} else {
|
||||
// clean up after previous app
|
||||
doc
|
||||
.removeAllListeners('results')
|
||||
.courier(courier);
|
||||
}
|
||||
if (!doc) {
|
||||
doc = courier.createSource('doc')
|
||||
.index(configFile.kibanaIndex)
|
||||
.type('config')
|
||||
.id(kbnVersion);
|
||||
} else {
|
||||
// clean up after previous app
|
||||
doc
|
||||
.removeAllListeners('results')
|
||||
.courier(courier);
|
||||
}
|
||||
|
||||
doc.on('results', function (resp) {
|
||||
if (!resp.found) return; // init should ensure it exists
|
||||
_.forOwn(resp._source, function (val, key) {
|
||||
if (vals[key] !== val) _change(key, val);
|
||||
doc.on('results', function (resp) {
|
||||
if (!resp.found) return; // init should ensure it exists
|
||||
_.forOwn(resp._source, function (val, key) {
|
||||
if (vals[key] !== val) _change(key, val);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/******
|
||||
* PUBLIC API
|
||||
******/
|
||||
/******
|
||||
* PUBLIC API
|
||||
******/
|
||||
|
||||
function init() {
|
||||
var defer = $q.defer();
|
||||
courier.fetch();
|
||||
doc.on('results', function completeInit(resp) {
|
||||
// ONLY ACT IF !resp.found
|
||||
if (!resp.found) {
|
||||
console.log('creating empty config doc');
|
||||
doc.doIndex({});
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('fetched config doc');
|
||||
doc.removeListener('results', completeInit);
|
||||
defer.resolve();
|
||||
});
|
||||
return defer.promise;
|
||||
}
|
||||
|
||||
function get(key) {
|
||||
return vals[key];
|
||||
}
|
||||
|
||||
function set(key, val) {
|
||||
// sets a value in the config
|
||||
// the es doc must be updated successfully for the update to reflect in the get api.
|
||||
if (vals[key] === val) {
|
||||
function init() {
|
||||
var defer = $q.defer();
|
||||
defer.resolve(true);
|
||||
courier.fetch();
|
||||
doc.on('results', function completeInit(resp) {
|
||||
// ONLY ACT IF !resp.found
|
||||
if (!resp.found) {
|
||||
console.log('creating empty config doc');
|
||||
doc.doIndex({});
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('fetched config doc');
|
||||
doc.removeListener('results', completeInit);
|
||||
defer.resolve();
|
||||
});
|
||||
return defer.promise;
|
||||
}
|
||||
|
||||
var update = {};
|
||||
update[key] = val;
|
||||
|
||||
return doc.doUpdate(update)
|
||||
.then(function () {
|
||||
_change(key, val);
|
||||
return true;
|
||||
})
|
||||
.catch(function (err) {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
function $watch(key, onChange) {
|
||||
// probably a horrible idea
|
||||
if (!watchers[key]) watchers[key] = [];
|
||||
watchers[key].push(onChange);
|
||||
_notify(onChange, vals[key]);
|
||||
return function un$watcher() {
|
||||
_.pull(watchers[key], onChange);
|
||||
};
|
||||
}
|
||||
|
||||
function $bindToScope($scope, key, opts) {
|
||||
var configWatcher = function (val) {
|
||||
if (opts && val === void 0) val = opts['default'];
|
||||
$scope[key] = val;
|
||||
};
|
||||
|
||||
var first = true;
|
||||
var scopeWatcher = function (newVal) {
|
||||
if (first) return first = false;
|
||||
set(key, newVal);
|
||||
};
|
||||
|
||||
// collect unwatch/listen functions and automatically
|
||||
// run them when $scope is destroyed
|
||||
var unwatchScope = $scope.$watch(key, scopeWatcher);
|
||||
var unwatchConfig = $watch(key, configWatcher);
|
||||
var unlisten = $scope.$on('$destroy', unwatch);
|
||||
|
||||
unwatchers.push(unwatch);
|
||||
function unwatch() {
|
||||
unwatchScope();
|
||||
unwatchConfig();
|
||||
unlisten();
|
||||
_.pull(unwatchers, unwatch);
|
||||
function get(key) {
|
||||
return vals[key];
|
||||
}
|
||||
|
||||
// return the unwatch function so users can unwatch manually
|
||||
return unwatch;
|
||||
}
|
||||
function set(key, val) {
|
||||
// sets a value in the config
|
||||
// the es doc must be updated successfully for the update to reflect in the get api.
|
||||
if (vals[key] === val) {
|
||||
var defer = $q.defer();
|
||||
defer.resolve(true);
|
||||
return defer.promise;
|
||||
}
|
||||
|
||||
function close() {
|
||||
watchers = null;
|
||||
unwatchers.forEach(function (unwatcher) {
|
||||
unwatcher();
|
||||
});
|
||||
}
|
||||
var update = {};
|
||||
update[key] = val;
|
||||
|
||||
// expose public API on the instance
|
||||
this.init = init;
|
||||
this.close = close;
|
||||
this.get = get;
|
||||
this.set = set;
|
||||
this.$bind = $bindToScope;
|
||||
this.$watch = $watch;
|
||||
|
||||
/*******
|
||||
* PRIVATE API
|
||||
*******/
|
||||
|
||||
function _change(key, val) {
|
||||
_notify(watchers[key], val, vals[key]);
|
||||
vals[key] = val;
|
||||
console.log(key, 'is now', val);
|
||||
}
|
||||
|
||||
function _notify(fns, cur, prev) {
|
||||
if ($rootScope.$$phase) {
|
||||
// reschedule for next tick
|
||||
nextTick(_notify, fns, cur, prev);
|
||||
return;
|
||||
return doc.doUpdate(update)
|
||||
.then(function () {
|
||||
_change(key, val);
|
||||
return true;
|
||||
})
|
||||
.catch(function (err) {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
var isArr = _.isArray(fns);
|
||||
if (!fns || (isArr && !fns.length)) return;
|
||||
function $watch(key, onChange) {
|
||||
// probably a horrible idea
|
||||
if (!watchers[key]) watchers[key] = [];
|
||||
watchers[key].push(onChange);
|
||||
_notify(onChange, vals[key]);
|
||||
return function un$watcher() {
|
||||
_.pull(watchers[key], onChange);
|
||||
};
|
||||
}
|
||||
|
||||
$rootScope.$apply(function () {
|
||||
if (!isArr) return fns(cur, prev);
|
||||
function $bindToScope($scope, key, opts) {
|
||||
var configWatcher = function (val) {
|
||||
if (opts && val === void 0) val = opts['default'];
|
||||
$scope[key] = val;
|
||||
};
|
||||
|
||||
fns.forEach(function (onChange) {
|
||||
onChange(cur, prev);
|
||||
var first = true;
|
||||
var scopeWatcher = function (newVal) {
|
||||
if (first) return first = false;
|
||||
set(key, newVal);
|
||||
};
|
||||
|
||||
// collect unwatch/listen functions and automatically
|
||||
// run them when $scope is destroyed
|
||||
var unwatchScope = $scope.$watch(key, scopeWatcher);
|
||||
var unwatchConfig = $watch(key, configWatcher);
|
||||
var unlisten = $scope.$on('$destroy', unwatch);
|
||||
|
||||
unwatchers.push(unwatch);
|
||||
function unwatch() {
|
||||
unwatchScope();
|
||||
unwatchConfig();
|
||||
unlisten();
|
||||
_.pull(unwatchers, unwatch);
|
||||
}
|
||||
|
||||
// return the unwatch function so users can unwatch manually
|
||||
return unwatch;
|
||||
}
|
||||
|
||||
function close() {
|
||||
watchers = null;
|
||||
unwatchers.forEach(function (unwatcher) {
|
||||
unwatcher();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// expose public API on the instance
|
||||
this.init = init;
|
||||
this.close = close;
|
||||
this.get = get;
|
||||
this.set = set;
|
||||
this.$bind = $bindToScope;
|
||||
this.$watch = $watch;
|
||||
|
||||
/*******
|
||||
* PRIVATE API
|
||||
*******/
|
||||
|
||||
function _change(key, val) {
|
||||
_notify(watchers[key], val, vals[key]);
|
||||
vals[key] = val;
|
||||
console.log(key, 'is now', val);
|
||||
}
|
||||
|
||||
function _notify(fns, cur, prev) {
|
||||
if ($rootScope.$$phase) {
|
||||
// reschedule for next tick
|
||||
nextTick(_notify, fns, cur, prev);
|
||||
return;
|
||||
}
|
||||
|
||||
var isArr = _.isArray(fns);
|
||||
if (!fns || (isArr && !fns.length)) return;
|
||||
|
||||
$rootScope.$apply(function () {
|
||||
if (!isArr) return fns(cur, prev);
|
||||
|
||||
fns.forEach(function (onChange) {
|
||||
onChange(cur, prev);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,7 +1,7 @@
|
|||
define(function (require) {
|
||||
var es; // share the client amoungst all apps
|
||||
require('angular')
|
||||
.module('kibana/services')
|
||||
require('modules')
|
||||
.get('kibana/services')
|
||||
.service('es', function (esFactory, configFile, $q) {
|
||||
if (es) return es;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
define(function (require) {
|
||||
|
||||
var module = require('angular').module('kibana/services');
|
||||
var module = require('modules').get('kibana/services');
|
||||
|
||||
module.service('savedSearches', function (courier, configFile, $q) {
|
||||
this.get = function (id) {
|
||||
|
|
|
@ -11,28 +11,32 @@ define(function (require) {
|
|||
*
|
||||
* @param {function} done - callback
|
||||
*/
|
||||
return function SetupApp(app, done) {
|
||||
return function prebootSetup(done) {
|
||||
// load angular deps
|
||||
require([
|
||||
'kibana',
|
||||
|
||||
'elasticsearch',
|
||||
'services/es',
|
||||
'services/config',
|
||||
'constants/base'
|
||||
], function () {
|
||||
$(function () {
|
||||
], function (kibana) {
|
||||
|
||||
var setup = angular.module('setup', [
|
||||
'elasticsearch',
|
||||
'kibana/services',
|
||||
'kibana/constants'
|
||||
]);
|
||||
$(function () {
|
||||
// create the setup module, it should require the same things
|
||||
// that kibana currently requires, which should only include the
|
||||
// loaded modules
|
||||
var setup = angular.module('setup', kibana.requires);
|
||||
|
||||
var appEl = document.createElement('div');
|
||||
var kibanaIndexExists;
|
||||
|
||||
setup
|
||||
.value('configFile', configFile)
|
||||
.run(function (es, config) {
|
||||
.value('configFile', configFile);
|
||||
|
||||
angular
|
||||
.bootstrap(appEl, ['setup'])
|
||||
.invoke(function (es, config) {
|
||||
// init the setup module
|
||||
async.series([
|
||||
async.apply(checkForKibanaIndex, es),
|
||||
|
@ -47,8 +51,6 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
angular.bootstrap(appEl, ['setup']);
|
||||
|
||||
function checkForKibanaIndex(es, done) {
|
||||
console.log('look for kibana index');
|
||||
es.indices.exists({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue