Skip to content

Commit

Permalink
Publish configs for maps_legacy and tile_maps using NP format
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Apr 29, 2020
1 parent 6a4c970 commit 151ddc9
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/plugins/maps_legacy/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { schema, TypeOf } from '@kbn/config-schema';
import { configSchema as tilemapSchema } from '../tile_map/config';

// TODO: Move this to regionmap plugin on migration
export const regionmapSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
layers: schema.maybe(
schema.arrayOf(
schema.object({
url: schema.string(),
format: schema.object({
type: schema.string({ defaultValue: 'geojson' }),
}),
meta: schema.object({
feature_collection_path: schema.string({ defaultValue: 'data' }),
}),
attribution: schema.string(),
name: schema.string(),
fields: schema.arrayOf(
schema.object({
name: schema.string(),
description: schema.string(),
})
),
})
)
),
});

export const configSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
proxyElasticMapsServiceInMaps: schema.boolean({ defaultValue: false }),
tilemap: tilemapSchema,
regionmap: regionmapSchema,
manifestServiceUrl: schema.string({ defaultValue: '' }),
emsFileApiUrl: schema.string({ defaultValue: 'https://vector.maps.elastic.co' }),
emsTileApiUrl: schema.string({ defaultValue: 'https://tiles.maps.elastic.co' }),
emsLandingPageUrl: schema.string({ defaultValue: 'https://maps.elastic.co/v7.7' }),
emsFontLibraryUrl: schema.string({
defaultValue: 'https://tiles.maps.elastic.co/fonts/{fontstack}/{range}.pbf',
}),
emsTileLayerId: schema.object({
bright: schema.string({ defaultValue: 'road_map' }),
desaturated: schema.string({ defaultValue: 'road_map_desaturated' }),
dark: schema.string({ defaultValue: 'dark_map' }),
}),
});

export type ConfigSchema = TypeOf<typeof configSchema>;
42 changes: 42 additions & 0 deletions src/plugins/maps_legacy/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { PluginConfigDescriptor } from 'kibana/server';
import { configSchema, ConfigSchema } from '../config';

export const config: PluginConfigDescriptor<ConfigSchema> = {
exposeToBrowser: {
includeElasticMapsService: true,
proxyElasticMapsServiceInMaps: true,
tilemap: true,
regionmap: true,
manifestServiceUrl: true,
emsFileApiUrl: true,
emsTileApiUrl: true,
emsLandingPageUrl: true,
emsFontLibraryUrl: true,
emsTileLayerId: true,
},
schema: configSchema,
};

export const plugin = () => ({
setup() {},
start() {},
});
47 changes: 47 additions & 0 deletions src/plugins/tile_map/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { schema, TypeOf } from '@kbn/config-schema';

export const configSchema = schema.object({
url: schema.string(),
deprecated: schema.any({
defaultValue: {
config: {
options: {
attribution: '',
},
},
},
}),
options: schema.object({
attribution: schema.string({ defaultValue: '' }),
minZoom: schema.number({ defaultValue: 0 }),
maxZoom: schema.number({ defaultValue: 10 }),
tileSize: schema.maybe(schema.number()),
subdomains: schema.maybe(schema.arrayOf(schema.string())),
errorTileUrl: schema.maybe(schema.string()),
tms: schema.maybe(schema.boolean()),
reuseTiles: schema.maybe(schema.boolean()),
bounds: schema.maybe(schema.arrayOf(schema.number())),
default: schema.maybe(schema.boolean()),
}),
});

export type ConfigSchema = TypeOf<typeof configSchema>;
14 changes: 14 additions & 0 deletions src/plugins/tile_map/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "tileMap",
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["map", "tilemap"],
"ui": true,
"server": true,
"requiredPlugins": [
"visualizations",
"expressions",
"mapsLegacy",
"data"
]
}
35 changes: 35 additions & 0 deletions src/plugins/tile_map/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { PluginConfigDescriptor } from 'kibana/server';
import { configSchema, ConfigSchema } from '../config';

export const config: PluginConfigDescriptor<ConfigSchema> = {
exposeToBrowser: {
url: true,
deprecated: true,
options: true,
},
schema: configSchema,
};

export const plugin = () => ({
setup() {},
start() {},
});

0 comments on commit 151ddc9

Please sign in to comment.