diff --git a/bower.json b/bower.json index 0802de4dee697c..95687679245d6f 100644 --- a/bower.json +++ b/bower.json @@ -49,7 +49,8 @@ "requirejs-text": "~2.0.10", "lodash-deep": "spenceralger/lodash-deep#compat", "marked": "~0.3.2", - "numeral": "~1.5.3" + "numeral": "~1.5.3", + "angularjs-nvd3-directives": "~0.0.7" }, "devDependencies": {} } diff --git a/src/hapi/plugins/status/public/index.html b/src/hapi/plugins/status/public/index.html index e557a0c37d3fea..89b986a299c530 100644 --- a/src/hapi/plugins/status/public/index.html +++ b/src/hapi/plugins/status/public/index.html @@ -1,9 +1,70 @@ - + + Kibana Status + + + + + + -

Kibana Status Page

-

Statusy stuff goes here... it's goign to be totally awesome!

+
+
+

+ Kibana Status +

+
+
+
+

What is this page?

+

This page is your sanity check, and your savior. You can check for potential problems

+

Here is the status of your kibana instance and the plugins you have installed along with some, statistics to asses potential problems.

+
+
+

What is this page?

+

This page is your sanity check, and your savior. You can check for potential problems

+
+
+
+ {{ui.systemStatus().msg}} +
+
+
+
+ {{key}}: {{plugin.message}} +
+
+
+
+
+

{{key}}

+ + + +
+
+
+
+ +
+ + + diff --git a/src/hapi/plugins/status/public/index.js b/src/hapi/plugins/status/public/index.js new file mode 100644 index 00000000000000..daf7846d76e3f9 --- /dev/null +++ b/src/hapi/plugins/status/public/index.js @@ -0,0 +1,106 @@ +define(['angular', 'jquery', 'lodash', 'nvd3', 'nvd3_directives'], + function (angular, $, _, nvd3, directives) { + + // Make sure we don't have to deal with statuses by hand + function getStatus(plugin) { + var statusMap = { + green: { + label: 'success', + msg: 'All systems are a Go.', + idx: 1 + }, + yellow: { + label: 'warning', + msg: 'S.N.A.F.U.', + idx: 2 + }, + red: { + label: 'danger', + msg: 'Danger Will Robinson! Danger!', + idx: 3 + }, + loading: { + label: 'info', + msg: 'Loading...', + idx: 0 + } + }; + if(!_.isObject(plugin) || _.isUndefined(plugin)) { + plugin = {state: plugin}; + } + return statusMap[plugin.state]; + } + function getLabel(plugin) { return getStatus(plugin).label; } + + + // The Kibana App + angular.module('KibanaStatusApp', ['nvd3ChartDirectives']) + .controller('StatusPage', ['$scope', '$http', function($scope, $http) { + // the object representing all of the elements the ui touches + $scope.ui = { + systemStatus: function() { + function getIdx(plugin) { return getStatus(plugin).idx; } + return function() { + var currentStatus = 'loading'; + var currentIdx = getIdx(currentStatus); + // FIXME eh, not too thrilled about this. + var status = _.reduce($scope.ui.plugins, function(curr, plugin, key) { + var pluginIdx = getIdx(plugin); + if (pluginIdx > currentIdx) { + // set the current status + currentStatus = plugin.state; + currentIdx = getIdx(plugin); + } + return currentStatus; + }, 'loading'); + + + // give the ui the label for colors and such + return getStatus(status); + } + }(), + charts: [], + plugins: [], + nvd3Config: { + getX: function(d) { return d[0]; }, + getY: function(d) { + if(d) { + if(_.isArray(d[1])) { + return d[1][0]; + } + } else { + debugger; + } + return d[1]; + } + } + }; + + + // go ahead and get the info you want + $http + .get('/status/health') + .success(function(data) { + // Assign the propper variables to the scope + $scope.ui.charts = data.metrics; + $scope.ui.plugins = _.mapValues(data.status, function(plugin) { + plugin.uiStatus = getLabel(plugin); + return plugin; + }); + + console.log($scope.ui); + }) + .error(function() { + alert('Something went terribly wrong while making the request!!!'); + }); + }]); + + return { + init: function() { + $(function() { + angular.bootstrap(document, ['nvd3ChartDirectives', 'KibanaStatusApp']); + }); + } + }; + + }); diff --git a/src/kibana/components/vislib/lib/resize_checker.js b/src/kibana/components/vislib/lib/resize_checker.js index 479935a20969dc..f76c3b407fa657 100644 --- a/src/kibana/components/vislib/lib/resize_checker.js +++ b/src/kibana/components/vislib/lib/resize_checker.js @@ -204,4 +204,4 @@ define(function (require) { return ResizeChecker; }; -}); \ No newline at end of file +}); diff --git a/src/kibana/require.config.js b/src/kibana/require.config.js index c7334130585c85..bcd70f555cdc5b 100644 --- a/src/kibana/require.config.js +++ b/src/kibana/require.config.js @@ -1,5 +1,5 @@ require.config({ - baseUrl: './', + baseUrl: '/', paths: { kibana: 'index', // special utils @@ -21,6 +21,8 @@ require.config({ bower_components: 'bower_components', css: 'bower_components/require-css/css', d3: 'bower_components/d3/d3', + nvd3: 'bower_components/nvd3/nv.d3', + nvd3_directives: 'bower_components/angularjs-nvd3-directives/dist/angularjs-nvd3-directives', elasticsearch: 'bower_components/elasticsearch/elasticsearch.angular', faker: 'bower_components/Faker/faker', file_saver: 'bower_components/FileSaver/FileSaver', @@ -42,6 +44,9 @@ require.config({ deps: ['jquery'], exports: 'angular' }, + file_saver: { + exports: 'saveAs' + }, gridster: ['jquery', 'css!bower_components/gridster/dist/jquery.gridster.css'], 'angular-route': ['angular'], 'elasticsearch': ['angular'], @@ -53,15 +58,14 @@ require.config({ inflection: { exports: 'inflection' }, - file_saver: { - exports: 'saveAs' - }, leaflet: { deps: ['css!bower_components/leaflet/dist/leaflet.css'] }, marked: { exports: 'marked' - } + }, + nvd3: ['css!bower_components/nvd3/nv.d3.css', 'd3'], + nvd3_directives: ['angular', 'd3', 'nvd3'] }, waitSeconds: 60 });