Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix export all #4954

Merged
merged 1 commit into from
Sep 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ define(function (require) {
};


this.find = function (searchString) {
this.find = function (searchString, size = 100) {
var self = this;
var body;
if (searchString) {
Expand All @@ -64,7 +64,7 @@ define(function (require) {
index: kbnIndex,
type: 'dashboard',
body: body,
size: 100
size: size
})
.then(function (resp) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ define(function (require) {
});
};

this.find = function (searchString) {
this.find = function (searchString, size = 100) {
var self = this;
var body;
if (searchString) {
Expand All @@ -67,7 +67,7 @@ define(function (require) {
index: kbnIndex,
type: 'search',
body: body,
size: 100
size: size
})
.then(function (resp) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<kbn-settings-objects class="container">
<div class="header">
<h2 class="title">Edit Saved Objects</h2>
<button class="btn btn-default controls" ng-click="exportAll()"><i aria-hidden="true" class="fa fa-download"></i> Export</button>
<button class="btn btn-default controls" ng-click="exportAll()"><i aria-hidden="true" class="fa fa-download"></i> Export Everything</button>
<button file-upload="importAll(fileContents)" class="btn btn-default controls" ng-click><i aria-hidden="true" class="fa fa-upload"></i> Import</button>
</div>
<p>
Expand Down
12 changes: 7 additions & 5 deletions src/plugins/kibana/public/settings/sections/objects/_objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ define(function (require) {
var saveAs = require('@spalger/filesaver').saveAs;
var registry = require('plugins/kibana/settings/saved_object_registry');
var objectIndexHTML = require('plugins/kibana/settings/sections/objects/_objects.html');
const MAX_SIZE = Math.pow(2, 31) - 1;

require('ui/directives/file_upload');

Expand Down Expand Up @@ -91,11 +92,12 @@ define(function (require) {
retrieveAndExportDocs(objs);
};

$scope.exportAll = function () {
var objs = $scope.services.map(function (service) {
return service.data.map(_.partialRight(_.extend, {type: service.type}));
});
retrieveAndExportDocs(_.flattenDeep(objs));
$scope.exportAll = () => {
Promise.map($scope.services, (service) =>
service.service.find('', MAX_SIZE).then((results) =>
results.hits.map((hit) => _.extend(hit, {type: service.type}))
)
).then((results) => retrieveAndExportDocs(_.flattenDeep(results)));
};

function retrieveAndExportDocs(objs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ define(function (require) {
});
};

this.find = function (searchString) {
this.find = function (searchString, size = 100) {
var self = this;
var body;
if (searchString) {
Expand All @@ -62,7 +62,7 @@ define(function (require) {
index: kbnIndex,
type: 'visualization',
body: body,
size: 100,
size: size
})
.then(function (resp) {
return {
Expand Down