From 661fcaf2e3ecb73d91b9450ed0511fda406915c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bour?= Date: Wed, 12 Dec 2018 14:19:09 +0100 Subject: [PATCH] feat: add elasticdump extract --- index.html | 1 + src/base.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/index.html b/index.html index a302acb..ea5c8d1 100755 --- a/index.html +++ b/index.html @@ -44,6 +44,7 @@ diff --git a/src/base.js b/src/base.js index 470a9bb..fac4da4 100755 --- a/src/base.js +++ b/src/base.js @@ -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 @@ -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();