diff --git a/public/common/lodash-mixins/get_pluck.js b/public/common/lodash-mixins/get_pluck.js
index 7236d3a..43c52d2 100644
--- a/public/common/lodash-mixins/get_pluck.js
+++ b/public/common/lodash-mixins/get_pluck.js
@@ -1,7 +1,7 @@
export function lodashGetPluckMixin(_) {
- let toPath = require('lodash/internal/toPath');
- let toObject = require('lodash/internal/toObject');
+ const toPath = require('lodash/internal/toPath');
+ const toObject = require('lodash/internal/toObject');
/**
* The base implementation of `get` without support for string paths
@@ -24,13 +24,13 @@ export function lodashGetPluckMixin(_) {
}
let index = 0;
- let length = path.length;
+ const length = path.length;
while (object != null && index < length) {
- let key = path[index++];
+ const key = path[index++];
if (_.isArray(object) && !_.has(object, key)) {
- object = _.map(object, _.property(_.slice(path, index-1)));
+ object = _.map(object, _.property(_.slice(path, index - 1)));
index = length;
}
else {
@@ -38,7 +38,7 @@ export function lodashGetPluckMixin(_) {
}
}
- return (index && index == length) ? object : undefined;
+ return (index && index === length) ? object : undefined;
}
_.mixin(_, {
@@ -72,7 +72,7 @@ export function lodashGetPluckMixin(_) {
* // => 'default'
*/
getPluck: function (object, path, defaultValue) {
- let result = object == null ? undefined : baseGetWithPluck(object, toPath(path), path + '');
+ const result = object == null ? undefined : baseGetWithPluck(object, toPath(path), path + '');
return result === undefined ? defaultValue : result;
}
});
diff --git a/public/field_formats/object/object.js b/public/field_formats/object/object.js
index cb0aaf3..9891dff 100644
--- a/public/field_formats/object/object.js
+++ b/public/field_formats/object/object.js
@@ -17,11 +17,11 @@ import { lodashGetPluckMixin } from '../../common/lodash-mixins/get_pluck';
lodashOopMixin(_);
lodashGetPluckMixin(_);
-const vis_template = _.template(format_html)
-const image_template = _.template(image_html)
-const link_template = _.template(link_html)
-const text_template = _.template(text_html)
-const empty_template = _.template(empty_html)
+const vis_template = _.template(format_html);
+const image_template = _.template(image_html);
+const link_template = _.template(link_html);
+const text_template = _.template(text_html);
+const empty_template = _.template(empty_html);
const DEFAULT_VALUES = {
label: null, // Optional data label
@@ -57,24 +57,24 @@ export function createObjectFormat(FieldFormat) {
};
}
- _get_field_models(value, field, hit, basePath, objectFields) {
+ _getFieldModels(value, field, hit, basePath, objectFields) {
let filtered = false;
- let fields = [];
+ const fields = [];
// Apply each field configured for the formatter to the value
- _.forEach(objectFields, _.bind(function(objectField) {
+ _.forEach(objectFields, _.bind(function (objectField) {
let label = '';
let fieldPath = '';
- if (objectField.label) label = objectField.label + ": ";
+ if (objectField.label) label = objectField.label + ': ';
if (objectField.path) fieldPath = objectField.path;
if (objectField.filtered) filtered = objectField.filtered;
// Get the value from the field path
let fieldValues = _.getPluck(value, fieldPath);
- if (objectField.type == 'text') {
+ if (objectField.type === 'text') {
// We generate a nice comma delimited list, like the built in String does.
if (_.isArray(fieldValues)) {
if (objectField.limit) {
@@ -82,7 +82,7 @@ export function createObjectFormat(FieldFormat) {
}
fieldValues = _(fieldValues)
- .map( item => ( _.isObject(item) ? JSON.stringify(item) : item) )
+ .map(item => (_.isObject(item) ? JSON.stringify(item) : item))
.join(', ');
}
else if (_.isObject(fieldValues)) {
@@ -99,13 +99,13 @@ export function createObjectFormat(FieldFormat) {
fieldValues = _.slice(fieldValues, 0, objectField.limit);
}
- let fullPath = this._get_full_path(basePath, field, objectField.path, null);
- let filterPath = this._get_full_path(basePath, field, objectField.path, objectField.filterField);
- let valueModels = [];
+ const fullPath = this._getFullPath(basePath, field, objectField.path, null);
+ const filterPath = this._getFullPath(basePath, field, objectField.path, objectField.filterField);
+ const valueModels = [];
- _.forEach(fieldValues, _.bind(function(fieldValue) {
+ _.forEach(fieldValues, _.bind(function (fieldValue) {
- let valueModel = {
+ const valueModel = {
value: fieldValue,
display: _.escape(fieldValue)
};
@@ -120,7 +120,7 @@ export function createObjectFormat(FieldFormat) {
valueModels.push(valueModel);
}, this));
- let fieldHtml = this._field_to_html({
+ const fieldHtml = this._fieldToHtml({
label: label,
formatType: objectField.type,
values: valueModels,
@@ -136,34 +136,34 @@ export function createObjectFormat(FieldFormat) {
});
}, this));
- return {filtered: filtered, fields: fields};
- };
+ return { filtered: filtered, fields: fields };
+ }
- _field_to_html(fieldModel) {
+ _fieldToHtml(fieldModel) {
let html = null;
switch (fieldModel.formatType) {
case 'image':
- html = image_template({field: fieldModel})
+ html = image_template({ field: fieldModel });
break;
case 'link':
- html = link_template({field: fieldModel})
+ html = link_template({ field: fieldModel });
break;
case 'text':
default:
- html = text_template({field: fieldModel})
+ html = text_template({ field: fieldModel });
break;
}
return html;
- };
+ }
- _get_full_path(basePath, field, valuePath, filterField) {
+ _getFullPath(basePath, field, valuePath, filterField) {
- let parts = [field.name];
+ const parts = [field.name];
if (basePath) {
parts.push(basePath);
@@ -176,7 +176,7 @@ export function createObjectFormat(FieldFormat) {
}
return parts.join('.');
- };
+ }
asPrettyString(val) {
if (val === null || val === undefined) return ' - ';
@@ -185,7 +185,7 @@ export function createObjectFormat(FieldFormat) {
case 'object': return JSON.stringify(val, null, ' ');
default: return '' + val;
}
- };
+ }
}
ObjectFormat.prototype._convert = {
@@ -193,9 +193,9 @@ export function createObjectFormat(FieldFormat) {
return this.asPrettyString(val);
},
html(val, field, hit) {
- let basePath = this.param('basePath');
- let objectFields = this.param('fields');
- let limit = this.param('limit');
+ const basePath = this.param('basePath');
+ const objectFields = this.param('fields');
+ const limit = this.param('limit');
if (basePath) {
val = _.get(val, basePath);
@@ -206,7 +206,7 @@ export function createObjectFormat(FieldFormat) {
}
// Filter out any null or empty entries
- val = $.grep(val, function(n){ return n == 0 || n });
+ val = $.grep(val, function (n) { return n === 0 || n });
// If we have a limit on this list, impose it now
if (limit) {
@@ -214,14 +214,14 @@ export function createObjectFormat(FieldFormat) {
}
if (val.length > 0) {
- let htmlSnippets = [];
+ const htmlSnippets = [];
- _.forEach(val, _.bind(function(value){
+ _.forEach(val, _.bind(function (value) {
if (value) {
- let fieldModels = this._get_field_models(value, field, hit, basePath, objectFields);
- htmlSnippets.push(vis_template({filtered: fieldModels.filtered,
- fields: fieldModels.fields,
- uid: Math.floor((Math.random() * 1000000) + 1)}));
+ const fieldModels = this._getFieldModels(value, field, hit, basePath, objectFields);
+ htmlSnippets.push(vis_template({ filtered: fieldModels.filtered,
+ fields: fieldModels.fields,
+ uid: Math.floor((Math.random() * 1000000) + 1) }));
}
}, this));
@@ -241,7 +241,7 @@ export function objectEditor() {
formatId: 'ist-object',
template: objectTemplate,
controllerAs: 'object',
- controller: function ($scope, chrome) {
+ controller: function ($scope) {
this.formatTypes = [
{ id: 'text', name: 'Text' },
diff --git a/public/field_formats/object/templates/object_format.html b/public/field_formats/object/templates/object_format.html
index 170e002..81f66ee 100644
--- a/public/field_formats/object/templates/object_format.html
+++ b/public/field_formats/object/templates/object_format.html
@@ -23,7 +23,7 @@
diff --git a/public/hacks/field_mapper_hack.js b/public/hacks/field_mapper_hack.js
index cadc29d..d042b61 100644
--- a/public/hacks/field_mapper_hack.js
+++ b/public/hacks/field_mapper_hack.js
@@ -1,56 +1,56 @@
import _ from 'lodash';
-import angular from 'angular';
import 'ui/courier';
import 'ui/index_patterns';
import 'ui/modals/confirm_modal_promise';
import { uiModules } from 'ui/modules';
-let app = uiModules.get('app/kibana-object-formatter', [
- 'kibana/index_patterns'
- ]);
+const app = uiModules.get('app/kibana-object-formatter', [
+ 'kibana/index_patterns'
+]);
/**
* Patch 'fieldsFetcher.fetch' to allow us to insert additional fields.
*/
-app.run(['indexPatterns', 'config', function(indexPatterns, config) {
+app.run(['indexPatterns', 'config', function (indexPatterns, config) {
- let fieldsFetcher = indexPatterns.fieldsFetcher;
- let fieldsFunc = fieldsFetcher.fetch;
+ const fieldsFetcher = indexPatterns.fieldsFetcher;
+ const fieldsFunc = fieldsFetcher.fetch;
- (function(fieldsFunc) { // Cache the original method
- fieldsFetcher.fetch = function() { // Wrap the method
+ (function (fieldsFunc) { // Cache the original method
+ fieldsFetcher.fetch = function () { // Wrap the method
- let indexPattern = arguments[0]
+ const indexPattern = arguments[0];
- let promise = fieldsFunc.apply(this, arguments);
+ const promise = fieldsFunc.apply(this, arguments);
return promise.then(fields => {
let paths = [];
- let mappingNames = [];
+ const mappingNames = [];
// 1) Iterate the field names, identify the "parent" paths
- _.forEach(fields, function(field) {
+ _.forEach(fields, function (field) {
- let fieldName = field["name"];
+ const fieldName = field.name;
mappingNames.push(fieldName);
- let parts = fieldName.split(".");
+ const parts = fieldName.split('.');
while (parts.length > 1) {
parts.pop();
- paths.push(parts.join("."));
+ paths.push(parts.join('.'));
}
});
paths = _.uniq(_.difference(paths, mappingNames));
// 2) Test the discovered field names against the configuration
- let defaultConfig = "{\n \"index_pattern\": {\n \"*\": {\n \"include\": [],\n \"exclude\": [\".*\"]\n }\n }\n}"
+ const defaultConfig = '{\n \"index_pattern\": {\n \"*\": {\n' +
+ '\"include\": [],\n \"exclude\": [\".*\"]\n }\n }\n}';
let settings = config.get('fieldMapperHack:fields', defaultConfig);
- settings = settings['index_pattern'];
+ settings = settings.index_pattern;
- let match = { includes: [], excludes: []};
+ let match = { includes: [], excludes: [] };
if (_.has(settings, indexPattern.id)) {
match = settings[indexPattern.id];
@@ -59,19 +59,19 @@ app.run(['indexPatterns', 'config', function(indexPatterns, config) {
match = settings['*'];
}
- let included = []
- let excluded = []
+ const included = [];
+ const excluded = [];
- _.forEach(match['include'], function(expression){
- _.forEach(paths, function(path){
+ _.forEach(match.include, function (expression) {
+ _.forEach(paths, function (path) {
if (path.match(expression)) {
included.push(path);
}
});
});
- _.forEach(match['exclude'], function(expression){
- _.forEach(included, function(path){
+ _.forEach(match.exclude, function (expression) {
+ _.forEach(included, function (path) {
if (path.match(expression)) {
excluded.push(path);
}
@@ -79,7 +79,7 @@ app.run(['indexPatterns', 'config', function(indexPatterns, config) {
});
// 3) Add a field mapping for the missing parents
- _.forEach(_.difference(included, excluded), function(path){
+ _.forEach(_.difference(included, excluded), function (path) {
fields.push({
name: path,
aggregatable: false,
@@ -87,7 +87,7 @@ app.run(['indexPatterns', 'config', function(indexPatterns, config) {
analyzed: false,
doc_values: false,
indexed: true,
- type: "string"
+ type: 'string'
});
});
diff --git a/public/hacks/object_filtering_hack.js b/public/hacks/object_filtering_hack.js
index c81560a..a4cd5a2 100644
--- a/public/hacks/object_filtering_hack.js
+++ b/public/hacks/object_filtering_hack.js
@@ -1,42 +1,41 @@
import _ from 'lodash';
-import angular from 'angular';
import 'ui/courier';
import { uiModules } from 'ui/modules';
import { FilterManagerProvider } from 'ui/filter_manager';
import { fieldFormats } from 'ui/registry/field_formats';
-let app = uiModules.get('app/kibana-object-formatter');
+const app = uiModules.get('app/kibana-object-formatter');
/**
* Patch 'FilterManager' to allow us to hand-craft filters for fields
* that use the Object formatter.
*/
-app.run(function(config, Private) {
+app.run(function (config, Private) {
const filterManager = Private(FilterManagerProvider);
const _ObjectFormat = fieldFormats.getType('ist-object');
- let addFunc = filterManager.add;
+ const addFunc = filterManager.add;
- (function(addFunc) { // Cache the original method
- filterManager.add = function() { // Wrap the method
+ (function (addFunc) { // Cache the original method
+ filterManager.add = function () { // Wrap the method
- let field = arguments[0];
+ const field = arguments[0];
let values = arguments[1];
- let operation = arguments[2];
- let index = arguments[3];
+ const operation = arguments[2];
+ const index = arguments[3];
// If the field is one of our special Object fields
if (field && field.format && field.format.type === _ObjectFormat) {
- let params = field.format._params;
- let basePath = params.basePath;
+ const params = field.format._params;
+ const basePath = params.basePath;
let filters = null;
if (!_.isArray(values)) {
values = [values];
}
- _.forEach(values, function(value) {
+ _.forEach(values, function (value) {
if (basePath) {
value = _.get(value, basePath);
}
@@ -45,25 +44,25 @@ app.run(function(config, Private) {
value = [value];
}
- _.forEach(params.fields, _.bind(function(fieldEntry) {
+ _.forEach(params.fields, _.bind(function (fieldEntry) {
if (fieldEntry.filtered) {
let path = fieldEntry.path;
- let entry_values = [];
+ const entryValues = [];
- _.forEach(value, function(value_entry) {
+ _.forEach(value, function (valueEntry) {
- let plucked = _.getPluck(value_entry, path);
+ const plucked = _.getPluck(valueEntry, path);
if (_.isArray(plucked)) {
- _.forEach(plucked, function(v) {
+ _.forEach(plucked, function (v) {
if (v) {
- entry_values.push(v);
+ entryValues.push(v);
}
});
}
else {
if (plucked) {
- entry_values.push(plucked);
+ entryValues.push(plucked);
}
}
});
@@ -74,7 +73,7 @@ app.run(function(config, Private) {
path = [path, fieldEntry.filterField].join('.');
}
- filters = addFunc.apply(this, [path, entry_values, operation, index]);
+ filters = addFunc.apply(this, [path, entryValues, operation, index]);
}
}, filterManager));
});