mirror of https://gitee.com/bigwinds/arangodb
explain bind param support, view + aardvark
This commit is contained in:
parent
bb814f1c5d
commit
068bee4c80
|
@ -170,12 +170,18 @@ controller.post("disableVersionCheck", function(req, res) {
|
|||
*/
|
||||
controller.post("/query/explain", function(req, res) {
|
||||
|
||||
var explain, query = req.body().query;
|
||||
var explain, query = req.body().query,
|
||||
bindVars = req.body().bindVars;
|
||||
|
||||
if (query.length > 0) {
|
||||
try {
|
||||
if (bindVars) {
|
||||
explain = require("org/arangodb/aql/explainer").explain(query, {colors: false}, false, bindVars);
|
||||
}
|
||||
else {
|
||||
explain = require("org/arangodb/aql/explainer").explain(query, {colors: false}, false);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
explain = JSON.stringify(e);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
inputEditor = ace.edit("aqlEditor"),
|
||||
varsEditor = ace.edit("varsEditor");
|
||||
inputEditor.setValue(this.getCustomQueryValueByName(queryName));
|
||||
varsEditor.setValue(this.getCustomQueryParameterByName(queryName));
|
||||
varsEditor.setValue(JSON.stringify(this.getCustomQueryParameterByName(queryName)));
|
||||
this.deselect(varsEditor);
|
||||
this.deselect(inputEditor);
|
||||
$('#querySelect').val(queryName);
|
||||
|
@ -541,6 +541,14 @@
|
|||
bindVars = '{}';
|
||||
}
|
||||
|
||||
if (typeof bindVars === 'string') {
|
||||
try {
|
||||
bindVars = JSON.parse(bindVars);
|
||||
}
|
||||
catch (err) {
|
||||
console.log("could not parse bind parameter");
|
||||
}
|
||||
}
|
||||
this.collection.add({
|
||||
name: saveName,
|
||||
parameter: bindVars,
|
||||
|
@ -672,6 +680,7 @@
|
|||
};
|
||||
|
||||
var bindVars = varsEditor.getValue();
|
||||
|
||||
if (bindVars.length > 0) {
|
||||
try {
|
||||
var params = JSON.parse(bindVars);
|
||||
|
@ -681,6 +690,7 @@
|
|||
}
|
||||
catch (e) {
|
||||
arangoHelper.arangoError("Query error", "Could not parse bind parameters.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return JSON.stringify(data);
|
||||
|
@ -859,15 +869,19 @@
|
|||
|
||||
var self = this;
|
||||
var outputEditor = ace.edit("queryOutput");
|
||||
var queryData = this.readQueryData();
|
||||
$('.queryExecutionTime').text('');
|
||||
this.execPending = false;
|
||||
|
||||
if (queryData) {
|
||||
window.progressView.show(
|
||||
"Explain is operating..."
|
||||
);
|
||||
this.execPending = false;
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/_admin/aardvark/query/explain/",
|
||||
data: this.readQueryData(),
|
||||
data: queryData,
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
|
@ -881,6 +895,7 @@
|
|||
}
|
||||
},
|
||||
error: function (data) {
|
||||
window.progressView.hide();
|
||||
try {
|
||||
var temp = JSON.parse(data.responseText);
|
||||
arangoHelper.arangoError("Explain error", temp.errorNum);
|
||||
|
@ -894,7 +909,7 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
/*
|
||||
var self = this;
|
||||
$("svg#explainOutput").html();
|
||||
|
@ -952,6 +967,9 @@
|
|||
// clear result
|
||||
outputEditor.setValue('');
|
||||
|
||||
var queryData = this.readQueryData();
|
||||
if (queryData) {
|
||||
|
||||
window.progressView.show(
|
||||
"Query is operating..."
|
||||
);
|
||||
|
@ -963,7 +981,7 @@
|
|||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/_api/cursor",
|
||||
data: this.readQueryData(),
|
||||
data: queryData,
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
|
@ -1008,11 +1026,11 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
submitQuery: function () {
|
||||
var outputEditor = ace.edit("queryOutput");
|
||||
// this.fillExplain();
|
||||
this.fillResult(this.switchTab.bind(this, "result-switch"));
|
||||
outputEditor.resize();
|
||||
var inputEditor = ace.edit("aqlEditor");
|
||||
|
@ -1021,14 +1039,7 @@
|
|||
},
|
||||
|
||||
explainQuery: function() {
|
||||
|
||||
this.fillExplain();
|
||||
/*
|
||||
this.fillExplain(this.switchTab.bind(this, "explain-switch"));
|
||||
this.execPending = true;
|
||||
var inputEditor = ace.edit("aqlEditor");
|
||||
this.deselect(inputEditor);
|
||||
*/
|
||||
},
|
||||
|
||||
// This function changes the focus onto the tab that has been clicked
|
||||
|
|
Loading…
Reference in New Issue