Skip to content

Commit

Permalink
use savedObjectsClient to get index-patterns (#25630)
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese authored Nov 15, 2018
1 parent 8d61ddf commit 30ebf9c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 48 deletions.
16 changes: 13 additions & 3 deletions x-pack/plugins/canvas/public/lib/es_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ export const getFields = (index = '_all') => {
};

export const getIndices = () => {
return fetch
.get(`${apiPath}/es_indices`)
.then(({ data: indices }) => indices)
const savedObjectsClient = chrome.getSavedObjectsClient();
return savedObjectsClient
.find({
type: 'index-pattern',
fields: ['title'],
search_fields: ['title'],
perPage: 1000,
})
.then(resp => {
return resp.savedObjects.map(savedObject => {
return savedObject.attributes.title;
});
})
.catch(err => notify.error(err, { title: `Couldn't fetch Elasticsearch indices` }));
};
20 changes: 0 additions & 20 deletions x-pack/plugins/canvas/server/routes/es_indices/get_es_indices.js

This file was deleted.

23 changes: 0 additions & 23 deletions x-pack/plugins/canvas/server/routes/es_indices/index.js

This file was deleted.

2 changes: 0 additions & 2 deletions x-pack/plugins/canvas/server/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import { workpad } from './workpad';
import { socketApi } from './socket';
import { translate } from './translate';
import { esFields } from './es_fields';
import { esIndices } from './es_indices';
import { plugins } from './plugins';

export function routes(server) {
workpad(server);
socketApi(server);
translate(server);
esFields(server);
esIndices(server);
plugins(server);
}

0 comments on commit 30ebf9c

Please sign in to comment.