show error toast each time the visualize tilemap vis is created

This commit is contained in:
Thomas Neirynck 2017-01-05 10:44:15 -05:00
parent c0bec83a6d
commit 5769991f3f
3 changed files with 13 additions and 18 deletions

View file

@ -151,7 +151,7 @@ uiModules.get('kibana')
}
/**
* Make this instance property to allow for overrides by test code
* Make this a method to allow for overrides by test code
*/
async _getTileServiceManifest(manifestUrl, additionalQueryParams) {
const manifestServiceTokens = url.parse(manifestUrl);

View file

@ -2,11 +2,15 @@ import _ from 'lodash';
import MapsProvider from 'ui/vis_maps/maps';
import VisRenderbotProvider from 'ui/vis/renderbot';
import MapsVisTypeBuildChartDataProvider from 'ui/vislib_vis_type/build_chart_data';
module.exports = function MapsRenderbotFactory(Private, $injector) {
module.exports = function MapsRenderbotFactory(Private, $injector, tilemapSettings, Notifier) {
const AngularPromise = $injector.get('Promise');
const Maps = Private(MapsProvider);
const Renderbot = Private(VisRenderbotProvider);
const buildChartData = Private(MapsVisTypeBuildChartDataProvider);
const notify = new Notifier({
location: 'Tilemap'
});
_.class(MapsRenderbot).inherits(Renderbot);
function MapsRenderbot(vis, $el, uiState) {
@ -15,6 +19,11 @@ module.exports = function MapsRenderbotFactory(Private, $injector) {
}
MapsRenderbot.prototype._createVis = function () {
if (tilemapSettings.getError()) {
//Still allow the visualization to be build, but show a toast that there was a problem retrieving map settings
//Even though the basemap will not display, the user will at least still see the overlay data
notify.warning(tilemapSettings.getError().message);
}
if (this.mapsVis) this.destroy();
this.mapsParams = this._getMapsParams();
this.mapsVis = new Maps(this.$el[0], this.vis, this.mapsParams);

View file

@ -7,16 +7,11 @@ import VislibVisualizationsMarkerTypesGeohashGridProvider from './marker_types/g
import VislibVisualizationsMarkerTypesHeatmapProvider from './marker_types/heatmap';
import '../lib/tilemap_settings';
export default function MapFactory(Private, tilemapSettings, Notifier) {
export default function MapFactory(Private, tilemapSettings) {
const defaultMapZoom = 2;
const defaultMapCenter = [15, 5];
const defaultMarkerType = 'Scaled Circle Markers';
const notify = new Notifier({
location: 'Tilemap'
});
const previousErrors = [];
const markerTypes = {
'Scaled Circle Markers': Private(VislibVisualizationsMarkerTypesScaledCirclesProvider),
'Shaded Circle Markers': Private(VislibVisualizationsMarkerTypesShadedCirclesProvider),
@ -61,16 +56,7 @@ export default function MapFactory(Private, tilemapSettings, Notifier) {
fadeAnimation: false,
};
let url;
if (tilemapSettings.hasError()) {
if (!previousErrors.includes(tilemapSettings.getError())) {
notify.warning(tilemapSettings.getError().message);
previousErrors.push(tilemapSettings.getError());
}
url = '';
} else {
url = tilemapSettings.getUrl();
}
const url = tilemapSettings.hasError() ? '' : tilemapSettings.getUrl();
this._createMap(options, url);
}