mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Added basic Cat API support to the KB
also added pending tasks to the cluster API kb. Closes #113
This commit is contained in:
parent
4dff3c5ee4
commit
437f6cbba5
4 changed files with 86 additions and 40 deletions
|
@ -23,14 +23,20 @@ define([
|
|||
cb = typeof cb === 'function' ? cb : $.noop;
|
||||
|
||||
input.getCurrentRequest(function (req) {
|
||||
if (!req) return;
|
||||
output.update('');
|
||||
|
||||
if (!req) {
|
||||
return;
|
||||
}
|
||||
|
||||
$("#notification").text("Calling ES....").css("visibility", "visible");
|
||||
|
||||
var es_path = req.url;
|
||||
var es_method = req.method;
|
||||
var es_data = req.data.join("\n");
|
||||
if (es_data) es_data += "\n"; //append a new line for bulk requests.
|
||||
if (es_data) {
|
||||
es_data += "\n";
|
||||
} //append a new line for bulk requests.
|
||||
|
||||
es.send(es_method, es_path, es_data, null, function (xhr, status) {
|
||||
$("#notification").text("").css("visibility", "hidden");
|
||||
|
@ -43,16 +49,29 @@ define([
|
|||
|
||||
|
||||
var value = xhr.responseText;
|
||||
try {
|
||||
value = JSON.stringify(JSON.parse(value), null, 3);
|
||||
var mode = "ace/mode/json";
|
||||
var contentType = xhr.getAllResponseHeaders("Content-Type") || "";
|
||||
if (contentType.indexOf("text/plain") >= 0) {
|
||||
mode = "ace/mode/text";
|
||||
}
|
||||
catch (e) {
|
||||
else if (contentType.indexOf("application/yaml") >= 0) {
|
||||
mode = "ace/mode/text"
|
||||
}
|
||||
else {
|
||||
// assume json - auto pretty
|
||||
try {
|
||||
value = JSON.stringify(JSON.parse(value), null, 3);
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
cb(value);
|
||||
|
||||
output.update(value, mode);
|
||||
|
||||
}
|
||||
else {
|
||||
cb("Request failed to get to the server (status code: " + xhr.status + "):" + xhr.responseText);
|
||||
cb("Request failed to get to the server (status code: " + xhr.status + "):" + xhr.responseText, 'ace/mode/text');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -79,16 +98,19 @@ define([
|
|||
if (sourceLocation == "stored") {
|
||||
if (previousSaveState) {
|
||||
resetToValues(previousSaveState.server, previousSaveState.content);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
input.autoIndent();
|
||||
}
|
||||
} else if (/^https?:\/\//.exec(sourceLocation)) {
|
||||
}
|
||||
else if (/^https?:\/\//.exec(sourceLocation)) {
|
||||
$.get(sourceLocation, null, function (data) {
|
||||
resetToValues(null, data);
|
||||
input.highlightCurrentRequestAndUpdateActionBar();
|
||||
input.updateActionsBar();
|
||||
});
|
||||
} else if (previousSaveState) {
|
||||
}
|
||||
else if (previousSaveState) {
|
||||
resetToValues(previousSaveState.server);
|
||||
}
|
||||
|
||||
|
@ -151,7 +173,9 @@ define([
|
|||
}
|
||||
|
||||
var s = prefix + req.method + " " + req.endpoint;
|
||||
if (req.data) s += "\n" + req.data;
|
||||
if (req.data) {
|
||||
s += "\n" + req.data;
|
||||
}
|
||||
|
||||
s += suffix;
|
||||
|
||||
|
@ -212,18 +236,11 @@ define([
|
|||
input.commands.addCommand({
|
||||
name: 'send to elasticsearch',
|
||||
bindKey: {win: 'Ctrl-Enter', mac: 'Command-Enter'},
|
||||
exec: function () {
|
||||
output.update('');
|
||||
submitCurrentRequestToES(function (resp) {
|
||||
output.update(resp, 'ace/mode/json');
|
||||
});
|
||||
}
|
||||
exec: submitCurrentRequestToES
|
||||
});
|
||||
|
||||
$send.click(function () {
|
||||
submitCurrentRequestToES(function (resp) {
|
||||
output.update(resp, 'ace/mode/json');
|
||||
});
|
||||
submitCurrentRequestToES();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
@ -237,8 +254,9 @@ define([
|
|||
var a = li.find('a');
|
||||
a.attr('href', link.url);
|
||||
a.text(link.name);
|
||||
if (a[0].href != window.location.href)
|
||||
if (a[0].href != window.location.href) {
|
||||
li.appendTo(linkMenu);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ define([
|
|||
'_',
|
||||
'./api',
|
||||
'./api_1_0/aliases',
|
||||
'./api_1_0/cat',
|
||||
'./api_1_0/cluster',
|
||||
'./api_1_0/facets',
|
||||
'./api_1_0/aggregations',
|
||||
|
|
33
sense/app/kb/api_1_0/cat.js
Normal file
33
sense/app/kb/api_1_0/cat.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
define(function () {
|
||||
'use strict';
|
||||
|
||||
|
||||
function addSimpleCat(endpoint, api) {
|
||||
api.addEndpointDescription(endpoint, {
|
||||
match: endpoint,
|
||||
def_method: 'GET',
|
||||
methods: ['GET' ],
|
||||
endpoint_autocomplete: [
|
||||
endpoint
|
||||
],
|
||||
indices_mode: 'none',
|
||||
types_mode: 'none',
|
||||
doc_id_mode: 'none',
|
||||
data_autocomplete_rules: {}
|
||||
});
|
||||
}
|
||||
|
||||
return function init(api) {
|
||||
addSimpleCat('_cat/aliases', api);
|
||||
addSimpleCat('_cat/allocation', api);
|
||||
addSimpleCat('_cat/count', api);
|
||||
addSimpleCat('_cat/health', api);
|
||||
addSimpleCat('_cat/indices', api);
|
||||
addSimpleCat('_cat/master', api);
|
||||
addSimpleCat('_cat/nodes', api);
|
||||
addSimpleCat('_cat/pending_tasks', api);
|
||||
addSimpleCat('_cat/recovery', api);
|
||||
addSimpleCat('_cat/thread_pool', api);
|
||||
addSimpleCat('_cat/shards', api);
|
||||
};
|
||||
});
|
|
@ -1,26 +1,20 @@
|
|||
define(function () {
|
||||
'use strict';
|
||||
|
||||
function addSimple(endpoint, api) {
|
||||
api.addEndpointDescription(endpoint, {
|
||||
def_method: 'GET',
|
||||
methods: ['GET' ],
|
||||
indices_mode: 'none',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return function init(api) {
|
||||
api.addEndpointDescription('_cluster/nodes/stats', {
|
||||
methods: ['GET'],
|
||||
indices_mode: 'none',
|
||||
types_mode: 'none'
|
||||
});
|
||||
|
||||
api.addEndpointDescription('_cluster/state', {
|
||||
methods: ['GET'],
|
||||
endpoint_autocomplete: ['_cluster/state'],
|
||||
indices_mode: 'none',
|
||||
types_mode: 'none'
|
||||
});
|
||||
|
||||
api.addEndpointDescription('_cluster/health', {
|
||||
methods: ['GET'],
|
||||
endpoint_autocomplete: ['_cluster/health'],
|
||||
indices_mode: 'none',
|
||||
types_mode: 'none'
|
||||
});
|
||||
addSimple('_cluster/nodes/stats', api);
|
||||
addSimple('_cluster/state', api);
|
||||
addSimple('_cluster/health', api);
|
||||
addSimple('_cluster/pending_tasks', api);
|
||||
|
||||
api.addEndpointDescription('_cluster/settings', {
|
||||
methods: ['GET', 'PUT'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue