remove angular from Vis (#50402)
This commit is contained in:
parent
b5a0d4b03d
commit
4f888196b7
|
@ -21,7 +21,7 @@ import chrome from 'ui/chrome';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { render, unmountComponentAtNode } from 'react-dom';
|
import { render, unmountComponentAtNode } from 'react-dom';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { VisProvider } from '../../../../ui/public/visualize/loader/vis';
|
import { Vis } from '../../../../ui/public/visualize/loader/vis';
|
||||||
import { Visualization } from '../../../../ui/public/visualize/components';
|
import { Visualization } from '../../../../ui/public/visualize/components';
|
||||||
|
|
||||||
export const visualization = () => ({
|
export const visualization = () => ({
|
||||||
|
@ -33,8 +33,6 @@ export const visualization = () => ({
|
||||||
const visType = config.visType || visConfig.type;
|
const visType = config.visType || visConfig.type;
|
||||||
const $injector = await chrome.dangerouslyGetActiveInjector();
|
const $injector = await chrome.dangerouslyGetActiveInjector();
|
||||||
const $rootScope = $injector.get('$rootScope') as any;
|
const $rootScope = $injector.get('$rootScope') as any;
|
||||||
const Private = $injector.get('Private') as any;
|
|
||||||
const Vis = Private(VisProvider);
|
|
||||||
|
|
||||||
if (handlers.vis) {
|
if (handlers.vis) {
|
||||||
// special case in visualize, we need to render first (without executing the expression), for maps to work
|
// special case in visualize, we need to render first (without executing the expression), for maps to work
|
||||||
|
|
|
@ -57,7 +57,7 @@ import {
|
||||||
subscribeWithScope,
|
subscribeWithScope,
|
||||||
tabifyAggResponse,
|
tabifyAggResponse,
|
||||||
vislibSeriesResponseHandlerProvider,
|
vislibSeriesResponseHandlerProvider,
|
||||||
VisProvider,
|
Vis,
|
||||||
SavedObjectSaveModal,
|
SavedObjectSaveModal,
|
||||||
} from '../kibana_services';
|
} from '../kibana_services';
|
||||||
|
|
||||||
|
@ -190,7 +190,6 @@ function discoverController(
|
||||||
localStorage,
|
localStorage,
|
||||||
uiCapabilities
|
uiCapabilities
|
||||||
) {
|
) {
|
||||||
const Vis = Private(VisProvider);
|
|
||||||
const responseHandler = vislibSeriesResponseHandlerProvider().handler;
|
const responseHandler = vislibSeriesResponseHandlerProvider().handler;
|
||||||
const getUnhashableStates = Private(getUnhashableStatesProvider);
|
const getUnhashableStates = Private(getUnhashableStatesProvider);
|
||||||
const shareContextMenuExtensions = Private(ShareContextMenuExtensionsRegistryProvider);
|
const shareContextMenuExtensions = Private(ShareContextMenuExtensionsRegistryProvider);
|
||||||
|
|
|
@ -114,7 +114,7 @@ export { tabifyAggResponse } from 'ui/agg_response/tabify';
|
||||||
export { vislibSeriesResponseHandlerProvider } from 'ui/vis/response_handlers/vislib';
|
export { vislibSeriesResponseHandlerProvider } from 'ui/vis/response_handlers/vislib';
|
||||||
|
|
||||||
// EXPORT types
|
// EXPORT types
|
||||||
export { VisProvider } from 'ui/vis';
|
export { Vis } from 'ui/vis';
|
||||||
export { StaticIndexPattern, IndexPatterns, IndexPattern, FieldType } from 'ui/index_patterns';
|
export { StaticIndexPattern, IndexPatterns, IndexPattern, FieldType } from 'ui/index_patterns';
|
||||||
export { SearchSource } from 'ui/courier';
|
export { SearchSource } from 'ui/courier';
|
||||||
export { ElasticSearchHit } from 'ui/registry/doc_views_types';
|
export { ElasticSearchHit } from 'ui/registry/doc_views_types';
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
* NOTE: It's a type of SavedObject, but specific to visualizations.
|
* NOTE: It's a type of SavedObject, but specific to visualizations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { VisProvider } from 'ui/vis';
|
import { Vis } from 'ui/vis';
|
||||||
import { uiModules } from 'ui/modules';
|
import { uiModules } from 'ui/modules';
|
||||||
import { updateOldState } from 'ui/vis/vis_update_state';
|
import { updateOldState } from 'ui/vis/vis_update_state';
|
||||||
import { VisualizeConstants } from '../visualize_constants';
|
import { VisualizeConstants } from '../visualize_constants';
|
||||||
|
@ -39,7 +39,6 @@ import {
|
||||||
uiModules
|
uiModules
|
||||||
.get('app/visualize')
|
.get('app/visualize')
|
||||||
.factory('SavedVis', function (Promise, savedSearches, Private) {
|
.factory('SavedVis', function (Promise, savedSearches, Private) {
|
||||||
const Vis = Private(VisProvider);
|
|
||||||
const SavedObject = Private(SavedObjectProvider);
|
const SavedObject = Private(SavedObjectProvider);
|
||||||
createLegacyClass(SavedVis).inherits(SavedObject);
|
createLegacyClass(SavedVis).inherits(SavedObject);
|
||||||
function SavedVis(opts) {
|
function SavedVis(opts) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import ngMock from 'ng_mock';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import ChoroplethLayer from '../choropleth_layer';
|
import ChoroplethLayer from '../choropleth_layer';
|
||||||
import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
import * as visModule from 'ui/vis';
|
import { Vis } from 'ui/vis';
|
||||||
import { ImageComparator } from 'test_utils/image_comparator';
|
import { ImageComparator } from 'test_utils/image_comparator';
|
||||||
import worldJson from './world.json';
|
import worldJson from './world.json';
|
||||||
import EMS_CATALOGUE from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_manifest.json';
|
import EMS_CATALOGUE from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_manifest.json';
|
||||||
|
@ -50,7 +50,6 @@ const PIXEL_DIFF = 96;
|
||||||
describe('RegionMapsVisualizationTests', function () {
|
describe('RegionMapsVisualizationTests', function () {
|
||||||
let domNode;
|
let domNode;
|
||||||
let RegionMapsVisualization;
|
let RegionMapsVisualization;
|
||||||
let Vis;
|
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
let vis;
|
let vis;
|
||||||
let dependencies;
|
let dependencies;
|
||||||
|
@ -113,7 +112,6 @@ describe('RegionMapsVisualizationTests', function () {
|
||||||
visualizationsSetup.types.registerVisualization(() => createRegionMapTypeDefinition(dependencies));
|
visualizationsSetup.types.registerVisualization(() => createRegionMapTypeDefinition(dependencies));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vis = Private(visModule.VisProvider);
|
|
||||||
RegionMapsVisualization = createRegionMapVisualization(dependencies);
|
RegionMapsVisualization = createRegionMapVisualization(dependencies);
|
||||||
indexPattern = Private(LogstashIndexPatternStubProvider);
|
indexPattern = Private(LogstashIndexPatternStubProvider);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
import * as visModule from 'ui/vis';
|
import { Vis } from 'ui/vis';
|
||||||
import { ImageComparator } from 'test_utils/image_comparator';
|
import { ImageComparator } from 'test_utils/image_comparator';
|
||||||
import dummyESResponse from './dummy_es_response.json';
|
import dummyESResponse from './dummy_es_response.json';
|
||||||
import initial from './initial.png';
|
import initial from './initial.png';
|
||||||
|
@ -65,7 +65,6 @@ let visRegComplete = false;
|
||||||
describe('CoordinateMapsVisualizationTest', function () {
|
describe('CoordinateMapsVisualizationTest', function () {
|
||||||
let domNode;
|
let domNode;
|
||||||
let CoordinateMapsVisualization;
|
let CoordinateMapsVisualization;
|
||||||
let Vis;
|
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
let vis;
|
let vis;
|
||||||
let dependencies;
|
let dependencies;
|
||||||
|
@ -91,7 +90,6 @@ describe('CoordinateMapsVisualizationTest', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Vis = Private(visModule.VisProvider);
|
|
||||||
CoordinateMapsVisualization = createTileMapVisualization(dependencies);
|
CoordinateMapsVisualization = createTileMapVisualization(dependencies);
|
||||||
indexPattern = Private(LogstashIndexPatternStubProvider);
|
indexPattern = Private(LogstashIndexPatternStubProvider);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import $ from 'jquery';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
|
|
||||||
import { VisProvider } from 'ui/vis';
|
import { Vis } from 'ui/vis';
|
||||||
import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
|
|
||||||
import { createMetricVisTypeDefinition } from '../metric_vis_type';
|
import { createMetricVisTypeDefinition } from '../metric_vis_type';
|
||||||
|
@ -34,7 +34,6 @@ describe('metric_vis - createMetricVisTypeDefinition', () => {
|
||||||
beforeEach(
|
beforeEach(
|
||||||
ngMock.inject(Private => {
|
ngMock.inject(Private => {
|
||||||
setup = () => {
|
setup = () => {
|
||||||
const Vis = Private(VisProvider);
|
|
||||||
const metricVisType = createMetricVisTypeDefinition();
|
const metricVisType = createMetricVisTypeDefinition();
|
||||||
const indexPattern = Private(LogstashIndexPatternStubProvider);
|
const indexPattern = Private(LogstashIndexPatternStubProvider);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import $ from 'jquery';
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import { legacyResponseHandlerProvider } from 'ui/vis/response_handlers/legacy';
|
import { legacyResponseHandlerProvider } from 'ui/vis/response_handlers/legacy';
|
||||||
import { VisProvider } from 'ui/vis';
|
import { Vis } from 'ui/vis';
|
||||||
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
import { VisFactoryProvider } from 'ui/vis/vis_factory';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
import { AppStateProvider } from 'ui/state_management/app_state';
|
import { AppStateProvider } from 'ui/state_management/app_state';
|
||||||
|
@ -36,7 +36,6 @@ describe('Table Vis - Controller', async function () {
|
||||||
let Private;
|
let Private;
|
||||||
let $scope;
|
let $scope;
|
||||||
let $el;
|
let $el;
|
||||||
let Vis;
|
|
||||||
let fixtures;
|
let fixtures;
|
||||||
let AppState;
|
let AppState;
|
||||||
let tableAggResponse;
|
let tableAggResponse;
|
||||||
|
@ -63,7 +62,6 @@ describe('Table Vis - Controller', async function () {
|
||||||
$compile = $injector.get('$compile');
|
$compile = $injector.get('$compile');
|
||||||
fixtures = require('fixtures/fake_hierarchical_data');
|
fixtures = require('fixtures/fake_hierarchical_data');
|
||||||
AppState = Private(AppStateProvider);
|
AppState = Private(AppStateProvider);
|
||||||
Vis = Private(VisProvider);
|
|
||||||
tableAggResponse = legacyResponseHandlerProvider().handler;
|
tableAggResponse = legacyResponseHandlerProvider().handler;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import fixtures from 'fixtures/fake_hierarchical_data';
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
import { legacyResponseHandlerProvider } from 'ui/vis/response_handlers/legacy';
|
import { legacyResponseHandlerProvider } from 'ui/vis/response_handlers/legacy';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
import { VisProvider } from 'ui/vis';
|
import { Vis } from 'ui/vis';
|
||||||
import { tabifyAggResponse } from 'ui/agg_response/tabify';
|
import { tabifyAggResponse } from 'ui/agg_response/tabify';
|
||||||
import { round } from 'lodash';
|
import { round } from 'lodash';
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ import { setup as visualizationsSetup } from '../../../../visualizations/public/
|
||||||
describe('Table Vis - AggTable Directive', function () {
|
describe('Table Vis - AggTable Directive', function () {
|
||||||
let $rootScope;
|
let $rootScope;
|
||||||
let $compile;
|
let $compile;
|
||||||
let Vis;
|
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
let settings;
|
let settings;
|
||||||
let tableAggResponse;
|
let tableAggResponse;
|
||||||
|
@ -113,7 +112,6 @@ describe('Table Vis - AggTable Directive', function () {
|
||||||
ngMock.inject(function ($injector, Private, config) {
|
ngMock.inject(function ($injector, Private, config) {
|
||||||
tableAggResponse = legacyResponseHandlerProvider().handler;
|
tableAggResponse = legacyResponseHandlerProvider().handler;
|
||||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
Vis = Private(VisProvider);
|
|
||||||
settings = config;
|
settings = config;
|
||||||
|
|
||||||
$rootScope = $injector.get('$rootScope');
|
$rootScope = $injector.get('$rootScope');
|
||||||
|
|
|
@ -23,13 +23,12 @@ import expect from '@kbn/expect';
|
||||||
import fixtures from 'fixtures/fake_hierarchical_data';
|
import fixtures from 'fixtures/fake_hierarchical_data';
|
||||||
import { legacyResponseHandlerProvider } from 'ui/vis/response_handlers/legacy';
|
import { legacyResponseHandlerProvider } from 'ui/vis/response_handlers/legacy';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
import { VisProvider } from 'ui/vis';
|
import { Vis } from 'ui/vis';
|
||||||
import { tabifyAggResponse } from 'ui/agg_response/tabify';
|
import { tabifyAggResponse } from 'ui/agg_response/tabify';
|
||||||
|
|
||||||
describe('Table Vis - AggTableGroup Directive', function () {
|
describe('Table Vis - AggTableGroup Directive', function () {
|
||||||
let $rootScope;
|
let $rootScope;
|
||||||
let $compile;
|
let $compile;
|
||||||
let Vis;
|
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
let tableAggResponse;
|
let tableAggResponse;
|
||||||
const tabifiedData = {};
|
const tabifiedData = {};
|
||||||
|
@ -69,7 +68,6 @@ describe('Table Vis - AggTableGroup Directive', function () {
|
||||||
|
|
||||||
tableAggResponse = legacyResponseHandlerProvider().handler;
|
tableAggResponse = legacyResponseHandlerProvider().handler;
|
||||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
Vis = Private(VisProvider);
|
|
||||||
|
|
||||||
$rootScope = $injector.get('$rootScope');
|
$rootScope = $injector.get('$rootScope');
|
||||||
$compile = $injector.get('$compile');
|
$compile = $injector.get('$compile');
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
import * as visModule from 'ui/vis';
|
import { Vis } from 'ui/vis';
|
||||||
import { ImageComparator } from 'test_utils/image_comparator';
|
import { ImageComparator } from 'test_utils/image_comparator';
|
||||||
import { TagCloudVisualization } from '../tag_cloud_visualization';
|
import { TagCloudVisualization } from '../tag_cloud_visualization';
|
||||||
import basicdrawPng from './basicdraw.png';
|
import basicdrawPng from './basicdraw.png';
|
||||||
|
@ -33,7 +33,6 @@ const PIXEL_DIFF = 64;
|
||||||
describe('TagCloudVisualizationTest', function () {
|
describe('TagCloudVisualizationTest', function () {
|
||||||
|
|
||||||
let domNode;
|
let domNode;
|
||||||
let Vis;
|
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
let vis;
|
let vis;
|
||||||
let imageComparator;
|
let imageComparator;
|
||||||
|
@ -57,7 +56,6 @@ describe('TagCloudVisualizationTest', function () {
|
||||||
|
|
||||||
beforeEach(ngMock.module('kibana'));
|
beforeEach(ngMock.module('kibana'));
|
||||||
beforeEach(ngMock.inject((Private) => {
|
beforeEach(ngMock.inject((Private) => {
|
||||||
Vis = Private(visModule.VisProvider);
|
|
||||||
indexPattern = Private(LogstashIndexPatternStubProvider);
|
indexPattern = Private(LogstashIndexPatternStubProvider);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,7 @@ const APP_NAME = 'VisEditor';
|
||||||
export class VisEditor extends Component {
|
export class VisEditor extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
const { vis } = props;
|
this.appState = props.appState;
|
||||||
this.appState = vis.API.getAppState();
|
|
||||||
this.localStorage = new Storage(window.localStorage);
|
this.localStorage = new Storage(window.localStorage);
|
||||||
this.state = {
|
this.state = {
|
||||||
model: props.visParams,
|
model: props.visParams,
|
||||||
|
@ -183,7 +182,6 @@ export class VisEditor extends Component {
|
||||||
dirty={this.state.dirty}
|
dirty={this.state.dirty}
|
||||||
autoApply={this.state.autoApply}
|
autoApply={this.state.autoApply}
|
||||||
model={model}
|
model={model}
|
||||||
appState={this.appState}
|
|
||||||
savedObj={this.props.savedObj}
|
savedObj={this.props.savedObj}
|
||||||
timeRange={this.props.timeRange}
|
timeRange={this.props.timeRange}
|
||||||
uiState={this.uiState}
|
uiState={this.uiState}
|
||||||
|
@ -239,4 +237,5 @@ VisEditor.propTypes = {
|
||||||
isEditorMode: PropTypes.bool,
|
isEditorMode: PropTypes.bool,
|
||||||
savedObj: PropTypes.object,
|
savedObj: PropTypes.object,
|
||||||
timeRange: PropTypes.object,
|
timeRange: PropTypes.object,
|
||||||
|
appState: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ import ngMock from 'ng_mock';
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import { createVegaVisualization } from '../vega_visualization';
|
import { createVegaVisualization } from '../vega_visualization';
|
||||||
import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
import * as visModule from 'ui/vis';
|
import { Vis } from 'ui/vis';
|
||||||
import { ImageComparator } from 'test_utils/image_comparator';
|
import { ImageComparator } from 'test_utils/image_comparator';
|
||||||
|
|
||||||
import vegaliteGraph from '!!raw-loader!./vegalite_graph.hjson';
|
import vegaliteGraph from '!!raw-loader!./vegalite_graph.hjson';
|
||||||
|
@ -50,7 +50,6 @@ const PIXEL_DIFF = 30;
|
||||||
describe('VegaVisualizations', () => {
|
describe('VegaVisualizations', () => {
|
||||||
let domNode;
|
let domNode;
|
||||||
let VegaVisualization;
|
let VegaVisualization;
|
||||||
let Vis;
|
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
let vis;
|
let vis;
|
||||||
let imageComparator;
|
let imageComparator;
|
||||||
|
@ -73,7 +72,6 @@ describe('VegaVisualizations', () => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vis = Private(visModule.VisProvider);
|
|
||||||
|
|
||||||
VegaVisualization = createVegaVisualization(vegaVisualizationDependencies);
|
VegaVisualization = createVegaVisualization(vegaVisualizationDependencies);
|
||||||
indexPattern = Private(LogstashIndexPatternStubProvider);
|
indexPattern = Private(LogstashIndexPatternStubProvider);
|
||||||
|
|
|
@ -39,7 +39,6 @@ export { DefaultEditorSize } from 'ui/vis/editor_size';
|
||||||
import * as types from 'ui/vis/vis';
|
import * as types from 'ui/vis/vis';
|
||||||
export type Vis = types.Vis;
|
export type Vis = types.Vis;
|
||||||
export type VisParams = types.VisParams;
|
export type VisParams = types.VisParams;
|
||||||
export type VisProvider = types.VisProvider;
|
|
||||||
export type VisState = types.VisState;
|
export type VisState = types.VisState;
|
||||||
export { VisualizationController } from 'ui/vis/vis_types/vis_type';
|
export { VisualizationController } from 'ui/vis/vis_types/vis_type';
|
||||||
export { Status } from 'ui/vis/update_status';
|
export { Status } from 'ui/vis/update_status';
|
||||||
|
|
|
@ -20,15 +20,13 @@
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import { tabifyGetColumns } from '../_get_columns';
|
import { tabifyGetColumns } from '../_get_columns';
|
||||||
import { VisProvider } from '../../../vis';
|
import { Vis } from '../../../vis';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
describe('get columns', function () {
|
describe('get columns', function () {
|
||||||
let Vis;
|
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
|
|
||||||
beforeEach(ngMock.module('kibana'));
|
beforeEach(ngMock.module('kibana'));
|
||||||
beforeEach(ngMock.inject(function (Private) {
|
beforeEach(ngMock.inject(function (Private) {
|
||||||
Vis = Private(VisProvider);
|
|
||||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -22,16 +22,14 @@ import fixtures from 'fixtures/fake_hierarchical_data';
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import { tabifyAggResponse } from '../tabify';
|
import { tabifyAggResponse } from '../tabify';
|
||||||
import { VisProvider } from '../../../vis';
|
import { Vis } from '../../../vis';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
|
|
||||||
describe('tabifyAggResponse Integration', function () {
|
describe('tabifyAggResponse Integration', function () {
|
||||||
let Vis;
|
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
|
|
||||||
beforeEach(ngMock.module('kibana'));
|
beforeEach(ngMock.module('kibana'));
|
||||||
beforeEach(ngMock.inject(function (Private) {
|
beforeEach(ngMock.inject(function (Private) {
|
||||||
Vis = Private(VisProvider);
|
|
||||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,10 @@
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import { TabbedAggResponseWriter } from '../_response_writer';
|
import { TabbedAggResponseWriter } from '../_response_writer';
|
||||||
import { VisProvider } from '../../../vis';
|
import { Vis } from '../../../vis';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
|
|
||||||
describe('TabbedAggResponseWriter class', function () {
|
describe('TabbedAggResponseWriter class', function () {
|
||||||
let Vis;
|
|
||||||
let Private;
|
let Private;
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
|
|
||||||
|
@ -32,7 +31,6 @@ describe('TabbedAggResponseWriter class', function () {
|
||||||
beforeEach(ngMock.inject(function ($injector) {
|
beforeEach(ngMock.inject(function ($injector) {
|
||||||
Private = $injector.get('Private');
|
Private = $injector.get('Private');
|
||||||
|
|
||||||
Vis = Private(VisProvider);
|
|
||||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import { buildOtherBucketAgg, mergeOtherBucketAggResponse, updateMissingBucket } from '../../buckets/_terms_other_bucket_helper';
|
import { buildOtherBucketAgg, mergeOtherBucketAggResponse, updateMissingBucket } from '../../buckets/_terms_other_bucket_helper';
|
||||||
import { VisProvider } from '../../../vis';
|
import { Vis } from '../../../vis';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
|
|
||||||
const visConfigSingleTerm = {
|
const visConfigSingleTerm = {
|
||||||
|
@ -158,7 +158,6 @@ describe('Terms Agg Other bucket helper', () => {
|
||||||
function init(aggConfig) {
|
function init(aggConfig) {
|
||||||
ngMock.module('kibana');
|
ngMock.module('kibana');
|
||||||
ngMock.inject((Private) => {
|
ngMock.inject((Private) => {
|
||||||
const Vis = Private(VisProvider);
|
|
||||||
const indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
const indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
|
|
||||||
vis = new Vis(indexPattern, aggConfig);
|
vis = new Vis(indexPattern, aggConfig);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import { VisProvider } from '..';
|
import { Vis } from '..';
|
||||||
import { AggType } from '../../agg_types/agg_type';
|
import { AggType } from '../../agg_types/agg_type';
|
||||||
import { AggConfig } from '../../agg_types/agg_config';
|
import { AggConfig } from '../../agg_types/agg_config';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
|
@ -28,12 +28,10 @@ import { fieldFormats } from '../../registry/field_formats';
|
||||||
|
|
||||||
describe('AggConfig', function () {
|
describe('AggConfig', function () {
|
||||||
|
|
||||||
let Vis;
|
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
|
|
||||||
beforeEach(ngMock.module('kibana'));
|
beforeEach(ngMock.module('kibana'));
|
||||||
beforeEach(ngMock.inject(function (Private) {
|
beforeEach(ngMock.inject(function (Private) {
|
||||||
Vis = Private(VisProvider);
|
|
||||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import sinon from 'sinon';
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import { AggConfig } from '../../agg_types/agg_config';
|
import { AggConfig } from '../../agg_types/agg_config';
|
||||||
import { VisProvider } from '..';
|
import { Vis } from '..';
|
||||||
import { AggConfigs } from '../../agg_types/agg_configs';
|
import { AggConfigs } from '../../agg_types/agg_configs';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
import { Schemas } from '../editors/default/schemas';
|
import { Schemas } from '../editors/default/schemas';
|
||||||
|
@ -30,13 +30,11 @@ import { AggGroupNames } from '../editors/default/agg_groups';
|
||||||
|
|
||||||
describe('AggConfigs', function () {
|
describe('AggConfigs', function () {
|
||||||
|
|
||||||
let Vis;
|
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
|
|
||||||
beforeEach(ngMock.module('kibana'));
|
beforeEach(ngMock.module('kibana'));
|
||||||
beforeEach(ngMock.inject(function (Private) {
|
beforeEach(ngMock.inject(function (Private) {
|
||||||
// load main deps
|
// load main deps
|
||||||
Vis = Private(VisProvider);
|
|
||||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,12 @@
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import { VisProvider } from '..';
|
import { Vis } from '..';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
import { start as visualizations } from '../../../../core_plugins/visualizations/public/np_ready/public/legacy';
|
import { start as visualizations } from '../../../../core_plugins/visualizations/public/np_ready/public/legacy';
|
||||||
|
|
||||||
describe('Vis Class', function () {
|
describe('Vis Class', function () {
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
let Vis;
|
|
||||||
let visTypes;
|
let visTypes;
|
||||||
|
|
||||||
let vis;
|
let vis;
|
||||||
|
@ -43,7 +42,6 @@ describe('Vis Class', function () {
|
||||||
|
|
||||||
beforeEach(ngMock.module('kibana'));
|
beforeEach(ngMock.module('kibana'));
|
||||||
beforeEach(ngMock.inject(function (Private) {
|
beforeEach(ngMock.inject(function (Private) {
|
||||||
Vis = Private(VisProvider);
|
|
||||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
visTypes = visualizations.types;
|
visTypes = visualizations.types;
|
||||||
}));
|
}));
|
||||||
|
|
2
src/legacy/ui/public/vis/index.d.ts
vendored
2
src/legacy/ui/public/vis/index.d.ts
vendored
|
@ -18,5 +18,5 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export { AggConfig } from '../agg_types/agg_config';
|
export { AggConfig } from '../agg_types/agg_config';
|
||||||
export { Vis, VisProvider, VisParams, VisState } from './vis';
|
export { Vis, VisParams, VisState } from './vis';
|
||||||
export { VisualizationController, VisType } from './vis_types/vis_type';
|
export { VisualizationController, VisType } from './vis_types/vis_type';
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export { VisProvider } from './vis';
|
export { Vis } from './vis';
|
||||||
|
|
2
src/legacy/ui/public/vis/vis.d.ts
vendored
2
src/legacy/ui/public/vis/vis.d.ts
vendored
|
@ -30,8 +30,6 @@ export interface Vis {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type VisProvider = (...dependencies: any[]) => Vis;
|
|
||||||
|
|
||||||
export interface VisParams {
|
export interface VisParams {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,181 +38,178 @@ import { start as visualizations } from '../../../core_plugins/visualizations/pu
|
||||||
|
|
||||||
import '../directives/bind';
|
import '../directives/bind';
|
||||||
|
|
||||||
export function VisProvider(Private, getAppState) {
|
const visTypes = visualizations.types;
|
||||||
const visTypes = visualizations.types;
|
|
||||||
|
|
||||||
class Vis extends EventEmitter {
|
class Vis extends EventEmitter {
|
||||||
constructor(indexPattern, visState) {
|
constructor(indexPattern, visState) {
|
||||||
super();
|
super();
|
||||||
visState = visState || {};
|
visState = visState || {};
|
||||||
|
|
||||||
if (_.isString(visState)) {
|
if (_.isString(visState)) {
|
||||||
visState = {
|
visState = {
|
||||||
type: visState
|
type: visState
|
||||||
};
|
|
||||||
}
|
|
||||||
this.indexPattern = indexPattern;
|
|
||||||
this._setUiState(new PersistedState());
|
|
||||||
this.setCurrentState(visState);
|
|
||||||
this.setState(this.getCurrentState(), false);
|
|
||||||
|
|
||||||
// Session state is for storing information that is transitory, and will not be saved with the visualization.
|
|
||||||
// For instance, map bounds, which depends on the view port, browser window size, etc.
|
|
||||||
this.sessionState = {};
|
|
||||||
|
|
||||||
this.API = {
|
|
||||||
SearchSource: SearchSource,
|
|
||||||
events: {
|
|
||||||
filter: data => this.eventsSubject.next({ name: 'filterBucket', data }),
|
|
||||||
brush: data => this.eventsSubject.next({ name: 'brush', data }),
|
|
||||||
},
|
|
||||||
getAppState,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
this.indexPattern = indexPattern;
|
||||||
|
this._setUiState(new PersistedState());
|
||||||
|
this.setCurrentState(visState);
|
||||||
|
this.setState(this.getCurrentState(), false);
|
||||||
|
|
||||||
setCurrentState(state) {
|
// Session state is for storing information that is transitory, and will not be saved with the visualization.
|
||||||
this.title = state.title || '';
|
// For instance, map bounds, which depends on the view port, browser window size, etc.
|
||||||
const type = state.type || this.type;
|
this.sessionState = {};
|
||||||
if (_.isString(type)) {
|
|
||||||
this.type = visTypes.get(type);
|
this.API = {
|
||||||
if (!this.type) {
|
SearchSource: SearchSource,
|
||||||
throw new Error(`Invalid type "${type}"`);
|
events: {
|
||||||
}
|
filter: data => this.eventsSubject.next({ name: 'filterBucket', data }),
|
||||||
} else {
|
brush: data => this.eventsSubject.next({ name: 'brush', data }),
|
||||||
this.type = type;
|
},
|
||||||
}
|
};
|
||||||
|
}
|
||||||
this.params = _.defaults({},
|
|
||||||
_.cloneDeep(state.params || {}),
|
setCurrentState(state) {
|
||||||
_.cloneDeep(this.type.visConfig.defaults || {})
|
this.title = state.title || '';
|
||||||
);
|
const type = state.type || this.type;
|
||||||
|
if (_.isString(type)) {
|
||||||
updateVisualizationConfig(state.params, this.params);
|
this.type = visTypes.get(type);
|
||||||
|
if (!this.type) {
|
||||||
if (state.aggs || !this.aggs) {
|
throw new Error(`Invalid type "${type}"`);
|
||||||
this.aggs = new AggConfigs(this.indexPattern, state.aggs ? state.aggs.aggs || state.aggs : [], this.type.schemas.all);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(state, updateCurrentState = true) {
|
this.params = _.defaults({},
|
||||||
this._state = _.cloneDeep(state);
|
_.cloneDeep(state.params || {}),
|
||||||
if (updateCurrentState) {
|
_.cloneDeep(this.type.visConfig.defaults || {})
|
||||||
this.setCurrentState(this._state);
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateState() {
|
updateVisualizationConfig(state.params, this.params);
|
||||||
this.setState(this.getCurrentState(true));
|
|
||||||
this.emit('update');
|
|
||||||
}
|
|
||||||
|
|
||||||
forceReload() {
|
if (state.aggs || !this.aggs) {
|
||||||
this.emit('reload');
|
this.aggs = new AggConfigs(this.indexPattern, state.aggs ? state.aggs.aggs || state.aggs : [], this.type.schemas.all);
|
||||||
}
|
|
||||||
|
|
||||||
getCurrentState(includeDisabled) {
|
|
||||||
return {
|
|
||||||
title: this.title,
|
|
||||||
type: this.type.name,
|
|
||||||
params: _.cloneDeep(this.params),
|
|
||||||
aggs: this.aggs.aggs
|
|
||||||
.map(agg => agg.toJSON())
|
|
||||||
.filter(agg => includeDisabled || agg.enabled)
|
|
||||||
.filter(Boolean)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
getSerializableState(state) {
|
|
||||||
return {
|
|
||||||
title: state.title,
|
|
||||||
type: state.type,
|
|
||||||
params: _.cloneDeep(state.params),
|
|
||||||
aggs: state.aggs.aggs
|
|
||||||
.map(agg => agg.toJSON())
|
|
||||||
.filter(agg => agg.enabled)
|
|
||||||
.filter(Boolean)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
copyCurrentState(includeDisabled = false) {
|
|
||||||
const state = this.getCurrentState(includeDisabled);
|
|
||||||
state.aggs = new AggConfigs(this.indexPattern, state.aggs.aggs || state.aggs, this.type.schemas.all);
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
getStateInternal(includeDisabled) {
|
|
||||||
return {
|
|
||||||
title: this._state.title,
|
|
||||||
type: this._state.type,
|
|
||||||
params: this._state.params,
|
|
||||||
aggs: this._state.aggs
|
|
||||||
.filter(agg => includeDisabled || agg.enabled)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
getEnabledState() {
|
|
||||||
return this.getStateInternal(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
getAggConfig() {
|
|
||||||
return this.aggs.clone({ enabledOnly: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
getState() {
|
|
||||||
return this.getStateInternal(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
isHierarchical() {
|
|
||||||
if (_.isFunction(this.type.hierarchicalData)) {
|
|
||||||
return !!this.type.hierarchicalData(this);
|
|
||||||
} else {
|
|
||||||
return !!this.type.hierarchicalData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hasSchemaAgg(schemaName, aggTypeName) {
|
|
||||||
const aggs = this.aggs.bySchemaName(schemaName) || [];
|
|
||||||
return aggs.some(function (agg) {
|
|
||||||
if (!agg.type || !agg.type.name) return false;
|
|
||||||
return agg.type.name === aggTypeName;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
hasUiState() {
|
|
||||||
return !!this.__uiState;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
|
||||||
* this should not be used outside of visualize
|
|
||||||
* @param uiState
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
_setUiState(uiState) {
|
|
||||||
if (uiState instanceof PersistedState) {
|
|
||||||
this.__uiState = uiState;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getUiState() {
|
|
||||||
return this.__uiState;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Currently this is only used to extract map-specific information
|
|
||||||
* (e.g. mapZoom, mapCenter).
|
|
||||||
*/
|
|
||||||
uiStateVal(key, val) {
|
|
||||||
if (this.hasUiState()) {
|
|
||||||
if (_.isUndefined(val)) {
|
|
||||||
return this.__uiState.get(key);
|
|
||||||
}
|
|
||||||
return this.__uiState.set(key, val);
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vis.prototype.type = 'histogram';
|
setState(state, updateCurrentState = true) {
|
||||||
|
this._state = _.cloneDeep(state);
|
||||||
|
if (updateCurrentState) {
|
||||||
|
this.setCurrentState(this._state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Vis;
|
updateState() {
|
||||||
|
this.setState(this.getCurrentState(true));
|
||||||
|
this.emit('update');
|
||||||
|
}
|
||||||
|
|
||||||
|
forceReload() {
|
||||||
|
this.emit('reload');
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentState(includeDisabled) {
|
||||||
|
return {
|
||||||
|
title: this.title,
|
||||||
|
type: this.type.name,
|
||||||
|
params: _.cloneDeep(this.params),
|
||||||
|
aggs: this.aggs.aggs
|
||||||
|
.map(agg => agg.toJSON())
|
||||||
|
.filter(agg => includeDisabled || agg.enabled)
|
||||||
|
.filter(Boolean)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
getSerializableState(state) {
|
||||||
|
return {
|
||||||
|
title: state.title,
|
||||||
|
type: state.type,
|
||||||
|
params: _.cloneDeep(state.params),
|
||||||
|
aggs: state.aggs.aggs
|
||||||
|
.map(agg => agg.toJSON())
|
||||||
|
.filter(agg => agg.enabled)
|
||||||
|
.filter(Boolean)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
copyCurrentState(includeDisabled = false) {
|
||||||
|
const state = this.getCurrentState(includeDisabled);
|
||||||
|
state.aggs = new AggConfigs(this.indexPattern, state.aggs.aggs || state.aggs, this.type.schemas.all);
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
getStateInternal(includeDisabled) {
|
||||||
|
return {
|
||||||
|
title: this._state.title,
|
||||||
|
type: this._state.type,
|
||||||
|
params: this._state.params,
|
||||||
|
aggs: this._state.aggs
|
||||||
|
.filter(agg => includeDisabled || agg.enabled)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
getEnabledState() {
|
||||||
|
return this.getStateInternal(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
getAggConfig() {
|
||||||
|
return this.aggs.clone({ enabledOnly: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
getState() {
|
||||||
|
return this.getStateInternal(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
isHierarchical() {
|
||||||
|
if (_.isFunction(this.type.hierarchicalData)) {
|
||||||
|
return !!this.type.hierarchicalData(this);
|
||||||
|
} else {
|
||||||
|
return !!this.type.hierarchicalData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hasSchemaAgg(schemaName, aggTypeName) {
|
||||||
|
const aggs = this.aggs.bySchemaName(schemaName) || [];
|
||||||
|
return aggs.some(function (agg) {
|
||||||
|
if (!agg.type || !agg.type.name) return false;
|
||||||
|
return agg.type.name === aggTypeName;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
hasUiState() {
|
||||||
|
return !!this.__uiState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* this should not be used outside of visualize
|
||||||
|
* @param uiState
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_setUiState(uiState) {
|
||||||
|
if (uiState instanceof PersistedState) {
|
||||||
|
this.__uiState = uiState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getUiState() {
|
||||||
|
return this.__uiState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currently this is only used to extract map-specific information
|
||||||
|
* (e.g. mapZoom, mapCenter).
|
||||||
|
*/
|
||||||
|
uiStateVal(key, val) {
|
||||||
|
if (this.hasUiState()) {
|
||||||
|
if (_.isUndefined(val)) {
|
||||||
|
return this.__uiState.get(key);
|
||||||
|
}
|
||||||
|
return this.__uiState.set(key, val);
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vis.prototype.type = 'histogram';
|
||||||
|
|
||||||
|
export { Vis };
|
||||||
|
|
|
@ -21,7 +21,7 @@ import $ from 'jquery';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import ngMock from 'ng_mock';
|
import ngMock from 'ng_mock';
|
||||||
import { VisProvider } from '../../vis';
|
import { Vis } from '../../vis';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
|
|
||||||
describe('visualize_legend directive', function () {
|
describe('visualize_legend directive', function () {
|
||||||
|
@ -29,7 +29,6 @@ describe('visualize_legend directive', function () {
|
||||||
let $compile;
|
let $compile;
|
||||||
let $timeout;
|
let $timeout;
|
||||||
let $el;
|
let $el;
|
||||||
let Vis;
|
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
let fixtures;
|
let fixtures;
|
||||||
|
|
||||||
|
@ -39,7 +38,6 @@ describe('visualize_legend directive', function () {
|
||||||
$compile = $injector.get('$compile');
|
$compile = $injector.get('$compile');
|
||||||
$timeout = $injector.get('$timeout');
|
$timeout = $injector.get('$timeout');
|
||||||
fixtures = require('fixtures/fake_hierarchical_data');
|
fixtures = require('fixtures/fake_hierarchical_data');
|
||||||
Vis = Private(VisProvider);
|
|
||||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import _ from 'lodash';
|
||||||
import fixtures from 'fixtures/fake_hierarchical_data';
|
import fixtures from 'fixtures/fake_hierarchical_data';
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
|
import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
|
||||||
import { VisProvider } from '../../../vis';
|
import { Vis } from '../../../vis';
|
||||||
import '../../../persisted_state';
|
import '../../../persisted_state';
|
||||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||||
import { vislibSlicesResponseHandlerProvider } from '../../../vis/response_handlers/vislib';
|
import { vislibSlicesResponseHandlerProvider } from '../../../vis/response_handlers/vislib';
|
||||||
|
@ -113,7 +113,6 @@ describe('No global chart settings', function () {
|
||||||
addTooltip: true
|
addTooltip: true
|
||||||
};
|
};
|
||||||
let chart1;
|
let chart1;
|
||||||
let Vis;
|
|
||||||
let persistedState;
|
let persistedState;
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
let responseHandler;
|
let responseHandler;
|
||||||
|
@ -123,7 +122,6 @@ describe('No global chart settings', function () {
|
||||||
beforeEach(ngMock.module('kibana'));
|
beforeEach(ngMock.module('kibana'));
|
||||||
beforeEach(ngMock.inject(function (Private, $injector) {
|
beforeEach(ngMock.inject(function (Private, $injector) {
|
||||||
chart1 = Private(FixturesVislibVisFixtureProvider)(visLibParams1);
|
chart1 = Private(FixturesVislibVisFixtureProvider)(visLibParams1);
|
||||||
Vis = Private(VisProvider);
|
|
||||||
persistedState = new ($injector.get('PersistedState'))();
|
persistedState = new ($injector.get('PersistedState'))();
|
||||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
responseHandler = vislibSlicesResponseHandlerProvider().handler;
|
responseHandler = vislibSlicesResponseHandlerProvider().handler;
|
||||||
|
@ -203,7 +201,6 @@ describe('Vislib PieChart Class Test Suite', function () {
|
||||||
addTooltip: true
|
addTooltip: true
|
||||||
};
|
};
|
||||||
let vis;
|
let vis;
|
||||||
let Vis;
|
|
||||||
let persistedState;
|
let persistedState;
|
||||||
let indexPattern;
|
let indexPattern;
|
||||||
let data;
|
let data;
|
||||||
|
@ -213,7 +210,6 @@ describe('Vislib PieChart Class Test Suite', function () {
|
||||||
beforeEach(ngMock.module('kibana'));
|
beforeEach(ngMock.module('kibana'));
|
||||||
beforeEach(ngMock.inject(function (Private, $injector) {
|
beforeEach(ngMock.inject(function (Private, $injector) {
|
||||||
vis = Private(FixturesVislibVisFixtureProvider)(visLibParams);
|
vis = Private(FixturesVislibVisFixtureProvider)(visLibParams);
|
||||||
Vis = Private(VisProvider);
|
|
||||||
persistedState = new ($injector.get('PersistedState'))();
|
persistedState = new ($injector.get('PersistedState'))();
|
||||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
responseHandler = vislibSlicesResponseHandlerProvider().handler;
|
responseHandler = vislibSlicesResponseHandlerProvider().handler;
|
||||||
|
|
|
@ -33,114 +33,109 @@ import { PersistedState } from '../../persisted_state';
|
||||||
|
|
||||||
import { start as visualizations } from '../../../../core_plugins/visualizations/public/np_ready/public/legacy';
|
import { start as visualizations } from '../../../../core_plugins/visualizations/public/np_ready/public/legacy';
|
||||||
|
|
||||||
export function VisProvider(getAppState) {
|
const visTypes = visualizations.types;
|
||||||
const visTypes = visualizations.types;
|
|
||||||
|
|
||||||
class Vis extends EventEmitter {
|
export class Vis extends EventEmitter {
|
||||||
constructor(visState = { type: 'histogram' }) {
|
constructor(visState = { type: 'histogram' }) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this._setUiState(new PersistedState());
|
this._setUiState(new PersistedState());
|
||||||
this.setState(visState);
|
this.setState(visState);
|
||||||
|
|
||||||
// Session state is for storing information that is transitory, and will not be saved with the visualization.
|
// Session state is for storing information that is transitory, and will not be saved with the visualization.
|
||||||
// For instance, map bounds, which depends on the view port, browser window size, etc.
|
// For instance, map bounds, which depends on the view port, browser window size, etc.
|
||||||
this.sessionState = {};
|
this.sessionState = {};
|
||||||
|
|
||||||
this.API = {
|
this.API = {
|
||||||
events: {
|
events: {
|
||||||
filter: data => {
|
filter: data => {
|
||||||
if (!this.eventsSubject) return;
|
if (!this.eventsSubject) return;
|
||||||
this.eventsSubject.next({ name: 'filterBucket', data });
|
this.eventsSubject.next({ name: 'filterBucket', data });
|
||||||
},
|
|
||||||
brush: data => {
|
|
||||||
if (!this.eventsSubject) return;
|
|
||||||
this.eventsSubject.next({ name: 'brush', data });
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
getAppState,
|
brush: data => {
|
||||||
};
|
if (!this.eventsSubject) return;
|
||||||
}
|
this.eventsSubject.next({ name: 'brush', data });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
setState(state) {
|
setState(state) {
|
||||||
this.title = state.title || '';
|
this.title = state.title || '';
|
||||||
const type = state.type || this.type;
|
const type = state.type || this.type;
|
||||||
if (_.isString(type)) {
|
if (_.isString(type)) {
|
||||||
this.type = visTypes.get(type);
|
this.type = visTypes.get(type);
|
||||||
if (!this.type) {
|
if (!this.type) {
|
||||||
throw new Error(`Invalid type "${type}"`);
|
throw new Error(`Invalid type "${type}"`);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.type = type;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
this.params = _.defaultsDeep({},
|
this.type = type;
|
||||||
_.cloneDeep(state.params || {}),
|
|
||||||
_.cloneDeep(this.type.visConfig.defaults || {})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentState(state) {
|
this.params = _.defaultsDeep({},
|
||||||
this.setState(state);
|
_.cloneDeep(state.params || {}),
|
||||||
}
|
_.cloneDeep(this.type.visConfig.defaults || {})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
getState() {
|
setCurrentState(state) {
|
||||||
return {
|
this.setState(state);
|
||||||
title: this.title,
|
}
|
||||||
type: this.type.name,
|
|
||||||
params: _.cloneDeep(this.params),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
updateState() {
|
getState() {
|
||||||
this.emit('update');
|
return {
|
||||||
}
|
title: this.title,
|
||||||
|
type: this.type.name,
|
||||||
|
params: _.cloneDeep(this.params),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
forceReload() {
|
updateState() {
|
||||||
this.emit('reload');
|
this.emit('update');
|
||||||
}
|
}
|
||||||
|
|
||||||
isHierarchical() {
|
forceReload() {
|
||||||
if (_.isFunction(this.type.hierarchicalData)) {
|
this.emit('reload');
|
||||||
return !!this.type.hierarchicalData(this);
|
}
|
||||||
} else {
|
|
||||||
return !!this.type.hierarchicalData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hasUiState() {
|
isHierarchical() {
|
||||||
return !!this.__uiState;
|
if (_.isFunction(this.type.hierarchicalData)) {
|
||||||
}
|
return !!this.type.hierarchicalData(this);
|
||||||
|
} else {
|
||||||
/***
|
return !!this.type.hierarchicalData;
|
||||||
* this should not be used outside of visualize
|
|
||||||
* @param uiState
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
_setUiState(uiState) {
|
|
||||||
if (uiState instanceof PersistedState) {
|
|
||||||
this.__uiState = uiState;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getUiState() {
|
|
||||||
return this.__uiState;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Currently this is only used to extract map-specific information
|
|
||||||
* (e.g. mapZoom, mapCenter).
|
|
||||||
*/
|
|
||||||
uiStateVal(key, val) {
|
|
||||||
if (this.hasUiState()) {
|
|
||||||
if (_.isUndefined(val)) {
|
|
||||||
return this.__uiState.get(key);
|
|
||||||
}
|
|
||||||
return this.__uiState.set(key, val);
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Vis;
|
hasUiState() {
|
||||||
|
return !!this.__uiState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* this should not be used outside of visualize
|
||||||
|
* @param uiState
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_setUiState(uiState) {
|
||||||
|
if (uiState instanceof PersistedState) {
|
||||||
|
this.__uiState = uiState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getUiState() {
|
||||||
|
return this.__uiState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currently this is only used to extract map-specific information
|
||||||
|
* (e.g. mapZoom, mapCenter).
|
||||||
|
*/
|
||||||
|
uiStateVal(key, val) {
|
||||||
|
if (this.hasUiState()) {
|
||||||
|
if (_.isUndefined(val)) {
|
||||||
|
return this.__uiState.get(key);
|
||||||
|
}
|
||||||
|
return this.__uiState.set(key, val);
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue