1
0
Fork 0

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

This commit is contained in:
Simran Brucherseifer 2016-08-24 13:39:45 +02:00
commit bafe7fd8b3
17 changed files with 238 additions and 175 deletions

View File

@ -413,3 +413,8 @@
* GITHUB: https://github.com/jacomyal/sigma.js
* License: [MIT License](https://github.com/jacomyal/sigma.js/blob/master/LICENSE.txt)
#### wheelnav.js
* GITHUB: https://github.com/softwaretailoring/wheelnav
* License: [MIT License](https://github.com/softwaretailoring/wheelnav/blob/master/LICENSE)

View File

@ -79,24 +79,37 @@ V8Expression* Executor::generateExpression(AstNode const* node) {
constantValues->ForceSet(TRI_V8_STD_STRING(name), toV8(isolate, it.first));
}
// compile the expression
v8::Handle<v8::Value> func(compileExpression());
TRI_ASSERT(_buffer != nullptr);
// exit early if an error occurred
HandleV8Error(tryCatch, func);
v8::Handle<v8::Script> compiled = v8::Script::Compile(
TRI_V8_STD_STRING((*_buffer)), TRI_V8_ASCII_STRING("--script--"));
// a "simple" expression here is any expression that will only return
// non-cyclic
// data and will not return any special JavaScript types such as Date, RegExp
// or
// Function
// as we know that all built-in AQL functions are simple but do not know
// anything
// about user-defined functions, so we expect them to be non-simple
bool const isSimple = (!node->callsUserDefinedFunction());
if (! compiled.IsEmpty()) {
v8::Handle<v8::Value> func(compiled->Run());
return new V8Expression(isolate, v8::Handle<v8::Function>::Cast(func),
constantValues, isSimple);
// exit early if an error occurred
HandleV8Error(tryCatch, func, _buffer, false);
// a "simple" expression here is any expression that will only return
// non-cyclic
// data and will not return any special JavaScript types such as Date, RegExp
// or
// Function
// as we know that all built-in AQL functions are simple but do not know
// anything
// about user-defined functions, so we expect them to be non-simple
bool const isSimple = (!node->callsUserDefinedFunction());
return new V8Expression(isolate, v8::Handle<v8::Function>::Cast(func),
constantValues, isSimple);
}
else {
v8::Handle<v8::Value> empty;
HandleV8Error(tryCatch, empty, _buffer, true);
// well we're almost sure we never reach this since the above call should throw:
THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL);
}
}
/// @brief executes an expression directly
@ -114,43 +127,56 @@ int Executor::executeExpression(Query* query, AstNode const* node,
v8::HandleScope scope(isolate);
v8::TryCatch tryCatch;
// compile the expression
v8::Handle<v8::Value> func(compileExpression());
// exit early if an error occurred
HandleV8Error(tryCatch, func);
TRI_ASSERT(_buffer != nullptr);
TRI_ASSERT(query != nullptr);
v8::Handle<v8::Script> compiled = v8::Script::Compile(
TRI_V8_STD_STRING((*_buffer)), TRI_V8_ASCII_STRING("--script--"));
TRI_GET_GLOBALS();
v8::Handle<v8::Value> result;
auto old = v8g->_query;
if (! compiled.IsEmpty()) {
try {
v8g->_query = static_cast<void*>(query);
TRI_ASSERT(v8g->_query != nullptr);
v8::Handle<v8::Value> func(compiled->Run());
// execute the function
v8::Handle<v8::Value> args[] = { v8::Object::New(isolate), v8::Object::New(isolate) };
result = v8::Handle<v8::Function>::Cast(func)
->Call(v8::Object::New(isolate), 2, args);
// exit early if an error occurred
HandleV8Error(tryCatch, func, _buffer, false);
v8g->_query = old;
TRI_ASSERT(query != nullptr);
// exit if execution raised an error
HandleV8Error(tryCatch, result);
} catch (...) {
v8g->_query = old;
throw;
TRI_GET_GLOBALS();
v8::Handle<v8::Value> result;
auto old = v8g->_query;
try {
v8g->_query = static_cast<void*>(query);
TRI_ASSERT(v8g->_query != nullptr);
// execute the function
v8::Handle<v8::Value> args[] = { v8::Object::New(isolate), v8::Object::New(isolate) };
result = v8::Handle<v8::Function>::Cast(func)
->Call(v8::Object::New(isolate), 2, args);
v8g->_query = old;
// exit if execution raised an error
HandleV8Error(tryCatch, result, _buffer, false);
} catch (...) {
v8g->_query = old;
throw;
}
if (result->IsUndefined()) {
// undefined => null
builder.add(VPackValue(VPackValueType::Null));
return TRI_ERROR_NO_ERROR;
}
return TRI_V8ToVPack(isolate, builder, result, false);
}
else {
v8::Handle<v8::Value> empty;
HandleV8Error(tryCatch, empty, _buffer, true);
if (result->IsUndefined()) {
// undefined => null
builder.add(VPackValue(VPackValueType::Null));
return TRI_ERROR_NO_ERROR;
}
return TRI_V8ToVPack(isolate, builder, result, false);
// well we're almost sure we never reach this since the above call should throw:
THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL);
}
}
/// @brief returns a reference to a built-in function
@ -277,7 +303,9 @@ v8::Handle<v8::Value> Executor::toV8(v8::Isolate* isolate,
/// @brief checks if a V8 exception has occurred and throws an appropriate C++
/// exception from it if so
void Executor::HandleV8Error(v8::TryCatch& tryCatch,
v8::Handle<v8::Value>& result) {
v8::Handle<v8::Value>& result,
arangodb::basics::StringBuffer* const buffer,
bool duringCompile) {
ISOLATE;
if (tryCatch.HasCaught()) {
@ -326,6 +354,11 @@ void Executor::HandleV8Error(v8::TryCatch& tryCatch,
// exception is no ArangoError
std::string details(TRI_ObjectToString(tryCatch.Exception()));
if (buffer) {
std::string script(buffer->c_str(), buffer->length());
LOG(ERR) << details << " " << script;
details += "\nSee log for more details";
}
if (*stacktrace && stacktrace.length() > 0) {
details += "\nstacktrace of offending AQL function: ";
details += *stacktrace;
@ -334,35 +367,36 @@ void Executor::HandleV8Error(v8::TryCatch& tryCatch,
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_QUERY_SCRIPT, details);
}
std::string msg("unknown error in scripting");
if (duringCompile) {
msg += " (during compilation)";
}
if (buffer) {
std::string script(buffer->c_str(), buffer->length());
LOG(ERR) << msg << " " << script;
msg += " See log for details";
}
// we can't figure out what kind of error occurred and throw a generic error
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
"unknown error in scripting");
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, msg);
}
if (result.IsEmpty()) {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
"unknown error in scripting");
std::string msg("unknown error in scripting");
if (duringCompile) {
msg += " (during compilation)";
}
if (buffer) {
std::string script(buffer->c_str(), buffer->length());
LOG(ERR) << msg << " " << script;
msg += " See log for details";
}
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, msg);
}
// if we get here, no exception has been raised
}
/// @brief compile a V8 function from the code contained in the buffer
v8::Handle<v8::Value> Executor::compileExpression() {
TRI_ASSERT(_buffer != nullptr);
ISOLATE;
v8::Handle<v8::Script> compiled = v8::Script::Compile(
TRI_V8_STD_STRING((*_buffer)), TRI_V8_ASCII_STRING("--script--"));
if (compiled.IsEmpty()) {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
"unable to compile v8 expression");
}
return compiled->Run();
}
/// @brief generate JavaScript code for an arbitrary expression
void Executor::generateCodeExpression(AstNode const* node) {
// initialize and/or clear the buffer

View File

@ -64,7 +64,7 @@ class Executor {
/// @brief checks if a V8 exception has occurred and throws an appropriate C++
/// exception from it if so
static void HandleV8Error(v8::TryCatch&, v8::Handle<v8::Value>&);
static void HandleV8Error(v8::TryCatch&, v8::Handle<v8::Value>&, arangodb::basics::StringBuffer* const, bool duringCompile);
private:
/// @brief traverse the expression and note all user-defined functions
@ -153,9 +153,6 @@ class Executor {
/// @brief create the string buffer
arangodb::basics::StringBuffer* initializeBuffer();
/// @brief compile a V8 function from the code contained in the buffer
v8::Handle<v8::Value> compileExpression();
private:
/// @brief a string buffer used for operations
arangodb::basics::StringBuffer* _buffer;

View File

@ -135,7 +135,7 @@ AqlValue V8Expression::execute(v8::Isolate* isolate, Query* query,
v8g->_query = old;
Executor::HandleV8Error(tryCatch, result);
Executor::HandleV8Error(tryCatch, result, nullptr, false);
} catch (...) {
v8g->_query = old;
// bubble up exception

File diff suppressed because one or more lines are too long

View File

@ -2739,4 +2739,4 @@ var cutByResolution = function (str) {
</div>
<div id="workMonitorContent" class="innerContent">
</div></script></head><body><nav class="navbar" style="display: none"><div class="primary"><div class="navlogo"><a class="logo big" href="#"><img class="arangodbLogo" src="img/arangodb_logo_big.png"></a><a class="logo small" href="#"><img class="arangodbLogo" src="img/arangodb_logo_small.png"></a><a class="version"><span>VERSION: </span><span id="currentVersion"></span></a></div><div class="statmenu" id="statisticBar"></div><div class="navmenu" id="navigationBar"></div></div></nav><div id="modalPlaceholder"></div><div class="bodyWrapper" style="display: none"><div class="centralRow"><div id="navbar2" class="navbarWrapper secondary"><div class="subnavmenu" id="subNavigationBar"></div></div><div class="resizecontainer contentWrapper"><div id="loadingScreen" class="loadingScreen" style="display: none"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw margin-bottom"></i> <span class="sr-only">Loading...</span></div><div id="content" class="centralContent"></div><footer class="footer"><div id="footerBar"></div></footer></div></div></div><div id="progressPlaceholder" style="display:none"></div><div id="spotlightPlaceholder" style="display:none"></div><div id="graphSettingsContent" style="display: none"></div><div id="offlinePlaceholder" style="display:none"><div class="offline-div"><div class="pure-u"><div class="pure-u-1-4"></div><div class="pure-u-1-2 offline-window"><div class="offline-header"><h3>You have been disconnected from the server</h3></div><div class="offline-body"><p>The connection to the server has been lost. The server may be under heavy load.</p><p>Trying to reconnect in <span id="offlineSeconds">10</span> seconds.</p><p class="animation_state"><span><button class="button-success">Reconnect now</button></span></p></div></div><div class="pure-u-1-4"></div></div></div></div><div class="arangoFrame" style=""><div class="outerDiv"><div class="innerDiv"></div></div></div><script src="libs.js?version=1471438286364"></script><script src="app.js?version=1471438286364"></script></body></html>
</div></script></head><body><nav class="navbar" style="display: none"><div class="primary"><div class="navlogo"><a class="logo big" href="#"><img class="arangodbLogo" src="img/arangodb_logo_big.png"></a><a class="logo small" href="#"><img class="arangodbLogo" src="img/arangodb_logo_small.png"></a><a class="version"><span>VERSION: </span><span id="currentVersion"></span></a></div><div class="statmenu" id="statisticBar"></div><div class="navmenu" id="navigationBar"></div></div></nav><div id="modalPlaceholder"></div><div class="bodyWrapper" style="display: none"><div class="centralRow"><div id="navbar2" class="navbarWrapper secondary"><div class="subnavmenu" id="subNavigationBar"></div></div><div class="resizecontainer contentWrapper"><div id="loadingScreen" class="loadingScreen" style="display: none"><i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw margin-bottom"></i> <span class="sr-only">Loading...</span></div><div id="content" class="centralContent"></div><footer class="footer"><div id="footerBar"></div></footer></div></div></div><div id="progressPlaceholder" style="display:none"></div><div id="spotlightPlaceholder" style="display:none"></div><div id="graphSettingsContent" style="display: none"></div><div id="offlinePlaceholder" style="display:none"><div class="offline-div"><div class="pure-u"><div class="pure-u-1-4"></div><div class="pure-u-1-2 offline-window"><div class="offline-header"><h3>You have been disconnected from the server</h3></div><div class="offline-body"><p>The connection to the server has been lost. The server may be under heavy load.</p><p>Trying to reconnect in <span id="offlineSeconds">10</span> seconds.</p><p class="animation_state"><span><button class="button-success">Reconnect now</button></span></p></div></div><div class="pure-u-1-4"></div></div></div></div><div class="arangoFrame" style=""><div class="outerDiv"><div class="innerDiv"></div></div></div><script src="libs.js?version=1472022235976"></script><script src="app.js?version=1472022235976"></script></body></html>

File diff suppressed because one or more lines are too long

View File

@ -824,15 +824,16 @@
this.waitForInit(this.graphManagement.bind(this));
return;
}
if (!this.graphManagementView) {
this.graphManagementView =
new window.GraphManagementView(
{
collection: new window.GraphCollection(),
collectionCollection: this.arangoCollectionsStore
}
);
if (this.graphManagementView) {
this.graphManagementView.undelegateEvents();
}
this.graphManagementView =
new window.GraphManagementView(
{
collection: new window.GraphCollection(),
collectionCollection: this.arangoCollectionsStore
}
);
this.graphManagementView.render();
},

View File

@ -55,7 +55,6 @@
e.preventDefault();
var name = $(e.currentTarget).parent().parent().attr('id');
name = name.substr(0, name.length - 5);
console.log(name);
window.App.navigate('graph2/' + encodeURIComponent(name), {trigger: true});
},

View File

@ -241,11 +241,21 @@
'change input[type="color"]': 'checkColor',
'change select': 'saveGraphSettings',
'focus #graphSettingsView input': 'lastFocus',
'focus #graphSettingsView select': 'lastFocus'
'focus #graphSettingsView select': 'lastFocus',
'focusout #graphSettingsView input[type="text"]': 'checkinput'
},
lastFocus: function (e) {
this.lastFocussed = e.currentTarget.id;
this.lastFocussedValue = $(e.currentTarget).val();
},
checkinput: function (e) {
if (e.currentTarget.id === this.lastFocussed) {
if (this.lastFocussedValue !== $(e.currentTarget).val()) {
this.saveGraphSettings();
}
}
},
checkEnterKey: function (e) {

View File

@ -102,6 +102,10 @@
sigma.classes.graph.addMethod('getNodeEdgesCount', function (id) {
return this.allNeighborsCount[id];
});
sigma.classes.graph.addMethod('getNodesCount', function () {
return this.nodesArray.length;
});
} catch (ignore) {}
},
@ -503,7 +507,6 @@
addNode: function () {
var self = this;
var x = self.addNodeX / 100;
var y = self.addNodeY / 100;
@ -518,7 +521,7 @@
self.currentGraph.graph.addNode({
id: id,
label: id.split('/')[1] || '',
size: self.graphConfig.nodeSize || Math.random(),
size: self.graphConfig.nodeSize || 15,
color: self.graphConfig.nodeColor || '#2ecc71',
x: x,
y: y
@ -985,7 +988,7 @@
wheel.colors = hotaru;
wheel.multiSelect = false;
wheel.clickModeRotate = false;
wheel.sliceHoverAttr = {stroke: '#fff', 'stroke-width': 2};
wheel.sliceHoverAttr = {stroke: '#fff', 'stroke-width': 4};
wheel.slicePathFunction = slicePath().DonutSlice;
wheel.createWheel([icon.edit, icon.trash, icon.flag, icon.connect, icon.expand]);
@ -1133,8 +1136,8 @@
}
});
$('#nodesCount').text(parseInt($('#nodesCount').text()) + newNodeCounter);
$('#edgesCount').text(parseInt($('#edgesCount').text()) + newEdgeCounter);
$('#nodesCount').text(parseInt($('#nodesCount').text(), 10) + newNodeCounter);
$('#edgesCount').text(parseInt($('#edgesCount').text(), 10) + newEdgeCounter);
// rerender graph
if (newNodeCounter > 0 || newEdgeCounter > 0) {
@ -1507,18 +1510,6 @@
}
};
s.bind('rightClickStage', function (e) {
self.addNodeX = e.data.captor.x;
self.addNodeY = e.data.captor.y;
self.createContextMenu(e);
self.clearMouseCanvas();
});
s.bind('rightClickNode', function (e) {
var nodeId = e.data.node.id;
self.createNodeContextMenu(nodeId, e);
});
s.bind('clickNode', function (e) {
if (self.contextState.createEdge === true) {
// create the edge
@ -1531,6 +1522,12 @@
self.addEdgeModal(foundEdgeDefinitions, self.contextState._from, self.contextState._to);
} else {
if (!self.dragging) {
if (self.contextState.createEdge === true) {
self.newEdgeColor = '#ff0000';
} else {
self.newEdgeColor = '#000000';
}
// halo on active nodes:
if (renderer === 'canvas') {
self.currentGraph.renderers[0].halo({
@ -1548,34 +1545,42 @@
nodes: [e.data.node]
});
}
if (!this.aqlMode) {
self.createNodeContextMenu(e.data.node.id, e);
}
}
}
});
s.bind('clickStage', function () {
self.clearOldContextMenu(true);
self.clearMouseCanvas();
s.renderers[0].halo({
nodes: self.activeNodes
});
s.bind('clickStage', function (e) {
if (e.data.captor.isDragging) {
self.clearOldContextMenu(true);
self.clearMouseCanvas();
} else {
// stage menu
if (!$('#nodeContextMenu').is(':visible')) {
var offset = $('#graph-container').offset();
self.addNodeX = sigma.utils.getX(e) - offset.left / 2;
self.addNodeY = sigma.utils.getY(e) - offset.top / 2;
// self.addNodeX = e.data.captor.x;
// self.addNodeY = e.data.captor.y;
self.createContextMenu(e);
self.clearMouseCanvas();
} else {
// cleanup
self.clearOldContextMenu(true);
self.clearMouseCanvas();
}
// remember halo
s.renderers[0].halo({
nodes: self.activeNodes
});
}
});
}
s.bind('doubleClickStage', function () {
self.activeNodes = [];
s.graph.nodes().forEach(function (n) {
n.color = n.originalColor;
});
s.graph.edges().forEach(function (e) {
e.color = e.originalColor;
});
$('.nodeInfoDiv').remove();
s.refresh();
});
if (renderer === 'canvas') {
// render parallel edges
if (this.graphConfig) {
@ -1584,57 +1589,70 @@
}
}
s.bind('overNode', function (e) {
if (self.contextState.createEdge === true) {
self.newEdgeColor = '#ff0000';
} else {
self.newEdgeColor = '#000000';
}
});
s.bind('clickEdge', function (e) {
showAttributes(e, false);
});
s.bind('doubleClickNode', function (e) {
var nodeId = e.data.node.id;
var toKeep = s.graph.neighbors(nodeId);
toKeep[nodeId] = e.data.node;
s.graph.nodes().forEach(function (n) {
if (toKeep[n.id]) {
n.color = n.originalColor;
} else {
n.color = '#eee';
}
});
s.graph.edges().forEach(function (e) {
if (toKeep[e.source] && toKeep[e.target]) {
e.color = 'rgb(64, 74, 83)';
} else {
e.color = '#eee';
}
});
s.refresh();
});
s.renderers[0].bind('render', function (e) {
s.renderers[0].halo({
nodes: self.activeNodes
});
});
if (!this.aqlMode) {
s.bind('rightClickNode', function (e) {
var unhighlightNodes = function () {
self.nodeHighlighted = false;
if (s.graph.getNodesCount() < 250) {
self.activeNodes = [];
s.graph.nodes().forEach(function (n) {
n.color = n.originalColor;
});
s.graph.edges().forEach(function (e) {
e.color = e.originalColor;
});
s.refresh({ skipIndexation: true });
}
};
s.bind('rightClickStage', function (e) {
unhighlightNodes();
self.nodeHighlighted = 'undefinedid';
});
s.bind('rightClickNode', function (e) {
if (self.nodeHighlighted !== e.data.node.id) {
var nodeId = e.data.node.id;
self.createNodeContextMenu(nodeId, e);
});
}
var toKeep = s.graph.neighbors(nodeId);
toKeep[nodeId] = e.data.node;
s.graph.nodes().forEach(function (n) {
if (toKeep[n.id]) {
n.color = n.originalColor;
} else {
n.color = '#eee';
}
});
s.graph.edges().forEach(function (e) {
if (toKeep[e.source] && toKeep[e.target]) {
e.color = 'rgb(64, 74, 83)';
} else {
e.color = '#eee';
}
});
self.nodeHighlighted = true;
s.refresh({ skipIndexation: true });
} else {
unhighlightNodes();
}
});
if (this.graphConfig) {
if (this.graphConfig.edgeEditable) {
s.bind('rightClickEdge', function (e) {
s.bind('clickEdge', function (e) {
var edgeId = e.data.edge.id;
self.createEdgeContextMenu(edgeId, e);
});
@ -1792,7 +1810,7 @@
// clear selected nodes state
this.selectedNodes = {};
this.activeNodes = [];
this.currentGraph.refresh();
this.currentGraph.refresh({ skipIndexation: true });
} else {
$('#selectNodes').addClass('activated');
this.graphLasso.activate();

View File

@ -549,7 +549,6 @@
// get cached query if available
var queryObject = this.getCachedQuery();
var self = this;
console.log(queryObject);
if (queryObject !== null && queryObject !== undefined && queryObject !== '') {
this.aqlEditor.setValue(queryObject.query, 1);
@ -1584,7 +1583,7 @@
window.progressView.hide();
var result = self.analyseQuery(data.result);
console.log('Using ' + result.defaultType + ' as data format.');
// console.log('Using ' + result.defaultType + ' as data format.');
if (result.defaultType === 'table') {
$('#outputEditorWrapper' + counter + ' .arangoToolbarTop').after(
'<div id="outputTable' + counter + '" class="outputTable"></div>'

View File

@ -86,7 +86,7 @@
#wheelnav-nodeContextMenu-slice-3,
#wheelnav-nodeContextMenu-slice-4,
#wheelnav-nodeContextMenu-slice-5 {
opacity: .8;
opacity: 1;
}
#wheelnav-nodeContextMenu-title-0,