From 7b4ff2de505ebc666566a707682460eb15cd0fbf Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 7 Mar 2019 21:15:35 -0700 Subject: [PATCH] [Maps] replace angular serviceSettings service with EmsClient (#32725) (#32731) * [Maps] replace angular serviceSettings service with EmsClient * clean up --- x-pack/plugins/maps/public/index.js | 1 - x-pack/plugins/maps/public/kibana_services.js | 2 -- .../sources/ems_file_source/ems_file_source.js | 13 ++++++++++--- x-pack/plugins/maps/server/routes.js | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/maps/public/index.js b/x-pack/plugins/maps/public/index.js index c8de69bc6c8d5..eef364498c9eb 100644 --- a/x-pack/plugins/maps/public/index.js +++ b/x-pack/plugins/maps/public/index.js @@ -27,7 +27,6 @@ import 'react-vis/dist/style.css'; import 'mapbox-gl/dist/mapbox-gl.css'; -import 'ui/vis/map/service_settings'; import './angular/services/gis_map_saved_object_loader'; import './angular/map_controller'; import listingTemplate from './angular/listing_ng_wrapper.html'; diff --git a/x-pack/plugins/maps/public/kibana_services.js b/x-pack/plugins/maps/public/kibana_services.js index 564e1367d961a..d8d395ef414b1 100644 --- a/x-pack/plugins/maps/public/kibana_services.js +++ b/x-pack/plugins/maps/public/kibana_services.js @@ -12,7 +12,6 @@ import { getRequestInspectorStats, getResponseInspectorStats } from 'ui/courier/ export const timeService = timefilter; export let indexPatternService; export let SearchSource; -export let emsServiceSettings; export async function fetchSearchSourceAndRecordWithInspector({ searchSource, requestId, requestName, requestDesc, inspectorAdapters }) { const inspectorRequest = inspectorAdapters.requests.start( @@ -40,5 +39,4 @@ uiModules.get('app/maps').run(($injector) => { indexPatternService = $injector.get('indexPatterns'); const Private = $injector.get('Private'); SearchSource = Private(SearchSourceProvider); - emsServiceSettings = $injector.get('serviceSettings'); }); diff --git a/x-pack/plugins/maps/public/shared/layers/sources/ems_file_source/ems_file_source.js b/x-pack/plugins/maps/public/shared/layers/sources/ems_file_source/ems_file_source.js index 61bde7a07bf42..b0228ed0b69c2 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/ems_file_source/ems_file_source.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/ems_file_source/ems_file_source.js @@ -7,7 +7,6 @@ import { AbstractVectorSource } from '../vector_source'; import React from 'react'; import { GIS_API_PATH, EMS_FILE } from '../../../../../common/constants'; -import { emsServiceSettings } from '../../../../kibana_services'; import { getEmsVectorFilesMeta } from '../../../../meta'; import { EMSFileCreateSourceEditor } from './create_source_editor'; import { i18n } from '@kbn/i18n'; @@ -68,7 +67,14 @@ export class EMSFileSource extends AbstractVectorSource { } async getImmutableProperties() { - const emsLink = await emsServiceSettings.getEMSHotLink({ id: this._descriptor.id }); + let emsLink; + try { + const emsVectorFileMeta = await this._getEmsVectorFileMeta(); + emsLink = emsVectorFileMeta.emsLink; + } catch(error) { + // ignore error if EMS layer id could not be found + } + return [ { label: getDataSourceLabel(), @@ -79,7 +85,8 @@ export class EMSFileSource extends AbstractVectorSource { defaultMessage: `Layer`, }), value: this._descriptor.id, - link: emsLink } + link: emsLink + } ]; } diff --git a/x-pack/plugins/maps/server/routes.js b/x-pack/plugins/maps/server/routes.js index 4139749907042..49bf24ead7a74 100644 --- a/x-pack/plugins/maps/server/routes.js +++ b/x-pack/plugins/maps/server/routes.js @@ -106,7 +106,8 @@ export function initRoutes(server, licenseUid) { fields: fileLayer.getFieldsInLanguage(), url: fileLayer.getDefaultFormatUrl(), format: format, //legacy: format and meta are split up - meta: meta //legacy, format and meta are split up + meta: meta, //legacy, format and meta are split up, + emsLink: fileLayer.getEMSHotLink() }; });