mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Use Kibana locale when loading content from the Elastic Maps Service (#29671)
This commit is contained in:
parent
8604e8f3f4
commit
bfbce22165
8 changed files with 25 additions and 10 deletions
|
@ -79,7 +79,9 @@ export function RegionMapsVisualizationProvider(Private, config, i18n) {
|
|||
const metricFieldFormatter = getFormat(this._vis.params.metric.format);
|
||||
|
||||
this._choroplethLayer.setMetrics(results, metricFieldFormatter, valueColumn.name);
|
||||
this._choroplethLayer.setTooltipFormatter(tooltipFormatter, metricFieldFormatter, termColumn.name, valueColumn.name);
|
||||
if (termColumn && valueColumn) {
|
||||
this._choroplethLayer.setTooltipFormatter(tooltipFormatter, metricFieldFormatter, termColumn.name, valueColumn.name);
|
||||
}
|
||||
|
||||
this._kibanaMap.useUiStateFromVisualization(this._vis);
|
||||
}
|
||||
|
|
|
@ -89,10 +89,9 @@ const unescapeTemplateVars = url => {
|
|||
};
|
||||
|
||||
|
||||
//this is not the default locale from Kibana, but the default locale supported by the Elastic Maps Service
|
||||
const DEFAULT_LANGUAGE = 'en';
|
||||
|
||||
|
||||
|
||||
export class EMSClientV66 {
|
||||
|
||||
EMS_LOAD_TIMEOUT = 32000;
|
||||
|
@ -107,13 +106,16 @@ export class EMSClientV66 {
|
|||
this._manifestServiceUrl = manifestServiceUrl;
|
||||
this._loadFileLayers = null;
|
||||
this._loadTMSServices = null;
|
||||
this._emsLandingPageUrl = landingPageUrl;
|
||||
this._emsLandingPageUrl = typeof landingPageUrl === 'string' ? landingPageUrl : '';
|
||||
this._language = typeof language === 'string' ? language : DEFAULT_LANGUAGE;
|
||||
|
||||
this._invalidateSettings();
|
||||
|
||||
}
|
||||
|
||||
getLocale() {
|
||||
return this._language;
|
||||
}
|
||||
|
||||
getValueInLanguage(i18nObject) {
|
||||
if (!i18nObject) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
|
||||
import { ORIGIN } from './origin';
|
||||
import url from 'url';
|
||||
|
||||
export class FileLayer {
|
||||
|
||||
|
@ -84,8 +85,14 @@ export class FileLayer {
|
|||
}
|
||||
|
||||
getEMSHotLink() {
|
||||
const id = `file/${this.getId()}`;
|
||||
return `${this._emsClient.getLandingPageUrl()}#${id}`;
|
||||
const landingPageString = this._emsClient.getLandingPageUrl();
|
||||
const urlObject = url.parse(landingPageString);
|
||||
urlObject.hash = `file/${this.getId()}`;
|
||||
urlObject.query = {
|
||||
...urlObject.query,
|
||||
locale: this._emsClient.getLocale()
|
||||
};
|
||||
return url.format(urlObject);
|
||||
}
|
||||
|
||||
getDefaultFormatType() {
|
||||
|
|
|
@ -247,7 +247,7 @@ export default () => Joi.object({
|
|||
tilemap: tilemapSchema,
|
||||
regionmap: regionmapSchema,
|
||||
manifestServiceUrl: Joi.string().default('https://catalogue.maps.elastic.co/v6.6/manifest'),
|
||||
emsLandingPageUrl: Joi.string().default('https://maps.elastic.co/v6.6'),
|
||||
emsLandingPageUrl: Joi.string().default('https://maps.elastic.co/v6.7'),
|
||||
}).default(),
|
||||
tilemap: tilemapSchema.notes('Deprecated'),
|
||||
regionmap: regionmapSchema.notes('Deprecated'),
|
||||
|
|
|
@ -156,7 +156,7 @@ describe('ems_client', () => {
|
|||
{ name: 'name', description: 'name', type: 'property' } ]);
|
||||
|
||||
|
||||
expect((await layer.getEMSHotLink())).to.be('https://landing.foobar#file/world_countries');
|
||||
expect((await layer.getEMSHotLink())).to.be('https://landing.foobar/?locale=zz#file/world_countries');
|
||||
|
||||
});
|
||||
|
||||
|
@ -182,6 +182,7 @@ describe('ems_client', () => {
|
|||
function getEMSClient(options = {}) {
|
||||
|
||||
const emsClient = new EMSClientV66({
|
||||
language: 'en',
|
||||
kbnVersion: '6.x.x',
|
||||
manifestServiceUrl: 'https://foobar',
|
||||
htmlSanitizer: x => x,
|
||||
|
|
|
@ -289,10 +289,9 @@ describe('service_settings (FKA tilemaptest)', function () {
|
|||
});
|
||||
|
||||
it ('should get hotlink', async () => {
|
||||
mapConfig.emsLandingPageUrl = 'https://foo/bar';
|
||||
const fileLayers = await serviceSettings.getFileLayers();
|
||||
const hotlink = await serviceSettings.getEMSHotLink(fileLayers[0]);
|
||||
expect(hotlink).to.eql('undefined#file/world_countries');//undefined becuase emsLandingPageUrl is set at kibana-load
|
||||
expect(hotlink).to.eql('?locale=en#file/world_countries');//url host undefined becuase emsLandingPageUrl is set at kibana-load
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import _ from 'lodash';
|
|||
import MarkdownIt from 'markdown-it';
|
||||
import { ORIGIN } from '../../../../legacy/core_plugins/tile_map/common/origin';
|
||||
import { EMSClientV66 } from '../../../../legacy/core_plugins/tile_map/common/ems_client';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
const markdownIt = new MarkdownIt({
|
||||
html: false,
|
||||
|
@ -42,6 +43,7 @@ uiModules.get('kibana')
|
|||
|
||||
this._showZoomMessage = true;
|
||||
this._emsClient = new EMSClientV66({
|
||||
language: i18n.getLocale(),
|
||||
kbnVersion: kbnVersion,
|
||||
manifestServiceUrl: mapConfig.manifestServiceUrl,
|
||||
htmlSanitizer: $sanitize,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import { GIS_API_PATH } from '../common/constants';
|
||||
import fetch from 'node-fetch';
|
||||
import _ from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
const ROOT = `/${GIS_API_PATH}`;
|
||||
|
||||
|
@ -17,6 +18,7 @@ export function initRoutes(server, licenseUid) {
|
|||
const mapConfig = serverConfig.get('map');
|
||||
|
||||
const emsClient = new server.plugins.tile_map.ems_client.EMSClientV66({
|
||||
language: i18n.getLocale(),
|
||||
kbnVersion: serverConfig.get('pkg.version'),
|
||||
manifestServiceUrl: mapConfig.manifestServiceUrl,
|
||||
landingPageUrl: mapConfig.emsLandingPageUrl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue