diff --git a/.gitignore b/.gitignore index 57fcd67..884e3af 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ dist/ bower_components node_modules *.tgz +*.zip *.swp diff --git a/Gruntfile.js b/Gruntfile.js index 609b407..6518ef3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,11 +1,12 @@ module.exports = function (grunt) { - + var releaseBase = 'origin-kibana-'; var releaseTag = 'v' + grunt.file.readJSON('package.json').version; - var releaseFile = releaseBase + releaseTag + ".tgz"; - + var releaseFile = releaseBase + releaseTag + ".zip"; + var distDir = 'dist/kibana/origin-kibana'; + grunt.initConfig({ - + pkg: grunt.file.readJSON('package.json'), less: { production: { @@ -30,7 +31,7 @@ module.exports = function (grunt) { expand: true, cwd: 'lib/', src: ['**/*', '!**/*.less','!**/fonts/**','!**/fa-fonts/**'], - dest: 'dist/public', + dest: distDir + '/public', filter: 'isFile' }, { @@ -38,46 +39,46 @@ module.exports = function (grunt) { flatten: true, cwd: 'bower_components/patternfly/dist/fonts', src: '**', - dest: 'dist/public/fonts/' + dest: distDir + '/public/fonts/' }, { expand: true, flatten: true, cwd: 'bower_components/patternfly/components/font-awesome/fonts', src: '**', - dest: 'dist/public/fonts/' + dest: distDir + '/public/fonts/' }, { expand: true, flatten: true, cwd: 'bower_components/patternfly/components/bootstrap/dist/fonts', src: '**', - dest: 'dist/public/fonts/' + dest: distDir + '/public/fonts/' }, { expand: false, flatten: false, cwd: '.', src: 'package.json', - dest: 'dist/' + dest: distDir + '/' }, { expand: false, flatten: false, cwd: '.', src: 'index.js', - dest: 'dist/' + dest: distDir + '/' } ] } }, clean: ['dist', releaseBase + '*'], - touch: ['dist/public/styles/overrides.css'], + touch: [distDir + '/public/styles/overrides.css'], compress: { options: { pretty: true, archive: releaseFile, - mode: 'tgz' + mode: 'zip' }, files: { expand: true, diff --git a/README.md b/README.md index 0e5dbf2..a1982dd 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ by this plugin are: Overriding Styles The plugin adds an empty stylesheet `$PLUGIN/public/styles/overrides.css' as a hook for users to modify the styles. After deployment, you might wish to modify the header -style to include a custer header logo: +style to include a custom header logo: ``` .container-brand { @@ -22,21 +22,24 @@ style to include a custer header logo: ``` This stylesheet is loaded after the main stylesheet provided by the plugin. -Currently compatible with the 4.5.x code stream of Kibana +Currently compatible with the **5.5.x** code stream of Kibana ### Hacking the code +* Download and install [Elasticsearch](https://www.elastic.co/downloads/elasticsearch) +* Clone the Openshift `origin-kibana` repo * Run `npm install` to install node dependencies * Run `bower install` to install patternfly locally * Run `grunt` to build main.css -* Copy the contents of the `dist` directory to `/installedPlugins/origin-kibana` -* Start Kibana +* Start Kibana to use this plugin `npm start` ### Current supported fragment parameters When linking to kibana with the origin-kibana plugin you can control the container name and link back to the main console by setting the following parameters in the document hash: -* `console_container_name` - Used to set the container name text in the header -* `console_back_url` - Used as the URL in the back link to get back to the main console -* `console_auth_token` - Contains the authorization token for the user logged into the main console +| parameter | Description| +| ------ | ------| +| `console_container_name` | Used to set the container name text in the header | +| `console_back_url` | Used as the URL in the back link to get back to the main console | +| `console_auth_token` | Contains the authorization token for the user logged into the main console | Any parameter in the document hash prefixed with `console_` will be removed from the document hash once the UI is loaded. diff --git a/console.png b/console.png index 1f4e3e4..11bf3af 100644 Binary files a/console.png and b/console.png differ diff --git a/index.js b/index.js index 96c1f43..dc2c974 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,8 @@ export default function (kibana) { return new kibana.Plugin({ + name: 'origin-kibana', uiExports: { - visTypes: [ + hacks: [ 'plugins/origin-kibana/styles/main.css', 'plugins/origin-kibana/styles/overrides.css', 'plugins/origin-kibana/directives', diff --git a/lib/directives.js b/lib/directives.js index b7e75a0..b0e1986 100644 --- a/lib/directives.js +++ b/lib/directives.js @@ -1,8 +1,10 @@ -define(['require'], function(require){ +define(['require'], function(require, Logger){ const plugin = require('ui/modules').get('kibana'); - plugin.directive('body', ['$compile', function($compile) { + plugin.directive('body', ['$compile', 'Logger', function($compile, Logger) { + var logger = Logger.get(); const html = angular.element(require('./templates/header.html')); const linkFn = $compile(html); + logger.debug('returning OpenShift body directive'); return { restrict: 'E', link: function(scope, element, attrs) { diff --git a/lib/headerController.js b/lib/headerController.js index 991d819..2ffde0a 100644 --- a/lib/headerController.js +++ b/lib/headerController.js @@ -1,6 +1,7 @@ define(['require'], function (require) { const plugin = require('ui/modules').get('kibana'); - plugin.controller('OSHeaderController', ['$scope', 'UserStore', function ($scope, UserStore) { + plugin.controller('OSHeaderController', ['$scope', 'UserStore', 'Logger', function ($scope, UserStore, Logger) { + var logger = Logger.get(); const user = UserStore.getUser(); $scope.containerName = user.container_name; $scope.goBack = user.back_url; diff --git a/lib/logger.js b/lib/logger.js index 2af3f15..c4e6cdc 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -2,18 +2,34 @@ define(['require'], function (require) { const plugin = require('ui/modules').get('kibana'); plugin.provider('Logger', function () { + _level = function() { + return localStorage['OpenShiftLogLevel.main']||'error'; + }; var _logger = { - log: function() { + log: function(msg) { + console.log(msg); }, - info: function() { + info: function(msg) { + if (_level() === 'info') { + console.log('[INFO] ', msg); + } }, - debug: function() { + debug: function(msg) { + if (_level() === 'debug') { + console.log('[DEBUG] ', msg); + } }, - warn: function() { + warn: function(msg) { + if (_level() === 'warn') { + console.log('[WARN] ', msg); + } }, - error: function() { + error: function(msg) { + if (_level() === 'error') { + console.log('[ERROR] ', msg); + } } - }; + }; this.$get = function () { return { get: function (category) { diff --git a/lib/styles/main.less b/lib/styles/main.less index 73be559..1133e78 100644 --- a/lib/styles/main.less +++ b/lib/styles/main.less @@ -7,11 +7,11 @@ /* Overrides */ @import "variables.less"; -.navbar-inverse .logo { +.global-nav .logo.kibana { background-image: none; background-size: contain; - height: 45px; - width: 300px; + height: 0; + width: 0; } .navbar-inverse .navbar-nav > .active > a:before, @@ -121,12 +121,26 @@ height: 7px; } +.global-nav { + top: 25px; + background: #030303; +} + +.global-nav.global-nav__logo { + display: none +} + +.app-wrapper { + top: 25px +} + .container-header { border-top: 3px solid red; background: #030303; color: #f1f1f1; padding-left: 17px; padding-bottom: 8px; + z-index: 10; } .container-brand { diff --git a/lib/userstore.js b/lib/userstore.js index cc1aad3..3c29ed7 100644 --- a/lib/userstore.js +++ b/lib/userstore.js @@ -1,6 +1,8 @@ +import { QueryString } from 'ui/utils/query_string'; + define(['require'], function (require) { var plugin = require('ui/modules').get('kibana'); - var qs = require('ui/utils/query_string'); + var qs = QueryString; //ref: https://github.com/openshift/origin/blob/master/assets/app/scripts/services/userstore.js plugin.provider('LocalStorageUserStore', function () { this.$get = function ($location, Logger) { diff --git a/package.json b/package.json index 6e2b884..744c310 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origin-kibana", - "version": "4.5.1-2", + "version": "5.5.2-1", "homepage": "https://github.com/openshift/origin-kibana", "authors": [ "dev@openshift.redhat.com" @@ -20,7 +20,13 @@ ], "main": "index.js", "scripts": { - "postinstall": "bower install" + "lint": "eslint", + "start": "plugin-helpers start", + "test:server": "plugin-helpers test:server", + "test:browser": "plugin-helpers test:browser", + "build": "plugin-helpers build", + "postinstall": "plugin-helpers postinstall", + "postinstall-orig": "bower install" }, "devDependencies": { "bower": "^1.4.1", @@ -31,7 +37,13 @@ "grunt-contrib-copy": "~0.8.2", "grunt-contrib-less": "~1.1.0", "grunt-github-releaser": "~0.1.18", - "grunt-touch": "^1.0.0" + "grunt-touch": "^1.0.0", + "@elastic/eslint-config-kibana": "0.0.2", + "@elastic/plugin-helpers": "^6.0.0", + "babel-eslint": "4.1.8", + "chai": "^3.5.0", + "eslint": "1.10.3", + "eslint-plugin-mocha": "1.1.0" }, "repository": { "type": "git", diff --git a/public b/public new file mode 120000 index 0000000..3f81a5e --- /dev/null +++ b/public @@ -0,0 +1 @@ +dist/kibana/origin-kibana/public \ No newline at end of file