1
0
Fork 0

Merge branch 'devel' of https://github.com/arangodb/arangodb into spdvpk

This commit is contained in:
Jan Steemann 2016-02-26 10:19:17 +01:00
commit c0fd3b13ca
33 changed files with 1139 additions and 282 deletions

View File

@ -1,3 +1,5 @@
# -*- mode: CMAKE; -*-
# ------------------------------------------------------------------------------
# External Projects used by ArangoDB
# ------------------------------------------------------------------------------
@ -32,10 +34,10 @@ if (GO_FOUND)
endif ()
################################################################################
## ZLIB
## BOOST
################################################################################
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/zlib/zlib-1.2.8)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/boost)
################################################################################
## EV
@ -43,6 +45,12 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/zlib/zlib-1.2.8)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libev)
################################################################################
## OPENSSL
################################################################################
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/OpenSSL)
################################################################################
## V8 and ICU
################################################################################
@ -105,3 +113,9 @@ if (USE_PRECOMPILED_V8)
else ()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/V8)
endif ()
################################################################################
## ZLIB
################################################################################
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/zlib/zlib-1.2.8)

37
3rdParty/OpenSSL/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,37 @@
# -*- mode: CMAKE; -*-
# ------------------------------------------------------------------------------
# OPENSSL
# ------------------------------------------------------------------------------
find_package(OpenSSL REQUIRED)
if (OPENSSL_VERSION)
string(REPLACE "." ";" OPENSSL_VERSION_LIST ${OPENSSL_VERSION})
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
if (${OPENSSL_VERSION_MAJOR} GREATER 0 AND ${OPENSSL_VERSION_MINOR} GREATER 0)
add_definitions(-DOPENSSL_NO_SSL2)
endif ()
endif ()
set(OPENSSL_VERSION
"${OPENSSL_VERSION}"
CACHE INTERNAL
"OpenSSL: Version"
FORCE
)
set(OPENSSL_INCLUDE_DIR
"${OPENSSL_INCLUDE_DIR}"
CACHE INTERNAL
"OpenSSL: Include Directory"
FORCE
)
set(OPENSSL_LIBRARIES
"${OPENSSL_LIBRARIES}"
CACHE INTERNAL
"OpenSSL: Libraries Directory"
FORCE
)

View File

