Skip to content

Commit

Permalink
feat: add elasticdump extract
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneBour committed Dec 12, 2018
1 parent b8d0444 commit 661fcaf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<ul class="dropdown-menu">
<li><a id="copy_as_curl" tabindex="-1" href="#">Copy as cURL</a></li>
<li><a id="copy_as_php" tabindex="-1" href="#">Copy as PHP</a></li>
<li><a id="copy_for_elasticdump" tabindex="-1" href="#">Copy for Elasticdump</a></li>
<li><a id="query_save" tabindex="-1" href="#">Save query</a></li>
<li><a id="auto_indent" tabindex="-1" href="#">Auto indent</a></li>
</ul>
Expand Down
33 changes: 33 additions & 0 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,34 @@ function copyAsPhp() {
}



function copyForElasticdump() {
var req = sense.utils.getCurrentRequest();
if (!req) return;

if(req.url.charAt(0) == '/') {
req.url = req.url.slice(1);
}
var data = req.url.split('/');
var index = data[0];
var type = '';
if(data[1].slice(1) !== '_')
type = data[1];

var es_server = $("#es_server").val(),
es_url = req.url,
es_method = req.method,
es_data = req.data;

var url = constructESUrl(es_server, index + '/' + type);

var elasticdump = 'elasticdump --input=' + url + ' --output=./' + index + '_' + type + '_' + (new Date()).getTime()
+ '.json --type=data --searchBody=\'' + reformatData(es_data, 0).data + '\' --limit=1000';

copyToClipboard(elasticdump);

}

function handleCURLPaste(text) {
var curlInput = sense.curl.parseCURL(text);
if ($("#es_server").val()) curlInput.server = null; // do not override server
Expand Down Expand Up @@ -571,6 +599,11 @@ function init() {
e.preventDefault();
});

$("#copy_for_elasticdump").click(function (e) {
copyForElasticdump();
e.preventDefault();
});

$("#query_save").click(function (e) {
querySave();
e.preventDefault();
Expand Down

0 comments on commit 661fcaf

Please sign in to comment.