Skip to content

Commit

Permalink
Files moved and relative paths updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Feb 10, 2020
1 parent 6820c45 commit 2649472
Show file tree
Hide file tree
Showing 326 changed files with 33,891 additions and 10 deletions.
50 changes: 50 additions & 0 deletions x-pack/plugins/maps/common/i18n_getters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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 { i18n } from '@kbn/i18n';

import { ES_SPATIAL_RELATIONS } from './constants';

export function getAppTitle() {
return i18n.translate('xpack.maps.appTitle', {
defaultMessage: 'Maps',
});
}

export function getDataSourceLabel() {
return i18n.translate('xpack.maps.source.dataSourceLabel', {
defaultMessage: 'Data source',
});
}

export function getUrlLabel() {
return i18n.translate('xpack.maps.source.urlLabel', {
defaultMessage: 'Url',
});
}

export function getEsSpatialRelationLabel(spatialRelation) {
switch (spatialRelation) {
case ES_SPATIAL_RELATIONS.INTERSECTS:
return i18n.translate('xpack.maps.common.esSpatialRelation.intersectsLabel', {
defaultMessage: 'intersects',
});
case ES_SPATIAL_RELATIONS.DISJOINT:
return i18n.translate('xpack.maps.common.esSpatialRelation.disjointLabel', {
defaultMessage: 'disjoint',
});
case ES_SPATIAL_RELATIONS.WITHIN:
return i18n.translate('xpack.maps.common.esSpatialRelation.withinLabel', {
defaultMessage: 'within',
});
case ES_SPATIAL_RELATIONS.CONTAINS:
return i18n.translate('xpack.maps.common.esSpatialRelation.containsLabel', {
defaultMessage: 'contains',
});
default:
return spatialRelation;
}
}
22 changes: 22 additions & 0 deletions x-pack/plugins/maps/common/parse_xml_string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 { parseString } from 'xml2js';

// promise based wrapper around parseString
export async function parseXmlString(xmlString) {
const parsePromise = new Promise((resolve, reject) => {
parseString(xmlString, (error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});

return await parsePromise;
}
16 changes: 16 additions & 0 deletions x-pack/plugins/maps/common/parse_xml_string.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 { parseXmlString } from './parse_xml_string';

describe('parseXmlString', () => {
it('Should parse xml string into JS object', async () => {
const xmlAsObject = await parseXmlString('<foo>bar</foo>');
expect(xmlAsObject).toEqual({
foo: 'bar',
});
});
});
Loading

0 comments on commit 2649472

Please sign in to comment.