@ -91,6 +91,9 @@ else ()
endif ()
endif()
list(APPEND V8_COMPILE_ARGS icui18n icuuc icudata)
list(APPEND V8_COMPILE_ARGS v8)
ExternalProject_Add(v8_build
BUILD_IN_SOURCE TRUE
SOURCE_DIR "${V8_DIR}"

72
3rdParty/boost/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,72 @@
cmake_minimum_required(VERSION 2.6)
# ------------------------------------------------------------------------------
# V8 / ICU
# ------------------------------------------------------------------------------
################################################################################
## BOOST
################################################################################
option(USE_BOOST_SYSTEM_LIBS "use libraries provided by the system" OFF)
set(BOOST_MINIMUM_VERSION 1.58)
set(Boost_USE_MULTITHREADED ON)
if (USE_BOOST_SYSTEM_LIBS)
find_package(Boost ${BOOST_MINIMUM_VERSION} REQUIRED)
else ()
set(BOOST_INCLUDE ${PROJECT_SOURCE_DIR}/3rdParty/boost/${BOOST_MINIMUM_VERSION}.0 CACHE path "BOOST include path")
set(Boost_INCLUDE_DIR ${BOOST_INCLUDE})
set(Boost_VERSION ${BOOST_MINIMUM_VERSION})
find_package(Boost ${BOOST_MINIMUM_VERSION} REQUIRED)
endif ()
find_package(Boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} EXACT COMPONENTS unit_test_framework)
if (${Boost_UNIT_TEST_FRAMEWORK_FOUND} STREQUAL "ON")
try_compile(
HAVE_USABLE_BOOT_LIBRARIES
"${CMAKE_BINARY_DIR}/temp"
"${CMAKE_SOURCE_DIR}/cmake/test_boost.cpp"
LINK_LIBRARIES
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES=${Boost_INCLUDE_DIR}"
)
if (HAVE_USABLE_BOOT_LIBRARIES)
option(USE_BOOST_UNITTESTS "use boost unit-tests" ON)
else ()
message("cannot use BOOST library ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
option(USE_BOOST_UNITTESTS "use boost unit-tests" OFF)
endif ()
else ()
option(USE_BOOST_UNITTESTS "use boost unit-tests" OFF)
endif ()
if (NOT USE_BOOST_UNITTESTS)
message("BOOST unit tests are disabled")
endif ()
set(BOOST_VERSION
"${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}"
CACHE INTERNAL
"Boost: Version"
FORCE
)
set(BOOST_INCLUDE_DIR
"${Boost_INCLUDE_DIR}"
CACHE INTERNAL
"Boost: Include Directory"
FORCE
)
set(BOOST_LIBS
"${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}"
CACHE INTERNAL
"Boost: Libraries"
FORCE
)

View File

@ -56,6 +56,8 @@ endif ()
################################################################################
include(CheckCXXSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFile)
CHECK_INCLUDE_FILE(poll.h HAVE_POLL_H)
CHECK_INCLUDE_FILE(port.h HAVE_PORT_H)

View File

@ -144,6 +144,8 @@ static ConversionResult copyString8to32 (char32_t* dst, size_t dstSize, size_t&
if (dstCount < dstSize) {
*targetStart = 0;
}
} else {
dstCount = 0;
}
return res;

View File

@ -241,11 +241,11 @@ endif()
include_directories(${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
add_executable(example test/example.c)
add_executable(example EXCLUDE_FROM_ALL test/example.c)
target_link_libraries(example zlib)
add_test(example example)
add_executable(minigzip test/minigzip.c)
add_executable(minigzip EXCLUDE_FROM_ALL test/minigzip.c)
target_link_libraries(minigzip zlib)
if(HAVE_OFF64_T)

View File

@ -398,92 +398,25 @@ if (USE_FAILURE_TESTS)
add_definitions("-DARANGODB_ENABLE_FAILURE_TESTS=1")
endif ()
################################################################################
## BOOST
################################################################################
option(USE_BOOST_SYSTEM_LIBS "use libraries provided by the system" OFF)
set(BOOST_MINIMUM_VERSION 1.58)
set(Boost_USE_MULTITHREADED ON)
if (USE_BOOST_SYSTEM_LIBS)
find_package(Boost ${BOOST_MINIMUM_VERSION} REQUIRED)
else ()
set(BOOST_INCLUDE ${PROJECT_SOURCE_DIR}/3rdParty/boost/${BOOST_MINIMUM_VERSION}.0 CACHE path "BOOST include path")
set(Boost_INCLUDE_DIR ${BOOST_INCLUDE})
set(Boost_VERSION ${BOOST_MINIMUM_VERSION})
find_package(Boost ${BOOST_MINIMUM_VERSION} REQUIRED)
endif ()
find_package(Boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} EXACT COMPONENTS unit_test_framework)
if (${Boost_UNIT_TEST_FRAMEWORK_FOUND})
try_compile(
HAVE_USABLE_BOOT_LIBRARIES
"${CMAKE_BINARY_DIR}/temp"
"${CMAKE_SOURCE_DIR}/cmake/test_boost.cpp"
LINK_LIBRARIES
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES=${Boost_INCLUDE_DIR}"
)
if (HAVE_USABLE_BOOT_LIBRARIES)
option(USE_BOOST_UNITTESTS "use boost unit-tests" ON)
else ()
message("cannot use BOOST library ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
option(USE_BOOST_UNITTESTS "use boost unit-tests" OFF)
endif ()
else ()
option(USE_BOOST_UNITTESTS "use boost unit-tests" OFF)
endif ()
if (NOT USE_BOOST_UNITTESTS)
message("BOOST unit tests are disabled")
endif ()
include_directories(${Boost_INCLUDE_DIR})
set(BOOST_VERSION
"${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}"
CACHE INTERNAL
"Boost: Version"
FORCE
)
add_definitions(-DARANGODB_BOOST_VERSION=\"${BOOST_VERSION}\")
################################################################################
## OPENSSL
################################################################################
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
if (OPENSSL_VERSION)
string(REPLACE "." ";" OPENSSL_VERSION_LIST ${OPENSSL_VERSION})
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
if (${OPENSSL_VERSION_MAJOR} GREATER 0 AND ${OPENSSL_VERSION_MINOR} GREATER 0)
add_definitions(-DOPENSSL_NO_SSL2)
endif ()
endif ()
################################################################################
## TCMALLOC
################################################################################
set(USE_TCMALLOC, TRUE)
if (WINDOWS OR SOLARIS)
set(USE_TCMALLOC, FALSE)
option(USE_TCMALLOC
"use TCMALLOC library"
FALSE
)
else ()
option(USE_TCMALLOC
"use TCMALLOC if the library is available"
TRUE
)
endif ()
if (USE_TCMALLOC)
find_package(tcmalloc)
endif()
endif ()
################################################################################
## 3RD PARTY
@ -491,6 +424,10 @@ endif()
# 3rdParty exports:
#
# BOOST_VERSION
# BOOST_INCLUDE_DIR
# USE_BOOST_UNITTESTS
#
# V8_VERSION
# V8_LIBS
# V8_INCLUDE_DIR
@ -509,6 +446,19 @@ endif()
add_subdirectory(3rdParty)
################################################################################
## BOOST
################################################################################
include_directories(${BOOST_INCLUDE_DIR})
add_definitions(-DARANGODB_BOOST_VERSION=\"${BOOST_VERSION}\")
################################################################################
## ICU
################################################################################
include_directories(${ICU_INCLUDE_DIR})
################################################################################
## LIBEV
################################################################################
@ -517,11 +467,11 @@ include_directories(${LIBEV_INCLUDE_DIR})
add_definitions("-DARANGODB_LIBEV_VERSION=\"${LIBEV_VERSION}\"")
################################################################################
## ZLIB
## OPENSSL
################################################################################
include_directories(${ZLIB_INCLUDE_DIR})
add_definitions("-DARANGODB_ZLIB_VERSION=\"${ZLIB_VERSION}\"")
include_directories(${OPENSSL_INCLUDE_DIR})
add_definitions(-DARANGODB_OPENSSL_VERSION=\"${BOOST_VERSION}\")
################################################################################
## V8
@ -531,10 +481,11 @@ include_directories(${V8_INCLUDE_DIR})
add_definitions("-DARANGODB_V8_VERSION=\"${V8_VERSION}\"")
################################################################################
## ICU
## ZLIB
################################################################################
include_directories(${ICU_INCLUDE_DIR})
include_directories(${ZLIB_INCLUDE_DIR})
add_definitions("-DARANGODB_ZLIB_VERSION=\"${ZLIB_VERSION}\"")
################################################################################
## PATHS
@ -631,3 +582,15 @@ add_subdirectory(arangosh)
add_subdirectory(arangod)
add_subdirectory(UnitTests)
add_subdirectory(Documentation)
add_dependencies(arangob zlibstatic v8_build)
add_dependencies(arangod ev zlibstatic v8_build)
add_dependencies(arangodump zlibstatic v8_build)
add_dependencies(arangoimp zlibstatic v8_build)
add_dependencies(arangorestore zlibstatic v8_build)
add_dependencies(arangosh zlibstatic v8_build)
if (USE_BOOST_UNITTESTS)
add_dependencies(basics_suite v8_build)
add_dependencies(geo_suite v8_build)
endif ()

View File

@ -4,7 +4,7 @@
## --SECTION-- COMMON VARIABLES
## -----------------------------------------------------------------------------
.PHONY: warning
.PHONY: warning help
warning:
@echo "ArangoDB has switch to CMAKE. In order to compile, use:"
@ -14,13 +14,59 @@ warning:
@echo " cmake .."
@echo " make"
@echo ""
@echo MacOS users:""
@echo "MacOS users:"
@echo " Please use OPENSSL from homebrew and use"
@echo ""
@echo " cmake .. -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl"
@echo ""
@echo " Note that some versions of Apple's clang have severe performance"
@echo " issues. Use GCC5 from homebrew in this case."
@echo ""
@echo "Use 'make help' to see more options."
help:
@echo "The most common -D<options> are"
@echo ""
@echo " -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-5"
@echo " sets the C++ compiler"
@echo " -DCMAKE_C_COMPILER=/usr/local/bin/gcc-5"
@echo " sets the C compiler"
@echo ""
@echo "ArangoDB supports:"
@echo ""
@echo " -DUSE_BACKTRACE=off"
@echo " if ON, enables backtraces in fatal errors"
@echo " -DUSE_FAILURE_TESTS=off"
@echo " if ON, add failure functions for testing"
@echo " -DUSE_MAINTAINER_MODE=off"
@echo " if ON, enable maintainer features"
@echo ""
@echo "BOOST supports:"
@echo ""
@echo " -DUSE_BOOST_SYSTEM_LIBS=off"
@echo " if ON, use the operating system Boost installation"
@echo " -DUSE_BOOST_UNITTESTS=on"
@echo " if ON, use Boost unittest framework if this available"
@echo ""
@echo "OPENSSL supports:"
@echo " -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl"
@echo " sets the location of the openssl includes and libraries"
@echo ""
@echo "BOOST supports:"
@echo ""
@echo " -DUSE_TCMALLOC=on"
@echo " if ON, link against TCMALLOC"
@echo ""
@echo "V8 supports:"
@echo " -DUSE_PRECOMPILED_V8=off"
@echo " if ON, use precompiled V8 libraries"
@echo ""
@echo "ZLIB supports:"
@echo " -DASM686=on"
@echo " if ON, enables building i686 assembly implementation"
@echo " -DAMD64=on"
@echo " if ON, enables building amd64 assembly implementation"
VERSION_MAJOR := $(wordlist 1,1,$(subst ., ,$(VERSION)))
VERSION_MINOR := $(wordlist 2,2,$(subst ., ,$(VERSION)))

View File

@ -38,7 +38,7 @@ if (USE_BOOST_UNITTESTS)
target_link_libraries(${TEST_BASICS_SUITE}
${LIB_ARANGO}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
${BOOST_LIBS}
${SYSTEM_LIBRARIES}
)
endif ()
@ -57,8 +57,7 @@ if (USE_BOOST_UNITTESTS)
target_link_libraries(${TEST_GEO_SUITE}
${LIB_ARANGO}
${Boost_LIBRARIES}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
${BOOST_LIBS}
${SYSTEM_LIBRARIES}
)
endif ()

View File

@ -146,6 +146,12 @@
content: [{
label: "Submit",
letter: "Ctrl + Return"
},{
label: "Explain Query",
letter: "Ctrl + Shift + E"
},{
label: "Save Query",
letter: "Ctrl + Shift + S"
},{
label: "Toggle comments",
letter: "Ctrl + Shift + C"

File diff suppressed because one or more lines are too long

View File

@ -5708,7 +5708,6 @@ div.headerBar {
.modal-body .tab-content #appstore {
max-height: 290px; }
.modal-body .errorMessage {
background-color: #fff;
color: #da4f49;
font-size: 9pt;
font-weight: 400;

View File

@ -10496,6 +10496,12 @@ function GraphViewer(svg, width, height, adapterConfig, config) {
content: [{
label: "Submit",
letter: "Ctrl + Return"
},{
label: "Explain Query",
letter: "Ctrl + Shift + E"
},{
label: "Save Query",
letter: "Ctrl + Shift + S"
},{
label: "Toggle comments",
letter: "Ctrl + Shift + C"
@ -27611,6 +27617,8 @@ window.ArangoUsers = Backbone.Collection.extend({
outputTemplate: templateEngine.createTemplate("queryViewOutput.ejs"),
outputCounter: 0,
allowUpload: false,
customQueries: [],
queries: [],
@ -27650,10 +27658,19 @@ window.ArangoUsers = Backbone.Collection.extend({
"click .outputEditorWrapper .fa-close": "closeResult",
"click #toggleQueries1": "toggleQueries",
"click #toggleQueries2": "toggleQueries",
"click #saveCurrentQuery": "addAQL",
"click #exportQuery": "exportCustomQueries",
"click #importQuery": "openImportDialog",
"click #removeResults": "removeResults",
"click #deleteQuery": "selectAndDeleteQueryFromTable",
"click #explQuery": "selectAndExplainQueryFromTable",
"keyup #arangoBindParamTable input": "updateBindParams",
"change #arangoBindParamTable input": "updateBindParams",
"click #arangoMyQueriesTable tr" : "showQueryPreview",
"dblclick #arangoMyQueriesTable tr" : "selectQueryFromTable",
"click #arangoMyQueriesTable #copyQuery" : "selectQueryFromTable",
'click #closeQueryModal': 'closeExportDialog',
'click #confirmQueryImport': 'importCustomQueries',
"click #arangoMyQueriesTable #runQuery" : "selectAndRunQueryFromTable"
},
@ -27661,12 +27678,78 @@ window.ArangoUsers = Backbone.Collection.extend({
this.aqlEditor.setValue('');
},
initQueryImport: function () {
var self = this;
self.allowUpload = false;
$('#importQueries').change(function(e) {
self.files = e.target.files || e.dataTransfer.files;
self.file = self.files[0];
self.allowUpload = true;
$('#confirmQueryImport').removeClass('disabled');
});
},
importCustomQueries: function () {
var self = this;
if (this.allowUpload === true) {
var callback = function() {
this.collection.fetch({
success: function() {
self.updateLocalQueries();
self.updateQueryTable();
self.resize();
self.allowUpload = false;
$('#confirmQueryImport').addClass('disabled');
$('#queryImportDialog').modal('hide');
},
error: function(data) {
arangoHelper.arangoError("Custom Queries", data.responseText);
}
});
}.bind(this);
self.collection.saveImportQueries(self.file, callback.bind(this));
}
},
removeResults: function() {
$('.outputEditorWrapper').hide('fast', function() {
$('.outputEditorWrapper').remove();
});
$('#removeResults').hide();
},
getCustomQueryParameterByName: function (qName) {
return this.collection.findWhere({name: qName}).get("parameter");
},
getCustomQueryValueByName: function (qName) {
return this.collection.findWhere({name: qName}).get("value");
if (qName) {
return this.collection.findWhere({name: qName}).get("value");
}
},
openImportDialog: function() {
$('#queryImportDialog').modal('show');
},
closeImportDialog: function() {
$('#queryImportDialog').modal('hide');
},
exportCustomQueries: function () {
var name;
$.ajax("whoAmI?_=" + Date.now()).success(function(data) {
name = data.user;
if (name === null || name === false) {
name = "root";
}
window.open("query/download/" + encodeURIComponent(name));
});
},
toggleQueries: function(e) {
@ -27681,7 +27764,7 @@ window.ArangoUsers = Backbone.Collection.extend({
"aqlEditor", "queryTable", "previewWrapper",
"bindParamEditor", "toggleQueries1", "toggleQueries2",
"saveCurrentQuery", "querySize", "executeQuery",
"explainQuery", "clearQuery"
"explainQuery", "clearQuery", "importQuery", "exportQuery"
];
_.each(divs, function(div) {
$("#" + div).toggle();
@ -27693,19 +27776,64 @@ window.ArangoUsers = Backbone.Collection.extend({
$('#arangoMyQueriesTable tr').removeClass('selected');
$(e.currentTarget).addClass('selected');
var name = $(e.currentTarget).children().first().text();
var name = this.getQueryNameFromTable(e);
this.queryPreview.setValue(this.getCustomQueryValueByName(name));
this.deselect(this.queryPreview);
},
getQueryNameFromTable: function(e) {
var name;
if ($(e.currentTarget).is('tr')) {
name = $(e.currentTarget).children().first().text();
}
else if ($(e.currentTarget).is('span')) {
name = $(e.currentTarget).parent().parent().prev().text();
}
return name;
},
deleteQueryModal: function(name){
var buttons = [], tableContent = [];
tableContent.push(
window.modalView.createReadOnlyEntry(
undefined,
name,
'Do you want to delete the query?',
undefined,
undefined,
false,
undefined
)
);
buttons.push(
window.modalView.createDeleteButton('Delete', this.deleteAQL.bind(this, name))
);
window.modalView.show(
'modalTable.ejs', 'Delete Query', buttons, tableContent
);
},
selectAndDeleteQueryFromTable: function(e) {
var name = this.getQueryNameFromTable(e);
this.deleteQueryModal(name);
},
selectAndExplainQueryFromTable: function(e) {
this.selectQueryFromTable(e, false);
this.explainQuery();
},
selectAndRunQueryFromTable: function(e) {
this.selectQueryFromTable(e);
this.selectQueryFromTable(e, false);
this.executeQuery();
},
selectQueryFromTable: function(e) {
var name = $(e.currentTarget).parent().parent().prev().text();
this.toggleQueries();
selectQueryFromTable: function(e, toggle) {
var name = this.getQueryNameFromTable(e);
if (toggle === undefined) {
this.toggleQueries();
}
this.aqlEditor.setValue(this.getCustomQueryValueByName(name));
this.fillBindParamTable(this.getCustomQueryParameterByName(name));
@ -27713,6 +27841,25 @@ window.ArangoUsers = Backbone.Collection.extend({
this.deselect(this.aqlEditor);
},
deleteAQL: function (name) {
var callbackRemove = function(error) {
if (error) {
arangoHelper.arangoError("Query", "Could not delete query.");
}
else {
this.updateLocalQueries();
this.updateQueryTable();
this.resize();
window.modalView.hide();
}
}.bind(this);
var toDelete = this.collection.findWhere({name: name});
this.collection.remove(toDelete);
this.collection.saveCollectionQueries(callbackRemove);
},
switchAce: function(e) {
var count = $(e.currentTarget).attr('counter');
@ -27818,8 +27965,8 @@ window.ArangoUsers = Backbone.Collection.extend({
self.deselect(outputEditor);
$.noty.clearQueue();
$.noty.closeAll();
self.handleResult(counter);
}
window.progressView.hide();
},
error: function (data) {
window.progressView.hide();
@ -27830,7 +27977,7 @@ window.ArangoUsers = Backbone.Collection.extend({
catch (e) {
arangoHelper.arangoError("Explain error", "ERROR");
}
window.progressView.hide();
self.handleResult(counter);
this.removeOutputEditor(counter);
}
});
@ -27890,6 +28037,9 @@ window.ArangoUsers = Backbone.Collection.extend({
var target = $("#" + $(e.currentTarget).attr('element')).parent();
$(target).hide('fast', function() {
$(target).remove();
if ($('.outputEditorWrapper').length === 0) {
$('#removeResults').hide();
}
});
},
@ -27921,12 +28071,14 @@ window.ArangoUsers = Backbone.Collection.extend({
this.getCachedQueryAfterRender();
this.fillSelectBoxes();
this.makeResizeable();
this.initQueryImport();
//set height of editor wrapper
$('.inputEditorWrapper').height($(window).height() / 10 * 3);
window.setTimeout(function() {
self.resize();
}, 10);
self.deselect(self.aqlEditor);
},
resize: function() {
@ -27984,6 +28136,24 @@ window.ArangoUsers = Backbone.Collection.extend({
this.$(this.myQueriesId).html(this.table.render({content: this.myQueriesTableDesc}));
},
checkType: function(val) {
var type = "stringtype";
try {
val = JSON.parse(val);
if (val instanceof Array) {
type = 'arraytype';
}
else {
type = typeof val + 'type';
}
}
catch(ignore) {
}
return type;
},
updateBindParams: function(e) {
var id, self = this;
@ -27992,6 +28162,14 @@ window.ArangoUsers = Backbone.Collection.extend({
id = $(e.currentTarget).attr("name");
//this.bindParamTableObj[id] = $(e.currentTarget).val();
this.bindParamTableObj[id] = arangoHelper.parseInput(e.currentTarget);
var types = [
"arraytype", "objecttype", "booleantype", "numbertype", "stringtype"
];
_.each(types, function(type) {
$(e.currentTarget).removeClass(type);
});
$(e.currentTarget).addClass(self.checkType($(e.currentTarget).val()));
}
else {
_.each($('#arangoBindParamTable input'), function(element) {
@ -28060,7 +28238,15 @@ window.ArangoUsers = Backbone.Collection.extend({
counter ++;
_.each($('#arangoBindParamTable input'), function(element) {
if ($(element).attr('name') === key) {
$(element).val(val);
if (val instanceof Array) {
$(element).val(JSON.stringify(val)).addClass('arraytype');
}
else if (typeof val === 'object') {
$(element).val(JSON.stringify(val)).addClass(typeof val + 'type');
}
else {
$(element).val(val).addClass(typeof val + 'type');
}
}
});
});
@ -28100,6 +28286,7 @@ window.ArangoUsers = Backbone.Collection.extend({
}
self.resize();
});
this.aqlEditor.commands.addCommand({
name: "togglecomment",
bindKey: {win: "Ctrl-Shift-C", linux: "Ctrl-Shift-C", mac: "Command-Shift-C"},
@ -28109,6 +28296,29 @@ window.ArangoUsers = Backbone.Collection.extend({
multiSelectAction: "forEach"
});
this.aqlEditor.commands.addCommand({
name: "executeQuery",
bindKey: {win: "Ctrl-Return", mac: "Command-Return", linux: "Ctrl-Return"},
exec: function() {
self.executeQuery();
}
});
this.aqlEditor.commands.addCommand({
name: "saveQuery",
bindKey: {win: "Ctrl-Shift-S", mac: "Command-Shift-S", linux: "Ctrl-Shift-S"},
exec: function() {
self.addAQL();
}
});
this.aqlEditor.commands.addCommand({
name: "explainQuery",
bindKey: {win: "Ctrl-Shift-E", mac: "Command-Shift-E", linux: "Ctrl-Shift-E"},
exec: function() {
self.explainQuery();
}
});
this.queryPreview = ace.edit("queryPreview");
this.queryPreview.getSession().setMode("ace/mode/aql");
@ -28124,9 +28334,10 @@ window.ArangoUsers = Backbone.Collection.extend({
_.each(this.myQueriesTableDesc.rows, function(k) {
k.thirdRow = '<span class="spanWrapper">' +
'<span id="deleteQuery" title="Delete query"><i class="fa fa-minus-circle"></i></span>' +
'<span id="copyQuery" title="Copy query"><i class="fa fa-copy"></i></span>' +
'<span id="explQuery" title="Explain query"><i class="fa fa-comments"></i></i></span>' +
'<span id="runQuery" title="Run query"><i class="fa fa-play-circle-o"></i></i></span>' +
'<span id="deleteQuery" title="Delete query"><i class="fa fa-minus-circle"></i></span>' +
'</span>';
if (k.hasOwnProperty('parameter')) {
delete k.parameter;
@ -28140,6 +28351,49 @@ window.ArangoUsers = Backbone.Collection.extend({
this.$(this.myQueriesId).html(this.table.render({content: this.myQueriesTableDesc}));
},
listenKey: function (e) {
if (e.keyCode === 13) {
this.saveAQL(e);
}
this.checkSaveName();
},
addAQL: function () {
//update queries first, before showing
this.refreshAQL(true);
//render options
this.createCustomQueryModal();
setTimeout(function () {
$('#new-query-name').focus();
}, 500);
},
createCustomQueryModal: function(){
var buttons = [], tableContent = [];
tableContent.push(
window.modalView.createTextEntry(
'new-query-name',
'Name',
'',
undefined,
undefined,
false,
[
{
rule: Joi.string().required(),
msg: "No query name given."
}
]
)
);
buttons.push(
window.modalView.createSuccessButton('Save', this.saveAQL.bind(this))
);
window.modalView.show('modalTable.ejs', 'Save Query', buttons, tableContent, undefined, undefined,
{'keyup #new-query-name' : this.listenKey.bind(this)});
},
checkSaveName: function() {
var saveName = $('#new-query-name').val();
if ( saveName === "Insert Query"){
@ -28152,11 +28406,12 @@ window.ArangoUsers = Backbone.Collection.extend({
var found = this.customQueries.some(function(query){
return query.name === saveName;
});
if(found){
if (found) {
$('#modalButton1').removeClass('button-success');
$('#modalButton1').addClass('button-warning');
$('#modalButton1').text('Update');
} else {
}
else {
$('#modalButton1').removeClass('button-warning');
$('#modalButton1').addClass('button-success');
$('#modalButton1').text('Save');
@ -28169,9 +28424,8 @@ window.ArangoUsers = Backbone.Collection.extend({
//update queries first, before writing
this.refreshAQL();
var varsEditor = ace.edit("varsEditor"),
saveName = $('#new-query-name').val(),
bindVars = varsEditor.getValue();
var saveName = $('#new-query-name').val(),
bindVars = this.bindParamTableObj;
if ($('#new-query-name').hasClass('invalid-input')) {
return;
@ -28227,8 +28481,6 @@ window.ArangoUsers = Backbone.Collection.extend({
this.collection.fetch({
success: function() {
self.updateLocalQueries();
self.renderSelectboxes();
$('#querySelect').val(saveName);
}
});
}
@ -28257,6 +28509,8 @@ window.ArangoUsers = Backbone.Collection.extend({
sentQueryEditor.getSession().setMode("ace/mode/aql");
outputEditor.getSession().setMode("ace/mode/json");
outputEditor.setReadOnly(true);
outputEditor.setFontSize("13px");
sentQueryEditor.setFontSize("13px");
sentQueryEditor.setReadOnly(true);
this.fillResult(outputEditor, sentQueryEditor, counter);
@ -28313,6 +28567,7 @@ window.ArangoUsers = Backbone.Collection.extend({
}
$.noty.clearQueue();
$.noty.closeAll();
self.handleResult(counter);
},
error: function (data) {
try {
@ -28323,12 +28578,22 @@ window.ArangoUsers = Backbone.Collection.extend({
outputEditor.setValue('ERROR');
arangoHelper.arangoError("Query error", "ERROR");
}
window.progressView.hide();
self.handleResult(counter);
}
});
}
},
handleResult: function(counter) {
window.progressView.hide();
$('#removeResults').show();
//TODO animate not sure
//$('html,body').animate({
// scrollTop: $('#outputEditorWrapper' + counter).offset().top - 120
//}, 500);
},
setEditorAutoHeight: function (editor) {
editor.setOptions({
maxLines: Infinity
@ -28367,6 +28632,7 @@ window.ArangoUsers = Backbone.Collection.extend({
window.clearTimeout(self.checkQueryTimer);
arangoHelper.arangoNotification("Query", "Query canceled.");
window.progressView.hide();
//TODO REMOVE OUTPUT BOX
}
});
};
@ -28429,12 +28695,23 @@ window.ArangoUsers = Backbone.Collection.extend({
try {
var error = JSON.parse(resp.responseText);
if (error.errorMessage) {
arangoHelper.arangoError("Query", error.errorMessage);
if (error.errorMessage.match(/\d+:\d+/g) !== null) {
self.markPositionError(
error.errorMessage.match(/'.*'/g)[0],
error.errorMessage.match(/\d+:\d+/g)[0]
);
arangoHelper.arangoError("Query", error.errorMessage);
}
else {
console.log(resp);
}
self.removeOutputEditor(counter);
}
}
catch (e) {
arangoHelper.arangoError("Query", "Something went wrong.");
self.removeOutputEditor(counter);
console.log(e);
}
window.progressView.hide();
@ -28444,6 +28721,19 @@ window.ArangoUsers = Backbone.Collection.extend({
checkQueryStatus();
},
markPositionError: function(text, pos) {
var row = pos.split(":")[0],
line = pos.split(":")[1];
text = text.substr(1, text.length - 2);
this.aqlEditor.find(text);
window.setTimeout(function() {
$('.ace_start').first().css('background', 'rgba(255, 129, 129, 0.7)');
}, 100);
},
refreshAQL: function() {
var self = this;
@ -28453,6 +28743,7 @@ window.ArangoUsers = Backbone.Collection.extend({
}
else {
self.updateLocalQueries();
self.updateQueryTable();
}
}.bind(self);

View File

@ -2483,6 +2483,57 @@ if (list.length > 0) {
</div>
</div></script><script id="queryView2.ejs" type="text/template"><div class="headerBar">
<a class="arangoHeader">AQL Editor 2</a>
</div>
<div id="queryContent" class="queryContent">
<div class="arangoToolbar arangoToolbarTop">
<div class="pull-left">
<button id="toggleQueries1" class="button-success"><i class="fa fa-star-o"></i>Queries</button>
<button id="toggleQueries2" class="button-success" style="display: none"><i class="fa fa-star"></i>Queries</button>
<button id="saveCurrentQuery" class="button-success"><i class="fa fa-save"></i>Save</button>
</div>
<div class="pull-right">
<div class="styled-select">
<select id="querySize" class="query-size"/>
</div>
</div>
</div>
<div class="inputEditorWrapper">
<div class="aqlEditorWrapper" class="arangoEditor">
<span id="clearQuery" class="aceAction"><i class="fa fa-times-circle"></i></span>
<div id="aqlEditor"></div>
<div id="queryTable" style="display: none"></div>
</div>
<div class="bindParamEditorWrapper" class="arangoEditor">
<div id="bindParamEditor"></div>
<div id="previewWrapper" class="previewWrapper" style="display: none">
<div id="previewBar" class="previewBar">
<span>Preview</span>
</div>
<div id="queryPreview"></div>
</div>
</div>
</div>
<div class="arangoToolbar arangoToolbarBottom">
<div class="pull-right">
<button id="exportQuery" class="button-success query-button" style="display:none">Export Queries</button>
<button id="importQuery" class="button-success query-button" style="display:none">Import Queries</button>
<button id="executeQuery" class="button-success query-button">Execute</button>
<button id="explainQuery" class="button-success query-button">Explain</button>
<button id="removeResults" class="button-close query-button" style="display: none">Remove results</button>
</div>
</div>
</div>
<div id="outputEditors" class="outputEditors">
</div>
<div id="queryImportDialog" class="modal hide fade in" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" style="display: none;">
@ -2519,57 +2570,7 @@ if (list.length > 0) {
<div class="modal-footer">
<button id="confirmQueryImport" class="button-success disabled" style="float:right">Import</button>
<button id="closeQueryModal" class="button-close">Cancel</button>
</div>
</div></script><script id="queryView2.ejs" type="text/template"><div class="headerBar">
<a class="arangoHeader">AQL Editor 2</a>
</div>
<div id="queryContent" class="queryContent">
<div class="arangoToolbar arangoToolbarTop">
<div class="pull-left">
<button id="toggleQueries1" class="button-success"><i class="fa fa-star-o"></i>Queries</button>
<button id="toggleQueries2" class="button-success" style="display: none"><i class="fa fa-star"></i>Queries</button>
<button id="saveCurrentQuery" class="button-success"><i class="fa fa-save"></i>Save</button>
</div>
<div class="pull-right">
<div class="styled-select">
<select id="querySize" class="query-size"/>
</div>
</div>
</div>
<div class="inputEditorWrapper">
<div class="aqlEditorWrapper" class="arangoEditor">
<div id="aqlEditor"></div>
<div id="queryTable" style="display: none"></div>
</div>
<div class="bindParamEditorWrapper" class="arangoEditor">
<div id="bindParamEditor"></div>
<div id="previewWrapper" class="previewWrapper" style="display: none">
<div id="previewBar" class="previewBar">
<span>Preview</span>
</div>
<div id="queryPreview"></div>
</div>
</div>
</div>
<div class="arangoToolbar arangoToolbarBottom">
<div class="pull-right">
<button id="executeQuery" class="button-success query-button">Execute</button>
<button id="explainQuery" class="button-success query-button">Explain</button>
<button id="clearQuery" class="button-close query-button">Clear</button>
</div>
</div>
</div>
<div id="outputEditors" class="outputEditors">
</div></script><script id="queryViewOutput.ejs" type="text/template"><div id="outputEditorWrapper<%= counter %>" class="outputEditorWrapper">
</div></script><script id="queryViewOutput.ejs" type="text/template"><div id="outputEditorWrapper<%= counter %>" class="outputEditorWrapper">
<div class="arangoToolbar arangoToolbarTop">
<div class="pull-left">
<span class="toolbarType"><%=type%></span>
@ -2597,6 +2598,8 @@ if (list.length > 0) {
<% } %>
</div>
</div>
</div>
</div></script><script id="shellView.ejs" type="text/template"><div class="headerBar">
<a class="arangoHeader">JS Shell</a>
</div>

View File

@ -2670,6 +2670,64 @@ if (list.length > 0) {
</div>
</script>
<script id="queryView2.ejs" type="text/template">
<div class="headerBar">
<a class="arangoHeader">AQL Editor 2</a>
</div>
<div id="queryContent" class="queryContent">
<div class="arangoToolbar arangoToolbarTop">
<div class="pull-left">
<button id="toggleQueries1" class="button-success"><i class="fa fa-star-o"></i>Queries</button>
<button id="toggleQueries2" class="button-success" style="display: none"><i class="fa fa-star"></i>Queries</button>
<button id="saveCurrentQuery" class="button-success"><i class="fa fa-save"></i>Save</button>
</div>
<div class="pull-right">
<div class="styled-select">
<select id="querySize" class="query-size"/>
</div>
</div>
</div>
<div class="inputEditorWrapper">
<div class="aqlEditorWrapper" class="arangoEditor">
<span id="clearQuery" class="aceAction"><i class="fa fa-times-circle"></i></span>
<div id="aqlEditor"></div>
<div id="queryTable" style="display: none"></div>
</div>
<div class="bindParamEditorWrapper" class="arangoEditor">
<div id="bindParamEditor"></div>
<div id="previewWrapper" class="previewWrapper" style="display: none">
<div id="previewBar" class="previewBar">
<span>Preview</span>
</div>
<div id="queryPreview"></div>
</div>
</div>
</div>
<div class="arangoToolbar arangoToolbarBottom">
<div class="pull-right">
<button id="exportQuery" class="button-success query-button" style="display:none">Export Queries</button>
<button id="importQuery" class="button-success query-button" style="display:none">Import Queries</button>
<button id="executeQuery" class="button-success query-button">Execute</button>
<button id="explainQuery" class="button-success query-button">Explain</button>
<button id="removeResults" class="button-close query-button" style="display: none">Remove results</button>
</div>
</div>
</div>
<div id="outputEditors" class="outputEditors">
</div>
<div id="queryImportDialog" class="modal hide fade in" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" style="display: none;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
@ -2706,61 +2764,6 @@ if (list.length > 0) {
<button id="closeQueryModal" class="button-close">Cancel</button>
</div>
</div>
</script>
<script id="queryView2.ejs" type="text/template">
<div class="headerBar">
<a class="arangoHeader">AQL Editor 2</a>
</div>
<div id="queryContent" class="queryContent">
<div class="arangoToolbar arangoToolbarTop">
<div class="pull-left">
<button id="toggleQueries1" class="button-success"><i class="fa fa-star-o"></i>Queries</button>
<button id="toggleQueries2" class="button-success" style="display: none"><i class="fa fa-star"></i>Queries</button>
<button id="saveCurrentQuery" class="button-success"><i class="fa fa-save"></i>Save</button>
</div>
<div class="pull-right">
<div class="styled-select">
<select id="querySize" class="query-size"/>
</div>
</div>
</div>
<div class="inputEditorWrapper">
<div class="aqlEditorWrapper" class="arangoEditor">
<div id="aqlEditor"></div>
<div id="queryTable" style="display: none"></div>
</div>
<div class="bindParamEditorWrapper" class="arangoEditor">
<div id="bindParamEditor"></div>
<div id="previewWrapper" class="previewWrapper" style="display: none">
<div id="previewBar" class="previewBar">
<span>Preview</span>
</div>
<div id="queryPreview"></div>
</div>
</div>
</div>
<div class="arangoToolbar arangoToolbarBottom">
<div class="pull-right">
<button id="executeQuery" class="button-success query-button">Execute</button>
<button id="explainQuery" class="button-success query-button">Explain</button>
<button id="clearQuery" class="button-close query-button">Clear</button>
</div>
</div>
</div>
<div id="outputEditors" class="outputEditors">
</div>
</script>
@ -2796,6 +2799,7 @@ if (list.length > 0) {
</div>
</div>
</div>
</script>
<script id="shellView.ejs" type="text/template">

File diff suppressed because one or more lines are too long

View File

@ -5700,7 +5700,6 @@ div.headerBar {
.modal-body .tab-content #appstore {
max-height: 290px; }
.modal-body .errorMessage {
background-color: #fff;
color: #da4f49;
font-size: 9pt;
font-weight: 400;
@ -6088,6 +6087,10 @@ div.headerBar {
.arangoToolbarBottom {
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px; }
.arangoToolbarBottom #executeQuery {
margin-right: 5px; }
.arangoToolbarBottom .button-close:last-child {
margin-right: 10px; }
.dbselection {
float: left;
@ -6791,6 +6794,21 @@ toolbar {
.inputEditorWrapper .aqlEditorWrapper {
background: #eee;
overflow: hidden; }
.inputEditorWrapper .bindParamEditorWrapper .stringtype,
.inputEditorWrapper .aqlEditorWrapper .stringtype {
color: black; }
.inputEditorWrapper .bindParamEditorWrapper .objecttype,
.inputEditorWrapper .aqlEditorWrapper .objecttype {
color: blue; }
.inputEditorWrapper .bindParamEditorWrapper .arraytype,
.inputEditorWrapper .aqlEditorWrapper .arraytype {
color: green; }
.inputEditorWrapper .bindParamEditorWrapper .numbertype,
.inputEditorWrapper .aqlEditorWrapper .numbertype {
color: red; }
.inputEditorWrapper .bindParamEditorWrapper .booleantype,
.inputEditorWrapper .aqlEditorWrapper .booleantype {
color: lightgreen; }
.inputEditorWrapper .bindParamEditorWrapper table,
.inputEditorWrapper .aqlEditorWrapper table {
border-top: 0;
@ -6810,7 +6828,9 @@ toolbar {
.inputEditorWrapper .aqlEditorWrapper table tr.selected .spanWrapper {
background-color: rgba(255, 255, 255, 0.65); }
.inputEditorWrapper .bindParamEditorWrapper table tr.selected .fa-copy,
.inputEditorWrapper .aqlEditorWrapper table tr.selected .fa-copy {
.inputEditorWrapper .bindParamEditorWrapper table tr.selected .fa-comments,
.inputEditorWrapper .aqlEditorWrapper table tr.selected .fa-copy,
.inputEditorWrapper .aqlEditorWrapper table tr.selected .fa-comments {
color: #000; }
.inputEditorWrapper .bindParamEditorWrapper table thead,
.inputEditorWrapper .aqlEditorWrapper table thead {
@ -6823,13 +6843,20 @@ toolbar {
.inputEditorWrapper .bindParamEditorWrapper table td .spanWrapper,
.inputEditorWrapper .aqlEditorWrapper table td .spanWrapper {
border-radius: 3px;
cursor: auto;
float: right; }
.inputEditorWrapper .bindParamEditorWrapper table td .spanWrapper:hover,
.inputEditorWrapper .aqlEditorWrapper table td .spanWrapper:hover {
cursor: auto; }
.inputEditorWrapper .bindParamEditorWrapper table td .spanWrapper .fa,
.inputEditorWrapper .aqlEditorWrapper table td .spanWrapper .fa {
cursor: pointer;
font-size: 18pt;
margin-left: 5px;
margin-right: 5px; }
.inputEditorWrapper .bindParamEditorWrapper table td .spanWrapper .fa-minus-circle,
.inputEditorWrapper .aqlEditorWrapper table td .spanWrapper .fa-minus-circle {
margin-left: 20px; }
.inputEditorWrapper .bindParamEditorWrapper table td .spanWrapper .fa-play-circle-o,
.inputEditorWrapper .aqlEditorWrapper table td .spanWrapper .fa-play-circle-o {
color: #8aa051; }
@ -6851,6 +6878,30 @@ toolbar {
.inputEditorWrapper .aqlEditorWrapper,
.inputEditorWrapper .bindParamEditorWrapper {
height: 100%; }
.inputEditorWrapper .aqlEditorWrapper .selectError,
.inputEditorWrapper .bindParamEditorWrapper .selectError {
background: #da4f49; }
.inputEditorWrapper .aqlEditorWrapper .aceAction,
.inputEditorWrapper .bindParamEditorWrapper .aceAction {
background-color: rgba(0, 0, 0, 0.6);
border-radius: 3px;
color: #fff;
cursor: pointer;
font-size: 13pt;
opacity: .8;
position: absolute;
right: 10px;
text-align: center;
top: 10px;
width: 33px;
z-index: 10; }
.inputEditorWrapper .aqlEditorWrapper .aceAction i,
.inputEditorWrapper .bindParamEditorWrapper .aceAction i {
margin-bottom: 3px; }
.inputEditorWrapper .aqlEditorWrapper .aceAction:hover,
.inputEditorWrapper .bindParamEditorWrapper .aceAction:hover {
cursor: pointer;
opacity: 1; }
.inputEditorWrapper .aqlEditorWrapper .previewWrapper,
.inputEditorWrapper .bindParamEditorWrapper .previewWrapper {
background-color: #fff; }

View File

@ -146,6 +146,12 @@
content: [{
label: "Submit",
letter: "Ctrl + Return"
},{
label: "Explain Query",
letter: "Ctrl + Shift + E"
},{
label: "Save Query",
letter: "Ctrl + Shift + S"
},{
label: "Toggle comments",
letter: "Ctrl + Shift + C"

View File

@ -97,42 +97,5 @@
</div>
<div id="queryImportDialog" class="modal hide fade in" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" style="display: none;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<a class="arangoHeader">Import custom queries</a>
</div>
<div class="modal-body">
<table>
<tbody>
<tr class="tableRow">
<th class="collectionTh">Format:</th>
<th class="collectionTh" colspan="2">
<p>JSON documents embedded into a list:</p>
<p></p>
<p>[{</p>
<p style="margin-left: 10px">"name": "Query Name",</p>
<p style="margin-left: 10px">"value": "Query Definition",</p>
<p style="margin-left: 10px">"parameter": "Query Bind Parameter as Object"</p>
<p>}]</p>
</th>
</tr>
<tr class="tableRow">
<th class="collectionTh">File:</th>
<th class="collectionTh" colspan="2">
<input id="importQueries" name="importQueries" type="file" style="border: 0" />
</th>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button id="confirmQueryImport" class="button-success disabled" style="float:right">Import</button>
<button id="closeQueryModal" class="button-close">Cancel</button>
</div>
</div>
</script>

View File

@ -23,6 +23,7 @@
<div class="inputEditorWrapper">
<div class="aqlEditorWrapper" class="arangoEditor">
<span id="clearQuery" class="aceAction"><i class="fa fa-times-circle"></i></span>
<div id="aqlEditor"></div>
<div id="queryTable" style="display: none"></div>
</div>
@ -39,9 +40,11 @@
<div class="arangoToolbar arangoToolbarBottom">
<div class="pull-right">
<button id="exportQuery" class="button-success query-button" style="display:none">Export Queries</button>
<button id="importQuery" class="button-success query-button" style="display:none">Import Queries</button>
<button id="executeQuery" class="button-success query-button">Execute</button>
<button id="explainQuery" class="button-success query-button">Explain</button>
<button id="clearQuery" class="button-close query-button">Clear</button>
<button id="removeResults" class="button-close query-button" style="display: none">Remove results</button>
</div>
</div>
@ -50,6 +53,43 @@
<div id="outputEditors" class="outputEditors">
</div>
<div id="queryImportDialog" class="modal hide fade in" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" style="display: none;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<a class="arangoHeader">Import custom queries</a>
</div>
<div class="modal-body">
<table>
<tbody>
<tr class="tableRow">
<th class="collectionTh">Format:</th>
<th class="collectionTh" colspan="2">
<p>JSON documents embedded into a list:</p>
<p></p>
<p>[{</p>
<p style="margin-left: 10px">"name": "Query Name",</p>
<p style="margin-left: 10px">"value": "Query Definition",</p>
<p style="margin-left: 10px">"parameter": "Query Bind Parameter as Object"</p>
<p>}]</p>
</th>
</tr>
<tr class="tableRow">
<th class="collectionTh">File:</th>
<th class="collectionTh" colspan="2">
<input id="importQueries" name="importQueries" type="file" style="border: 0" />
</th>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button id="confirmQueryImport" class="button-success disabled" style="float:right">Import</button>
<button id="closeQueryModal" class="button-close">Cancel</button>
</div>
</script>
<script id="queryViewOutput.ejs" type="text/template">
@ -84,4 +124,5 @@
</div>
</div>
</div>
</script>

View File

@ -16,6 +16,8 @@
outputTemplate: templateEngine.createTemplate("queryViewOutput.ejs"),
outputCounter: 0,
allowUpload: false,
customQueries: [],
queries: [],
@ -55,10 +57,19 @@
"click .outputEditorWrapper .fa-close": "closeResult",
"click #toggleQueries1": "toggleQueries",
"click #toggleQueries2": "toggleQueries",
"click #saveCurrentQuery": "addAQL",
"click #exportQuery": "exportCustomQueries",
"click #importQuery": "openImportDialog",
"click #removeResults": "removeResults",
"click #deleteQuery": "selectAndDeleteQueryFromTable",
"click #explQuery": "selectAndExplainQueryFromTable",
"keyup #arangoBindParamTable input": "updateBindParams",
"change #arangoBindParamTable input": "updateBindParams",
"click #arangoMyQueriesTable tr" : "showQueryPreview",
"dblclick #arangoMyQueriesTable tr" : "selectQueryFromTable",
"click #arangoMyQueriesTable #copyQuery" : "selectQueryFromTable",
'click #closeQueryModal': 'closeExportDialog',
'click #confirmQueryImport': 'importCustomQueries',
"click #arangoMyQueriesTable #runQuery" : "selectAndRunQueryFromTable"
},
@ -66,12 +77,78 @@
this.aqlEditor.setValue('');
},
initQueryImport: function () {
var self = this;
self.allowUpload = false;
$('#importQueries').change(function(e) {
self.files = e.target.files || e.dataTransfer.files;
self.file = self.files[0];
self.allowUpload = true;
$('#confirmQueryImport').removeClass('disabled');
});
},
importCustomQueries: function () {
var self = this;
if (this.allowUpload === true) {
var callback = function() {
this.collection.fetch({
success: function() {
self.updateLocalQueries();
self.updateQueryTable();
self.resize();
self.allowUpload = false;
$('#confirmQueryImport').addClass('disabled');
$('#queryImportDialog').modal('hide');
},
error: function(data) {
arangoHelper.arangoError("Custom Queries", data.responseText);
}
});
}.bind(this);
self.collection.saveImportQueries(self.file, callback.bind(this));
}
},
removeResults: function() {
$('.outputEditorWrapper').hide('fast', function() {
$('.outputEditorWrapper').remove();
});
$('#removeResults').hide();
},
getCustomQueryParameterByName: function (qName) {
return this.collection.findWhere({name: qName}).get("parameter");
},
getCustomQueryValueByName: function (qName) {
return this.collection.findWhere({name: qName}).get("value");
if (qName) {
return this.collection.findWhere({name: qName}).get("value");
}
},
openImportDialog: function() {
$('#queryImportDialog').modal('show');
},
closeImportDialog: function() {
$('#queryImportDialog').modal('hide');
},
exportCustomQueries: function () {
var name;
$.ajax("whoAmI?_=" + Date.now()).success(function(data) {
name = data.user;
if (name === null || name === false) {
name = "root";
}
window.open("query/download/" + encodeURIComponent(name));
});
},
toggleQueries: function(e) {
@ -86,7 +163,7 @@
"aqlEditor", "queryTable", "previewWrapper",
"bindParamEditor", "toggleQueries1", "toggleQueries2",
"saveCurrentQuery", "querySize", "executeQuery",
"explainQuery", "clearQuery"
"explainQuery", "clearQuery", "importQuery", "exportQuery"
];
_.each(divs, function(div) {
$("#" + div).toggle();
@ -98,19 +175,64 @@
$('#arangoMyQueriesTable tr').removeClass('selected');
$(e.currentTarget).addClass('selected');
var name = $(e.currentTarget).children().first().text();
var name = this.getQueryNameFromTable(e);
this.queryPreview.setValue(this.getCustomQueryValueByName(name));
this.deselect(this.queryPreview);
},
getQueryNameFromTable: function(e) {
var name;
if ($(e.currentTarget).is('tr')) {
name = $(e.currentTarget).children().first().text();
}
else if ($(e.currentTarget).is('span')) {
name = $(e.currentTarget).parent().parent().prev().text();
}
return name;
},
deleteQueryModal: function(name){
var buttons = [], tableContent = [];
tableContent.push(
window.modalView.createReadOnlyEntry(
undefined,
name,
'Do you want to delete the query?',
undefined,
undefined,
false,
undefined
)
);
buttons.push(
window.modalView.createDeleteButton('Delete', this.deleteAQL.bind(this, name))
);
window.modalView.show(
'modalTable.ejs', 'Delete Query', buttons, tableContent
);
},
selectAndDeleteQueryFromTable: function(e) {
var name = this.getQueryNameFromTable(e);
this.deleteQueryModal(name);
},
selectAndExplainQueryFromTable: function(e) {
this.selectQueryFromTable(e, false);
this.explainQuery();
},
selectAndRunQueryFromTable: function(e) {
this.selectQueryFromTable(e);
this.selectQueryFromTable(e, false);
this.executeQuery();
},
selectQueryFromTable: function(e) {
var name = $(e.currentTarget).parent().parent().prev().text();
this.toggleQueries();
selectQueryFromTable: function(e, toggle) {
var name = this.getQueryNameFromTable(e);
if (toggle === undefined) {
this.toggleQueries();
}
this.aqlEditor.setValue(this.getCustomQueryValueByName(name));
this.fillBindParamTable(this.getCustomQueryParameterByName(name));
@ -118,6 +240,25 @@
this.deselect(this.aqlEditor);
},
deleteAQL: function (name) {
var callbackRemove = function(error) {
if (error) {
arangoHelper.arangoError("Query", "Could not delete query.");
}
else {
this.updateLocalQueries();
this.updateQueryTable();
this.resize();
window.modalView.hide();
}
}.bind(this);
var toDelete = this.collection.findWhere({name: name});
this.collection.remove(toDelete);
this.collection.saveCollectionQueries(callbackRemove);
},
switchAce: function(e) {
var count = $(e.currentTarget).attr('counter');
@ -223,8 +364,8 @@
self.deselect(outputEditor);
$.noty.clearQueue();
$.noty.closeAll();
self.handleResult(counter);
}
window.progressView.hide();
},
error: function (data) {
window.progressView.hide();
@ -235,7 +376,7 @@
catch (e) {
arangoHelper.arangoError("Explain error", "ERROR");
}
window.progressView.hide();
self.handleResult(counter);
this.removeOutputEditor(counter);
}
});
@ -295,6 +436,9 @@
var target = $("#" + $(e.currentTarget).attr('element')).parent();
$(target).hide('fast', function() {
$(target).remove();
if ($('.outputEditorWrapper').length === 0) {
$('#removeResults').hide();
}
});
},
@ -326,12 +470,14 @@
this.getCachedQueryAfterRender();
this.fillSelectBoxes();
this.makeResizeable();
this.initQueryImport();
//set height of editor wrapper
$('.inputEditorWrapper').height($(window).height() / 10 * 3);
window.setTimeout(function() {
self.resize();
}, 10);
self.deselect(self.aqlEditor);
},
resize: function() {
@ -389,6 +535,24 @@
this.$(this.myQueriesId).html(this.table.render({content: this.myQueriesTableDesc}));
},
checkType: function(val) {
var type = "stringtype";
try {
val = JSON.parse(val);
if (val instanceof Array) {
type = 'arraytype';
}
else {
type = typeof val + 'type';
}
}
catch(ignore) {
}
return type;
},
updateBindParams: function(e) {
var id, self = this;
@ -397,6 +561,14 @@
id = $(e.currentTarget).attr("name");
//this.bindParamTableObj[id] = $(e.currentTarget).val();
this.bindParamTableObj[id] = arangoHelper.parseInput(e.currentTarget);
var types = [
"arraytype", "objecttype", "booleantype", "numbertype", "stringtype"
];
_.each(types, function(type) {
$(e.currentTarget).removeClass(type);
});
$(e.currentTarget).addClass(self.checkType($(e.currentTarget).val()));
}
else {
_.each($('#arangoBindParamTable input'), function(element) {
@ -465,7 +637,15 @@
counter ++;
_.each($('#arangoBindParamTable input'), function(element) {
if ($(element).attr('name') === key) {
$(element).val(val);
if (val instanceof Array) {
$(element).val(JSON.stringify(val)).addClass('arraytype');
}
else if (typeof val === 'object') {
$(element).val(JSON.stringify(val)).addClass(typeof val + 'type');
}
else {
$(element).val(val).addClass(typeof val + 'type');
}
}
});
});
@ -505,6 +685,7 @@
}
self.resize();
});
this.aqlEditor.commands.addCommand({
name: "togglecomment",
bindKey: {win: "Ctrl-Shift-C", linux: "Ctrl-Shift-C", mac: "Command-Shift-C"},
@ -514,6 +695,29 @@
multiSelectAction: "forEach"
});
this.aqlEditor.commands.addCommand({
name: "executeQuery",
bindKey: {win: "Ctrl-Return", mac: "Command-Return", linux: "Ctrl-Return"},
exec: function() {
self.executeQuery();
}
});
this.aqlEditor.commands.addCommand({
name: "saveQuery",
bindKey: {win: "Ctrl-Shift-S", mac: "Command-Shift-S", linux: "Ctrl-Shift-S"},
exec: function() {
self.addAQL();
}
});
this.aqlEditor.commands.addCommand({
name: "explainQuery",
bindKey: {win: "Ctrl-Shift-E", mac: "Command-Shift-E", linux: "Ctrl-Shift-E"},
exec: function() {
self.explainQuery();
}
});
this.queryPreview = ace.edit("queryPreview");
this.queryPreview.getSession().setMode("ace/mode/aql");
@ -529,9 +733,10 @@
_.each(this.myQueriesTableDesc.rows, function(k) {
k.thirdRow = '<span class="spanWrapper">' +
'<span id="deleteQuery" title="Delete query"><i class="fa fa-minus-circle"></i></span>' +
'<span id="copyQuery" title="Copy query"><i class="fa fa-copy"></i></span>' +
'<span id="explQuery" title="Explain query"><i class="fa fa-comments"></i></i></span>' +
'<span id="runQuery" title="Run query"><i class="fa fa-play-circle-o"></i></i></span>' +
'<span id="deleteQuery" title="Delete query"><i class="fa fa-minus-circle"></i></span>' +
'</span>';
if (k.hasOwnProperty('parameter')) {
delete k.parameter;
@ -545,6 +750,49 @@
this.$(this.myQueriesId).html(this.table.render({content: this.myQueriesTableDesc}));
},
listenKey: function (e) {
if (e.keyCode === 13) {
this.saveAQL(e);
}
this.checkSaveName();
},
addAQL: function () {
//update queries first, before showing
this.refreshAQL(true);
//render options
this.createCustomQueryModal();
setTimeout(function () {
$('#new-query-name').focus();
}, 500);
},
createCustomQueryModal: function(){
var buttons = [], tableContent = [];
tableContent.push(
window.modalView.createTextEntry(
'new-query-name',
'Name',
'',
undefined,
undefined,
false,
[
{
rule: Joi.string().required(),
msg: "No query name given."
}
]
)
);
buttons.push(
window.modalView.createSuccessButton('Save', this.saveAQL.bind(this))
);
window.modalView.show('modalTable.ejs', 'Save Query', buttons, tableContent, undefined, undefined,
{'keyup #new-query-name' : this.listenKey.bind(this)});
},
checkSaveName: function() {
var saveName = $('#new-query-name').val();
if ( saveName === "Insert Query"){
@ -557,11 +805,12 @@
var found = this.customQueries.some(function(query){
return query.name === saveName;
});
if(found){
if (found) {
$('#modalButton1').removeClass('button-success');
$('#modalButton1').addClass('button-warning');
$('#modalButton1').text('Update');
} else {
}
else {
$('#modalButton1').removeClass('button-warning');
$('#modalButton1').addClass('button-success');
$('#modalButton1').text('Save');
@ -574,9 +823,8 @@
//update queries first, before writing
this.refreshAQL();
var varsEditor = ace.edit("varsEditor"),
saveName = $('#new-query-name').val(),
bindVars = varsEditor.getValue();
var saveName = $('#new-query-name').val(),
bindVars = this.bindParamTableObj;
if ($('#new-query-name').hasClass('invalid-input')) {
return;
@ -632,8 +880,6 @@
this.collection.fetch({
success: function() {
self.updateLocalQueries();
self.renderSelectboxes();
$('#querySelect').val(saveName);
}
});
}
@ -662,6 +908,8 @@
sentQueryEditor.getSession().setMode("ace/mode/aql");
outputEditor.getSession().setMode("ace/mode/json");
outputEditor.setReadOnly(true);
outputEditor.setFontSize("13px");
sentQueryEditor.setFontSize("13px");
sentQueryEditor.setReadOnly(true);
this.fillResult(outputEditor, sentQueryEditor, counter);
@ -718,6 +966,7 @@
}
$.noty.clearQueue();
$.noty.closeAll();
self.handleResult(counter);
},
error: function (data) {
try {
@ -728,12 +977,22 @@
outputEditor.setValue('ERROR');
arangoHelper.arangoError("Query error", "ERROR");
}
window.progressView.hide();
self.handleResult(counter);
}
});
}
},
handleResult: function(counter) {
window.progressView.hide();
$('#removeResults').show();
//TODO animate not sure
//$('html,body').animate({
// scrollTop: $('#outputEditorWrapper' + counter).offset().top - 120
//}, 500);
},
setEditorAutoHeight: function (editor) {
editor.setOptions({
maxLines: Infinity
@ -772,6 +1031,7 @@
window.clearTimeout(self.checkQueryTimer);
arangoHelper.arangoNotification("Query", "Query canceled.");
window.progressView.hide();
//TODO REMOVE OUTPUT BOX
}
});
};
@ -834,12 +1094,23 @@
try {
var error = JSON.parse(resp.responseText);
if (error.errorMessage) {
arangoHelper.arangoError("Query", error.errorMessage);
if (error.errorMessage.match(/\d+:\d+/g) !== null) {
self.markPositionError(
error.errorMessage.match(/'.*'/g)[0],
error.errorMessage.match(/\d+:\d+/g)[0]
);
arangoHelper.arangoError("Query", error.errorMessage);
}
else {
console.log(resp);
}
self.removeOutputEditor(counter);
}
}
catch (e) {
arangoHelper.arangoError("Query", "Something went wrong.");
self.removeOutputEditor(counter);
console.log(e);
}
window.progressView.hide();
@ -849,6 +1120,19 @@
checkQueryStatus();
},
markPositionError: function(text, pos) {
var row = pos.split(":")[0],
line = pos.split(":")[1];
text = text.substr(1, text.length - 2);
this.aqlEditor.find(text);
window.setTimeout(function() {
$('.ace_start').first().css('background', 'rgba(255, 129, 129, 0.7)');
}, 100);
},
refreshAQL: function() {
var self = this;
@ -858,6 +1142,7 @@
}
else {
self.updateLocalQueries();
self.updateQueryTable();
}
}.bind(self);

View File

@ -296,7 +296,6 @@
}
.errorMessage {
background-color: $c-white;
color: $c-negative;
font-size: 9pt;
font-weight: 400;

View File

@ -29,6 +29,26 @@
background: #eee;
overflow: hidden;
.stringtype {
color: black;
}
.objecttype {
color: blue;
}
.arraytype {
color: green;
}
.numbertype {
color: red;
}
.booleantype {
color: lightgreen;
}
table {
border-top: 0;
font: 13px/normal Monaco,Menlo,'Ubuntu Mono',Consolas,source-code-pro,monospace;
@ -51,9 +71,11 @@
background-color: rgba(255, 255, 255, .65);
}
.fa-copy {
.fa-copy,
.fa-comments {
color: $c-black;
}
}
}
@ -68,8 +90,13 @@
.spanWrapper {
border-radius: 3px;
cursor: auto;
float: right;
&:hover {
cursor: auto;
}
.fa {
cursor: pointer;
font-size: 18pt;
@ -77,6 +104,10 @@
margin-right: 5px;
}
.fa-minus-circle {
margin-left: 20px;
}
.fa-play-circle-o {
color: $c-positive;
}
@ -107,6 +138,34 @@
.bindParamEditorWrapper {
height: 100%;
.selectError {
background: $c-negative;
}
.aceAction {
background-color: rgba(0, 0, 0, .6);
border-radius: 3px;
color: $c-white;
cursor: pointer;
font-size: 13pt;
opacity: .8;
position: absolute;
right: 10px;
text-align: center;
top: 10px;
width: 33px;
z-index: 10;
i {
margin-bottom: 3px;
}
&:hover {
cursor: pointer;
opacity: 1;
}
}
.previewWrapper {
background-color: $c-white;

View File

@ -71,4 +71,14 @@
.arangoToolbarBottom {
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
#executeQuery {
margin-right: 5px;
}
.button-close {
&:last-child {
margin-right: 10px;
}
}
}

View File

@ -154,6 +154,8 @@ std::string Version::getV8Version() {
std::string Version::getOpenSSLVersion() {
#ifdef OPENSSL_VERSION_TEXT
return std::string(OPENSSL_VERSION_TEXT);
#elif defined(ARANGODB_OPENSSL_VERSION)
return std::string(ARANGODB_OPENSSL_VERSION);
#else
return std::string("");
#endif