Skip to content

Commit

Permalink
use manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed May 2, 2017
1 parent 8f4499f commit 79284e4
Showing 1 changed file with 67 additions and 66 deletions.
133 changes: 67 additions & 66 deletions src/ui/public/vis_maps/lib/map_settings.js
@@ -1,8 +1,7 @@
import { uiModules } from 'ui/modules';
import _ from 'lodash';
import marked from 'marked';
// import { modifyUrl } from 'ui/url';

import { modifyUrl } from 'ui/url';
marked.setOptions({
gfm: true, // Github-flavored markdown
sanitize: true // Sanitize HTML tags
Expand All @@ -11,9 +10,9 @@ marked.setOptions({
uiModules.get('kibana')
.service('mapSettings', function ($http, $sanitize, vectormapsConfig, kbnVersion) {

// const extendUrl = (url, props) => (
// modifyUrl(url, parsed => _.merge(parsed, props))
// );
const extendUrl = (url, props) => (
modifyUrl(url, parsed => _.merge(parsed, props))
);

/**
* Unescape a url template that was escaped by encodeURI() so leaflet
Expand Down Expand Up @@ -54,7 +53,8 @@ uiModules.get('kibana')

return this._getVectormapsManifest(vectormapsConfig.manifestServiceUrl, this._queryParams)
.then(response => {
this._response = response;
this._response = response.data;

// const service = _.get(response, 'data.services[0]');
// if (!service) {
// throw new Error('Manifest response does not include sufficient service data.');
Expand All @@ -65,6 +65,7 @@ uiModules.get('kibana')
// query: this._queryParams
// }));

this._error = null;
this._settingsInitialized = true;
})
.catch(e => {
Expand Down Expand Up @@ -146,12 +147,12 @@ uiModules.get('kibana')
/**
* Make this a method to allow for overrides by test code
*/
_getVectormapsManifest() {
// return $http({
// url: extendUrl(manifestUrl, { query: this._queryParams }),
// method: 'GET'
// });
return mockRequest();
_getVectormapsManifest(manifestUrl) {
return $http({
url: extendUrl(manifestUrl, { query: this._queryParams }),
method: 'GET'
});
// return mockRequest();
}

}
Expand All @@ -160,57 +161,57 @@ uiModules.get('kibana')
});


async function mockRequest() {

return new Promise(function (resolve) {
setTimeout(function () {

const ret = `{
"layers":[
{
"attribution":"",
"name":"US States",
"url":"https://storage.googleapis.com/elastic-layer.appspot.com/L2FwcGhvc3RpbmdfcHJvZC9ibG9icy9BRW5CMlVvNGJ0aVNidFNJR2dEQl9rbTBjeXhKMU01WjRBeW1kN3JMXzM2Ry1qc3F6QjF4WE5XdHY2ODlnQkRpZFdCY2g1T2dqUGRHSFhSRTU3amlxTVFwZjNBSFhycEFwV2lYR29vTENjZjh1QTZaZnRpaHBzby5VXzZoNk1paGJYSkNPalpI",
"fields":[
{
"name":"postal",
"description":"Two letter abbreviation"
},
{
"name":"name",
"description":"State name"
}
],
"created_at":"2017-04-26T19:45:22.377820",
"id":5086441721823232
},
{
"attribution":"\u00a9 [Elastic Tile Service](https://www.elastic.co/elastic-tile-service)",
"name":"World Countries",
"url":"https://storage.googleapis.com/elastic-layer.appspot.com/L2FwcGhvc3RpbmdfcHJvZC9ibG9icy9BRW5CMlVwWTZTWnhRRzNmUk9HUE93TENjLXNVd2IwdVNpc09SRXRyRzBVWWdqOU5qY2hldGJLOFNZSFpUMmZmZWdNZGx0NWprT1R1ZkZ0U1JEdFBtRnkwUWo0S0JuLTVYY1I5RFdSMVZ5alBIZkZuME1qVS04TS5oQTRNTl9yRUJCWk9tMk03",
"fields":[
{
"name":"iso2",
"description":"Two letter abbreviation"
},
{
"name":"name",
"description":"Country name"
},
{
"name":"iso3",
"description":"Three letter abbreviation"
}
],
"created_at":"2017-04-26T17:12:15.978370",
"id":5659313586569216
}
]
}`;

resolve(JSON.parse(ret));
}, 100);
});


}
// async function mockRequest() {
//
// return new Promise(function (resolve) {
// setTimeout(function () {
//
// const ret = `{
// "layers":[
// {
// "attribution":"",
// "name":"US States",
// "url":"https://storage.googleapis.com/elastic-layer.appspot.com/L2FwcGhvc3RpbmdfcHJvZC9ibG9icy9BRW5CMlVvNGJ0aVNidFNJR2dEQl9rbTBjeXhKMU01WjRBeW1kN3JMXzM2Ry1qc3F6QjF4WE5XdHY2ODlnQkRpZFdCY2g1T2dqUGRHSFhSRTU3amlxTVFwZjNBSFhycEFwV2lYR29vTENjZjh1QTZaZnRpaHBzby5VXzZoNk1paGJYSkNPalpI",
// "fields":[
// {
// "name":"postal",
// "description":"Two letter abbreviation"
// },
// {
// "name":"name",
// "description":"State name"
// }
// ],
// "created_at":"2017-04-26T19:45:22.377820",
// "id":5086441721823232
// },
// {
// "attribution":"\u00a9 [Elastic Tile Service](https://www.elastic.co/elastic-tile-service)",
// "name":"World Countries",
// "url":"https://storage.googleapis.com/elastic-layer.appspot.com/L2FwcGhvc3RpbmdfcHJvZC9ibG9icy9BRW5CMlVwWTZTWnhRRzNmUk9HUE93TENjLXNVd2IwdVNpc09SRXRyRzBVWWdqOU5qY2hldGJLOFNZSFpUMmZmZWdNZGx0NWprT1R1ZkZ0U1JEdFBtRnkwUWo0S0JuLTVYY1I5RFdSMVZ5alBIZkZuME1qVS04TS5oQTRNTl9yRUJCWk9tMk03",
// "fields":[
// {
// "name":"iso2",
// "description":"Two letter abbreviation"
// },
// {
// "name":"name",
// "description":"Country name"
// },
// {
// "name":"iso3",
// "description":"Three letter abbreviation"
// }
// ],
// "created_at":"2017-04-26T17:12:15.978370",
// "id":5659313586569216
// }
// ]
// }`;
//
// resolve(JSON.parse(ret));
// }, 100);
// });
//
//
// }

0 comments on commit 79284e4

Please sign in to comment.