mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Use es6 exports, replace module.exports (#12084)
* use es6 exports in fixtures * use es6 exports in test_utils * use es6 exports in src/ui * use es6 exports in src/utils * use es6 exports in src/server * use es6 exports in timelion * use es6 exports in core plugins, but not console * use es6 exports in console * use es6 exports in src/cli * use eslint --fix for no-extra-semi rule * selectively disable kibana-custom/no-default-export * replace define() with exports * clean up some object exports in these cases, named exports are the better replacement * use es6 exports in src/optimize, where possible * fix uses of named exports * fix some imports in console * revert postcss optimizer to module.exports * [timelion] put shared code in common directory * fix url module export don't export as default, rely on the named export * convert define modules in src to export * convert ui-bootstrap to cjs module * lint webpackShims no reason not to, they pass when the no-var rule is disabled * fix new code not using es6 exports * fix some straggling exports
This commit is contained in:
parent
992684962b
commit
262bcb411a
308 changed files with 1928 additions and 1988 deletions
|
@ -7,7 +7,7 @@ import BasePathProxy from './base_path_proxy';
|
|||
|
||||
process.env.kbnWorkerType = 'managr';
|
||||
|
||||
module.exports = class ClusterManager {
|
||||
export default class ClusterManager {
|
||||
constructor(opts = {}, settings = {}) {
|
||||
this.log = new Log(opts.quiet, opts.silent);
|
||||
this.addedCount = 0;
|
||||
|
@ -169,4 +169,4 @@ module.exports = class ClusterManager {
|
|||
this.log.bad('failed to watch files!\n', err.stack);
|
||||
process.exit(1); // eslint-disable-line no-process-exit
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ const dead = fork => {
|
|||
return fork.isDead() || fork.killed;
|
||||
};
|
||||
|
||||
module.exports = class Worker extends EventEmitter {
|
||||
export default class Worker extends EventEmitter {
|
||||
constructor(opts) {
|
||||
opts = opts || {};
|
||||
super();
|
||||
|
@ -162,4 +162,4 @@ module.exports = class Worker extends EventEmitter {
|
|||
// wait for the fork to report it is online before resolving
|
||||
await new Promise(cb => this.once('fork:online', cb));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
import ansicolors from 'ansicolors';
|
||||
|
||||
exports.green = _.flow(ansicolors.black, ansicolors.bgGreen);
|
||||
exports.red = _.flow(ansicolors.white, ansicolors.bgRed);
|
||||
exports.yellow = _.flow(ansicolors.black, ansicolors.bgYellow);
|
||||
export const green = _.flow(ansicolors.black, ansicolors.bgGreen);
|
||||
export const red = _.flow(ansicolors.white, ansicolors.bgRed);
|
||||
export const yellow = _.flow(ansicolors.black, ansicolors.bgYellow);
|
||||
|
|
|
@ -91,4 +91,4 @@ Command.prototype.action = _.wrap(Command.prototype.action, function (action, fn
|
|||
});
|
||||
});
|
||||
|
||||
module.exports = Command;
|
||||
export default Command;
|
||||
|
|
|
@ -4,12 +4,12 @@ const log = _.restParam(function (color, label, rest1) {
|
|||
console.log.apply(console, [color(` ${_.trim(label)} `)].concat(rest1));
|
||||
});
|
||||
|
||||
import color from './color';
|
||||
import { green, yellow, red } from './color';
|
||||
|
||||
module.exports = class Log {
|
||||
export default class Log {
|
||||
constructor(quiet, silent) {
|
||||
this.good = quiet || silent ? _.noop : _.partial(log, color.green);
|
||||
this.warn = quiet || silent ? _.noop : _.partial(log, color.yellow);
|
||||
this.bad = silent ? _.noop : _.partial(log, color.red);
|
||||
this.good = quiet || silent ? _.noop : _.partial(log, green);
|
||||
this.warn = quiet || silent ? _.noop : _.partial(log, yellow);
|
||||
this.bad = silent ? _.noop : _.partial(log, red);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ function readServerSettings(opts, extraCliOptions) {
|
|||
return settings;
|
||||
}
|
||||
|
||||
module.exports = function (program) {
|
||||
export default function (program) {
|
||||
const command = program.command('serve');
|
||||
|
||||
command
|
||||
|
@ -170,7 +170,7 @@ module.exports = function (program) {
|
|||
|
||||
return kbnServer;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function logFatal(message, server) {
|
||||
if (server) {
|
||||
|
|
|
@ -42,4 +42,4 @@ function Api(name) {
|
|||
|
||||
}(Api.prototype));
|
||||
|
||||
module.exports = Api;
|
||||
export default Api;
|
||||
|
|
|
@ -53,4 +53,6 @@ ES_5_0.prototype = _.create(Api.prototype, { 'constructor': ES_5_0 });
|
|||
};
|
||||
})(ES_5_0.prototype);
|
||||
|
||||
module.exports = new ES_5_0();
|
||||
const instance = new ES_5_0();
|
||||
|
||||
export default instance;
|
|
@ -435,8 +435,9 @@ var rules = {
|
|||
}
|
||||
}
|
||||
};
|
||||
module.exports = function (api) {
|
||||
|
||||
export default function (api) {
|
||||
|
||||
api.addGlobalAutocompleteRules('aggregations', rules);
|
||||
api.addGlobalAutocompleteRules('aggs', rules);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('_post_aliases', {
|
||||
methods: ['POST'],
|
||||
patterns: [
|
||||
|
@ -68,4 +68,4 @@ module.exports = function (api) {
|
|||
api.addGlobalAutocompleteRules('aliases', {
|
||||
'*': aliasRules
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ function addNodeattrsCat(api) {
|
|||
});
|
||||
}
|
||||
|
||||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
addSimpleCat('_cat/aliases', api);
|
||||
addSimpleCat('_cat/allocation', api, null, ['_cat/allocation', '_cat/allocation/{nodes}']);
|
||||
addSimpleCat('_cat/count', api);
|
||||
|
@ -53,4 +53,4 @@ module.exports = function (api) {
|
|||
addSimpleCat('_cat/plugins', api);
|
||||
addSimpleCat('_cat/segments', api);
|
||||
addNodeattrsCat(api);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('_cluster/nodes/stats');
|
||||
api.addEndpointDescription('_cluster/state', {
|
||||
patterns: [
|
||||
|
@ -139,4 +139,4 @@ module.exports = function (api) {
|
|||
dry_run: { __one_of: [true, false] }
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('_count', {
|
||||
methods: ['GET', 'POST'],
|
||||
priority: 10, // collides with get doc by id
|
||||
|
@ -19,4 +19,4 @@ module.exports = function (api) {
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('_get_doc', {
|
||||
methods: ['GET'],
|
||||
patterns: [
|
||||
|
@ -230,4 +230,4 @@ module.exports = function (api) {
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('_field_stats', {
|
||||
methods: ['GET', 'POST'],
|
||||
patterns: [
|
||||
|
@ -44,4 +44,4 @@ module.exports = function (api) {
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -330,7 +330,7 @@ filters.nested = {
|
|||
_name: ''
|
||||
};
|
||||
|
||||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addGlobalAutocompleteRules('filter', filters);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addGlobalAutocompleteRules('highlight', {
|
||||
pre_tags: {},
|
||||
post_tags: {},
|
||||
|
@ -21,4 +21,4 @@ module.exports = function (api) {
|
|||
lang: "",
|
||||
params: {}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('_refresh', {
|
||||
methods: ['POST'],
|
||||
patterns: [
|
||||
|
@ -231,4 +231,4 @@ module.exports = function (api) {
|
|||
"{indices}/_open"
|
||||
]
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ const simulateUrlParamsDefinition = {
|
|||
"verbose": "__flag__"
|
||||
};
|
||||
|
||||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
|
||||
// Note: this isn't an actual API endpoint. It exists so the forEach processor's "processor" field
|
||||
// may recursively use the autocomplete rules for any processor.
|
||||
|
@ -383,4 +383,4 @@ module.exports = function (api) {
|
|||
]
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ var BOOLEAN = {
|
|||
__one_of: [true, false]
|
||||
};
|
||||
|
||||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('_get_mapping', {
|
||||
methods: ['GET'],
|
||||
priority: 10, // collides with get doc by id
|
||||
|
@ -216,4 +216,4 @@ module.exports = function (api) {
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('_nodes/hot_threads', {
|
||||
methods: ['GET'],
|
||||
patterns: [
|
||||
|
@ -75,4 +75,4 @@ module.exports = function (api) {
|
|||
]
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('_put_percolator', {
|
||||
priority: 10, // to override doc
|
||||
methods: ['PUT', 'POST'],
|
||||
|
@ -87,4 +87,4 @@ module.exports = function (api) {
|
|||
filter: {}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ var DECAY_FUNC_DESC = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addGlobalAutocompleteRules('query', {
|
||||
match: {
|
||||
__template: {
|
||||
|
@ -624,4 +624,4 @@ module.exports = function (api) {
|
|||
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
|
||||
api.addEndpointDescription('_post_reindex', {
|
||||
methods: [ 'POST' ],
|
||||
|
@ -54,4 +54,4 @@ module.exports = function (api) {
|
|||
'script': { __scope_link: 'GLOBAL.script' },
|
||||
}
|
||||
})
|
||||
};
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('_search', {
|
||||
methods: ['GET', 'POST'],
|
||||
priority: 10, // collides with get doc by id
|
||||
|
@ -252,4 +252,4 @@ module.exports = function (api) {
|
|||
local: "__flag__"
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
|
||||
api.addEndpointDescription('_get_settings', {
|
||||
patterns: [
|
||||
|
@ -83,4 +83,4 @@ module.exports = function (api) {
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('restore_snapshot', {
|
||||
methods: ['POST'],
|
||||
patterns: [
|
||||
|
@ -126,4 +126,4 @@ module.exports = function (api) {
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (api) {
|
||||
export default function (api) {
|
||||
api.addEndpointDescription('_delete_template', {
|
||||
methods: ['DELETE'],
|
||||
patterns: [
|
||||
|
@ -24,4 +24,4 @@ module.exports = function (api) {
|
|||
settings: { __scope_link: '_put_settings' }
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
let _ = require("lodash");
|
||||
|
||||
module.exports.resolveApi = function (sense_version, apis, reply) {
|
||||
export function resolveApi(sense_version, apis, reply) {
|
||||
let result = {};
|
||||
_.each(apis, function (name) {
|
||||
{
|
||||
|
@ -11,4 +11,4 @@ module.exports.resolveApi = function (sense_version, apis, reply) {
|
|||
});
|
||||
|
||||
return reply(result).type("application/json");
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Boom from 'boom';
|
||||
import apiServer from './api_server/server';
|
||||
import { resolveApi } from './api_server/server';
|
||||
import { existsSync } from 'fs';
|
||||
import { resolve, join, sep } from 'path';
|
||||
import { has, isEmpty } from 'lodash';
|
||||
|
@ -109,7 +109,7 @@ export default function (kibana) {
|
|||
return;
|
||||
}
|
||||
|
||||
return apiServer.resolveApi(sense_version, apis.split(','), reply);
|
||||
return resolveApi(sense_version, apis.split(','), reply);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
let kb = require('./kb');
|
||||
let utils = require('./utils');
|
||||
let autocomplete_engine = require('./autocomplete/engine');
|
||||
let url_pattern_matcher = require('./autocomplete/url_pattern_matcher');
|
||||
let _ = require('lodash');
|
||||
let ace = require('ace');
|
||||
require('ace/ext-language_tools');
|
||||
import {
|
||||
getTopLevelUrlCompleteComponents,
|
||||
getEndpointBodyCompleteComponents,
|
||||
getGlobalAutocompleteComponents,
|
||||
getUnmatchedEndpointComponents
|
||||
} from './kb';
|
||||
import utils from './utils';
|
||||
import { populateContext } from './autocomplete/engine';
|
||||
import { URL_PATH_END_MARKER } from './autocomplete/url_pattern_matcher';
|
||||
import _ from 'lodash';
|
||||
import ace from 'ace';
|
||||
import 'ace/ext-language_tools';
|
||||
|
||||
var AceRange = ace.require('ace/range').Range;
|
||||
|
||||
var LAST_EVALUATED_TOKEN = null;
|
||||
|
||||
module.exports = function (editor) {
|
||||
export default function (editor) {
|
||||
|
||||
function isSeparatorToken(token) {
|
||||
switch ((token || {}).type) {
|
||||
|
@ -505,7 +510,7 @@ module.exports = function (editor) {
|
|||
context.token = ret.token;
|
||||
context.otherTokenValues = ret.otherTokenValues;
|
||||
context.urlTokenPath = ret.urlTokenPath;
|
||||
autocomplete_engine.populateContext(ret.urlTokenPath, context, editor, true, kb.getTopLevelUrlCompleteComponents());
|
||||
populateContext(ret.urlTokenPath, context, editor, true, getTopLevelUrlCompleteComponents());
|
||||
context.autoCompleteSet = addMetaToTermsList(context.autoCompleteSet, "endpoint");
|
||||
}
|
||||
|
||||
|
@ -520,7 +525,7 @@ module.exports = function (editor) {
|
|||
return context;
|
||||
}
|
||||
|
||||
autocomplete_engine.populateContext(ret.urlTokenPath, context, editor, false, kb.getTopLevelUrlCompleteComponents());
|
||||
populateContext(ret.urlTokenPath, context, editor, false, getTopLevelUrlCompleteComponents());
|
||||
|
||||
if (!context.endpoint) {
|
||||
console.log("couldn't resolve an endpoint.");
|
||||
|
@ -537,7 +542,7 @@ module.exports = function (editor) {
|
|||
context.otherTokenValues = currentParam[tokenPath[0]];
|
||||
}
|
||||
|
||||
autocomplete_engine.populateContext(tokenPath, context, editor, true,
|
||||
populateContext(tokenPath, context, editor, true,
|
||||
context.endpoint.paramsAutocomplete.getTopLevelComponents());
|
||||
return context;
|
||||
}
|
||||
|
@ -554,7 +559,7 @@ module.exports = function (editor) {
|
|||
return context;
|
||||
}
|
||||
|
||||
autocomplete_engine.populateContext(ret.urlTokenPath, context, editor, false, kb.getTopLevelUrlCompleteComponents());
|
||||
populateContext(ret.urlTokenPath, context, editor, false, getTopLevelUrlCompleteComponents());
|
||||
|
||||
context.bodyTokenPath = ret.bodyTokenPath;
|
||||
if (!ret.bodyTokenPath) { // zero length tokenPath is true
|
||||
|
@ -564,16 +569,16 @@ module.exports = function (editor) {
|
|||
}
|
||||
|
||||
// needed for scope linking + global term resolving
|
||||
context.endpointComponentResolver = kb.getEndpointBodyCompleteComponents;
|
||||
context.globalComponentResolver = kb.getGlobalAutocompleteComponents;
|
||||
context.endpointComponentResolver = getEndpointBodyCompleteComponents;
|
||||
context.globalComponentResolver = getGlobalAutocompleteComponents;
|
||||
var components;
|
||||
if (context.endpoint) {
|
||||
components = context.endpoint.bodyAutocompleteRootComponents;
|
||||
}
|
||||
else {
|
||||
components = kb.getUnmatchedEndpointComponents();
|
||||
components = getUnmatchedEndpointComponents();
|
||||
}
|
||||
autocomplete_engine.populateContext(ret.bodyTokenPath, context, editor, true, components);
|
||||
populateContext(ret.bodyTokenPath, context, editor, true, components);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
@ -806,7 +811,7 @@ module.exports = function (editor) {
|
|||
}
|
||||
else {
|
||||
// mark the url as completed.
|
||||
ret.urlTokenPath.push(url_pattern_matcher.URL_PATH_END_MARKER);
|
||||
ret.urlTokenPath.push(URL_PATH_END_MARKER);
|
||||
}
|
||||
|
||||
if (t && t.type == "method") {
|
||||
|
@ -955,7 +960,7 @@ module.exports = function (editor) {
|
|||
ace.define('ace/autocomplete/text_completer', ['require', 'exports', 'module'], function (require, exports) {
|
||||
exports.getCompletions = function (editor, session, pos, prefix, callback) {
|
||||
callback(null, []);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var langTools = ace.require('ace/ext/language_tools');
|
||||
|
@ -1020,4 +1025,4 @@ module.exports = function (editor) {
|
|||
removeChangeListener: removeChangeListener
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -378,9 +378,9 @@ GlobalOnlyComponent.prototype = _.create(
|
|||
|
||||
|
||||
// a list of component that match anything but give auto complete suggestions based on global API entries.
|
||||
module.exports.globalsOnlyAutocompleteComponents = function () {
|
||||
export function globalsOnlyAutocompleteComponents() {
|
||||
return [new GlobalOnlyComponent("__global__")];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param endpoint_id id of the endpoint being compiled.
|
||||
|
@ -395,6 +395,6 @@ module.exports.globalsOnlyAutocompleteComponents = function () {
|
|||
* }
|
||||
* }
|
||||
*/
|
||||
module.exports.compileBodyDescription = function (endpoint_id, description, parametrizedComponentFactories) {
|
||||
export function compileBodyDescription(endpoint_id, description, parametrizedComponentFactories) {
|
||||
return compileDescription(description, new CompilingContext(endpoint_id, parametrizedComponentFactories));
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
let _ = require('lodash');
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports.AutocompleteComponent = function (name) {
|
||||
export function AutocompleteComponent(name) {
|
||||
this.name = name;
|
||||
};
|
||||
}
|
||||
|
||||
/** called to get the possible suggestions for tokens, when this object is at the end of
|
||||
* the resolving chain (and thus can suggest possible continuation paths)
|
||||
*/
|
||||
module.exports.AutocompleteComponent.prototype.getTerms = function () {
|
||||
AutocompleteComponent.prototype.getTerms = function () {
|
||||
return [];
|
||||
};
|
||||
|
||||
|
@ -21,14 +21,14 @@ module.exports.AutocompleteComponent.prototype.getTerms = function () {
|
|||
priority: optional priority to solve collisions between multiple paths. Min value is used across entire chain
|
||||
}
|
||||
*/
|
||||
module.exports.AutocompleteComponent.prototype.match = function () {
|
||||
AutocompleteComponent.prototype.match = function () {
|
||||
return {
|
||||
next: this.next
|
||||
};
|
||||
};
|
||||
|
||||
function SharedComponent(name, parent) {
|
||||
module.exports.AutocompleteComponent.call(this, name);
|
||||
AutocompleteComponent.call(this, name);
|
||||
this._nextDict = {};
|
||||
if (parent) {
|
||||
parent.addComponent(this);
|
||||
|
@ -38,11 +38,9 @@ function SharedComponent(name, parent) {
|
|||
}
|
||||
|
||||
SharedComponent.prototype = _.create(
|
||||
module.exports.AutocompleteComponent.prototype,
|
||||
AutocompleteComponent.prototype,
|
||||
{ 'constructor': SharedComponent });
|
||||
|
||||
module.exports.SharedComponent = SharedComponent;
|
||||
|
||||
(function (cls) {
|
||||
/* return the first component with a given name */
|
||||
cls.getComponent = function (name) {
|
||||
|
@ -69,7 +67,6 @@ function ListComponent(name, list, parent, multi_valued, allow_non_valid_values)
|
|||
}
|
||||
|
||||
ListComponent.prototype = _.create(SharedComponent.prototype, { "constructor": ListComponent });
|
||||
module.exports.ListComponent = ListComponent;
|
||||
|
||||
|
||||
(function (cls) {
|
||||
|
@ -142,7 +139,6 @@ function SimpleParamComponent(name, parent) {
|
|||
}
|
||||
|
||||
SimpleParamComponent.prototype = _.create(SharedComponent.prototype, { "constructor": SimpleParamComponent });
|
||||
module.exports.SimpleParamComponent = SimpleParamComponent;
|
||||
|
||||
(function (cls) {
|
||||
cls.match = function (token, context, editor) {
|
||||
|
@ -163,7 +159,8 @@ function ConstantComponent(name, parent, options) {
|
|||
}
|
||||
|
||||
ConstantComponent.prototype = _.create(SharedComponent.prototype, { "constructor": ConstantComponent });
|
||||
module.exports.ConstantComponent = ConstantComponent;
|
||||
|
||||
export { SharedComponent, ListComponent, SimpleParamComponent, ConstantComponent };
|
||||
|
||||
(function (cls) {
|
||||
cls.getTerms = function () {
|
||||
|
@ -188,7 +185,7 @@ module.exports.ConstantComponent = ConstantComponent;
|
|||
}
|
||||
})(ConstantComponent.prototype);
|
||||
|
||||
module.exports.wrapComponentWithDefaults = function (component, defaults) {
|
||||
export function wrapComponentWithDefaults(component, defaults) {
|
||||
function Wrapper() {
|
||||
|
||||
}
|
||||
|
@ -214,7 +211,7 @@ module.exports.wrapComponentWithDefaults = function (component, defaults) {
|
|||
return result;
|
||||
};
|
||||
return new Wrapper();
|
||||
};
|
||||
}
|
||||
|
||||
let tracer = function () {
|
||||
if (window.engine_trace) {
|
||||
|
@ -304,13 +301,13 @@ function walkTokenPath(tokenPath, walkingStates, context, editor) {
|
|||
return walkTokenPath(tokenPath.slice(1), nextWalkingStates, context, editor);
|
||||
}
|
||||
|
||||
module.exports.resolvePathToComponents = function (tokenPath, context, editor, components) {
|
||||
export function resolvePathToComponents(tokenPath, context, editor, components) {
|
||||
var walkStates = walkTokenPath(tokenPath, [new WalkingState("ROOT", components, [])], context, editor);
|
||||
var result = [].concat.apply([], _.pluck(walkStates, 'components'));
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports.populateContext = function (tokenPath, context, editor, includeAutoComplete, components) {
|
||||
export function populateContext(tokenPath, context, editor, includeAutoComplete, components) {
|
||||
|
||||
var walkStates = walkTokenPath(tokenPath, [new WalkingState("ROOT", components, [])], context, editor);
|
||||
if (includeAutoComplete) {
|
||||
|
@ -353,4 +350,4 @@ module.exports.populateContext = function (tokenPath, context, editor, includeAu
|
|||
_.assign(context, extension);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
let _ = require('lodash');
|
||||
let engine = require('./engine');
|
||||
|
||||
function ParamComponent(name, parent, description) {
|
||||
export function ParamComponent(name, parent, description) {
|
||||
engine.ConstantComponent.call(this, name, parent);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
ParamComponent.prototype = _.create(engine.ConstantComponent.prototype, { "constructor": ParamComponent });
|
||||
module.exports.ParamComponent = ParamComponent;
|
||||
|
||||
(function (cls) {
|
||||
cls.getTerms = function () {
|
||||
|
@ -24,7 +23,7 @@ module.exports.ParamComponent = ParamComponent;
|
|||
|
||||
})(ParamComponent.prototype);
|
||||
|
||||
function UrlParams(description, defaults) {
|
||||
export function UrlParams(description, defaults) {
|
||||
// This is not really a component, just a handy container to make iteration logic simpler
|
||||
this.rootComponent = new engine.SharedComponent("ROOT");
|
||||
if (_.isUndefined(defaults)) {
|
||||
|
@ -55,5 +54,3 @@ function UrlParams(description, defaults) {
|
|||
}
|
||||
|
||||
})(UrlParams.prototype);
|
||||
|
||||
module.exports.UrlParams = UrlParams;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
let _ = require('lodash');
|
||||
let engine = require('./engine');
|
||||
|
||||
module.exports.URL_PATH_END_MARKER = "__url_path_end__";
|
||||
|
||||
export const URL_PATH_END_MARKER = "__url_path_end__";
|
||||
|
||||
function AcceptEndpointComponent(endpoint, parent) {
|
||||
engine.SharedComponent.call(this, endpoint.id, parent);
|
||||
|
@ -14,7 +13,7 @@ AcceptEndpointComponent.prototype = _.create(engine.SharedComponent.prototype, {
|
|||
(function (cls) {
|
||||
|
||||
cls.match = function (token, context, editor) {
|
||||
if (token !== module.exports.URL_PATH_END_MARKER) {
|
||||
if (token !== URL_PATH_END_MARKER) {
|
||||
return null;
|
||||
}
|
||||
if (this.endpoint.methods && -1 === _.indexOf(this.endpoint.methods, context.method)) {
|
||||
|
@ -41,7 +40,7 @@ AcceptEndpointComponent.prototype = _.create(engine.SharedComponent.prototype, {
|
|||
* }
|
||||
* @constructor
|
||||
*/
|
||||
function UrlPatternMatcher(parametrizedComponentFactories) {
|
||||
export function UrlPatternMatcher(parametrizedComponentFactories) {
|
||||
// This is not really a component, just a handy container to make iteration logic simpler
|
||||
this.rootComponent = new engine.SharedComponent("ROOT");
|
||||
this.parametrizedComponentFactories = parametrizedComponentFactories || {};
|
||||
|
@ -120,5 +119,3 @@ function UrlPatternMatcher(parametrizedComponentFactories) {
|
|||
}
|
||||
|
||||
})(UrlPatternMatcher.prototype);
|
||||
|
||||
module.exports.UrlPatternMatcher = UrlPatternMatcher;
|
||||
|
|
|
@ -1,102 +1,167 @@
|
|||
define(function () {
|
||||
'use strict';
|
||||
function detectCURLinLine(line) {
|
||||
// returns true if text matches a curl request
|
||||
return line.match(/^\s*?curl\s+(-X[A-Z]+)?\s*['"]?.*?['"]?(\s*$|\s+?-d\s*?['"])/);
|
||||
}
|
||||
|
||||
function detectCURLinLine(line) {
|
||||
// returns true if text matches a curl request
|
||||
return line.match(/^\s*?curl\s+(-X[A-Z]+)?\s*['"]?.*?['"]?(\s*$|\s+?-d\s*?['"])/);
|
||||
|
||||
}
|
||||
|
||||
function detectCURL(text) {
|
||||
// returns true if text matches a curl request
|
||||
if (!text) return false;
|
||||
for (var line of text.split("\n")) {
|
||||
if (detectCURLinLine(line)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseCURL(text) {
|
||||
var state = 'NONE';
|
||||
var out = [];
|
||||
var body = [];
|
||||
var line = '';
|
||||
var lines = text.trim().split("\n");
|
||||
var matches;
|
||||
|
||||
var EmptyLine = /^\s*$/;
|
||||
var Comment = /^\s*(?:#|\/{2,})(.*)\n?$/;
|
||||
var ExecutionComment = /^\s*#!/;
|
||||
var ClosingSingleQuote = /^([^']*)'/;
|
||||
var ClosingDoubleQuote = /^((?:[^\\"]|\\.)*)"/;
|
||||
var EscapedQuotes = /^((?:[^\\"']|\\.)+)/;
|
||||
|
||||
var LooksLikeCurl = /^\s*curl\s+/;
|
||||
var CurlVerb = /-X ?(GET|HEAD|POST|PUT|DELETE)/;
|
||||
|
||||
var HasProtocol = /[\s"']https?:\/\//;
|
||||
var CurlRequestWithProto = /[\s"']https?:\/\/[^\/ ]+\/+([^\s"']+)/;
|
||||
var CurlRequestWithoutProto = /[\s"'][^\/ ]+\/+([^\s"']+)/;
|
||||
var CurlData = /^.+\s(--data|-d)\s*/;
|
||||
var SenseLine = /^\s*(GET|HEAD|POST|PUT|DELETE)\s+\/?(.+)/;
|
||||
|
||||
if (lines.length > 0 && ExecutionComment.test(lines[0])) {
|
||||
lines.shift();
|
||||
}
|
||||
|
||||
function nextLine() {
|
||||
if (line.length > 0) {
|
||||
return true;
|
||||
}
|
||||
if (lines.length == 0) {
|
||||
return false;
|
||||
}
|
||||
line = lines.shift().replace(/[\r\n]+/g, "\n") + "\n";
|
||||
export function detectCURL(text) {
|
||||
// returns true if text matches a curl request
|
||||
if (!text) return false;
|
||||
for (var line of text.split("\n")) {
|
||||
if (detectCURLinLine(line)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function unescapeLastBodyEl() {
|
||||
var str = body.pop().replace(/\\([\\"'])/g, "$1");
|
||||
body.push(str);
|
||||
export function parseCURL(text) {
|
||||
var state = 'NONE';
|
||||
var out = [];
|
||||
var body = [];
|
||||
var line = '';
|
||||
var lines = text.trim().split("\n");
|
||||
var matches;
|
||||
|
||||
var EmptyLine = /^\s*$/;
|
||||
var Comment = /^\s*(?:#|\/{2,})(.*)\n?$/;
|
||||
var ExecutionComment = /^\s*#!/;
|
||||
var ClosingSingleQuote = /^([^']*)'/;
|
||||
var ClosingDoubleQuote = /^((?:[^\\"]|\\.)*)"/;
|
||||
var EscapedQuotes = /^((?:[^\\"']|\\.)+)/;
|
||||
|
||||
var LooksLikeCurl = /^\s*curl\s+/;
|
||||
var CurlVerb = /-X ?(GET|HEAD|POST|PUT|DELETE)/;
|
||||
|
||||
var HasProtocol = /[\s"']https?:\/\//;
|
||||
var CurlRequestWithProto = /[\s"']https?:\/\/[^\/ ]+\/+([^\s"']+)/;
|
||||
var CurlRequestWithoutProto = /[\s"'][^\/ ]+\/+([^\s"']+)/;
|
||||
var CurlData = /^.+\s(--data|-d)\s*/;
|
||||
var SenseLine = /^\s*(GET|HEAD|POST|PUT|DELETE)\s+\/?(.+)/;
|
||||
|
||||
if (lines.length > 0 && ExecutionComment.test(lines[0])) {
|
||||
lines.shift();
|
||||
}
|
||||
|
||||
function nextLine() {
|
||||
if (line.length > 0) {
|
||||
return true;
|
||||
}
|
||||
if (lines.length == 0) {
|
||||
return false;
|
||||
}
|
||||
line = lines.shift().replace(/[\r\n]+/g, "\n") + "\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
function unescapeLastBodyEl() {
|
||||
var str = body.pop().replace(/\\([\\"'])/g, "$1");
|
||||
body.push(str);
|
||||
}
|
||||
|
||||
// Is the next char a single or double quote?
|
||||
// If so remove it
|
||||
function detectQuote() {
|
||||
if (line.substr(0, 1) == "'") {
|
||||
line = line.substr(1);
|
||||
state = 'SINGLE_QUOTE';
|
||||
}
|
||||
else if (line.substr(0, 1) == '"') {
|
||||
line = line.substr(1);
|
||||
state = 'DOUBLE_QUOTE';
|
||||
}
|
||||
else {
|
||||
state = 'UNQUOTED';
|
||||
}
|
||||
}
|
||||
|
||||
// Body is finished - append to output with final LF
|
||||
function addBodyToOut() {
|
||||
if (body.length > 0) {
|
||||
out.push(body.join(""));
|
||||
body = [];
|
||||
}
|
||||
state = 'LF';
|
||||
out.push("\n");
|
||||
}
|
||||
|
||||
// If the pattern matches, then the state is about to change,
|
||||
// so add the capture to the body and detect the next state
|
||||
// Otherwise add the whole line
|
||||
function consumeMatching(pattern) {
|
||||
var matches = line.match(pattern);
|
||||
if (matches) {
|
||||
body.push(matches[1]);
|
||||
line = line.substr(matches[0].length);
|
||||
detectQuote();
|
||||
}
|
||||
else {
|
||||
body.push(line);
|
||||
line = '';
|
||||
}
|
||||
}
|
||||
|
||||
function parseCurlLine() {
|
||||
var verb = 'GET';
|
||||
var request = '';
|
||||
var matches;
|
||||
if (matches = line.match(CurlVerb)) {
|
||||
verb = matches[1];
|
||||
}
|
||||
|
||||
// Is the next char a single or double quote?
|
||||
// If so remove it
|
||||
function detectQuote() {
|
||||
if (line.substr(0, 1) == "'") {
|
||||
line = line.substr(1);
|
||||
state = 'SINGLE_QUOTE';
|
||||
// JS regexen don't support possesive quantifiers, so
|
||||
// we need two distinct patterns
|
||||
var pattern = HasProtocol.test(line)
|
||||
? CurlRequestWithProto
|
||||
: CurlRequestWithoutProto;
|
||||
|
||||
if (matches = line.match(pattern)) {
|
||||
request = matches[1];
|
||||
}
|
||||
|
||||
out.push(verb + ' /' + request + "\n");
|
||||
|
||||
if (matches = line.match(CurlData)) {
|
||||
line = line.substr(matches[0].length);
|
||||
detectQuote();
|
||||
if (EmptyLine.test(line)) {
|
||||
line = '';
|
||||
}
|
||||
else if (line.substr(0, 1) == '"') {
|
||||
line = line.substr(1);
|
||||
state = 'DOUBLE_QUOTE';
|
||||
}
|
||||
else {
|
||||
state = 'NONE';
|
||||
line = '';
|
||||
out.push('');
|
||||
}
|
||||
}
|
||||
|
||||
while (nextLine()) {
|
||||
|
||||
if (state == 'SINGLE_QUOTE') {
|
||||
consumeMatching(ClosingSingleQuote);
|
||||
}
|
||||
|
||||
else if (state == 'DOUBLE_QUOTE') {
|
||||
consumeMatching(ClosingDoubleQuote);
|
||||
unescapeLastBodyEl();
|
||||
}
|
||||
|
||||
else if (state == 'UNQUOTED') {
|
||||
consumeMatching(EscapedQuotes);
|
||||
if (body.length) {
|
||||
unescapeLastBodyEl();
|
||||
}
|
||||
else {
|
||||
state = 'UNQUOTED';
|
||||
if (state == 'UNQUOTED') {
|
||||
addBodyToOut();
|
||||
line = ''
|
||||
}
|
||||
}
|
||||
|
||||
// Body is finished - append to output with final LF
|
||||
function addBodyToOut() {
|
||||
if (body.length > 0) {
|
||||
out.push(body.join(""));
|
||||
body = [];
|
||||
}
|
||||
state = 'LF';
|
||||
out.push("\n");
|
||||
}
|
||||
|
||||
// If the pattern matches, then the state is about to change,
|
||||
// so add the capture to the body and detect the next state
|
||||
// Otherwise add the whole line
|
||||
function consumeMatching(pattern) {
|
||||
var matches = line.match(pattern);
|
||||
if (matches) {
|
||||
body.push(matches[1]);
|
||||
line = line.substr(matches[0].length);
|
||||
detectQuote();
|
||||
// the BODY state (used to match the body of a Sense request)
|
||||
// can be terminated early if it encounters
|
||||
// a comment or an empty line
|
||||
else if (state == 'BODY') {
|
||||
if (Comment.test(line) || EmptyLine.test(line)) {
|
||||
addBodyToOut();
|
||||
}
|
||||
else {
|
||||
body.push(line);
|
||||
|
@ -104,114 +169,37 @@ define(function () {
|
|||
}
|
||||
}
|
||||
|
||||
function parseCurlLine() {
|
||||
var verb = 'GET';
|
||||
var request = '';
|
||||
var matches;
|
||||
if (matches = line.match(CurlVerb)) {
|
||||
verb = matches[1];
|
||||
}
|
||||
|
||||
// JS regexen don't support possesive quantifiers, so
|
||||
// we need two distinct patterns
|
||||
var pattern = HasProtocol.test(line)
|
||||
? CurlRequestWithProto
|
||||
: CurlRequestWithoutProto;
|
||||
|
||||
if (matches = line.match(pattern)) {
|
||||
request = matches[1];
|
||||
}
|
||||
|
||||
out.push(verb + ' /' + request + "\n");
|
||||
|
||||
if (matches = line.match(CurlData)) {
|
||||
line = line.substr(matches[0].length);
|
||||
detectQuote();
|
||||
if (EmptyLine.test(line)) {
|
||||
line = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
state = 'NONE';
|
||||
line = '';
|
||||
out.push('');
|
||||
else if (EmptyLine.test(line)) {
|
||||
if (state != 'LF') {
|
||||
out.push("\n");
|
||||
state = 'LF';
|
||||
}
|
||||
line = '';
|
||||
}
|
||||
|
||||
while (nextLine()) {
|
||||
|
||||
if (state == 'SINGLE_QUOTE') {
|
||||
consumeMatching(ClosingSingleQuote);
|
||||
}
|
||||
|
||||
else if (state == 'DOUBLE_QUOTE') {
|
||||
consumeMatching(ClosingDoubleQuote);
|
||||
unescapeLastBodyEl();
|
||||
}
|
||||
|
||||
else if (state == 'UNQUOTED') {
|
||||
consumeMatching(EscapedQuotes);
|
||||
if (body.length) {
|
||||
unescapeLastBodyEl();
|
||||
}
|
||||
if (state == 'UNQUOTED') {
|
||||
addBodyToOut();
|
||||
line = ''
|
||||
}
|
||||
}
|
||||
|
||||
// the BODY state (used to match the body of a Sense request)
|
||||
// can be terminated early if it encounters
|
||||
// a comment or an empty line
|
||||
else if (state == 'BODY') {
|
||||
if (Comment.test(line) || EmptyLine.test(line)) {
|
||||
addBodyToOut();
|
||||
}
|
||||
else {
|
||||
body.push(line);
|
||||
line = '';
|
||||
}
|
||||
}
|
||||
|
||||
else if (EmptyLine.test(line)) {
|
||||
if (state != 'LF') {
|
||||
out.push("\n");
|
||||
state = 'LF';
|
||||
}
|
||||
line = '';
|
||||
}
|
||||
|
||||
else if (matches = line.match(Comment)) {
|
||||
out.push("#" + matches[1] + "\n");
|
||||
state = 'NONE';
|
||||
line = '';
|
||||
}
|
||||
|
||||
else if (LooksLikeCurl.test(line)) {
|
||||
parseCurlLine();
|
||||
}
|
||||
|
||||
else if (matches = line.match(SenseLine)) {
|
||||
out.push(matches[1] + ' /' + matches[2] + "\n");
|
||||
line = '';
|
||||
state = 'BODY';
|
||||
}
|
||||
|
||||
// Nothing else matches, so output with a prefix of !!! for debugging purposes
|
||||
else {
|
||||
out.push('### ' + line);
|
||||
line = '';
|
||||
}
|
||||
else if (matches = line.match(Comment)) {
|
||||
out.push("#" + matches[1] + "\n");
|
||||
state = 'NONE';
|
||||
line = '';
|
||||
}
|
||||
|
||||
addBodyToOut();
|
||||
return out.join('').trim();
|
||||
else if (LooksLikeCurl.test(line)) {
|
||||
parseCurlLine();
|
||||
}
|
||||
|
||||
else if (matches = line.match(SenseLine)) {
|
||||
out.push(matches[1] + ' /' + matches[2] + "\n");
|
||||
line = '';
|
||||
state = 'BODY';
|
||||
}
|
||||
|
||||
// Nothing else matches, so output with a prefix of !!! for debugging purposes
|
||||
else {
|
||||
out.push('### ' + line);
|
||||
line = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
parseCURL: parseCURL,
|
||||
detectCURL: detectCURL
|
||||
};
|
||||
|
||||
});
|
||||
addBodyToOut();
|
||||
return out.join('').trim();
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
import { stringify as formatQueryString } from 'querystring'
|
||||
|
||||
import $ from 'jquery';
|
||||
|
||||
let esVersion = [];
|
||||
|
||||
module.exports.getVersion = function () {
|
||||
export function getVersion() {
|
||||
return esVersion;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports.send = function (method, path, data) {
|
||||
export function send(method, path, data) {
|
||||
var wrappedDfd = $.Deferred();
|
||||
|
||||
console.log("Calling " + path);
|
||||
|
@ -57,10 +56,10 @@ module.exports.send = function (method, path, data) {
|
|||
wrappedDfd.rejectWith(this, [jqXHR, textStatus, errorThrown]);
|
||||
});
|
||||
return wrappedDfd;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports.constructESUrl = function (baseUri, path) {
|
||||
export function constructESUrl(baseUri, path) {
|
||||
baseUri = baseUri.replace(/\/+$/, '');
|
||||
path = path.replace(/^\/+/, '');
|
||||
return baseUri + '/' + path;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const $ = require('jquery');
|
||||
const storage = require('./storage');
|
||||
|
||||
const history = module.exports = {
|
||||
const history = {
|
||||
restoreFromHistory() {
|
||||
// default method for history.restoreFromHistory
|
||||
// replace externally to do something when the user chooses
|
||||
|
@ -60,3 +60,5 @@ const history = module.exports = {
|
|||
.forEach(key => storage.delete(key));
|
||||
}
|
||||
};
|
||||
|
||||
export default history;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const $ = require('jquery');
|
||||
const storage = require('./storage');
|
||||
|
||||
module.exports = function (input, output) {
|
||||
export default function (input, output) {
|
||||
|
||||
const $left = input.$el.parent();
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
let $ = require('jquery');
|
||||
let _ = require('lodash');
|
||||
let mappings = require('./mappings');
|
||||
let Api = require('./kb/api');
|
||||
let autocomplete_engine = require('./autocomplete/engine');
|
||||
const $ = require('jquery');
|
||||
const _ = require('lodash');
|
||||
const mappings = require('./mappings');
|
||||
const Api = require('./kb/api');
|
||||
const autocomplete_engine = require('./autocomplete/engine');
|
||||
|
||||
var ACTIVE_API = new Api();
|
||||
let ACTIVE_API = new Api();
|
||||
|
||||
function nonValidIndexType(token) {
|
||||
return !(token === "_all" || token[0] !== "_");
|
||||
|
@ -166,15 +166,15 @@ var parametrizedComponentFactories = {
|
|||
}
|
||||
};
|
||||
|
||||
function getUnmatchedEndpointComponents() {
|
||||
export function getUnmatchedEndpointComponents() {
|
||||
return ACTIVE_API.getUnmatchedEndpointComponents();
|
||||
}
|
||||
|
||||
function getEndpointDescriptionByEndpoint(endpoint) {
|
||||
export function getEndpointDescriptionByEndpoint(endpoint) {
|
||||
return ACTIVE_API.getEndpointDescriptionByEndpoint(endpoint)
|
||||
}
|
||||
|
||||
function getEndpointBodyCompleteComponents(endpoint) {
|
||||
export function getEndpointBodyCompleteComponents(endpoint) {
|
||||
var desc = getEndpointDescriptionByEndpoint(endpoint);
|
||||
if (!desc) {
|
||||
throw new Error("failed to resolve endpoint ['" + endpoint + "']");
|
||||
|
@ -182,11 +182,11 @@ function getEndpointBodyCompleteComponents(endpoint) {
|
|||
return desc.bodyAutocompleteRootComponents;
|
||||
}
|
||||
|
||||
function getTopLevelUrlCompleteComponents() {
|
||||
export function getTopLevelUrlCompleteComponents() {
|
||||
return ACTIVE_API.getTopLevelUrlCompleteComponents();
|
||||
}
|
||||
|
||||
function getGlobalAutocompleteComponents(term, throwOnMissing) {
|
||||
export function getGlobalAutocompleteComponents(term, throwOnMissing) {
|
||||
return ACTIVE_API.getGlobalAutocompleteComponents(term, throwOnMissing);
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ function loadApisFromJson(json, urlParametrizedComponentFactories, bodyParametri
|
|||
return api;
|
||||
}
|
||||
|
||||
function setActiveApi(api) {
|
||||
export function setActiveApi(api) {
|
||||
if (_.isString(api)) {
|
||||
$.ajax({
|
||||
url: '../api/console/api_server?sense_version=' + encodeURIComponent('@@SENSE_VERSION') + "&apis=" + encodeURIComponent(api),
|
||||
|
@ -231,13 +231,6 @@ function setActiveApi(api) {
|
|||
|
||||
setActiveApi('es_5_0');
|
||||
|
||||
module.exports.setActiveApi = setActiveApi;
|
||||
module.exports.getGlobalAutocompleteComponents = getGlobalAutocompleteComponents;
|
||||
module.exports.getEndpointDescriptionByEndpoint = getEndpointDescriptionByEndpoint;
|
||||
module.exports.getEndpointBodyCompleteComponents = getEndpointBodyCompleteComponents;
|
||||
module.exports.getTopLevelUrlCompleteComponents = getTopLevelUrlCompleteComponents;
|
||||
module.exports.getUnmatchedEndpointComponents = getUnmatchedEndpointComponents;
|
||||
|
||||
module.exports._test = {
|
||||
export const _test = {
|
||||
loadApisFromJson: loadApisFromJson
|
||||
};
|
||||
|
|
|
@ -73,4 +73,4 @@ function Api(urlParametrizedComponentFactories, bodyParametrizedComponentFactori
|
|||
}(Api.prototype));
|
||||
|
||||
|
||||
module.exports = Api;
|
||||
export default Api;
|
||||
|
|
|
@ -278,7 +278,7 @@ function autocomplete_retriever() {
|
|||
}, 60000);
|
||||
}
|
||||
|
||||
module.exports = _.assign(mappingObj, {
|
||||
export default _.assign(mappingObj, {
|
||||
getFields: getFields,
|
||||
getIndices: getIndices,
|
||||
getTypes: getTypes,
|
||||
|
|
|
@ -47,7 +47,7 @@ function createInstance($el) {
|
|||
return editor;
|
||||
}
|
||||
|
||||
function SenseEditor($el) {
|
||||
export default function SenseEditor($el) {
|
||||
var editor = createInstance($el);
|
||||
var CURRENT_REQ_RANGE = null;
|
||||
|
||||
|
@ -632,5 +632,3 @@ function SenseEditor($el) {
|
|||
|
||||
return editor;
|
||||
}
|
||||
|
||||
module.exports = SenseEditor;
|
||||
|
|
|
@ -15,8 +15,7 @@ var HighlightRules = require("./input_highlight_rules").InputHighlightRules;
|
|||
|
||||
acequire("ace/config").setModuleUrl("sense_editor/mode/worker", require("file!./worker.js"));
|
||||
|
||||
|
||||
var Mode = function () {
|
||||
export function Mode() {
|
||||
this.$tokenizer = new AceTokenizer(new HighlightRules().getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
|
@ -24,7 +23,7 @@ var Mode = function () {
|
|||
this.createModeDelegates({
|
||||
"script-": ScriptMode
|
||||
});
|
||||
};
|
||||
}
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function () {
|
||||
|
@ -72,5 +71,3 @@ oop.inherits(Mode, TextMode);
|
|||
|
||||
|
||||
}).call(Mode.prototype);
|
||||
|
||||
module.exports.Mode = Mode;
|
||||
|
|
|
@ -4,8 +4,7 @@ let x_json = require('./x_json_highlight_rules');
|
|||
var oop = ace.require("ace/lib/oop");
|
||||
var TextHighlightRules = ace.require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var InputHighlightRules = function () {
|
||||
|
||||
export function InputHighlightRules() {
|
||||
function mergeTokens(/* ... */) {
|
||||
return [].concat.apply([], arguments);
|
||||
}
|
||||
|
@ -66,9 +65,6 @@ var InputHighlightRules = function () {
|
|||
this.normalizeRules();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
oop.inherits(InputHighlightRules, TextHighlightRules);
|
||||
|
||||
|
||||
module.exports.InputHighlightRules = InputHighlightRules;
|
||||
|
|
|
@ -12,12 +12,12 @@ var CStyleFoldMode = ace.require("ace/mode/folding/cstyle").FoldMode;
|
|||
ace.require("ace/worker/worker_client");
|
||||
var AceTokenizer = ace.require("ace/tokenizer").Tokenizer;
|
||||
|
||||
var Mode = function () {
|
||||
export function Mode() {
|
||||
this.$tokenizer = new AceTokenizer(new HighlightRules().getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
}
|
||||
oop.inherits(Mode, JSONMode);
|
||||
|
||||
(function () {
|
||||
|
@ -27,5 +27,3 @@ oop.inherits(Mode, JSONMode);
|
|||
|
||||
this.$id = "sense/mode/input";
|
||||
}).call(Mode.prototype);
|
||||
|
||||
module.exports.Mode = Mode;
|
||||
|
|
|
@ -5,7 +5,7 @@ let x_json = require('./x_json_highlight_rules');
|
|||
var oop = ace.require("ace/lib/oop");
|
||||
var JsonHighlightRules = ace.require("ace/mode/json_highlight_rules").JsonHighlightRules;
|
||||
|
||||
var OutputJsonHighlightRules = function () {
|
||||
export function OutputJsonHighlightRules() {
|
||||
|
||||
this.$rules = {};
|
||||
|
||||
|
@ -26,8 +26,6 @@ var OutputJsonHighlightRules = function () {
|
|||
this.normalizeRules();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
oop.inherits(OutputJsonHighlightRules, JsonHighlightRules);
|
||||
|
||||
module.exports.OutputJsonHighlightRules = OutputJsonHighlightRules;
|
||||
|
|
|
@ -11,12 +11,12 @@ acequire("ace/tokenizer")
|
|||
|
||||
var ScriptHighlightRules = require("./script_highlight_rules").ScriptHighlightRules;
|
||||
|
||||
|
||||
export var ScriptMode = function () {
|
||||
export function ScriptMode() {
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
}
|
||||
|
||||
oop.inherits(ScriptMode, TextMode);
|
||||
|
||||
(function () {
|
||||
|
|
|
@ -7,7 +7,7 @@ let painlessKeywords = (
|
|||
"def|int|long|byte|String|float|double|char|null|if|else|while|do|for|continue|break|new|try|catch|throw|this|instanceof|return|ctx"
|
||||
);
|
||||
|
||||
export var ScriptHighlightRules = function () {
|
||||
export function ScriptHighlightRules() {
|
||||
this.name = "ScriptHighlightRules";
|
||||
this.$rules = {
|
||||
"start": [
|
||||
|
@ -61,5 +61,6 @@ export var ScriptHighlightRules = function () {
|
|||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
oop.inherits(ScriptHighlightRules, TextHighlightRules);
|
|
@ -101,7 +101,7 @@ var jsonRules = function (root) {
|
|||
return rules;
|
||||
};
|
||||
|
||||
module.exports.addToRules = function (otherRules, embedUnder) {
|
||||
export function addToRules(otherRules, embedUnder) {
|
||||
otherRules.$rules = _.defaultsDeep(otherRules.$rules, jsonRules(embedUnder));
|
||||
otherRules.embedRules(ScriptHighlightRules, "script-", [{
|
||||
token: "punctuation.end_triple_quote",
|
||||
|
|
|
@ -120,4 +120,4 @@ function RowParser(editor) {
|
|||
|
||||
RowParser.prototype.MODE = MODE;
|
||||
|
||||
module.exports = RowParser;
|
||||
export default RowParser;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { throttle } from 'lodash';
|
||||
|
||||
module.exports = function (editor) {
|
||||
export default function (editor) {
|
||||
const resize = editor.resize;
|
||||
return throttle(() => resize.call(editor), 35)
|
||||
};
|
||||
}
|
||||
|
|
|
@ -55,4 +55,6 @@ class Storage {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = new Storage(localStorage, 'sense:');
|
||||
const instance = new Storage(localStorage, 'sense:');
|
||||
|
||||
export default instance;
|
||||
|
|
|
@ -98,4 +98,4 @@ utils.splitOnUnquotedCommaSpace = function (s) {
|
|||
return arr;
|
||||
}
|
||||
|
||||
module.exports = utils;
|
||||
export default utils;
|
||||
|
|
|
@ -9,4 +9,4 @@ if (angular.mocks) {
|
|||
);
|
||||
}
|
||||
|
||||
module.exports = angular.mock;
|
||||
export default angular.mock;
|
||||
|
|
|
@ -9,11 +9,11 @@ import { clientLogger } from './lib/client_logger';
|
|||
import { createClusters } from './lib/create_clusters';
|
||||
import filterHeaders from './lib/filter_headers';
|
||||
|
||||
import createProxy, { createPath } from './lib/create_proxy';
|
||||
import { createProxy, createPath } from './lib/create_proxy';
|
||||
|
||||
const DEFAULT_REQUEST_HEADERS = [ 'authorization' ];
|
||||
|
||||
module.exports = function (kibana) {
|
||||
export default function (kibana) {
|
||||
return new kibana.Plugin({
|
||||
require: ['kibana'],
|
||||
config(Joi) {
|
||||
|
@ -166,4 +166,4 @@ module.exports = function (kibana) {
|
|||
}
|
||||
});
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
import expect from 'expect.js';
|
||||
import createProxy from '../create_proxy';
|
||||
import { createPath } from '../create_proxy';
|
||||
|
||||
describe('plugins/elasticsearch', function () {
|
||||
describe('lib/create_proxy', function () {
|
||||
describe('#createPath', function () {
|
||||
it('prepends /elasticsearch to route', function () {
|
||||
const path = createProxy.createPath('/foobar', '/wat');
|
||||
const path = createPath('/foobar', '/wat');
|
||||
expect(path).to.equal('/foobar/wat');
|
||||
});
|
||||
|
||||
it('ensures leading slash for prefix', function () {
|
||||
const path = createProxy.createPath('foobar', '/wat');
|
||||
const path = createPath('foobar', '/wat');
|
||||
expect(path).to.equal('/foobar/wat');
|
||||
});
|
||||
|
||||
it('ensures leading slash for path', function () {
|
||||
const path = createProxy.createPath('/foobar', 'wat');
|
||||
const path = createPath('/foobar', 'wat');
|
||||
expect(path).to.equal('/foobar/wat');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Promise from 'bluebird';
|
||||
import portscanner from 'portscanner';
|
||||
|
||||
module.exports = function findPort(start, end, host) {
|
||||
export default function findPort(start, end, host) {
|
||||
host = host || 'localhost';
|
||||
return new Promise(function (resolve, reject) {
|
||||
portscanner.findAPortNotInUse(start, end, host, function (err, port) {
|
||||
|
@ -9,5 +9,5 @@ module.exports = function findPort(start, end, host) {
|
|||
resolve(port);
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = {
|
||||
export default {
|
||||
'_default_': {
|
||||
'dynamic': 'strict'
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (server, mappings) {
|
||||
export default function (server, mappings) {
|
||||
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin');
|
||||
const index = server.config().get('kibana.index');
|
||||
return callWithInternalUser('indices.create', {
|
||||
|
@ -24,4 +24,4 @@ module.exports = function (server, mappings) {
|
|||
throw new Error(`Waiting for Kibana index "${index}" to come online failed.`);
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,7 +2,14 @@ import createAgent from './create_agent';
|
|||
import mapUri from './map_uri';
|
||||
import { assign } from 'lodash';
|
||||
|
||||
function createProxy(server, method, path, config) {
|
||||
export function createPath(prefix, path) {
|
||||
path = path[0] === '/' ? path : `/${path}`;
|
||||
prefix = prefix[0] === '/' ? prefix : `/${prefix}`;
|
||||
|
||||
return `${prefix}${path}`;
|
||||
}
|
||||
|
||||
export function createProxy(server, method, path, config) {
|
||||
const proxies = new Map([
|
||||
['/elasticsearch', server.plugins.elasticsearch.getCluster('data')],
|
||||
['/es_admin', server.plugins.elasticsearch.getCluster('admin')]
|
||||
|
@ -25,7 +32,7 @@ function createProxy(server, method, path, config) {
|
|||
for (const [proxyPrefix, cluster] of proxies) {
|
||||
const options = {
|
||||
method,
|
||||
path: createProxy.createPath(proxyPrefix, path),
|
||||
path: createPath(proxyPrefix, path),
|
||||
config: {
|
||||
timeout: {
|
||||
socket: cluster.getRequestTimeout()
|
||||
|
@ -50,12 +57,3 @@ function createProxy(server, method, path, config) {
|
|||
server.route(options);
|
||||
}
|
||||
}
|
||||
|
||||
createProxy.createPath = function createPath(prefix, path) {
|
||||
path = path[0] === '/' ? path : `/${path}`;
|
||||
prefix = prefix[0] === '/' ? prefix : `/${prefix}`;
|
||||
|
||||
return `${prefix}${path}`;
|
||||
};
|
||||
|
||||
module.exports = createProxy;
|
||||
|
|
|
@ -16,7 +16,7 @@ const NO_INDEX = 'no_index';
|
|||
const INITIALIZING = 'initializing';
|
||||
const READY = 'ready';
|
||||
|
||||
module.exports = function (plugin, server, { mappings }) {
|
||||
export default function (plugin, server, { mappings }) {
|
||||
const config = server.config();
|
||||
const callAdminAsKibanaUser = server.plugins.elasticsearch.getCluster('admin').callWithInternalUser;
|
||||
const callDataAsKibanaUser = server.plugins.elasticsearch.getCluster('data').callWithInternalUser;
|
||||
|
@ -146,4 +146,4 @@ module.exports = function (plugin, server, { mappings }) {
|
|||
isRunning: function () { return !!timeoutId; },
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import semver from 'semver';
|
||||
const rcVersionRegex = /(\d+\.\d+\.\d+)\-rc(\d+)/i;
|
||||
|
||||
module.exports = function (server, doc) {
|
||||
export default function (server, doc) {
|
||||
const config = server.config();
|
||||
if (/alpha|beta|snapshot/i.test(doc._id)) return false;
|
||||
if (!doc._id) return false;
|
||||
|
@ -30,4 +30,4 @@ module.exports = function (server, doc) {
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { get } from 'lodash';
|
||||
import upgrade from './upgrade_config';
|
||||
|
||||
module.exports = function (server, { mappings }) {
|
||||
export default function (server, { mappings }) {
|
||||
const config = server.config();
|
||||
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin');
|
||||
const options = {
|
||||
|
@ -21,4 +21,4 @@ module.exports = function (server, { mappings }) {
|
|||
};
|
||||
|
||||
return callWithInternalUser('search', options).then(upgrade(server));
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import Promise from 'bluebird';
|
|||
import isUpgradeable from './is_upgradeable';
|
||||
import _ from 'lodash';
|
||||
|
||||
module.exports = function (server) {
|
||||
export default function (server) {
|
||||
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin');
|
||||
const config = server.config();
|
||||
|
||||
|
@ -54,4 +54,4 @@ module.exports = function (server) {
|
|||
id: config.get('pkg.version')
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,20 +3,18 @@
|
|||
// e.g. a pattern with title `logstash-*` will have a matching template named `kibana-logstash-*`.
|
||||
// This module provides utility functions for easily converting between template and pattern names.
|
||||
|
||||
module.exports = {
|
||||
ingestToPattern: (templateName) => {
|
||||
if (templateName.indexOf('kibana-') === -1) {
|
||||
throw new Error('not a valid kibana namespaced template name');
|
||||
}
|
||||
|
||||
return templateName.slice(templateName.indexOf('-') + 1);
|
||||
},
|
||||
|
||||
patternToIngest: (patternName) => {
|
||||
if (patternName === '') {
|
||||
throw new Error('pattern must not be empty');
|
||||
}
|
||||
|
||||
return `kibana-${patternName.toLowerCase()}`;
|
||||
export function ingestToPattern(templateName) {
|
||||
if (templateName.indexOf('kibana-') === -1) {
|
||||
throw new Error('not a valid kibana namespaced template name');
|
||||
}
|
||||
};
|
||||
|
||||
return templateName.slice(templateName.indexOf('-') + 1);
|
||||
}
|
||||
|
||||
export function patternToIngest(patternName) {
|
||||
if (patternName === '') {
|
||||
throw new Error('pattern must not be empty');
|
||||
}
|
||||
|
||||
return `kibana-${patternName.toLowerCase()}`;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { injectVars } from './inject_vars';
|
|||
|
||||
const mkdirp = Promise.promisify(mkdirpNode);
|
||||
|
||||
module.exports = function (kibana) {
|
||||
export default function (kibana) {
|
||||
const kbnBaseUrl = '/app/kibana';
|
||||
return new kibana.Plugin({
|
||||
id: 'kibana',
|
||||
|
@ -133,4 +133,4 @@ module.exports = function (kibana) {
|
|||
server.expose('injectVars', injectVars);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,66 +1,63 @@
|
|||
define(function () {
|
||||
return function HitSortFnFactory() {
|
||||
// eslint-disable-next-line kibana-custom/no-default-export
|
||||
export default function HitSortFnFactory() {
|
||||
/**
|
||||
* Creates a sort function that will resort hits based on the value
|
||||
* es used to sort them.
|
||||
*
|
||||
* background:
|
||||
* When a hit is sorted by elasticsearch, es will write the values that it used
|
||||
* to sort them into an array at the top level of the hit like so
|
||||
*
|
||||
* ```
|
||||
* hits: {
|
||||
* total: x,
|
||||
* hits: [
|
||||
* {
|
||||
* _id: i,
|
||||
* _source: {},
|
||||
* sort: [
|
||||
* // all values used to sort, in the order of precidance
|
||||
* ]
|
||||
* }
|
||||
* ]
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @param {[type]} field [description]
|
||||
* @param {[type]} direction [description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
return function createHitSortFn(direction) {
|
||||
const descending = (direction === 'desc');
|
||||
|
||||
/**
|
||||
* Creates a sort function that will resort hits based on the value
|
||||
* es used to sort them.
|
||||
*
|
||||
* background:
|
||||
* When a hit is sorted by elasticsearch, es will write the values that it used
|
||||
* to sort them into an array at the top level of the hit like so
|
||||
*
|
||||
* ```
|
||||
* hits: {
|
||||
* total: x,
|
||||
* hits: [
|
||||
* {
|
||||
* _id: i,
|
||||
* _source: {},
|
||||
* sort: [
|
||||
* // all values used to sort, in the order of precidance
|
||||
* ]
|
||||
* }
|
||||
* ]
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @param {[type]} field [description]
|
||||
* @param {[type]} direction [description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
return function createHitSortFn(direction) {
|
||||
const descending = (direction === 'desc');
|
||||
return function sortHits(hitA, hitB) {
|
||||
let bBelowa = null;
|
||||
|
||||
return function sortHits(hitA, hitB) {
|
||||
let bBelowa = null;
|
||||
const aSorts = hitA.sort || [];
|
||||
const bSorts = hitB.sort || [];
|
||||
|
||||
const aSorts = hitA.sort || [];
|
||||
const bSorts = hitB.sort || [];
|
||||
// walk each sort value, and compair until one is different
|
||||
for (let i = 0; i < bSorts.length; i++) {
|
||||
const a = aSorts[i];
|
||||
const b = bSorts[i];
|
||||
|
||||
// walk each sort value, and compair until one is different
|
||||
for (let i = 0; i < bSorts.length; i++) {
|
||||
const a = aSorts[i];
|
||||
const b = bSorts[i];
|
||||
|
||||
if (a == null || b > a) {
|
||||
bBelowa = !descending;
|
||||
break;
|
||||
}
|
||||
|
||||
if (b < a) {
|
||||
bBelowa = descending;
|
||||
break;
|
||||
}
|
||||
if (a == null || b > a) {
|
||||
bBelowa = !descending;
|
||||
break;
|
||||
}
|
||||
|
||||
if (bBelowa !== null) {
|
||||
return bBelowa ? -1 : 1;
|
||||
} else {
|
||||
return 0;
|
||||
if (b < a) {
|
||||
bBelowa = descending;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bBelowa !== null) {
|
||||
return bBelowa ? -1 : 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import './scripted_fields_table';
|
|||
import './scripted_field_editor';
|
||||
import './source_filters_table';
|
||||
import { RefreshKibanaIndex } from '../refresh_kibana_index';
|
||||
import UrlProvider from 'ui/url';
|
||||
import { KbnUrlProvider } from 'ui/url';
|
||||
import { IndicesEditSectionsProvider } from './edit_sections';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import { uiModules } from 'ui/modules';
|
||||
|
@ -46,7 +46,7 @@ uiModules.get('apps/management')
|
|||
const $state = $scope.state = new AppState();
|
||||
const refreshKibanaIndex = Private(RefreshKibanaIndex);
|
||||
|
||||
$scope.kbnUrl = Private(UrlProvider);
|
||||
$scope.kbnUrl = Private(KbnUrlProvider);
|
||||
$scope.indexPattern = $route.current.locals.indexPattern;
|
||||
docTitle.change($scope.indexPattern.id);
|
||||
const otherIds = _.without($route.current.locals.indexPatternIds, $scope.indexPattern.id);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'ui/field_editor';
|
||||
import { IndexPatternsFieldProvider } from 'ui/index_patterns/_field';
|
||||
import UrlProvider from 'ui/url';
|
||||
import { KbnUrlProvider } from 'ui/url';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import template from './scripted_field_editor.html';
|
||||
|
||||
|
@ -19,7 +19,7 @@ uiRoutes
|
|||
controller: function FieldEditorPageController($route, Private, Notifier, docTitle) {
|
||||
const Field = Private(IndexPatternsFieldProvider);
|
||||
const notify = new Notifier({ location: 'Field Editor' });
|
||||
const kbnUrl = Private(UrlProvider);
|
||||
const kbnUrl = Private(KbnUrlProvider);
|
||||
|
||||
this.mode = $route.current.mode;
|
||||
this.indexPattern = $route.current.locals.indexPattern;
|
||||
|
|
|
@ -2,7 +2,7 @@ import Boom from 'boom';
|
|||
import _ from 'lodash';
|
||||
import { errors as esErrors } from 'elasticsearch';
|
||||
|
||||
module.exports = function handleESError(error) {
|
||||
export default function handleESError(error) {
|
||||
if (!(error instanceof Error)) {
|
||||
throw new Error('Expected an instance of Error');
|
||||
}
|
||||
|
@ -23,4 +23,4 @@ module.exports = function handleESError(error) {
|
|||
} else {
|
||||
return error;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ function find(rules, check, last) {
|
|||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
near: find(revRoundingRules, function near(bound, interval, target) {
|
||||
if (bound > target) return interval;
|
||||
}, true),
|
||||
|
|
|
@ -11,7 +11,7 @@ import mapBucket from './map_bucket';
|
|||
import parseSettings from './parse_settings';
|
||||
import unitToSeconds from './unit_to_seconds';
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
bucketTransform,
|
||||
getAggValue,
|
||||
getBucketSize,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import moment from 'moment';
|
||||
import numeral from 'numeral';
|
||||
|
||||
module.exports = function formatNumber(num, which) {
|
||||
export default function formatNumber(num, which) {
|
||||
let format = '0.00';
|
||||
let postfix = '';
|
||||
switch (which) {
|
||||
|
@ -19,4 +19,4 @@ module.exports = function formatNumber(num, which) {
|
|||
break;
|
||||
}
|
||||
return numeral(num).format(format) + postfix;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import formatNumber from './format_number';
|
||||
|
||||
module.exports = function makeChartOptions(type) {
|
||||
export default function makeChartOptions(type) {
|
||||
return {
|
||||
chart: {
|
||||
type: 'lineChart',
|
||||
|
@ -25,4 +25,4 @@ module.exports = function makeChartOptions(type) {
|
|||
x: function (d) { return d.x; }
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import _ from 'lodash';
|
||||
|
||||
module.exports = function readStatData(data, seriesNames) {
|
||||
export default function readStatData(data, seriesNames) {
|
||||
// Metric Values format
|
||||
// metric: [[xValue, yValue], ...]
|
||||
// LoadMetric:
|
||||
|
@ -36,4 +36,4 @@ module.exports = function readStatData(data, seriesNames) {
|
|||
});
|
||||
|
||||
return metricList;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -35,4 +35,4 @@ findSourceFiles.statCache = {};
|
|||
findSourceFiles.realpathCache = {};
|
||||
findSourceFiles.cache = {};
|
||||
|
||||
module.exports = findSourceFiles;
|
||||
export default findSourceFiles;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function ({ env, bundle }) {
|
||||
export default function ({ env, bundle }) {
|
||||
|
||||
const pluginSlug = env.pluginInfo.sort()
|
||||
.map(p => ' * - ' + p)
|
||||
|
@ -55,4 +55,4 @@ ${requires}
|
|||
require('ui/test_harness').bootstrap(/* go! */);
|
||||
`;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
const toMS = require('../../server/lib/to_milliseconds.js');
|
||||
|
||||
module.exports = function calculateInterval(from, to, size, interval, min) {
|
||||
if (interval !== 'auto') return interval;
|
||||
const dateMathInterval = roundInterval((to - from) / size);
|
||||
if (toMS(dateMathInterval) < toMS(min)) return min;
|
||||
return dateMathInterval;
|
||||
};
|
||||
import toMS from '../../server/lib/to_milliseconds.js';
|
||||
|
||||
// Totally cribbed this from Kibana 3.
|
||||
// I bet there's something similar in the Kibana 4 code. Somewhere. Somehow.
|
||||
|
@ -45,3 +38,10 @@ function roundInterval(interval) {
|
|||
return '1y';
|
||||
}
|
||||
}
|
||||
|
||||
export function calculateInterval(from, to, size, interval, min) {
|
||||
if (interval !== 'auto') return interval;
|
||||
const dateMathInterval = roundInterval((to - from) / size);
|
||||
if (toMS(dateMathInterval) < toMS(min)) return min;
|
||||
return dateMathInterval;
|
||||
}
|
1
src/core_plugins/timelion/common/lib/index.js
Normal file
1
src/core_plugins/timelion/common/lib/index.js
Normal file
|
@ -0,0 +1 @@
|
|||
export { calculateInterval } from './calculate_interval';
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
module.exports = function (kibana) {
|
||||
export default function (kibana) {
|
||||
let mainFile = 'plugins/timelion/app';
|
||||
|
||||
const ownDescriptor = Object.getOwnPropertyDescriptor(kibana, 'autoload');
|
||||
|
@ -40,4 +40,4 @@ module.exports = function (kibana) {
|
|||
},
|
||||
init: require('./init.js'),
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import _ from 'lodash';
|
||||
import processFunctionDefinition from './server/lib/process_function_definition';
|
||||
|
||||
module.exports = function (server) {
|
||||
export default function (server) {
|
||||
//var config = server.config();
|
||||
require('./server/routes/run.js')(server);
|
||||
require('./server/routes/functions.js')(server);
|
||||
|
@ -25,4 +25,4 @@ module.exports = function (server) {
|
|||
};
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,68 +1,67 @@
|
|||
define(function (require) {
|
||||
const template = require('./timelion_help.html');
|
||||
const app = require('ui/modules').get('apps/timelion', []);
|
||||
const _ = require('lodash');
|
||||
const moment = require('moment');
|
||||
import template from './timelion_help.html';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
|
||||
app.directive('timelionHelp', function ($http) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template,
|
||||
controller: function ($scope) {
|
||||
$scope.functions = {
|
||||
list: [],
|
||||
details: null
|
||||
const app = uiModules.get('apps/timelion', []);
|
||||
|
||||
app.directive('timelionHelp', function ($http) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template,
|
||||
controller: function ($scope) {
|
||||
$scope.functions = {
|
||||
list: [],
|
||||
details: null
|
||||
};
|
||||
|
||||
function init() {
|
||||
$scope.es = {
|
||||
invalidCount: 0
|
||||
};
|
||||
|
||||
function init() {
|
||||
$scope.es = {
|
||||
invalidCount: 0
|
||||
};
|
||||
getFunctions();
|
||||
checkElasticsearch();
|
||||
}
|
||||
|
||||
function getFunctions() {
|
||||
return $http.get('../api/timelion/functions').then(function (resp) {
|
||||
$scope.functions.list = resp.data;
|
||||
});
|
||||
}
|
||||
$scope.recheckElasticsearch = function () {
|
||||
$scope.es.valid = null;
|
||||
checkElasticsearch().then(function (valid) {
|
||||
if (!valid) $scope.es.invalidCount++;
|
||||
});
|
||||
};
|
||||
|
||||
function checkElasticsearch() {
|
||||
return $http.get('../api/timelion/validate/es').then(function (resp) {
|
||||
if (resp.data.ok) {
|
||||
|
||||
$scope.es.valid = true;
|
||||
$scope.es.stats = {
|
||||
min: moment(resp.data.min).format('LLL'),
|
||||
max: moment(resp.data.max).format('LLL'),
|
||||
field: resp.data.field
|
||||
};
|
||||
} else {
|
||||
$scope.es.valid = false;
|
||||
$scope.es.invalidReason = (function () {
|
||||
try {
|
||||
const esResp = JSON.parse(resp.data.resp.response);
|
||||
return _.get(esResp, 'error.root_cause[0].reason');
|
||||
} catch (e) {
|
||||
if (_.get(resp, 'data.resp.message')) return _.get(resp, 'data.resp.message');
|
||||
if (_.get(resp, 'data.resp.output.payload.message')) return _.get(resp, 'data.resp.output.payload.message');
|
||||
return 'Unknown error';
|
||||
}
|
||||
}());
|
||||
}
|
||||
return $scope.es.valid;
|
||||
});
|
||||
}
|
||||
init();
|
||||
getFunctions();
|
||||
checkElasticsearch();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
function getFunctions() {
|
||||
return $http.get('../api/timelion/functions').then(function (resp) {
|
||||
$scope.functions.list = resp.data;
|
||||
});
|
||||
}
|
||||
$scope.recheckElasticsearch = function () {
|
||||
$scope.es.valid = null;
|
||||
checkElasticsearch().then(function (valid) {
|
||||
if (!valid) $scope.es.invalidCount++;
|
||||
});
|
||||
};
|
||||
|
||||
function checkElasticsearch() {
|
||||
return $http.get('../api/timelion/validate/es').then(function (resp) {
|
||||
if (resp.data.ok) {
|
||||
|
||||
$scope.es.valid = true;
|
||||
$scope.es.stats = {
|
||||
min: moment(resp.data.min).format('LLL'),
|
||||
max: moment(resp.data.max).format('LLL'),
|
||||
field: resp.data.field
|
||||
};
|
||||
} else {
|
||||
$scope.es.valid = false;
|
||||
$scope.es.invalidReason = (function () {
|
||||
try {
|
||||
const esResp = JSON.parse(resp.data.resp.response);
|
||||
return _.get(esResp, 'error.root_cause[0].reason');
|
||||
} catch (e) {
|
||||
if (_.get(resp, 'data.resp.message')) return _.get(resp, 'data.resp.message');
|
||||
if (_.get(resp, 'data.resp.output.payload.message')) return _.get(resp, 'data.resp.output.payload.message');
|
||||
return 'Unknown error';
|
||||
}
|
||||
}());
|
||||
}
|
||||
return $scope.es.valid;
|
||||
});
|
||||
}
|
||||
init();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function ($elem, fn, frequency) {
|
||||
export default function ($elem, fn, frequency) {
|
||||
|
||||
frequency = frequency || 500;
|
||||
let currentHeight = $elem.height();
|
||||
|
@ -25,4 +25,4 @@ module.exports = function ($elem, fn, frequency) {
|
|||
};
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function Panel(name, config) {
|
||||
export default function Panel(name, config) {
|
||||
|
||||
this.name = name;
|
||||
|
||||
|
@ -9,4 +9,4 @@ module.exports = function Panel(name, config) {
|
|||
if (!config.render) throw new Error ('Panel must have a rendering function');
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ import _ from 'lodash';
|
|||
import $ from 'jquery';
|
||||
import moment from 'moment-timezone';
|
||||
import observeResize from 'plugins/timelion/lib/observe_resize';
|
||||
import calculateInterval from 'plugins/timelion/lib/calculate_interval';
|
||||
import { calculateInterval } from '../../../common/lib';
|
||||
|
||||
const SET_LEGEND_NUMBERS_DELAY = 50;
|
||||
|
||||
module.exports = function timechartFn(Private, config, $rootScope, timefilter, $compile) {
|
||||
export default function timechartFn(Private, config, $rootScope, timefilter, $compile) {
|
||||
return function () {
|
||||
return {
|
||||
help: 'Draw a timeseries chart',
|
||||
|
@ -260,4 +260,4 @@ module.exports = function timechartFn(Private, config, $rootScope, timefilter, $
|
|||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function generateTicksProvider() {
|
||||
export default function generateTicksProvider() {
|
||||
|
||||
function floorInBase(n, base) {
|
||||
return base * Math.floor(n / base);
|
||||
|
@ -40,4 +40,4 @@ module.exports = function generateTicksProvider() {
|
|||
return function (axis) {
|
||||
return generateTicks(axis);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import moment from 'moment';
|
||||
|
||||
module.exports = function xaxisFormatterProvider(config) {
|
||||
export default function xaxisFormatterProvider(config) {
|
||||
|
||||
function getFormat(esInterval) {
|
||||
const parts = esInterval.match(/(\d+)(ms|s|m|h|d|w|M|y|)/);
|
||||
|
@ -24,4 +24,4 @@ module.exports = function xaxisFormatterProvider(config) {
|
|||
return function (esInterval) {
|
||||
return getFormat(esInterval);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,35 +1,32 @@
|
|||
import _ from 'lodash';
|
||||
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
|
||||
require('ui/state_management/app_state');
|
||||
import 'ui/state_management/app_state';
|
||||
|
||||
export default function dashboardContext(Private, getAppState) {
|
||||
const queryFilter = Private(FilterBarQueryFilterProvider);
|
||||
const bool = { must: [], must_not: [] };
|
||||
const filterBarFilters = queryFilter.getFilters();
|
||||
const queryBarFilter = getAppState().query;
|
||||
|
||||
module.exports = function dashboardContext(Private, getAppState) {
|
||||
return function () {
|
||||
const queryFilter = Private(FilterBarQueryFilterProvider);
|
||||
const bool = { must: [], must_not: [] };
|
||||
const filterBarFilters = queryFilter.getFilters();
|
||||
const queryBarFilter = getAppState().query;
|
||||
// Add the query bar filter, its handled differently.
|
||||
bool.must.push(queryBarFilter);
|
||||
|
||||
// Add the query bar filter, its handled differently.
|
||||
bool.must.push(queryBarFilter);
|
||||
|
||||
// Add each of the filter bar filters
|
||||
_.each(filterBarFilters, function (filter) {
|
||||
const esFilter = _.omit(filter, function (val, key) {
|
||||
if (key === 'meta' || key[0] === '$') return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
if (filter.meta.disabled) return;
|
||||
if (filter.meta.negate) {
|
||||
bool.must_not = bool.must_not || [];
|
||||
bool.must_not.push(esFilter.query || esFilter);
|
||||
} else {
|
||||
bool.must = bool.must || [];
|
||||
bool.must.push(esFilter.query || esFilter);
|
||||
}
|
||||
// Add each of the filter bar filters
|
||||
_.each(filterBarFilters, function (filter) {
|
||||
const esFilter = _.omit(filter, function (val, key) {
|
||||
if (key === 'meta' || key[0] === '$') return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
return { bool: bool };
|
||||
};
|
||||
};
|
||||
if (filter.meta.disabled) return;
|
||||
if (filter.meta.negate) {
|
||||
bool.must_not = bool.must_not || [];
|
||||
bool.must_not.push(esFilter.query || esFilter);
|
||||
} else {
|
||||
bool.must = bool.must || [];
|
||||
bool.must.push(esFilter.query || esFilter);
|
||||
}
|
||||
});
|
||||
|
||||
return { bool: bool };
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
define(function () {
|
||||
return function savedSearchObjectFn(savedSheets) {
|
||||
return savedSheets;
|
||||
};
|
||||
});
|
||||
export default function savedSearchObjectFn(savedSheets) {
|
||||
return savedSheets;
|
||||
}
|
||||
|
|
|
@ -1,32 +1,29 @@
|
|||
import { SavedObjectLoader } from 'ui/courier/saved_object/saved_object_loader';
|
||||
import { savedObjectManagementRegistry } from 'plugins/kibana/management/saved_object_registry';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import './_saved_sheet.js';
|
||||
|
||||
define(function (require) {
|
||||
const module = require('ui/modules').get('app/sheet');
|
||||
// bring in the factory
|
||||
require('./_saved_sheet.js');
|
||||
const module = uiModules.get('app/sheet');
|
||||
|
||||
|
||||
// Register this service with the saved object registry so it can be
|
||||
// edited by the object editor.
|
||||
savedObjectManagementRegistry.register({
|
||||
service: 'savedSheets',
|
||||
title: 'sheets'
|
||||
});
|
||||
|
||||
// This is the only thing that gets injected into controllers
|
||||
module.service('savedSheets', function (Promise, SavedSheet, kbnIndex, esAdmin, kbnUrl) {
|
||||
const savedSheetLoader = new SavedObjectLoader(SavedSheet, kbnIndex, esAdmin, kbnUrl);
|
||||
savedSheetLoader.urlFor = function (id) {
|
||||
return kbnUrl.eval('#/{{id}}', { id: id });
|
||||
};
|
||||
|
||||
// Customize loader properties since adding an 's' on type doesn't work for type 'timelion-sheet'.
|
||||
savedSheetLoader.loaderProperties = {
|
||||
name: 'timelion-sheet',
|
||||
noun: 'Saved Sheets',
|
||||
nouns: 'saved sheets'
|
||||
};
|
||||
return savedSheetLoader;
|
||||
});
|
||||
// Register this service with the saved object registry so it can be
|
||||
// edited by the object editor.
|
||||
savedObjectManagementRegistry.register({
|
||||
service: 'savedSheets',
|
||||
title: 'sheets'
|
||||
});
|
||||
|
||||
// This is the only thing that gets injected into controllers
|
||||
module.service('savedSheets', function (Promise, SavedSheet, kbnIndex, esAdmin, kbnUrl) {
|
||||
const savedSheetLoader = new SavedObjectLoader(SavedSheet, kbnIndex, esAdmin, kbnUrl);
|
||||
savedSheetLoader.urlFor = function (id) {
|
||||
return kbnUrl.eval('#/{{id}}', { id: id });
|
||||
};
|
||||
|
||||
// Customize loader properties since adding an 's' on type doesn't work for type 'timelion-sheet'.
|
||||
savedSheetLoader.loaderProperties = {
|
||||
name: 'timelion-sheet',
|
||||
noun: 'Saved Sheets',
|
||||
nouns: 'saved sheets'
|
||||
};
|
||||
return savedSheetLoader;
|
||||
});
|
||||
|
|
|
@ -1,75 +1,72 @@
|
|||
define(function () {
|
||||
function baseTickFormatter(value, axis) {
|
||||
const factor = axis.tickDecimals ? Math.pow(10, axis.tickDecimals) : 1;
|
||||
const formatted = '' + Math.round(value * factor) / factor;
|
||||
|
||||
function baseTickFormatter(value, axis) {
|
||||
const factor = axis.tickDecimals ? Math.pow(10, axis.tickDecimals) : 1;
|
||||
const formatted = '' + Math.round(value * factor) / factor;
|
||||
// If tickDecimals was specified, ensure that we have exactly that
|
||||
// much precision; otherwise default to the value's own precision.
|
||||
|
||||
// If tickDecimals was specified, ensure that we have exactly that
|
||||
// much precision; otherwise default to the value's own precision.
|
||||
|
||||
if (axis.tickDecimals != null) {
|
||||
const decimal = formatted.indexOf('.');
|
||||
const precision = decimal === -1 ? 0 : formatted.length - decimal - 1;
|
||||
if (precision < axis.tickDecimals) {
|
||||
return (precision ? formatted : formatted + '.') + ('' + factor).substr(1, axis.tickDecimals - precision);
|
||||
}
|
||||
if (axis.tickDecimals != null) {
|
||||
const decimal = formatted.indexOf('.');
|
||||
const precision = decimal === -1 ? 0 : formatted.length - decimal - 1;
|
||||
if (precision < axis.tickDecimals) {
|
||||
return (precision ? formatted : formatted + '.') + ('' + factor).substr(1, axis.tickDecimals - precision);
|
||||
}
|
||||
|
||||
return formatted;
|
||||
}
|
||||
|
||||
return function ticketFormatters() {
|
||||
const formatters = {
|
||||
'bits': function (val) {
|
||||
const labels = ['b','kb','mb','gb','tb','pb'];
|
||||
let index = 0;
|
||||
while (val >= 1000 && index < labels.length) {
|
||||
val /= 1000;
|
||||
index++;
|
||||
}
|
||||
return (Math.round(val * 100) / 100) + labels[index];
|
||||
},
|
||||
'bits/s': function (val) {
|
||||
const labels = ['b/s','kb/s','mb/s','gb/s','tb/s','pb/s'];
|
||||
let index = 0;
|
||||
while (val >= 1000 && index < labels.length) {
|
||||
val /= 1000;
|
||||
index++;
|
||||
}
|
||||
return (Math.round(val * 100) / 100) + labels[index];
|
||||
},
|
||||
'bytes': function (val) {
|
||||
const labels = ['B','KB','MB','GB','TB','PB'];
|
||||
let index = 0;
|
||||
while (val >= 1024 && index < labels.length) {
|
||||
val /= 1024;
|
||||
index++;
|
||||
}
|
||||
return (Math.round(val * 100) / 100) + labels[index];
|
||||
},
|
||||
'bytes/s': function (val) {
|
||||
const labels = ['B/s','KB/s','MB/s','GB/s','TB/s','PB/s'];
|
||||
let index = 0;
|
||||
while (val >= 1024 && index < labels.length) {
|
||||
val /= 1024;
|
||||
index++;
|
||||
}
|
||||
return (Math.round(val * 100) / 100) + labels[index];
|
||||
},
|
||||
'currency': function (val, axis) {
|
||||
return val.toLocaleString('en', { style: 'currency', currency: axis.options.units.prefix || 'USD' });
|
||||
},
|
||||
'percent': function (val) {
|
||||
return val * 100 + '%';
|
||||
},
|
||||
'custom': function (val, axis) {
|
||||
const formattedVal = baseTickFormatter(val, axis);
|
||||
const prefix = axis.options.units.prefix;
|
||||
const suffix = axis.options.units.suffix;
|
||||
return prefix + formattedVal + suffix;
|
||||
}
|
||||
};
|
||||
return formatted;
|
||||
}
|
||||
|
||||
return formatters;
|
||||
export default function tickFormatters() {
|
||||
const formatters = {
|
||||
'bits': function (val) {
|
||||
const labels = ['b','kb','mb','gb','tb','pb'];
|
||||
let index = 0;
|
||||
while (val >= 1000 && index < labels.length) {
|
||||
val /= 1000;
|
||||
index++;
|
||||
}
|
||||
return (Math.round(val * 100) / 100) + labels[index];
|
||||
},
|
||||
'bits/s': function (val) {
|
||||
const labels = ['b/s','kb/s','mb/s','gb/s','tb/s','pb/s'];
|
||||
let index = 0;
|
||||
while (val >= 1000 && index < labels.length) {
|
||||
val /= 1000;
|
||||
index++;
|
||||
}
|
||||
return (Math.round(val * 100) / 100) + labels[index];
|
||||
},
|
||||
'bytes': function (val) {
|
||||
const labels = ['B','KB','MB','GB','TB','PB'];
|
||||
let index = 0;
|
||||
while (val >= 1024 && index < labels.length) {
|
||||
val /= 1024;
|
||||
index++;
|
||||
}
|
||||
return (Math.round(val * 100) / 100) + labels[index];
|
||||
},
|
||||
'bytes/s': function (val) {
|
||||
const labels = ['B/s','KB/s','MB/s','GB/s','TB/s','PB/s'];
|
||||
let index = 0;
|
||||
while (val >= 1024 && index < labels.length) {
|
||||
val /= 1024;
|
||||
index++;
|
||||
}
|
||||
return (Math.round(val * 100) / 100) + labels[index];
|
||||
},
|
||||
'currency': function (val, axis) {
|
||||
return val.toLocaleString('en', { style: 'currency', currency: axis.options.units.prefix || 'USD' });
|
||||
},
|
||||
'percent': function (val) {
|
||||
return val * 100 + '%';
|
||||
},
|
||||
'custom': function (val, axis) {
|
||||
const formattedVal = baseTickFormatter(val, axis);
|
||||
const prefix = axis.options.units.prefix;
|
||||
const suffix = axis.options.units.suffix;
|
||||
return prefix + formattedVal + suffix;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
return formatters;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const tzDetect = require('jstimezonedetect').jstz;
|
||||
import moment from 'moment';
|
||||
|
||||
module.exports = function timezoneFn(config) {
|
||||
export default function timezoneFn(config) {
|
||||
return function () {
|
||||
|
||||
if (config.isDefault('dateFormat:tz')) {
|
||||
|
@ -13,4 +13,4 @@ module.exports = function timezoneFn(config) {
|
|||
}
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,40 +2,34 @@ import { VisVisTypeProvider } from 'ui/vis/vis_type';
|
|||
import image from '../images/icon-timelion.svg';
|
||||
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
|
||||
import { TemplateVisTypeProvider } from 'ui/template_vis_type';
|
||||
import template from 'plugins/timelion/vis/timelion_vis.html';
|
||||
import editorTemplate from 'plugins/timelion/vis/timelion_vis_params.html';
|
||||
import 'plugins/timelion/vis/timelion_vis_controller';
|
||||
import 'plugins/timelion/vis/timelion_vis_params_controller';
|
||||
import 'plugins/timelion/vis/timelion_vis.less';
|
||||
|
||||
define(function (require) {
|
||||
// we also need to load the controller and used by the template
|
||||
require('plugins/timelion/vis/timelion_vis_controller');
|
||||
require('plugins/timelion/vis/timelion_vis_params_controller');
|
||||
// export the provider so that the visType can be required with Private()
|
||||
export default function TimelionVisProvider(Private) {
|
||||
const VisType = Private(VisVisTypeProvider);
|
||||
const TemplateVisType = Private(TemplateVisTypeProvider);
|
||||
|
||||
// Stylin
|
||||
require('plugins/timelion/vis/timelion_vis.less');
|
||||
// return the visType object, which kibana will use to display and configure new
|
||||
// Vis object of this type.
|
||||
return new TemplateVisType({
|
||||
name: 'timelion',
|
||||
title: 'Timelion',
|
||||
image,
|
||||
description: 'Build time-series using functional expressions',
|
||||
category: VisType.CATEGORY.TIME,
|
||||
template,
|
||||
params: {
|
||||
editor: editorTemplate,
|
||||
},
|
||||
requiresSearch: false,
|
||||
requiresTimePicker: true,
|
||||
implementsRenderComplete: true,
|
||||
});
|
||||
}
|
||||
|
||||
// register the provider with the visTypes registry so that other know it exists
|
||||
VisTypesRegistryProvider.register(TimelionVisProvider);
|
||||
|
||||
function TimelionVisProvider(Private) {
|
||||
const VisType = Private(VisVisTypeProvider);
|
||||
const TemplateVisType = Private(TemplateVisTypeProvider);
|
||||
|
||||
// return the visType object, which kibana will use to display and configure new
|
||||
// Vis object of this type.
|
||||
return new TemplateVisType({
|
||||
name: 'timelion',
|
||||
title: 'Timelion',
|
||||
image,
|
||||
description: 'Build time-series using functional expressions',
|
||||
category: VisType.CATEGORY.TIME,
|
||||
template: require('plugins/timelion/vis/timelion_vis.html'),
|
||||
params: {
|
||||
editor: require('plugins/timelion/vis/timelion_vis_params.html')
|
||||
},
|
||||
requiresSearch: false,
|
||||
requiresTimePicker: true,
|
||||
implementsRenderComplete: true,
|
||||
});
|
||||
}
|
||||
|
||||
// export the provider so that the visType can be required with Private()
|
||||
return TimelionVisProvider;
|
||||
});
|
||||
// register the provider with the visTypes registry so that other know it exists
|
||||
VisTypesRegistryProvider.register(TimelionVisProvider);
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
import _ from 'lodash';
|
||||
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import timezoneProvider from 'plugins/timelion/services/timezone';
|
||||
import dashboardContextProvider from 'plugins/timelion/services/dashboard_context';
|
||||
import 'plugins/timelion/directives/chart/chart';
|
||||
import 'plugins/timelion/directives/timelion_interval/timelion_interval';
|
||||
import 'ui/state_management/app_state';
|
||||
|
||||
define(function (require) {
|
||||
require('plugins/timelion/directives/chart/chart');
|
||||
require('plugins/timelion/directives/timelion_interval/timelion_interval');
|
||||
require('ui/state_management/app_state');
|
||||
const module = uiModules.get('kibana/timelion_vis', ['kibana']);
|
||||
|
||||
const _ = require('lodash');
|
||||
const module = require('ui/modules').get('kibana/timelion_vis', ['kibana']);
|
||||
module.controller('TimelionVisController', function ($scope, $element, Private, Notifier, $http, $rootScope, timefilter) {
|
||||
const queryFilter = Private(FilterBarQueryFilterProvider);
|
||||
const timezone = Private(require('plugins/timelion/services/timezone'))();
|
||||
const dashboardContext = Private(require('plugins/timelion/services/dashboard_context'));
|
||||
module.controller('TimelionVisController', function ($scope, $element, Private, Notifier, $http, $rootScope, timefilter) {
|
||||
const queryFilter = Private(FilterBarQueryFilterProvider);
|
||||
const timezone = Private(timezoneProvider)();
|
||||
const dashboardContext = Private(dashboardContextProvider);
|
||||
|
||||
const notify = new Notifier({
|
||||
location: 'Timelion'
|
||||
const notify = new Notifier({
|
||||
location: 'Timelion'
|
||||
});
|
||||
|
||||
$scope.search = function run() {
|
||||
const expression = $scope.vis.params.expression;
|
||||
if (!expression) return;
|
||||
|
||||
$http.post('../api/timelion/run', {
|
||||
sheet: [expression],
|
||||
extended: {
|
||||
es: {
|
||||
filter: dashboardContext()
|
||||
}
|
||||
},
|
||||
time: _.extend(timefilter.time, {
|
||||
interval: $scope.vis.params.interval,
|
||||
timezone: timezone
|
||||
}),
|
||||
})
|
||||
// data, status, headers, config
|
||||
.success(function (resp) {
|
||||
$scope.sheet = resp.sheet;
|
||||
})
|
||||
.error(function (resp) {
|
||||
$scope.sheet = [];
|
||||
const err = new Error(resp.message);
|
||||
err.stack = resp.stack;
|
||||
notify.error(err);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.search = function run() {
|
||||
const expression = $scope.vis.params.expression;
|
||||
if (!expression) return;
|
||||
// This is bad, there should be a single event that triggers a refresh of data.
|
||||
|
||||
$http.post('../api/timelion/run', {
|
||||
sheet: [expression],
|
||||
extended: {
|
||||
es: {
|
||||
filter: dashboardContext()
|
||||
}
|
||||
},
|
||||
time: _.extend(timefilter.time, {
|
||||
interval: $scope.vis.params.interval,
|
||||
timezone: timezone
|
||||
}),
|
||||
})
|
||||
// data, status, headers, config
|
||||
.success(function (resp) {
|
||||
$scope.sheet = resp.sheet;
|
||||
})
|
||||
.error(function (resp) {
|
||||
$scope.sheet = [];
|
||||
const err = new Error(resp.message);
|
||||
err.stack = resp.stack;
|
||||
notify.error(err);
|
||||
});
|
||||
};
|
||||
// When the expression updates
|
||||
$scope.$watchMulti(['vis.params.expression', 'vis.params.interval'], $scope.search);
|
||||
|
||||
// This is bad, there should be a single event that triggers a refresh of data.
|
||||
// When the time filter changes
|
||||
$scope.$listen(timefilter, 'fetch', $scope.search);
|
||||
|
||||
// When the expression updates
|
||||
$scope.$watchMulti(['vis.params.expression', 'vis.params.interval'], $scope.search);
|
||||
// When a filter is added to the filter bar?
|
||||
$scope.$listen(queryFilter, 'fetch', $scope.search);
|
||||
|
||||
// When the time filter changes
|
||||
$scope.$listen(timefilter, 'fetch', $scope.search);
|
||||
// When auto refresh happens
|
||||
$scope.$on('courier:searchRefresh', $scope.search);
|
||||
|
||||
// When a filter is added to the filter bar?
|
||||
$scope.$listen(queryFilter, 'fetch', $scope.search);
|
||||
|
||||
// When auto refresh happens
|
||||
$scope.$on('courier:searchRefresh', $scope.search);
|
||||
|
||||
$scope.$on('fetch', $scope.search);
|
||||
|
||||
$scope.$on('renderComplete', event => {
|
||||
event.stopPropagation();
|
||||
$element.trigger('renderComplete');
|
||||
});
|
||||
$scope.$on('fetch', $scope.search);
|
||||
|
||||
$scope.$on('renderComplete', event => {
|
||||
event.stopPropagation();
|
||||
$element.trigger('renderComplete');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
define(function (require) {
|
||||
require('plugins/timelion/directives/timelion_expression_input');
|
||||
import { uiModules } from 'ui/modules';
|
||||
import 'plugins/timelion/directives/timelion_expression_input';
|
||||
|
||||
const module = require('ui/modules').get('kibana/timelion_vis', ['kibana']);
|
||||
module.controller('TimelionVisParamsController', function ($scope, $rootScope) {
|
||||
$scope.vis.params.expression = $scope.vis.params.expression || '.es(*)';
|
||||
$scope.vis.params.interval = $scope.vis.params.interval || '1m';
|
||||
const module = uiModules.get('kibana/timelion_vis', ['kibana']);
|
||||
module.controller('TimelionVisParamsController', function ($scope, $rootScope) {
|
||||
$scope.vis.params.expression = $scope.vis.params.expression || '.es(*)';
|
||||
$scope.vis.params.interval = $scope.vis.params.interval || '1m';
|
||||
|
||||
|
||||
$scope.search = function () {
|
||||
$rootScope.$broadcast('courier:searchRefresh');
|
||||
};
|
||||
});
|
||||
$scope.search = function () {
|
||||
$rootScope.$broadcast('courier:searchRefresh');
|
||||
};
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ import _ from 'lodash';
|
|||
// Good: min, max, average
|
||||
// Bad: sum, count
|
||||
|
||||
module.exports = function (dataTuples, targetTuples) {
|
||||
export default function average(dataTuples, targetTuples) {
|
||||
|
||||
// Phase 1: Downsample
|
||||
// We nessecarily won't well match the dataSource here as we don't know how much data
|
||||
|
@ -72,4 +72,4 @@ module.exports = function (dataTuples, targetTuples) {
|
|||
|
||||
const resultTuples = _.zip(resultTimes, resultValues);
|
||||
return resultTuples;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import _ from 'lodash';
|
|||
// Bad: sum, count
|
||||
|
||||
// Don't use this to down sample, it simply won't do the right thing.
|
||||
module.exports = function (dataTuples, targetTuples) {
|
||||
export default function carry(dataTuples, targetTuples) {
|
||||
|
||||
if (dataTuples.length > targetTuples.length) {
|
||||
throw new Error (`Don't use the 'carry' fit method to down sample, use 'scale' or 'average'`);
|
||||
|
@ -23,4 +23,4 @@ module.exports = function (dataTuples, targetTuples) {
|
|||
|
||||
return [bucket[0], currentCarry];
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import _ from 'lodash';
|
|||
// Upsampling and downsampling of non-cummulative sets
|
||||
// Good: average, min, max
|
||||
// Bad: sum, count
|
||||
module.exports = function (dataTuples, targetTuples) {
|
||||
export default function nearest(dataTuples, targetTuples) {
|
||||
return _.map(targetTuples, function (bucket) {
|
||||
const time = bucket[0];
|
||||
let i = 0;
|
||||
|
@ -24,4 +24,4 @@ module.exports = function (dataTuples, targetTuples) {
|
|||
|
||||
return [bucket[0], closest[1]];
|
||||
});
|
||||
};
|
||||
}
|
|
@ -2,6 +2,6 @@
|
|||
// **DON'T USE THIS**
|
||||
// Performing joins/math with other sets that don't match perfectly will be wrong
|
||||
// Does not resample at all.
|
||||
module.exports = function (dataTuples) {
|
||||
export default function none(dataTuples) {
|
||||
return dataTuples;
|
||||
};
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue