Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into client-and-server…
Browse files Browse the repository at this point in the history
…-np-dir-move
  • Loading branch information
Kerry350 committed Feb 17, 2020
2 parents 4f939c1 + 9388ff7 commit a7678cf
Show file tree
Hide file tree
Showing 120 changed files with 2,378 additions and 1,176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,6 @@ function VisualizeAppController(
})
);

subscriptions.add(
subscribeWithScope($scope, timefilter.getAutoRefreshFetch$(), {
next: () => {
$scope.vis.forceReload();
},
})
);

$scope.$on('$destroy', () => {
if ($scope._handler) {
$scope._handler.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export interface StatsCollectionConfig {
usageCollection: UsageCollectionSetup;
callCluster: CallCluster;
server: any;
start: string;
end: string;
start: string | number;
end: string | number;
}

export type StatsGetterConfig = UnencryptedStatsGetterConfig | EncryptedStatsGetterConfig;
Expand Down Expand Up @@ -193,7 +193,7 @@ export class TelemetryCollectionManager {
}
} catch (err) {
statsCollectionConfig.server.log(
['debu', 'telemetry', 'collection'],
['debug', 'telemetry', 'collection'],
`Failed to collect any usage with registered collections.`
);
// swallow error to try next collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
esFilters,
Filter,
ISearchSource,
TimefilterContract,
} from '../../../../../plugins/data/public';
import {
EmbeddableInput,
Expand Down Expand Up @@ -106,8 +107,10 @@ export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOut
private vis: Vis;
private domNode: any;
public readonly type = VISUALIZE_EMBEDDABLE_TYPE;
private autoRefreshFetchSubscription: Subscription;

constructor(
timefilter: TimefilterContract,
{
savedVisualization,
editUrl,
Expand Down Expand Up @@ -151,6 +154,10 @@ export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOut

this.vis._setUiState(this.uiState);

this.autoRefreshFetchSubscription = timefilter
.getAutoRefreshFetch$()
.subscribe(this.updateHandler.bind(this));

this.subscriptions.push(
Rx.merge(this.getOutput$(), this.getInput$()).subscribe(() => {
this.handleChanges();
Expand Down Expand Up @@ -345,6 +352,7 @@ export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOut
this.handler.destroy();
this.handler.getElement().remove();
}
this.autoRefreshFetchSubscription.unsubscribe();
}

public reload = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';

import { getCapabilities, getHttp, getTypes, getUISettings } from '../np_ready/public/services';
import { showNewVisModal } from '../np_ready/public/wizard';
import { TimefilterContract } from '../../../../../plugins/data/public';

interface VisualizationAttributes extends SavedObjectAttributes {
visState: string;
Expand All @@ -51,7 +52,10 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
> {
public readonly type = VISUALIZE_EMBEDDABLE_TYPE;

constructor(private getSavedVisualizationsLoader: () => SavedVisualizations) {
constructor(
private timefilter: TimefilterContract,
private getSavedVisualizationsLoader: () => SavedVisualizations
) {
super({
savedObjectMetaData: {
name: i18n.translate('visualizations.savedObjectName', { defaultMessage: 'Visualization' }),
Expand Down Expand Up @@ -114,6 +118,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
const indexPattern = await getIndexPattern(savedObject);
const indexPatterns = indexPattern ? [indexPattern] : [];
return new VisualizeEmbeddable(
this.timefilter,
{
savedVisualization: savedObject,
indexPatterns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const createInstance = async () => {
const plugin = new VisualizationsPlugin({} as PluginInitializerContext);

const setup = plugin.setup(coreMock.createSetup(), {
data: dataPluginMock.createSetupContract(),
expressions: expressionsPluginMock.createSetupContract(),
embeddable: embeddablePluginMock.createStartContract(),
usageCollection: usageCollectionPluginMock.createSetupContract(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ import { ExpressionsSetup } from '../../../../../../plugins/expressions/public';
import { IEmbeddableSetup } from '../../../../../../plugins/embeddable/public';
import { visualization as visualizationFunction } from './expressions/visualization_function';
import { visualization as visualizationRenderer } from './expressions/visualization_renderer';
import { DataPublicPluginStart } from '../../../../../../plugins/data/public';
import {
DataPublicPluginSetup,
DataPublicPluginStart,
} from '../../../../../../plugins/data/public';
import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection/public';
import {
createSavedVisLoader,
Expand Down Expand Up @@ -65,6 +68,7 @@ export interface VisualizationsSetupDeps {
expressions: ExpressionsSetup;
embeddable: IEmbeddableSetup;
usageCollection: UsageCollectionSetup;
data: DataPublicPluginSetup;
}

export interface VisualizationsStartDeps {
Expand Down Expand Up @@ -95,15 +99,18 @@ export class VisualizationsPlugin

public setup(
core: CoreSetup,
{ expressions, embeddable, usageCollection }: VisualizationsSetupDeps
{ expressions, embeddable, usageCollection, data }: VisualizationsSetupDeps
): VisualizationsSetup {
setUISettings(core.uiSettings);
setUsageCollector(usageCollection);

expressions.registerFunction(visualizationFunction);
expressions.registerRenderer(visualizationRenderer);

const embeddableFactory = new VisualizeEmbeddableFactory(this.getSavedVisualizationsLoader);
const embeddableFactory = new VisualizeEmbeddableFactory(
data.query.timefilter.timefilter,
this.getSavedVisualizationsLoader
);
embeddable.registerEmbeddableFactory(VISUALIZE_EMBEDDABLE_TYPE, embeddableFactory);

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
useRequestReadContext,
} from '../../../../contexts';

import * as utils from '../../../../../lib/utils/utils';
import { expandLiteralStrings } from '../../../../../../../es_ui_shared/console_lang/lib';

import { subscribeResizeChecker } from '../subscribe_console_resize_checker';
import { applyCurrentSettings } from './apply_editor_settings';
Expand Down Expand Up @@ -67,7 +67,7 @@ function EditorOutputUI() {
editor.update(
data
.map(d => d.response.value as string)
.map(readOnlySettings.tripleQuotes ? utils.expandLiteralStrings : a => a)
.map(readOnlySettings.tripleQuotes ? expandLiteralStrings : a => a)
.join('\n')
);
} else if (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
* under the License.
*/

import * as utils from '../../../lib/utils/utils';
import { extractDeprecationMessages } from '../../../lib/utils';
import { collapseLiteralStrings } from '../../../../../es_ui_shared/console_lang/lib';
// @ts-ignore
import * as es from '../../../lib/es/es';
import { BaseResponseType } from '../../../types/common';
import { BaseResponseType } from '../../../types';

export interface EsRequestArgs {
requests: any;
Expand Down Expand Up @@ -73,7 +74,7 @@ export function sendRequestToES(args: EsRequestArgs): Promise<ESRequestResult[]>
const req = requests.shift();
const esPath = req.url;
const esMethod = req.method;
let esData = utils.collapseLiteralStrings(req.data.join('\n'));
let esData = collapseLiteralStrings(req.data.join('\n'));
if (esData) {
esData += '\n';
} // append a new line for bulk requests.
Expand All @@ -97,7 +98,7 @@ export function sendRequestToES(args: EsRequestArgs): Promise<ESRequestResult[]>

const warnings = xhr.getResponseHeader('warning');
if (warnings) {
const deprecationMessages = utils.extractDeprecationMessages(warnings);
const deprecationMessages = extractDeprecationMessages(warnings);
value = deprecationMessages.join('\n') + '\n' + value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import ace from 'brace';
import { workerModule } from './worker';

const oop = ace.acequire('ace/lib/oop');
const TextMode = ace.acequire('ace/mode/text').Mode;
Expand All @@ -29,7 +30,6 @@ const WorkerClient = ace.acequire('ace/worker/worker_client').WorkerClient;
const AceTokenizer = ace.acequire('ace/tokenizer').Tokenizer;

const HighlightRules = require('./input_highlight_rules').InputHighlightRules;
import { workerModule } from './worker';

export function Mode() {
this.$tokenizer = new AceTokenizer(new HighlightRules().getRules());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

const ace = require('brace');
import { addToRules } from './x_json_highlight_rules';
import { addXJsonToRules } from '../../../../../../es_ui_shared/console_lang';

export function addEOL(tokens, reg, nextIfEOL, normalNext) {
if (typeof reg === 'object') {
Expand Down Expand Up @@ -101,7 +101,7 @@ export function InputHighlightRules() {
),
};

addToRules(this);
addXJsonToRules(this);

if (this.constructor === InputHighlightRules) {
this.normalizeRules();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

const ace = require('brace');
import 'brace/mode/json';
import { addToRules } from './x_json_highlight_rules';
import { addXJsonToRules } from '../../../../../../es_ui_shared/console_lang';

const oop = ace.acequire('ace/lib/oop');
const JsonHighlightRules = ace.acequire('ace/mode/json_highlight_rules').JsonHighlightRules;

export function OutputJsonHighlightRules() {
this.$rules = {};

addToRules(this, 'start');
addXJsonToRules(this, 'start');

this.$rules.start.unshift(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@
*/

import ace from 'brace';
import { ScriptHighlightRules } from '../../../../../../es_ui_shared/console_lang';

const oop = ace.acequire('ace/lib/oop');
const TextMode = ace.acequire('ace/mode/text').Mode;
const MatchingBraceOutdent = ace.acequire('ace/mode/matching_brace_outdent').MatchingBraceOutdent;
const CstyleBehaviour = ace.acequire('ace/mode/behaviour/cstyle').CstyleBehaviour;
const CStyleFoldMode = ace.acequire('ace/mode/folding/cstyle').FoldMode;
//const WorkerClient = ace.acequire('ace/worker/worker_client').WorkerClient;
ace.acequire('ace/tokenizer');

const ScriptHighlightRules = require('./script_highlight_rules').ScriptHighlightRules;

export function ScriptMode() {
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
Expand Down Expand Up @@ -57,19 +55,4 @@ oop.inherits(ScriptMode, TextMode);
this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};

// this.createWorker = function (session) {
// const worker = new WorkerClient(['ace', 'sense_editor'], 'sense_editor/mode/worker', 'SenseWorker', 'sense_editor/mode/worker');
// worker.attachToDocument(session.getDocument());

// worker.on('error', function (e) {
// session.setAnnotations([e.data]);
// });

// worker.on('ok', function (anno) {
// session.setAnnotations(anno.data);
// });

// return worker;
// };
}.call(ScriptMode.prototype));
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export declare const workerModule: { id: string; src: string };
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import $ from 'jquery';
import _ from 'lodash';

import { create } from '../create';
import { collapseLiteralStrings } from '../../../../../../es_ui_shared/console_lang/lib';
const editorInput1 = require('./editor_input1.txt');
const utils = require('../../../../lib/utils/utils');

describe('Editor', () => {
let input;
Expand Down Expand Up @@ -331,7 +331,7 @@ describe('Editor', () => {
const expected = {
method: 'POST',
url: '_search',
data: [utils.collapseLiteralStrings(simpleRequest.data)],
data: [collapseLiteralStrings(simpleRequest.data)],
};

compareRequest(request, expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

import _ from 'lodash';
import RowParser from '../../../lib/row_parser';
import * as utils from '../../../lib/utils/utils';
import { collapseLiteralStrings } from '../../../../../es_ui_shared/console_lang/lib';
import * as utils from '../../../lib/utils';

// @ts-ignore
import * as es from '../../../lib/es/es';

Expand Down Expand Up @@ -480,7 +482,7 @@ export class SenseEditor {
let ret = 'curl -X' + esMethod + ' "' + url + '"';
if (esData && esData.length) {
ret += " -H 'Content-Type: application/json' -d'\n";
const dataAsString = utils.collapseLiteralStrings(esData.join('\n'));
const dataAsString = collapseLiteralStrings(esData.join('\n'));
// since Sense doesn't allow single quote json string any single qoute is within a string.
ret += dataAsString.replace(/'/g, '\\"');
if (esData.length > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

import '../../application/models/sense_editor/sense_editor.test.mocks';

import $ from 'jquery';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
// @ts-ignore
} from '../kb/kb';

import * as utils from '../utils/utils';
import * as utils from '../utils';

// @ts-ignore
import { populateContext } from './engine';
Expand Down
Loading

0 comments on commit a7678cf

Please sign in to comment.