[Monitoring] NP migration: Local angular module (#51823)
* More np stuff * Fixed tests and added more np stuff * Added missing variable * Fixed path and linting * resolved conflicts * Fixed liniting issues * Fixed type tests * Fixed i18n check * Added from master * Added more shims * Updated master * Merged master * Fixed ts config file * Fixed ui_exports * Fixed snapshots * Fixed hard refresh bug and some tests * Addresed feedback * Added missing imports Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
a68a18e8c3
commit
205c2ab761
95 changed files with 1382 additions and 309 deletions
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"styleSheetToCompile": "public/index.scss"
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { config } from './config';
|
||||
import { deprecations } from './deprecations';
|
||||
import { getUiExports } from './ui_exports';
|
||||
import { Plugin } from './server/plugin';
|
||||
import { initInfraSource } from './server/lib/logs/init_infra_source';
|
||||
import { KIBANA_ALERTING_ENABLED } from './common/constants';
|
||||
|
||||
/**
|
||||
* Invokes plugin modules to instantiate the Monitoring plugin for Kibana
|
||||
* @param kibana {Object} Kibana plugin instance
|
||||
* @return {Object} Monitoring UI Kibana plugin object
|
||||
*/
|
||||
const deps = ['kibana', 'elasticsearch', 'xpack_main'];
|
||||
if (KIBANA_ALERTING_ENABLED) {
|
||||
deps.push(...['alerting', 'actions']);
|
||||
}
|
||||
export const monitoring = kibana =>
|
||||
new kibana.Plugin({
|
||||
require: deps,
|
||||
id: 'monitoring',
|
||||
configPrefix: 'monitoring',
|
||||
publicDir: resolve(__dirname, 'public'),
|
||||
init(server) {
|
||||
const configs = [
|
||||
'monitoring.ui.enabled',
|
||||
'monitoring.kibana.collection.enabled',
|
||||
'monitoring.ui.max_bucket_size',
|
||||
'monitoring.ui.min_interval_seconds',
|
||||
'kibana.index',
|
||||
'monitoring.ui.show_license_expiration',
|
||||
'monitoring.ui.container.elasticsearch.enabled',
|
||||
'monitoring.ui.container.logstash.enabled',
|
||||
'monitoring.tests.cloud_detector.enabled',
|
||||
'monitoring.kibana.collection.interval',
|
||||
'monitoring.ui.elasticsearch.hosts',
|
||||
'monitoring.ui.elasticsearch',
|
||||
'monitoring.xpack_api_polling_frequency_millis',
|
||||
'server.uuid',
|
||||
'server.name',
|
||||
'server.host',
|
||||
'server.port',
|
||||
'monitoring.cluster_alerts.email_notifications.enabled',
|
||||
'monitoring.cluster_alerts.email_notifications.email_address',
|
||||
'monitoring.ui.ccs.enabled',
|
||||
'monitoring.ui.elasticsearch.logFetchCount',
|
||||
'monitoring.ui.logs.index',
|
||||
];
|
||||
|
||||
const serverConfig = server.config();
|
||||
const serverFacade = {
|
||||
config: () => ({
|
||||
get: key => {
|
||||
if (configs.includes(key)) {
|
||||
return serverConfig.get(key);
|
||||
}
|
||||
throw `Unknown key '${key}'`;
|
||||
},
|
||||
}),
|
||||
injectUiAppVars: server.injectUiAppVars,
|
||||
log: (...args) => server.log(...args),
|
||||
logger: server.newPlatform.coreContext.logger,
|
||||
getOSInfo: server.getOSInfo,
|
||||
events: {
|
||||
on: (...args) => server.events.on(...args),
|
||||
},
|
||||
expose: (...args) => server.expose(...args),
|
||||
route: (...args) => server.route(...args),
|
||||
_hapi: server,
|
||||
_kbnServer: this.kbnServer,
|
||||
};
|
||||
const { usageCollection, licensing } = server.newPlatform.setup.plugins;
|
||||
const plugins = {
|
||||
xpack_main: server.plugins.xpack_main,
|
||||
elasticsearch: server.plugins.elasticsearch,
|
||||
infra: server.plugins.infra,
|
||||
alerting: server.plugins.alerting,
|
||||
usageCollection,
|
||||
licensing,
|
||||
};
|
||||
|
||||
const plugin = new Plugin();
|
||||
plugin.setup(serverFacade, plugins);
|
||||
},
|
||||
config,
|
||||
deprecations,
|
||||
uiExports: getUiExports(),
|
||||
postInit(server) {
|
||||
const serverConfig = server.config();
|
||||
initInfraSource(serverConfig, server.plugins.infra);
|
||||
},
|
||||
});
|
138
x-pack/legacy/plugins/monitoring/index.ts
Normal file
138
x-pack/legacy/plugins/monitoring/index.ts
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
import KbnServer, { Server } from 'src/legacy/server/kbn_server';
|
||||
import {
|
||||
LegacyPluginApi,
|
||||
LegacyPluginSpec,
|
||||
LegacyPluginOptions,
|
||||
} from 'src/legacy/plugin_discovery/types';
|
||||
import { KIBANA_ALERTING_ENABLED } from './common/constants';
|
||||
|
||||
// @ts-ignore
|
||||
import { getUiExports } from './ui_exports';
|
||||
// @ts-ignore
|
||||
import { config as configDefaults } from './config';
|
||||
// @ts-ignore
|
||||
import { deprecations } from './deprecations';
|
||||
// @ts-ignore
|
||||
import { Plugin } from './server/plugin';
|
||||
// @ts-ignore
|
||||
import { initInfraSource } from './server/lib/logs/init_infra_source';
|
||||
|
||||
type InfraPlugin = any; // TODO
|
||||
type PluginsSetup = any; // TODO
|
||||
type LegacySetup = any; // TODO
|
||||
|
||||
const deps = ['kibana', 'elasticsearch', 'xpack_main'];
|
||||
if (KIBANA_ALERTING_ENABLED) {
|
||||
deps.push(...['alerting', 'actions']);
|
||||
}
|
||||
|
||||
const validConfigOptions: string[] = [
|
||||
'monitoring.ui.enabled',
|
||||
'monitoring.kibana.collection.enabled',
|
||||
'monitoring.ui.max_bucket_size',
|
||||
'monitoring.ui.min_interval_seconds',
|
||||
'kibana.index',
|
||||
'monitoring.ui.show_license_expiration',
|
||||
'monitoring.ui.container.elasticsearch.enabled',
|
||||
'monitoring.ui.container.logstash.enabled',
|
||||
'monitoring.tests.cloud_detector.enabled',
|
||||
'monitoring.kibana.collection.interval',
|
||||
'monitoring.ui.elasticsearch.hosts',
|
||||
'monitoring.ui.elasticsearch',
|
||||
'monitoring.xpack_api_polling_frequency_millis',
|
||||
'server.uuid',
|
||||
'server.name',
|
||||
'server.host',
|
||||
'server.port',
|
||||
'monitoring.cluster_alerts.email_notifications.enabled',
|
||||
'monitoring.cluster_alerts.email_notifications.email_address',
|
||||
'monitoring.ui.ccs.enabled',
|
||||
'monitoring.ui.elasticsearch.logFetchCount',
|
||||
'monitoring.ui.logs.index',
|
||||
];
|
||||
|
||||
interface LegacyPluginOptionsWithKbnServer extends LegacyPluginOptions {
|
||||
kbnServer?: KbnServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes plugin modules to instantiate the Monitoring plugin for Kibana
|
||||
* @param kibana {Object} Kibana plugin instance
|
||||
* @return {Object} Monitoring UI Kibana plugin object
|
||||
*/
|
||||
export const monitoring = (kibana: LegacyPluginApi): LegacyPluginSpec => {
|
||||
return new kibana.Plugin({
|
||||
require: deps,
|
||||
id: 'monitoring',
|
||||
configPrefix: 'monitoring',
|
||||
publicDir: resolve(__dirname, 'public'),
|
||||
config: configDefaults,
|
||||
uiExports: getUiExports(),
|
||||
deprecations,
|
||||
|
||||
init(server: Server) {
|
||||
const serverConfig = server.config();
|
||||
const { getOSInfo, plugins, injectUiAppVars } = server as typeof server & { getOSInfo?: any };
|
||||
const log = (...args: Parameters<typeof server.log>) => server.log(...args);
|
||||
const route = (...args: Parameters<typeof server.route>) => server.route(...args);
|
||||
const expose = (...args: Parameters<typeof server.expose>) => server.expose(...args);
|
||||
const serverFacade = {
|
||||
config: () => ({
|
||||
get: (key: string) => {
|
||||
if (validConfigOptions.includes(key)) {
|
||||
return serverConfig.get(key);
|
||||
}
|
||||
throw new Error(`Unknown key '${key}'`);
|
||||
},
|
||||
}),
|
||||
injectUiAppVars,
|
||||
log,
|
||||
logger: server.newPlatform.coreContext.logger,
|
||||
getOSInfo,
|
||||
events: {
|
||||
on: (...args: Parameters<typeof server.events.on>) => server.events.on(...args),
|
||||
},
|
||||
route,
|
||||
expose,
|
||||
_hapi: server,
|
||||
_kbnServer: this.kbnServer,
|
||||
};
|
||||
|
||||
const legacyPlugins = plugins as Partial<typeof plugins> & { infra?: InfraPlugin };
|
||||
const { xpack_main, elasticsearch, infra, alerting } = legacyPlugins;
|
||||
const {
|
||||
core: coreSetup,
|
||||
plugins: { usageCollection, licensing },
|
||||
} = server.newPlatform.setup;
|
||||
|
||||
const pluginsSetup: PluginsSetup = {
|
||||
usageCollection,
|
||||
licensing,
|
||||
};
|
||||
|
||||
const __LEGACY: LegacySetup = {
|
||||
...serverFacade,
|
||||
plugins: {
|
||||
xpack_main,
|
||||
elasticsearch,
|
||||
infra,
|
||||
alerting,
|
||||
},
|
||||
};
|
||||
|
||||
new Plugin().setup(coreSetup, pluginsSetup, __LEGACY);
|
||||
},
|
||||
|
||||
postInit(server: Server) {
|
||||
const { infra } = server.plugins as Partial<typeof server.plugins> & { infra?: InfraPlugin };
|
||||
initInfraSource(server.config(), infra);
|
||||
},
|
||||
} as Partial<LegacyPluginOptionsWithKbnServer>);
|
||||
};
|
|
@ -14,6 +14,12 @@ jest.mock('../../', () => ({
|
|||
MonitoringTimeseriesContainer: () => 'MonitoringTimeseriesContainer',
|
||||
}));
|
||||
|
||||
jest.mock('../../../np_imports/ui/chrome', () => {
|
||||
return {
|
||||
getBasePath: () => '',
|
||||
};
|
||||
});
|
||||
|
||||
import { BeatsOverview } from './overview';
|
||||
|
||||
describe('Overview', () => {
|
||||
|
|
|
@ -43,25 +43,34 @@ const props = {
|
|||
updateLegend: () => void 0,
|
||||
};
|
||||
|
||||
describe('Test legends to toggle series: ', () => {
|
||||
jest.mock('../../np_imports/ui/chrome', () => {
|
||||
return {
|
||||
getBasePath: () => '',
|
||||
};
|
||||
});
|
||||
|
||||
// TODO: Skipping for now, seems flaky in New Platform (needs more investigation)
|
||||
describe.skip('Test legends to toggle series: ', () => {
|
||||
const ids = props.series.map(item => item.id);
|
||||
|
||||
it('should toggle based on seriesToShow array', () => {
|
||||
const component = shallow(<ChartTarget {...props} />);
|
||||
describe('props.series: ', () => {
|
||||
it('should toggle based on seriesToShow array', () => {
|
||||
const component = shallow(<ChartTarget {...props} />);
|
||||
|
||||
const componentClass = component.instance();
|
||||
const componentClass = component.instance();
|
||||
|
||||
const seriesA = componentClass.filterData(props.series, [ids[0]]);
|
||||
expect(seriesA.length).to.be(1);
|
||||
expect(seriesA[0].id).to.be(ids[0]);
|
||||
const seriesA = componentClass.filterData(props.series, [ids[0]]);
|
||||
expect(seriesA.length).to.be(1);
|
||||
expect(seriesA[0].id).to.be(ids[0]);
|
||||
|
||||
const seriesB = componentClass.filterData(props.series, [ids[1]]);
|
||||
expect(seriesB.length).to.be(1);
|
||||
expect(seriesB[0].id).to.be(ids[1]);
|
||||
const seriesB = componentClass.filterData(props.series, [ids[1]]);
|
||||
expect(seriesB.length).to.be(1);
|
||||
expect(seriesB[0].id).to.be(ids[1]);
|
||||
|
||||
const seriesAB = componentClass.filterData(props.series, ids);
|
||||
expect(seriesAB.length).to.be(2);
|
||||
expect(seriesAB[0].id).to.be(ids[0]);
|
||||
expect(seriesAB[1].id).to.be(ids[1]);
|
||||
const seriesAB = componentClass.filterData(props.series, ids);
|
||||
expect(seriesAB.length).to.be(2);
|
||||
expect(seriesAB[0].id).to.be(ids[0]);
|
||||
expect(seriesAB[1].id).to.be(ids[1]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
import chrome from '../../np_imports/ui/chrome';
|
||||
import { merge } from 'lodash';
|
||||
import { CHART_LINE_COLOR, CHART_TEXT_COLOR } from '../../../common/constants';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import React, { Fragment, Component } from 'react';
|
||||
import chrome from 'ui/chrome';
|
||||
import chrome from 'plugins/monitoring/np_imports/ui/chrome';
|
||||
import moment from 'moment';
|
||||
import numeral from '@elastic/numeral';
|
||||
import { capitalize, partial } from 'lodash';
|
||||
|
|
|
@ -8,6 +8,12 @@ import React from 'react';
|
|||
import { shallow } from 'enzyme';
|
||||
import { CcrShard } from './ccr_shard';
|
||||
|
||||
jest.mock('../../../np_imports/ui/chrome', () => {
|
||||
return {
|
||||
getBasePath: () => '',
|
||||
};
|
||||
});
|
||||
|
||||
describe('CcrShard', () => {
|
||||
const props = {
|
||||
formattedLeader: 'leader on remote',
|
||||
|
|
|
@ -27,7 +27,7 @@ import { SetupModeBadge } from '../../setup_mode/badge';
|
|||
import { KIBANA_SYSTEM_ID } from '../../../../common/constants';
|
||||
import { ListingCallOut } from '../../setup_mode/listing_callout';
|
||||
|
||||
const getColumns = (kbnUrl, scope, setupMode) => {
|
||||
const getColumns = setupMode => {
|
||||
const columns = [
|
||||
{
|
||||
name: i18n.translate('xpack.monitoring.kibana.listing.nameColumnTitle', {
|
||||
|
@ -68,11 +68,7 @@ const getColumns = (kbnUrl, scope, setupMode) => {
|
|||
return (
|
||||
<div>
|
||||
<EuiLink
|
||||
onClick={() => {
|
||||
scope.$evalAsync(() => {
|
||||
kbnUrl.changePath(`/kibana/instances/${kibana.kibana.uuid}`);
|
||||
});
|
||||
}}
|
||||
href={`#/kibana/instances/${kibana.kibana.uuid}`}
|
||||
data-test-subj={`kibanaLink-${name}`}
|
||||
>
|
||||
{name}
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
} from '@elastic/eui';
|
||||
import { LicenseStatus, AddLicense } from 'plugins/xpack_main/components';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import chrome from 'ui/chrome';
|
||||
import chrome from 'plugins/monitoring/np_imports/ui/chrome';
|
||||
|
||||
const licenseManagement = `${chrome.getBasePath()}/app/kibana#/management/elasticsearch/license_management`;
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
*/
|
||||
import React, { PureComponent } from 'react';
|
||||
import { capitalize } from 'lodash';
|
||||
import chrome from 'ui/chrome';
|
||||
import chrome from '../../np_imports/ui/chrome';
|
||||
import { EuiBasicTable, EuiTitle, EuiSpacer, EuiText, EuiCallOut, EuiLink } from '@elastic/eui';
|
||||
import { INFRA_SOURCE_ID } from '../../../common/constants';
|
||||
import { formatDateTimeLocal } from '../../../common/formatting';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { Reason } from './reason';
|
||||
import { capabilities } from 'ui/capabilities';
|
||||
import { capabilities } from '../../np_imports/ui/capabilities';
|
||||
|
||||
const columnTimestampTitle = i18n.translate('xpack.monitoring.logs.listing.timestampTitle', {
|
||||
defaultMessage: 'Timestamp',
|
||||
|
|
|
@ -8,14 +8,14 @@ import React from 'react';
|
|||
import { shallow } from 'enzyme';
|
||||
import { Logs } from './logs';
|
||||
|
||||
jest.mock('ui/chrome', () => {
|
||||
jest.mock('../../np_imports/ui/chrome', () => {
|
||||
return {
|
||||
getBasePath: () => '',
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock(
|
||||
'ui/capabilities',
|
||||
'../../np_imports/ui/capabilities',
|
||||
() => ({
|
||||
capabilities: {
|
||||
get: () => ({ logs: { show: true } }),
|
||||
|
|
|
@ -10,6 +10,12 @@ import { NoData } from '../';
|
|||
|
||||
const enabler = {};
|
||||
|
||||
jest.mock('../../../np_imports/ui/chrome', () => {
|
||||
return {
|
||||
getBasePath: () => '',
|
||||
};
|
||||
});
|
||||
|
||||
describe('NoData', () => {
|
||||
test('should show text next to the spinner while checking a setting', () => {
|
||||
const component = renderWithIntl(
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
import { uiModules } from 'ui/modules';
|
||||
|
||||
const uiModule = uiModules.get('monitoring/directives', []);
|
||||
uiModule.service('sessionTimeout', () => {});
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
import { Beat } from 'plugins/monitoring/components/beats/beat';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
import { BeatsOverview } from 'plugins/monitoring/components/beats/overview';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import numeral from '@elastic/numeral';
|
|||
import React from 'react';
|
||||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
import { EuiMonitoringTable } from 'plugins/monitoring/components/table';
|
||||
import { MachineLearningJobStatusIcon } from 'plugins/monitoring/components/elasticsearch/ml_job_listing/status_icon';
|
||||
import { LARGE_ABBREVIATED, LARGE_BYTES } from '../../../../common/formatting';
|
||||
|
|
|
@ -8,12 +8,12 @@ import { render, unmountComponentAtNode } from 'react-dom';
|
|||
import { EuiSelect, EuiFlexGroup, EuiFlexItem, EuiTitle } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { get } from 'lodash';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
import template from './index.html';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { shortenPipelineHash } from '../../../common/formatting';
|
||||
import 'ui/directives/kbn_href';
|
||||
import { getSetupModeState, initSetupModeState } from '../../lib/setup_mode';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
const setOptions = controller => {
|
||||
if (
|
||||
|
@ -76,6 +76,24 @@ export class MonitoringMainController {
|
|||
this.inApm = false;
|
||||
}
|
||||
|
||||
addTimerangeObservers = () => {
|
||||
this.subscriptions = new Subscription();
|
||||
|
||||
const refreshIntervalUpdated = () => {
|
||||
const { value: refreshInterval, pause: isPaused } = timefilter.getRefreshInterval();
|
||||
this.datePicker.onRefreshChange({ refreshInterval, isPaused }, true);
|
||||
};
|
||||
|
||||
const timeUpdated = () => {
|
||||
this.datePicker.onTimeUpdate({ dateRange: timefilter.getTime() }, true);
|
||||
};
|
||||
|
||||
this.subscriptions.add(
|
||||
timefilter.getRefreshIntervalUpdate$().subscribe(refreshIntervalUpdated)
|
||||
);
|
||||
this.subscriptions.add(timefilter.getTimeUpdate$().subscribe(timeUpdated));
|
||||
};
|
||||
|
||||
dropdownLoadedHandler() {
|
||||
this.pipelineDropdownElement = document.querySelector('#dropdown-elm');
|
||||
setOptions(this);
|
||||
|
@ -122,22 +140,25 @@ export class MonitoringMainController {
|
|||
this.datePicker = {
|
||||
timeRange: timefilter.getTime(),
|
||||
refreshInterval: timefilter.getRefreshInterval(),
|
||||
onRefreshChange: ({ isPaused, refreshInterval }) => {
|
||||
onRefreshChange: ({ isPaused, refreshInterval }, skipSet = false) => {
|
||||
this.datePicker.refreshInterval = {
|
||||
pause: isPaused,
|
||||
value: refreshInterval,
|
||||
};
|
||||
|
||||
timefilter.setRefreshInterval({
|
||||
pause: isPaused,
|
||||
value: refreshInterval ? refreshInterval : this.datePicker.refreshInterval.value,
|
||||
});
|
||||
if (!skipSet) {
|
||||
timefilter.setRefreshInterval({
|
||||
pause: isPaused,
|
||||
value: refreshInterval ? refreshInterval : this.datePicker.refreshInterval.value,
|
||||
});
|
||||
}
|
||||
},
|
||||
onTimeUpdate: ({ dateRange }) => {
|
||||
onTimeUpdate: ({ dateRange }, skipSet = false) => {
|
||||
this.datePicker.timeRange = {
|
||||
...dateRange,
|
||||
};
|
||||
timefilter.setTime(dateRange);
|
||||
if (!skipSet) {
|
||||
timefilter.setTime(dateRange);
|
||||
}
|
||||
this._executorService.cancel();
|
||||
this._executorService.run();
|
||||
},
|
||||
|
@ -175,7 +196,7 @@ export class MonitoringMainController {
|
|||
}
|
||||
}
|
||||
|
||||
const uiModule = uiModules.get('plugins/monitoring/directives', []);
|
||||
const uiModule = uiModules.get('monitoring/directives', []);
|
||||
uiModule.directive('monitoringMain', (breadcrumbs, license, kbnUrl, $injector) => {
|
||||
const $executor = $injector.get('$executor');
|
||||
|
||||
|
@ -187,6 +208,7 @@ uiModule.directive('monitoringMain', (breadcrumbs, license, kbnUrl, $injector) =
|
|||
controllerAs: 'monitoringMain',
|
||||
bindToController: true,
|
||||
link(scope, _element, attributes, controller) {
|
||||
controller.addTimerangeObservers();
|
||||
initSetupModeState(scope, $injector, () => {
|
||||
controller.setup(getSetupObj());
|
||||
});
|
||||
|
@ -226,12 +248,11 @@ uiModule.directive('monitoringMain', (breadcrumbs, license, kbnUrl, $injector) =
|
|||
Object.keys(setupObj.attributes).forEach(key => {
|
||||
attributes.$observe(key, () => controller.setup(getSetupObj()));
|
||||
});
|
||||
scope.$on(
|
||||
'$destroy',
|
||||
() =>
|
||||
controller.pipelineDropdownElement &&
|
||||
unmountComponentAtNode(controller.pipelineDropdownElement)
|
||||
);
|
||||
scope.$on('$destroy', () => {
|
||||
controller.pipelineDropdownElement &&
|
||||
unmountComponentAtNode(controller.pipelineDropdownElement);
|
||||
controller.subscriptions && controller.subscriptions.unsubscribe();
|
||||
});
|
||||
scope.$watch('pageData.versions', versions => {
|
||||
controller.pipelineVersions = versions;
|
||||
setOptions(controller);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { capitalize } from 'lodash';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
import { formatNumber, formatMetric } from 'plugins/monitoring/lib/format_number';
|
||||
import { extractIp } from 'plugins/monitoring/lib/extract_ip';
|
||||
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import uiRoutes from 'ui/routes';
|
||||
import chrome from 'ui/chrome';
|
||||
import 'ui/kbn_top_nav';
|
||||
import 'ui/directives/storage';
|
||||
import 'ui/autoload/all';
|
||||
import 'plugins/monitoring/filters';
|
||||
import 'plugins/monitoring/services/clusters';
|
||||
import 'plugins/monitoring/services/features';
|
||||
|
@ -18,27 +13,15 @@ import 'plugins/monitoring/services/title';
|
|||
import 'plugins/monitoring/services/breadcrumbs';
|
||||
import 'plugins/monitoring/directives/all';
|
||||
import 'plugins/monitoring/views/all';
|
||||
import { npSetup, npStart } from '../public/np_imports/legacy_imports';
|
||||
import { plugin } from './np_ready';
|
||||
import { localApplicationService } from '../../../../../src/legacy/core_plugins/kibana/public/local_application_service';
|
||||
|
||||
const uiSettings = chrome.getUiSettingsClient();
|
||||
|
||||
// default timepicker default to the last hour
|
||||
uiSettings.overrideLocalDefault(
|
||||
'timepicker:timeDefaults',
|
||||
JSON.stringify({
|
||||
from: 'now-1h',
|
||||
to: 'now',
|
||||
mode: 'quick',
|
||||
})
|
||||
);
|
||||
|
||||
// default autorefresh to active and refreshing every 10 seconds
|
||||
uiSettings.overrideLocalDefault(
|
||||
'timepicker:refreshIntervalDefaults',
|
||||
JSON.stringify({
|
||||
pause: false,
|
||||
value: 10000,
|
||||
})
|
||||
);
|
||||
|
||||
// Enable Angular routing
|
||||
uiRoutes.enable();
|
||||
const pluginInstance = plugin({} as any);
|
||||
pluginInstance.setup(npSetup.core, npSetup.plugins);
|
||||
pluginInstance.start(npStart.core, {
|
||||
...npStart.plugins,
|
||||
__LEGACY: {
|
||||
localApplicationService,
|
||||
},
|
||||
});
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { ajaxErrorHandlersProvider } from './ajax_error_handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
|
||||
export function getPageData($injector, api) {
|
||||
const $http = $injector.get('$http');
|
||||
|
|
|
@ -27,8 +27,8 @@ export function routeInitProvider(Private, monitoringClusters, globalState, lice
|
|||
return (
|
||||
monitoringClusters(clusterUuid, undefined, codePaths)
|
||||
// Set the clusters collection and current cluster in globalState
|
||||
.then(async clusters => {
|
||||
const inSetupMode = await isInSetupMode();
|
||||
.then(clusters => {
|
||||
const inSetupMode = isInSetupMode();
|
||||
const cluster = getClusterFromClusters(clusters, globalState);
|
||||
if (!cluster && !inSetupMode) {
|
||||
return kbnUrl.redirect('/no-data');
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import {
|
||||
coreMock,
|
||||
overlayServiceMock,
|
||||
notificationServiceMock,
|
||||
} from '../../../../../../src/core/public/mocks';
|
||||
|
||||
let toggleSetupMode;
|
||||
let initSetupModeState;
|
||||
let getSetupModeState;
|
||||
|
@ -55,10 +61,70 @@ function waitForSetupModeData(action) {
|
|||
process.nextTick(action);
|
||||
}
|
||||
|
||||
function setModules() {
|
||||
jest.resetModules();
|
||||
function mockFilterManager() {
|
||||
let subscriber;
|
||||
let filters = [];
|
||||
return {
|
||||
getUpdates$: () => ({
|
||||
subscribe: ({ next }) => {
|
||||
subscriber = next;
|
||||
return jest.fn();
|
||||
},
|
||||
}),
|
||||
setFilters: newFilters => {
|
||||
filters = newFilters;
|
||||
subscriber();
|
||||
},
|
||||
getFilters: () => filters,
|
||||
removeAll: () => {
|
||||
filters = [];
|
||||
subscriber();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const pluginData = {
|
||||
query: {
|
||||
filterManager: mockFilterManager(),
|
||||
timefilter: {
|
||||
timefilter: {
|
||||
getTime: jest.fn(() => ({ from: 'now-1h', to: 'now' })),
|
||||
setTime: jest.fn(),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
function setModulesAndMocks(isOnCloud = false) {
|
||||
jest.clearAllMocks().resetModules();
|
||||
injectorModulesMock.globalState.inSetupMode = false;
|
||||
|
||||
jest.doMock('ui/new_platform', () => ({
|
||||
npSetup: {
|
||||
plugins: {
|
||||
cloud: isOnCloud ? { cloudId: 'test', isCloudEnabled: true } : {},
|
||||
uiActions: {
|
||||
registerAction: jest.fn(),
|
||||
attachAction: jest.fn(),
|
||||
},
|
||||
},
|
||||
core: {
|
||||
...coreMock.createSetup(),
|
||||
notifications: notificationServiceMock.createStartContract(),
|
||||
},
|
||||
},
|
||||
npStart: {
|
||||
plugins: {
|
||||
data: pluginData,
|
||||
navigation: { ui: {} },
|
||||
},
|
||||
core: {
|
||||
...coreMock.createStart(),
|
||||
overlays: overlayServiceMock.createStartContract(),
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
const setupMode = require('./setup_mode');
|
||||
toggleSetupMode = setupMode.toggleSetupMode;
|
||||
initSetupModeState = setupMode.initSetupModeState;
|
||||
|
@ -69,17 +135,7 @@ function setModules() {
|
|||
|
||||
describe('setup_mode', () => {
|
||||
beforeEach(async () => {
|
||||
jest.doMock('ui/new_platform', () => ({
|
||||
npSetup: {
|
||||
plugins: {
|
||||
cloud: {
|
||||
cloudId: undefined,
|
||||
isCloudEnabled: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
setModules();
|
||||
setModulesAndMocks();
|
||||
});
|
||||
|
||||
describe('setup', () => {
|
||||
|
@ -125,16 +181,6 @@ describe('setup_mode', () => {
|
|||
|
||||
it('should not fetch data if on cloud', async done => {
|
||||
const addDanger = jest.fn();
|
||||
jest.doMock('ui/new_platform', () => ({
|
||||
npSetup: {
|
||||
plugins: {
|
||||
cloud: {
|
||||
cloudId: 'test',
|
||||
isCloudEnabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
data = {
|
||||
_meta: {
|
||||
hasPermissions: true,
|
||||
|
@ -145,7 +191,7 @@ describe('setup_mode', () => {
|
|||
addDanger,
|
||||
},
|
||||
}));
|
||||
setModules();
|
||||
setModulesAndMocks(true);
|
||||
initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
await toggleSetupMode(true);
|
||||
waitForSetupModeData(() => {
|
||||
|
@ -171,7 +217,7 @@ describe('setup_mode', () => {
|
|||
hasPermissions: false,
|
||||
},
|
||||
};
|
||||
setModules();
|
||||
setModulesAndMocks();
|
||||
initSetupModeState(angularStateMock.scope, angularStateMock.injector);
|
||||
await toggleSetupMode(true);
|
||||
waitForSetupModeData(() => {
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
import React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import { get, contains } from 'lodash';
|
||||
import chrome from 'ui/chrome';
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { npSetup } from 'ui/new_platform';
|
||||
import { PluginsSetup } from 'ui/new_platform/new_platform';
|
||||
import chrome from '../np_imports/ui/chrome';
|
||||
import { CloudSetup } from '../../../../../plugins/cloud/public';
|
||||
import { ajaxErrorHandlersProvider } from './ajax_error_handler';
|
||||
import { SetupModeEnterButton } from '../components/setup_mode/enter_button';
|
||||
|
@ -207,12 +207,12 @@ export const initSetupModeState = async ($scope: any, $injector: any, callback?:
|
|||
}
|
||||
};
|
||||
|
||||
export const isInSetupMode = async () => {
|
||||
export const isInSetupMode = () => {
|
||||
if (setupModeState.enabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const $injector = angularState.injector || (await chrome.dangerouslyGetActiveInjector());
|
||||
const $injector = angularState.injector || chrome.dangerouslyGetActiveInjector();
|
||||
const globalState = $injector.get('globalState');
|
||||
return globalState.inSetupMode;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import {
|
||||
ICompileProvider,
|
||||
IHttpProvider,
|
||||
IHttpService,
|
||||
ILocationProvider,
|
||||
IModule,
|
||||
IRootScopeService,
|
||||
} from 'angular';
|
||||
import $ from 'jquery';
|
||||
import _, { cloneDeep, forOwn, get, set } from 'lodash';
|
||||
import * as Rx from 'rxjs';
|
||||
import { CoreStart, LegacyCoreStart } from 'kibana/public';
|
||||
|
||||
const isSystemApiRequest = (request: any) =>
|
||||
Boolean(request && request.headers && !!request.headers['kbn-system-api']);
|
||||
|
||||
export const configureAppAngularModule = (angularModule: IModule, newPlatform: LegacyCoreStart) => {
|
||||
const legacyMetadata = newPlatform.injectedMetadata.getLegacyMetadata();
|
||||
|
||||
forOwn(newPlatform.injectedMetadata.getInjectedVars(), (val, name) => {
|
||||
if (name !== undefined) {
|
||||
// The legacy platform modifies some of these values, clone to an unfrozen object.
|
||||
angularModule.value(name, cloneDeep(val));
|
||||
}
|
||||
});
|
||||
|
||||
angularModule
|
||||
.value('kbnVersion', newPlatform.injectedMetadata.getKibanaVersion())
|
||||
.value('buildNum', legacyMetadata.buildNum)
|
||||
.value('buildSha', legacyMetadata.buildSha)
|
||||
.value('serverName', legacyMetadata.serverName)
|
||||
.value('esUrl', getEsUrl(newPlatform))
|
||||
.value('uiCapabilities', newPlatform.application.capabilities)
|
||||
.config(setupCompileProvider(newPlatform))
|
||||
.config(setupLocationProvider())
|
||||
.config($setupXsrfRequestInterceptor(newPlatform))
|
||||
.run(capture$httpLoadingCount(newPlatform))
|
||||
.run($setupUICapabilityRedirect(newPlatform));
|
||||
};
|
||||
|
||||
const getEsUrl = (newPlatform: CoreStart) => {
|
||||
const a = document.createElement('a');
|
||||
a.href = newPlatform.http.basePath.prepend('/elasticsearch');
|
||||
const protocolPort = /https/.test(a.protocol) ? 443 : 80;
|
||||
const port = a.port || protocolPort;
|
||||
return {
|
||||
host: a.hostname,
|
||||
port,
|
||||
protocol: a.protocol,
|
||||
pathname: a.pathname,
|
||||
};
|
||||
};
|
||||
|
||||
const setupCompileProvider = (newPlatform: LegacyCoreStart) => (
|
||||
$compileProvider: ICompileProvider
|
||||
) => {
|
||||
if (!newPlatform.injectedMetadata.getLegacyMetadata().devMode) {
|
||||
$compileProvider.debugInfoEnabled(false);
|
||||
}
|
||||
};
|
||||
|
||||
const setupLocationProvider = () => ($locationProvider: ILocationProvider) => {
|
||||
$locationProvider.html5Mode({
|
||||
enabled: false,
|
||||
requireBase: false,
|
||||
rewriteLinks: false,
|
||||
});
|
||||
|
||||
$locationProvider.hashPrefix('');
|
||||
};
|
||||
|
||||
const $setupXsrfRequestInterceptor = (newPlatform: LegacyCoreStart) => {
|
||||
const version = newPlatform.injectedMetadata.getLegacyMetadata().version;
|
||||
|
||||
// Configure jQuery prefilter
|
||||
$.ajaxPrefilter(({ kbnXsrfToken = true }: any, originalOptions, jqXHR) => {
|
||||
if (kbnXsrfToken) {
|
||||
jqXHR.setRequestHeader('kbn-version', version);
|
||||
}
|
||||
});
|
||||
|
||||
return ($httpProvider: IHttpProvider) => {
|
||||
// Configure $httpProvider interceptor
|
||||
$httpProvider.interceptors.push(() => {
|
||||
return {
|
||||
request(opts) {
|
||||
const { kbnXsrfToken = true } = opts as any;
|
||||
if (kbnXsrfToken) {
|
||||
set(opts, ['headers', 'kbn-version'], version);
|
||||
}
|
||||
return opts;
|
||||
},
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Injected into angular module by ui/chrome angular integration
|
||||
* and adds a root-level watcher that will capture the count of
|
||||
* active $http requests on each digest loop and expose the count to
|
||||
* the core.loadingCount api
|
||||
* @param {Angular.Scope} $rootScope
|
||||
* @param {HttpService} $http
|
||||
* @return {undefined}
|
||||
*/
|
||||
const capture$httpLoadingCount = (newPlatform: CoreStart) => (
|
||||
$rootScope: IRootScopeService,
|
||||
$http: IHttpService
|
||||
) => {
|
||||
newPlatform.http.addLoadingCountSource(
|
||||
new Rx.Observable(observer => {
|
||||
const unwatch = $rootScope.$watch(() => {
|
||||
const reqs = $http.pendingRequests || [];
|
||||
observer.next(reqs.filter(req => !isSystemApiRequest(req)).length);
|
||||
});
|
||||
|
||||
return unwatch;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* integrates with angular to automatically redirect to home if required
|
||||
* capability is not met
|
||||
*/
|
||||
const $setupUICapabilityRedirect = (newPlatform: CoreStart) => (
|
||||
$rootScope: IRootScopeService,
|
||||
$injector: any
|
||||
) => {
|
||||
const isKibanaAppRoute = window.location.pathname.endsWith('/app/kibana');
|
||||
// this feature only works within kibana app for now after everything is
|
||||
// switched to the application service, this can be changed to handle all
|
||||
// apps.
|
||||
if (!isKibanaAppRoute) {
|
||||
return;
|
||||
}
|
||||
$rootScope.$on(
|
||||
'$routeChangeStart',
|
||||
(event, { $$route: route }: { $$route?: { requireUICapability: boolean } } = {}) => {
|
||||
if (!route || !route.requireUICapability) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!get(newPlatform.application.capabilities, route.requireUICapability)) {
|
||||
$injector.get('kbnUrl').change('/home');
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import angular, { IModule } from 'angular';
|
||||
|
||||
import { AppMountContext, LegacyCoreStart } from 'kibana/public';
|
||||
|
||||
// @ts-ignore TODO: change to absolute path
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
// @ts-ignore TODO: change to absolute path
|
||||
import chrome from 'plugins/monitoring/np_imports/ui/chrome';
|
||||
// @ts-ignore TODO: change to absolute path
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
// @ts-ignore TODO: change to absolute path
|
||||
import { registerTimefilterWithGlobalState } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { configureAppAngularModule } from './angular_config';
|
||||
|
||||
import { localAppModule, appModuleName } from './modules';
|
||||
|
||||
export class AngularApp {
|
||||
private injector?: angular.auto.IInjectorService;
|
||||
|
||||
constructor({ core }: AppMountContext, { element }: { element: HTMLElement }) {
|
||||
uiModules.addToModule();
|
||||
const app: IModule = localAppModule(core);
|
||||
app.config(($routeProvider: any) => {
|
||||
$routeProvider.eagerInstantiationEnabled(false);
|
||||
uiRoutes.addToProvider($routeProvider);
|
||||
});
|
||||
configureAppAngularModule(app, core as LegacyCoreStart);
|
||||
registerTimefilterWithGlobalState(app);
|
||||
const appElement = document.createElement('div');
|
||||
appElement.setAttribute('style', 'height: 100%');
|
||||
appElement.innerHTML = '<div ng-view style="height: 100%" id="monitoring-angular-app"></div>';
|
||||
this.injector = angular.bootstrap(appElement, [appModuleName]);
|
||||
chrome.setInjector(this.injector);
|
||||
angular.element(element).append(appElement);
|
||||
}
|
||||
|
||||
public destroy = () => {
|
||||
if (this.injector) {
|
||||
this.injector.get('$rootScope').$destroy();
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import angular, { IWindowService } from 'angular';
|
||||
import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular';
|
||||
|
||||
import { AppMountContext } from 'kibana/public';
|
||||
import { Storage } from '../../../../../../../src/plugins/kibana_utils/public';
|
||||
|
||||
import {
|
||||
GlobalStateProvider,
|
||||
StateManagementConfigProvider,
|
||||
AppStateProvider,
|
||||
EventsProvider,
|
||||
PersistedState,
|
||||
createTopNavDirective,
|
||||
createTopNavHelper,
|
||||
KbnUrlProvider,
|
||||
RedirectWhenMissingProvider,
|
||||
npStart,
|
||||
} from '../legacy_imports';
|
||||
|
||||
// @ts-ignore
|
||||
import { PromiseServiceCreator } from './providers/promises';
|
||||
// @ts-ignore
|
||||
import { PrivateProvider } from './providers/private';
|
||||
|
||||
type IPrivate = <T>(provider: (...injectable: any[]) => T) => T;
|
||||
|
||||
export const appModuleName = 'monitoring';
|
||||
const thirdPartyAngularDependencies = ['ngSanitize', 'ngRoute', 'react'];
|
||||
|
||||
export const localAppModule = (core: AppMountContext['core']) => {
|
||||
createLocalI18nModule();
|
||||
createLocalPrivateModule();
|
||||
createLocalPromiseModule();
|
||||
createLocalStorage();
|
||||
createLocalConfigModule(core);
|
||||
createLocalKbnUrlModule();
|
||||
createLocalStateModule();
|
||||
createLocalPersistedStateModule();
|
||||
createLocalTopNavModule(npStart.plugins.navigation);
|
||||
createHrefModule(core);
|
||||
|
||||
const appModule = angular.module(appModuleName, [
|
||||
...thirdPartyAngularDependencies,
|
||||
'monitoring/Config',
|
||||
'monitoring/I18n',
|
||||
'monitoring/Private',
|
||||
'monitoring/PersistedState',
|
||||
'monitoring/TopNav',
|
||||
'monitoring/State',
|
||||
'monitoring/Storage',
|
||||
'monitoring/href',
|
||||
'monitoring/services',
|
||||
'monitoring/filters',
|
||||
'monitoring/directives',
|
||||
]);
|
||||
return appModule;
|
||||
};
|
||||
|
||||
function createLocalStateModule() {
|
||||
angular
|
||||
.module('monitoring/State', [
|
||||
'monitoring/Private',
|
||||
'monitoring/Config',
|
||||
'monitoring/KbnUrl',
|
||||
'monitoring/Promise',
|
||||
'monitoring/PersistedState',
|
||||
])
|
||||
.factory('AppState', function(Private: IPrivate) {
|
||||
return Private(AppStateProvider);
|
||||
})
|
||||
.service('globalState', function(Private: IPrivate) {
|
||||
return Private(GlobalStateProvider);
|
||||
});
|
||||
}
|
||||
|
||||
function createLocalPersistedStateModule() {
|
||||
angular
|
||||
.module('monitoring/PersistedState', ['monitoring/Private', 'monitoring/Promise'])
|
||||
.factory('PersistedState', (Private: IPrivate) => {
|
||||
const Events = Private(EventsProvider);
|
||||
return class AngularPersistedState extends PersistedState {
|
||||
constructor(value: any, path: string) {
|
||||
super(value, path, Events);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function createLocalKbnUrlModule() {
|
||||
angular
|
||||
.module('monitoring/KbnUrl', ['monitoring/Private', 'ngRoute'])
|
||||
.service('kbnUrl', (Private: IPrivate) => Private(KbnUrlProvider))
|
||||
.service('redirectWhenMissing', (Private: IPrivate) => Private(RedirectWhenMissingProvider));
|
||||
}
|
||||
|
||||
function createLocalConfigModule(core: AppMountContext['core']) {
|
||||
angular
|
||||
.module('monitoring/Config', ['monitoring/Private'])
|
||||
.provider('stateManagementConfig', StateManagementConfigProvider)
|
||||
.provider('config', () => {
|
||||
return {
|
||||
$get: () => ({
|
||||
get: core.uiSettings.get.bind(core.uiSettings),
|
||||
}),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function createLocalPromiseModule() {
|
||||
angular.module('monitoring/Promise', []).service('Promise', PromiseServiceCreator);
|
||||
}
|
||||
|
||||
function createLocalStorage() {
|
||||
angular
|
||||
.module('monitoring/Storage', [])
|
||||
.service('localStorage', ($window: IWindowService) => new Storage($window.localStorage))
|
||||
.service('sessionStorage', ($window: IWindowService) => new Storage($window.sessionStorage))
|
||||
.service('sessionTimeout', () => {});
|
||||
}
|
||||
|
||||
function createLocalPrivateModule() {
|
||||
angular.module('monitoring/Private', []).provider('Private', PrivateProvider);
|
||||
}
|
||||
|
||||
function createLocalTopNavModule({ ui }: any) {
|
||||
angular
|
||||
.module('monitoring/TopNav', ['react'])
|
||||
.directive('kbnTopNav', createTopNavDirective)
|
||||
.directive('kbnTopNavHelper', createTopNavHelper(ui));
|
||||
}
|
||||
|
||||
function createLocalI18nModule() {
|
||||
angular
|
||||
.module('monitoring/I18n', [])
|
||||
.provider('i18n', I18nProvider)
|
||||
.filter('i18n', i18nFilter)
|
||||
.directive('i18nId', i18nDirective);
|
||||
}
|
||||
|
||||
function createHrefModule(core: AppMountContext['core']) {
|
||||
const name: string = 'kbnHref';
|
||||
angular.module('monitoring/href', []).directive(name, () => {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: {
|
||||
pre: (_$scope, _$el, $attr) => {
|
||||
$attr.$observe(name, val => {
|
||||
if (val) {
|
||||
$attr.$set('href', core.http.basePath.prepend(val as string));
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
196
x-pack/legacy/plugins/monitoring/public/np_imports/angular/providers/private.js
vendored
Normal file
196
x-pack/legacy/plugins/monitoring/public/np_imports/angular/providers/private.js
vendored
Normal file
|
@ -0,0 +1,196 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* # `Private()`
|
||||
* Private module loader, used to merge angular and require js dependency styles
|
||||
* by allowing a require.js module to export a single provider function that will
|
||||
* create a value used within an angular application. This provider can declare
|
||||
* angular dependencies by listing them as arguments, and can be require additional
|
||||
* Private modules.
|
||||
*
|
||||
* ## Define a private module provider:
|
||||
* ```js
|
||||
* export default function PingProvider($http) {
|
||||
* this.ping = function () {
|
||||
* return $http.head('/health-check');
|
||||
* };
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* ## Require a private module:
|
||||
* ```js
|
||||
* export default function ServerHealthProvider(Private, Promise) {
|
||||
* let ping = Private(require('ui/ping'));
|
||||
* return {
|
||||
* check: Promise.method(function () {
|
||||
* let attempts = 0;
|
||||
* return (function attempt() {
|
||||
* attempts += 1;
|
||||
* return ping.ping()
|
||||
* .catch(function (err) {
|
||||
* if (attempts < 3) return attempt();
|
||||
* })
|
||||
* }())
|
||||
* .then(function () {
|
||||
* return true;
|
||||
* })
|
||||
* .catch(function () {
|
||||
* return false;
|
||||
* });
|
||||
* })
|
||||
* }
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* # `Private.stub(provider, newInstance)`
|
||||
* `Private.stub()` replaces the instance of a module with another value. This is all we have needed until now.
|
||||
*
|
||||
* ```js
|
||||
* beforeEach(inject(function ($injector, Private) {
|
||||
* Private.stub(
|
||||
* // since this module just exports a function, we need to change
|
||||
* // what Private returns in order to modify it's behavior
|
||||
* require('ui/agg_response/hierarchical/_build_split'),
|
||||
* sinon.stub().returns(fakeSplit)
|
||||
* );
|
||||
* }));
|
||||
* ```
|
||||
*
|
||||
* # `Private.swap(oldProvider, newProvider)`
|
||||
* This new method does an 1-for-1 swap of module providers, unlike `stub()` which replaces a modules instance.
|
||||
* Pass the module you want to swap out, and the one it should be replaced with, then profit.
|
||||
*
|
||||
* Note: even though this example shows `swap()` being called in a config
|
||||
* function, it can be called from anywhere. It is particularly useful
|
||||
* in this scenario though.
|
||||
*
|
||||
* ```js
|
||||
* beforeEach(module('kibana', function (PrivateProvider) {
|
||||
* PrivateProvider.swap(
|
||||
* function StubbedRedirectProvider($decorate) {
|
||||
* // $decorate is a function that will instantiate the original module when called
|
||||
* return sinon.spy($decorate());
|
||||
* }
|
||||
* );
|
||||
* }));
|
||||
* ```
|
||||
*
|
||||
* @param {[type]} prov [description]
|
||||
*/
|
||||
import _ from 'lodash';
|
||||
|
||||
const nextId = _.partial(_.uniqueId, 'privateProvider#');
|
||||
|
||||
function name(fn) {
|
||||
return (
|
||||
fn.name ||
|
||||
fn
|
||||
.toString()
|
||||
.split('\n')
|
||||
.shift()
|
||||
);
|
||||
}
|
||||
|
||||
export function PrivateProvider() {
|
||||
const provider = this;
|
||||
|
||||
// one cache/swaps per Provider
|
||||
const cache = {};
|
||||
const swaps = {};
|
||||
|
||||
// return the uniq id for this function
|
||||
function identify(fn) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('Expected private module "' + fn + '" to be a function');
|
||||
}
|
||||
|
||||
if (fn.$$id) return fn.$$id;
|
||||
else return (fn.$$id = nextId());
|
||||
}
|
||||
|
||||
provider.stub = function(fn, instance) {
|
||||
cache[identify(fn)] = instance;
|
||||
return instance;
|
||||
};
|
||||
|
||||
provider.swap = function(fn, prov) {
|
||||
const id = identify(fn);
|
||||
swaps[id] = prov;
|
||||
};
|
||||
|
||||
provider.$get = [
|
||||
'$injector',
|
||||
function PrivateFactory($injector) {
|
||||
// prevent circular deps by tracking where we came from
|
||||
const privPath = [];
|
||||
const pathToString = function() {
|
||||
return privPath.map(name).join(' -> ');
|
||||
};
|
||||
|
||||
// call a private provider and return the instance it creates
|
||||
function instantiate(prov, locals) {
|
||||
if (~privPath.indexOf(prov)) {
|
||||
throw new Error(
|
||||
'Circular reference to "' +
|
||||
name(prov) +
|
||||
'"' +
|
||||
' found while resolving private deps: ' +
|
||||
pathToString()
|
||||
);
|
||||
}
|
||||
|
||||
privPath.push(prov);
|
||||
|
||||
const context = {};
|
||||
let instance = $injector.invoke(prov, context, locals);
|
||||
if (!_.isObject(instance)) instance = context;
|
||||
|
||||
privPath.pop();
|
||||
return instance;
|
||||
}
|
||||
|
||||
// retrieve an instance from cache or create and store on
|
||||
function get(id, prov, $delegateId, $delegateProv) {
|
||||
if (cache[id]) return cache[id];
|
||||
|
||||
let instance;
|
||||
|
||||
if ($delegateId != null && $delegateProv != null) {
|
||||
instance = instantiate(prov, {
|
||||
$decorate: _.partial(get, $delegateId, $delegateProv),
|
||||
});
|
||||
} else {
|
||||
instance = instantiate(prov);
|
||||
}
|
||||
|
||||
return (cache[id] = instance);
|
||||
}
|
||||
|
||||
// main api, get the appropriate instance for a provider
|
||||
function Private(prov) {
|
||||
let id = identify(prov);
|
||||
let $delegateId;
|
||||
let $delegateProv;
|
||||
|
||||
if (swaps[id]) {
|
||||
$delegateId = id;
|
||||
$delegateProv = prov;
|
||||
|
||||
prov = swaps[$delegateId];
|
||||
id = identify(prov);
|
||||
}
|
||||
|
||||
return get(id, prov, $delegateId, $delegateProv);
|
||||
}
|
||||
|
||||
Private.stub = provider.stub;
|
||||
Private.swap = provider.swap;
|
||||
|
||||
return Private;
|
||||
},
|
||||
];
|
||||
}
|
116
x-pack/legacy/plugins/monitoring/public/np_imports/angular/providers/promises.js
vendored
Normal file
116
x-pack/legacy/plugins/monitoring/public/np_imports/angular/providers/promises.js
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
export function PromiseServiceCreator($q, $timeout) {
|
||||
function Promise(fn) {
|
||||
if (typeof this === 'undefined')
|
||||
throw new Error('Promise constructor must be called with "new"');
|
||||
|
||||
const defer = $q.defer();
|
||||
try {
|
||||
fn(defer.resolve, defer.reject);
|
||||
} catch (e) {
|
||||
defer.reject(e);
|
||||
}
|
||||
return defer.promise;
|
||||
}
|
||||
|
||||
Promise.all = Promise.props = $q.all;
|
||||
Promise.resolve = function(val) {
|
||||
const defer = $q.defer();
|
||||
defer.resolve(val);
|
||||
return defer.promise;
|
||||
};
|
||||
Promise.reject = function(reason) {
|
||||
const defer = $q.defer();
|
||||
defer.reject(reason);
|
||||
return defer.promise;
|
||||
};
|
||||
Promise.cast = $q.when;
|
||||
Promise.delay = function(ms) {
|
||||
return $timeout(_.noop, ms);
|
||||
};
|
||||
Promise.method = function(fn) {
|
||||
return function() {
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
return Promise.try(fn, args, this);
|
||||
};
|
||||
};
|
||||
Promise.nodeify = function(promise, cb) {
|
||||
promise.then(function(val) {
|
||||
cb(void 0, val);
|
||||
}, cb);
|
||||
};
|
||||
Promise.map = function(arr, fn) {
|
||||
return Promise.all(
|
||||
arr.map(function(i, el, list) {
|
||||
return Promise.try(fn, [i, el, list]);
|
||||
})
|
||||
);
|
||||
};
|
||||
Promise.each = function(arr, fn) {
|
||||
const queue = arr.slice(0);
|
||||
let i = 0;
|
||||
return (function next() {
|
||||
if (!queue.length) return arr;
|
||||
return Promise.try(fn, [arr.shift(), i++]).then(next);
|
||||
})();
|
||||
};
|
||||
Promise.is = function(obj) {
|
||||
// $q doesn't create instances of any constructor, promises are just objects with a then function
|
||||
// https://github.com/angular/angular.js/blob/58f5da86645990ef984353418cd1ed83213b111e/src/ng/q.js#L335
|
||||
return obj && typeof obj.then === 'function';
|
||||
};
|
||||
Promise.halt = _.once(function() {
|
||||
const promise = new Promise(() => {});
|
||||
promise.then = _.constant(promise);
|
||||
promise.catch = _.constant(promise);
|
||||
return promise;
|
||||
});
|
||||
Promise.try = function(fn, args, ctx) {
|
||||
if (typeof fn !== 'function') {
|
||||
return Promise.reject(new TypeError('fn must be a function'));
|
||||
}
|
||||
|
||||
let value;
|
||||
|
||||
if (Array.isArray(args)) {
|
||||
try {
|
||||
value = fn.apply(ctx, args);
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
value = fn.call(ctx, args);
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.resolve(value);
|
||||
};
|
||||
Promise.fromNode = function(takesCbFn) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
takesCbFn(function(err, ...results) {
|
||||
if (err) reject(err);
|
||||
else if (results.length > 1) resolve(results);
|
||||
else resolve(results[0]);
|
||||
});
|
||||
});
|
||||
};
|
||||
Promise.race = function(iterable) {
|
||||
return new Promise((resolve, reject) => {
|
||||
for (const i of iterable) {
|
||||
Promise.resolve(i).then(resolve, reject);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return Promise;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Last remaining 'ui/*' imports that will eventually be shimmed with their np alternatives
|
||||
*/
|
||||
|
||||
export { npSetup, npStart } from 'ui/new_platform';
|
||||
// @ts-ignore
|
||||
export { GlobalStateProvider } from 'ui/state_management/global_state';
|
||||
// @ts-ignore
|
||||
export { StateManagementConfigProvider } from 'ui/state_management/config_provider';
|
||||
// @ts-ignore
|
||||
export { AppStateProvider } from 'ui/state_management/app_state';
|
||||
// @ts-ignore
|
||||
export { EventsProvider } from 'ui/events';
|
||||
export { PersistedState } from 'ui/persisted_state';
|
||||
// @ts-ignore
|
||||
export { createTopNavDirective, createTopNavHelper } from 'ui/kbn_top_nav/kbn_top_nav';
|
||||
// @ts-ignore
|
||||
export { KbnUrlProvider, RedirectWhenMissingProvider } from 'ui/url';
|
||||
export { registerTimefilterWithGlobalStateFactory } from 'ui/timefilter/setup_router';
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { npStart } from '../legacy_imports';
|
||||
export const capabilities = { get: () => npStart.core.application.capabilities };
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import angular from 'angular';
|
||||
import { npStart, npSetup } from '../legacy_imports';
|
||||
|
||||
type OptionalInjector = void | angular.auto.IInjectorService;
|
||||
|
||||
class Chrome {
|
||||
private injector?: OptionalInjector;
|
||||
|
||||
public setInjector = (injector: OptionalInjector): void => void (this.injector = injector);
|
||||
public dangerouslyGetActiveInjector = (): OptionalInjector => this.injector;
|
||||
|
||||
public getBasePath = (): string => npStart.core.http.basePath.get();
|
||||
|
||||
public getInjected = (name?: string, defaultValue?: any): string | unknown => {
|
||||
const { getInjectedVar, getInjectedVars } = npSetup.core.injectedMetadata;
|
||||
return name ? getInjectedVar(name, defaultValue) : getInjectedVars();
|
||||
};
|
||||
|
||||
public get breadcrumbs() {
|
||||
const set = (...args: any[]) => npStart.core.chrome.setBreadcrumbs.apply(this, args as any);
|
||||
return { set };
|
||||
}
|
||||
}
|
||||
|
||||
const chrome = new Chrome();
|
||||
|
||||
export default chrome; // eslint-disable-line import/no-default-export
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import angular from 'angular';
|
||||
|
||||
type PrivateProvider = (...args: any) => any;
|
||||
interface Provider {
|
||||
name: string;
|
||||
provider: PrivateProvider;
|
||||
}
|
||||
|
||||
class Modules {
|
||||
private _services: Provider[] = [];
|
||||
private _filters: Provider[] = [];
|
||||
private _directives: Provider[] = [];
|
||||
|
||||
public get = (_name: string, _dep?: string[]) => {
|
||||
return this;
|
||||
};
|
||||
|
||||
public service = (...args: any) => {
|
||||
this._services.push(args);
|
||||
};
|
||||
|
||||
public filter = (...args: any) => {
|
||||
this._filters.push(args);
|
||||
};
|
||||
|
||||
public directive = (...args: any) => {
|
||||
this._directives.push(args);
|
||||
};
|
||||
|
||||
public addToModule = () => {
|
||||
angular.module('monitoring/services', []);
|
||||
angular.module('monitoring/filters', []);
|
||||
angular.module('monitoring/directives', []);
|
||||
|
||||
this._services.forEach(args => {
|
||||
angular.module('monitoring/services').service.apply(null, args as any);
|
||||
});
|
||||
|
||||
this._filters.forEach(args => {
|
||||
angular.module('monitoring/filters').filter.apply(null, args as any);
|
||||
});
|
||||
|
||||
this._directives.forEach(args => {
|
||||
angular.module('monitoring/directives').directive.apply(null, args as any);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const uiModules = new Modules();
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
type RouteObject = [string, any];
|
||||
interface Redirect {
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
class Routes {
|
||||
private _routes: RouteObject[] = [];
|
||||
private _redirect?: Redirect;
|
||||
|
||||
public when = (...args: RouteObject) => {
|
||||
const [, routeOptions] = args;
|
||||
routeOptions.reloadOnSearch = false;
|
||||
this._routes.push(args);
|
||||
return this;
|
||||
};
|
||||
|
||||
public otherwise = (redirect: Redirect) => {
|
||||
this._redirect = redirect;
|
||||
return this;
|
||||
};
|
||||
|
||||
public addToProvider = ($routeProvider: any) => {
|
||||
this._routes.forEach(args => {
|
||||
$routeProvider.when.apply(this, args);
|
||||
});
|
||||
|
||||
if (this._redirect) {
|
||||
$routeProvider.otherwise(this._redirect);
|
||||
}
|
||||
};
|
||||
}
|
||||
const uiRoutes = new Routes();
|
||||
export default uiRoutes; // eslint-disable-line import/no-default-export
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { IModule, IRootScopeService } from 'angular';
|
||||
import { npStart, registerTimefilterWithGlobalStateFactory } from '../legacy_imports';
|
||||
|
||||
const {
|
||||
core: { uiSettings },
|
||||
} = npStart;
|
||||
export const { timefilter } = npStart.plugins.data.query.timefilter;
|
||||
|
||||
uiSettings.overrideLocalDefault(
|
||||
'timepicker:refreshIntervalDefaults',
|
||||
JSON.stringify({ value: 10000, pause: false })
|
||||
);
|
||||
uiSettings.overrideLocalDefault(
|
||||
'timepicker:timeDefaults',
|
||||
JSON.stringify({ from: 'now-1h', to: 'now' })
|
||||
);
|
||||
|
||||
export const registerTimefilterWithGlobalState = (app: IModule) => {
|
||||
app.run((globalState: any, $rootScope: IRootScopeService) => {
|
||||
globalState.fetch();
|
||||
globalState.$inheritedGlobalState = true;
|
||||
globalState.save();
|
||||
registerTimefilterWithGlobalStateFactory(timefilter, globalState, $rootScope);
|
||||
});
|
||||
};
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { IScope } from 'angular';
|
||||
import * as Rx from 'rxjs';
|
||||
|
||||
/**
|
||||
* Subscribe to an observable at a $scope, ensuring that the digest cycle
|
||||
* is run for subscriber hooks and routing errors to fatalError if not handled.
|
||||
*/
|
||||
export const subscribeWithScope = <T>(
|
||||
$scope: IScope,
|
||||
observable: Rx.Observable<T>,
|
||||
observer?: Rx.PartialObserver<T>
|
||||
) => {
|
||||
return observable.subscribe({
|
||||
next(value) {
|
||||
if (observer && observer.next) {
|
||||
$scope.$applyAsync(() => observer.next!(value));
|
||||
}
|
||||
},
|
||||
error(error) {
|
||||
$scope.$applyAsync(() => {
|
||||
if (observer && observer.error) {
|
||||
observer.error(error);
|
||||
} else {
|
||||
throw new Error(
|
||||
`Uncaught error in subscribeWithScope(): ${
|
||||
error ? error.stack || error.message : error
|
||||
}`
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
complete() {
|
||||
if (observer && observer.complete) {
|
||||
$scope.$applyAsync(() => observer.complete!());
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
12
x-pack/legacy/plugins/monitoring/public/np_ready/index.ts
Normal file
12
x-pack/legacy/plugins/monitoring/public/np_ready/index.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from 'src/core/public';
|
||||
import { MonitoringPlugin } from './plugin';
|
||||
|
||||
export function plugin(ctx: PluginInitializerContext) {
|
||||
return new MonitoringPlugin(ctx);
|
||||
}
|
28
x-pack/legacy/plugins/monitoring/public/np_ready/plugin.ts
Normal file
28
x-pack/legacy/plugins/monitoring/public/np_ready/plugin.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { App, CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'kibana/public';
|
||||
|
||||
export class MonitoringPlugin implements Plugin {
|
||||
constructor(ctx: PluginInitializerContext) {}
|
||||
|
||||
public setup(core: CoreSetup, plugins: any) {
|
||||
const app: App = {
|
||||
id: 'monitoring',
|
||||
title: 'Monitoring',
|
||||
mount: async (context, params) => {
|
||||
const { AngularApp } = await import('../np_imports/angular');
|
||||
const monitoringApp = new AngularApp(context, params);
|
||||
return monitoringApp.destroy;
|
||||
},
|
||||
};
|
||||
|
||||
core.application.register(app);
|
||||
}
|
||||
|
||||
public start(core: CoreStart, plugins: any) {}
|
||||
public stop() {}
|
||||
}
|
|
@ -9,7 +9,7 @@ import expect from '@kbn/expect';
|
|||
import sinon from 'sinon';
|
||||
import { executorProvider } from '../executor_provider';
|
||||
import Bluebird from 'bluebird';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
|
||||
describe('$executor service', () => {
|
||||
let scope;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
import { breadcrumbsProvider } from './breadcrumbs_provider';
|
||||
const uiModule = uiModules.get('monitoring/breadcrumbs', []);
|
||||
uiModule.service('breadcrumbs', breadcrumbsProvider);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
import chrome from 'plugins/monitoring/np_imports/ui/chrome';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
// Helper for making objects to use in a link element
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { STANDALONE_CLUSTER_CLUSTER_UUID } from '../../common/constants';
|
||||
|
||||
function formatClusters(clusters) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
import { executorProvider } from './executor_provider';
|
||||
const uiModule = uiModules.get('monitoring/executor', []);
|
||||
uiModule.service('$executor', executorProvider);
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { subscribeWithScope } from 'plugins/monitoring/np_imports/ui/utils';
|
||||
import { Subscription } from 'rxjs';
|
||||
export function executorProvider(Promise, $timeout) {
|
||||
const queue = [];
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
|
||||
const uiModule = uiModules.get('monitoring/features', []);
|
||||
uiModule.service('features', function($window) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { contains } from 'lodash';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
import { ML_SUPPORTED_LICENSES } from '../../common/constants';
|
||||
|
||||
const uiModule = uiModules.get('monitoring/license', []);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
|
||||
import { docTitle } from 'ui/doc_title';
|
||||
|
||||
const uiModule = uiModules.get('monitoring/title', []);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { spy, stub } from 'sinon';
|
||||
import expect from '@kbn/expect';
|
||||
import { MonitoringViewBaseController } from '../';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { PromiseWithCancel, Status } from '../../../common/cancel_promise';
|
||||
|
||||
/*
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
import { noop } from 'lodash';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiChrome from 'ui/chrome';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import uiChrome from 'plugins/monitoring/np_imports/ui/chrome';
|
||||
import template from './index.html';
|
||||
|
||||
const tryPrivilege = ($http, kbnUrl) => {
|
||||
|
|
|
@ -8,12 +8,12 @@ import React from 'react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { render } from 'react-dom';
|
||||
import { find, get } from 'lodash';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import template from './index.html';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { Alerts } from '../../components/alerts';
|
||||
import { MonitoringViewBaseEuiTableController } from '../base_eui_table_controller';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { find, get } from 'lodash';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import React, { Fragment } from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { find } from 'lodash';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { ApmServerInstances } from '../../../components/apm/instances';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { find } from 'lodash';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
|
|
|
@ -9,7 +9,7 @@ import moment from 'moment';
|
|||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import { getPageData } from '../lib/get_page_data';
|
||||
import { PageLoading } from 'plugins/monitoring/components';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { PromiseWithCancel } from '../../common/cancel_promise';
|
||||
import { updateSetupModeData, getSetupModeState } from '../lib/setup_mode';
|
||||
|
@ -188,15 +188,20 @@ export class MonitoringViewBaseController {
|
|||
}
|
||||
|
||||
renderReact(component) {
|
||||
const renderElement = document.getElementById(this.reactNodeId);
|
||||
if (!renderElement) {
|
||||
console.warn(`"#${this.reactNodeId}" element has not been added to the DOM yet`);
|
||||
return;
|
||||
}
|
||||
if (this._isDataInitialized === false) {
|
||||
render(
|
||||
<I18nContext>
|
||||
<PageLoading />
|
||||
</I18nContext>,
|
||||
document.getElementById(this.reactNodeId)
|
||||
renderElement
|
||||
);
|
||||
} else {
|
||||
render(component, document.getElementById(this.reactNodeId));
|
||||
render(component, renderElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
|
||||
export function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { find } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { MonitoringViewBaseController } from '../../';
|
||||
import { getPageData } from './get_page_data';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
|
||||
export function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { find } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { MonitoringViewBaseEuiTableController } from '../../';
|
||||
import { getPageData } from './get_page_data';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
|
||||
export function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { find } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { MonitoringViewBaseController } from '../../';
|
||||
import { getPageData } from './get_page_data';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { MonitoringViewBaseEuiTableController } from '../../';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
|
|
|
@ -7,7 +7,7 @@ import React, { Fragment } from 'react';
|
|||
import { isEmpty } from 'lodash';
|
||||
import chrome from 'ui/chrome';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { MonitoringViewBaseController } from '../../';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
|
||||
export function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { getPageData } from './get_page_data';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
|
||||
export function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { get } from 'lodash';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { getPageData } from './get_page_data';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { AdvancedIndex } from '../../../../components/elasticsearch/index/advanced';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { MonitoringViewBaseController } from '../../../base_controller';
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import template from './index.html';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { labels } from '../../../components/elasticsearch/shard_allocation/lib/labels';
|
||||
import { indicesByNodes } from '../../../components/elasticsearch/shard_allocation/transformers/indices_by_nodes';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { find } from 'lodash';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { MonitoringViewBaseEuiTableController } from '../../';
|
||||
import { ElasticsearchIndices } from '../../../components';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
|
||||
export function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { find } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { MonitoringViewBaseEuiTableController } from '../../';
|
||||
import { getPageData } from './get_page_data';
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { AdvancedNode } from '../../../../components/elasticsearch/node/advanced';
|
||||
import { MonitoringViewBaseController } from '../../../base_controller';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
|
||||
export function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { partial } from 'lodash';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { getPageData } from './get_page_data';
|
||||
import template from './index.html';
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
import React, { Fragment } from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { find } from 'lodash';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import template from './index.html';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { MonitoringViewBaseEuiTableController } from '../../';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { ElasticsearchOverviewController } from './controller';
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import { get } from 'lodash';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import {
|
||||
EuiPage,
|
||||
EuiPageBody,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
|
||||
export function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import React, { Fragment } from 'react';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { MonitoringViewBaseEuiTableController } from '../../';
|
||||
import { getPageData } from './get_page_data';
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
* Kibana Overview
|
||||
*/
|
||||
import React from 'react';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { MonitoringTimeseriesContainer } from '../../../components/chart';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import {
|
||||
EuiPage,
|
||||
EuiPageBody,
|
||||
|
|
|
@ -8,11 +8,11 @@ import { get, find } from 'lodash';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import React from 'react';
|
||||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import chrome from 'ui/chrome';
|
||||
import chrome from 'plugins/monitoring/np_imports/ui/chrome';
|
||||
import { formatDateTimeLocal } from '../../../common/formatting';
|
||||
import { MANAGEMENT_BASE_PATH } from 'plugins/xpack_main/components';
|
||||
import { License } from 'plugins/monitoring/components';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
|
||||
const REACT_NODE_ID = 'licenseReact';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { LicenseViewController } from './controller';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import React from 'react';
|
||||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import { PageLoading } from 'plugins/monitoring/components';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import template from './index.html';
|
||||
import { CODE_PATH_LICENSE } from '../../../common/constants';
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { MonitoringViewBaseController } from '../../../base_controller';
|
||||
import { DetailStatus } from 'plugins/monitoring/components/logstash/detail_status';
|
||||
import {
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { DetailStatus } from 'plugins/monitoring/components/logstash/detail_status';
|
||||
import {
|
||||
EuiPage,
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { isPipelineMonitoringSupportedInVersion } from 'plugins/monitoring/lib/logstash/pipelines';
|
||||
import template from './index.html';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { MonitoringViewBaseEuiTableController } from '../../../';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { PipelineListing } from '../../../../components/logstash/pipeline_listing/pipeline_listing';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
|
||||
export function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import React, { Fragment } from 'react';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { MonitoringViewBaseEuiTableController } from '../../';
|
||||
import { getPageData } from './get_page_data';
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
* Logstash Overview
|
||||
*/
|
||||
import React from 'react';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { Overview } from '../../../components/logstash/overview';
|
||||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* Logstash Node Pipeline View
|
||||
*/
|
||||
import React from 'react';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import moment from 'moment';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { find } from 'lodash';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { isPipelineMonitoringSupportedInVersion } from 'plugins/monitoring/lib/logstash/pipelines';
|
||||
import template from './index.html';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { PipelineListing } from '../../../components/logstash/pipeline_listing/pipeline_listing';
|
||||
import { MonitoringViewBaseEuiTableController } from '../..';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import uiRoutes from 'ui/routes';
|
||||
import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
|
||||
import template from './index.html';
|
||||
import { NoDataController } from './controller';
|
||||
|
||||
|
|
|
@ -19,11 +19,22 @@ import { getLicenseExpiration } from './alerts/license_expiration';
|
|||
import { parseElasticsearchConfig } from './es_client/parse_elasticsearch_config';
|
||||
|
||||
export class Plugin {
|
||||
setup(core, plugins) {
|
||||
const kbnServer = core._kbnServer;
|
||||
const config = core.config();
|
||||
const usageCollection = plugins.usageCollection;
|
||||
const licensing = plugins.licensing;
|
||||
setup(_coreSetup, pluginsSetup, __LEGACY) {
|
||||
const {
|
||||
plugins,
|
||||
_kbnServer: kbnServer,
|
||||
log,
|
||||
logger,
|
||||
getOSInfo,
|
||||
_hapi: hapiServer,
|
||||
events,
|
||||
expose,
|
||||
config: monitoringConfig,
|
||||
injectUiAppVars,
|
||||
} = __LEGACY;
|
||||
const config = monitoringConfig();
|
||||
|
||||
const { usageCollection, licensing } = pluginsSetup;
|
||||
registerMonitoringCollection();
|
||||
/*
|
||||
* Register collector objects for stats to show up in the APIs
|
||||
|
@ -31,10 +42,10 @@ export class Plugin {
|
|||
registerCollectors(usageCollection, {
|
||||
elasticsearchPlugin: plugins.elasticsearch,
|
||||
kbnServerConfig: kbnServer.config,
|
||||
log: core.log,
|
||||
log,
|
||||
config,
|
||||
getOSInfo: core.getOSInfo,
|
||||
hapiServer: core._hapi,
|
||||
getOSInfo,
|
||||
hapiServer,
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -57,18 +68,18 @@ export class Plugin {
|
|||
|
||||
if (uiEnabled) {
|
||||
await instantiateClient({
|
||||
log: core.log,
|
||||
events: core.events,
|
||||
log,
|
||||
events,
|
||||
elasticsearchConfig,
|
||||
elasticsearchPlugin: plugins.elasticsearch,
|
||||
}); // Instantiate the dedicated ES client
|
||||
await initMonitoringXpackInfo({
|
||||
config,
|
||||
log: core.log,
|
||||
log,
|
||||
xpackMainPlugin: plugins.xpack_main,
|
||||
expose: core.expose,
|
||||
expose,
|
||||
}); // Route handlers depend on this for xpackInfo
|
||||
await requireUIRoutes(core);
|
||||
await requireUIRoutes(__LEGACY);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -99,7 +110,7 @@ export class Plugin {
|
|||
const bulkUploader = initBulkUploader({
|
||||
elasticsearchPlugin: plugins.elasticsearch,
|
||||
config,
|
||||
log: core.log,
|
||||
log,
|
||||
kbnServerStatus: kbnServer.status,
|
||||
kbnServerVersion: kbnServer.version,
|
||||
});
|
||||
|
@ -121,18 +132,18 @@ export class Plugin {
|
|||
}
|
||||
});
|
||||
} else if (!kibanaCollectionEnabled) {
|
||||
core.log(
|
||||
log(
|
||||
['info', LOGGING_TAG, KIBANA_MONITORING_LOGGING_TAG],
|
||||
'Internal collection for Kibana monitoring is disabled per configuration.'
|
||||
);
|
||||
}
|
||||
|
||||
core.injectUiAppVars('monitoring', () => {
|
||||
const config = core.config();
|
||||
injectUiAppVars('monitoring', () => {
|
||||
return {
|
||||
maxBucketSize: config.get('monitoring.ui.max_bucket_size'),
|
||||
minIntervalSeconds: config.get('monitoring.ui.min_interval_seconds'),
|
||||
kbnIndex: config.get('kibana.index'),
|
||||
monitoringUiEnabled: config.get('monitoring.ui.enabled'),
|
||||
showLicenseExpiration: config.get('monitoring.ui.show_license_expiration'),
|
||||
showCgroupMetricsElasticsearch: config.get('monitoring.ui.container.elasticsearch.enabled'),
|
||||
showCgroupMetricsLogstash: config.get('monitoring.ui.container.logstash.enabled'), // Note, not currently used, but see https://github.com/elastic/x-pack-kibana/issues/1559 part 2
|
||||
|
@ -159,11 +170,11 @@ export class Plugin {
|
|||
}
|
||||
|
||||
function getLogger(contexts) {
|
||||
return core.logger.get('plugins', LOGGING_TAG, ...contexts);
|
||||
return logger.get('plugins', LOGGING_TAG, ...contexts);
|
||||
}
|
||||
plugins.alerting.setup.registerType(
|
||||
getLicenseExpiration(
|
||||
core._hapi,
|
||||
hapiServer,
|
||||
getMonitoringCluster,
|
||||
getLogger,
|
||||
config.get('xpack.monitoring.ccs.enabled')
|
||||
|
|
|
@ -45,7 +45,7 @@ export const getUiExports = () => {
|
|||
icon: 'plugins/monitoring/icons/monitoring.svg',
|
||||
euiIconType: 'monitoringApp',
|
||||
linkToLastSubUrl: false,
|
||||
main: 'plugins/monitoring/monitoring',
|
||||
main: 'plugins/monitoring/legacy',
|
||||
category: DEFAULT_APP_CATEGORIES.management,
|
||||
},
|
||||
injectDefaultVars(server) {
|
||||
|
|
|
@ -35,9 +35,6 @@
|
|||
"test_utils/*": [
|
||||
"x-pack/test_utils/*"
|
||||
],
|
||||
"monitoring/common/*": [
|
||||
"x-pack/monitoring/common/*"
|
||||
],
|
||||
"plugins/*": ["src/legacy/core_plugins/*/public/"],
|
||||
"fixtures/*": ["src/fixtures/*"]
|
||||
},
|
||||
|
@ -46,4 +43,4 @@
|
|||
"jest"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue