mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'spdvpk' of github.com:arangodb/arangodb into spdvpk
This commit is contained in:
commit
687bc3c19b
|
@ -32,6 +32,14 @@ js-*.h
|
||||||
3rdParty/libev/ARCH.x64/
|
3rdParty/libev/ARCH.x64/
|
||||||
3rdParty/libev/ARCH.ia32/
|
3rdParty/libev/ARCH.ia32/
|
||||||
3rdParty/zlib-1.2.7/
|
3rdParty/zlib-1.2.7/
|
||||||
|
3rdParty/libev/.libs/
|
||||||
|
3rdParty/libev/config.h
|
||||||
|
3rdParty/libev/ev.lo
|
||||||
|
3rdParty/libev/event.lo
|
||||||
|
3rdParty/libev/libev.la
|
||||||
|
3rdParty/libev/libtool
|
||||||
|
3rdParty/libev/stamp-h1
|
||||||
|
3rdParty/libev/BUILD/
|
||||||
|
|
||||||
build/
|
build/
|
||||||
Build64/
|
Build64/
|
||||||
|
|
|
@ -545,18 +545,27 @@ OperationResult Transaction::documentCoordinator(std::string const& collectionNa
|
||||||
responseCode, resultHeaders, resultBody);
|
responseCode, resultHeaders, resultBody);
|
||||||
|
|
||||||
if (res == TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
VPackParser parser;
|
if (responseCode == arangodb::rest::HttpResponse::OK ||
|
||||||
try {
|
responseCode == arangodb::rest::HttpResponse::PRECONDITION_FAILED) {
|
||||||
parser.parse(resultBody);
|
VPackParser parser;
|
||||||
auto bui = parser.steal();
|
try {
|
||||||
auto buf = bui->steal();
|
parser.parse(resultBody);
|
||||||
return OperationResult(buf, nullptr, "", TRI_ERROR_NO_ERROR,
|
auto bui = parser.steal();
|
||||||
TRI_ERROR_NO_ERROR);
|
auto buf = bui->steal();
|
||||||
}
|
return OperationResult(buf, nullptr, "",
|
||||||
catch (VPackException& e) {
|
responseCode == arangodb::rest::HttpResponse::OK ?
|
||||||
std::string message = "JSON from DBserver not parseable: "
|
TRI_ERROR_NO_ERROR : TRI_ERROR_ARANGO_CONFLICT,
|
||||||
+ resultBody + ":" + e.what();
|
TRI_ERROR_NO_ERROR);
|
||||||
return OperationResult(TRI_ERROR_INTERNAL, message);
|
}
|
||||||
|
catch (VPackException& e) {
|
||||||
|
std::string message = "JSON from DBserver not parseable: "
|
||||||
|
+ resultBody + ":" + e.what();
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL, message);
|
||||||
|
}
|
||||||
|
} else if (responseCode == arangodb::rest::HttpResponse::NOT_FOUND) {
|
||||||
|
return OperationResult(TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND);
|
||||||
|
} else {
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OperationResult(res);
|
return OperationResult(res);
|
||||||
|
@ -664,18 +673,30 @@ OperationResult Transaction::insertCoordinator(std::string const& collectionName
|
||||||
value, headers, responseCode, resultHeaders, resultBody);
|
value, headers, responseCode, resultHeaders, resultBody);
|
||||||
|
|
||||||
if (res == TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
VPackParser parser;
|
if (responseCode == arangodb::rest::HttpResponse::ACCEPTED ||
|
||||||
try {
|
responseCode == arangodb::rest::HttpResponse::CREATED) {
|
||||||
parser.parse(resultBody);
|
VPackParser parser;
|
||||||
auto bui = parser.steal();
|
try {
|
||||||
auto buf = bui->steal();
|
parser.parse(resultBody);
|
||||||
return OperationResult(buf, nullptr, "", TRI_ERROR_NO_ERROR,
|
auto bui = parser.steal();
|
||||||
responseCode == arangodb::rest::HttpResponse::CREATED);
|
auto buf = bui->steal();
|
||||||
}
|
return OperationResult(buf, nullptr, "", TRI_ERROR_NO_ERROR,
|
||||||
catch (VPackException& e) {
|
responseCode == arangodb::rest::HttpResponse::CREATED);
|
||||||
std::string message = "JSON from DBserver not parseable: "
|
}
|
||||||
+ resultBody + ":" + e.what();
|
catch (VPackException& e) {
|
||||||
return OperationResult(TRI_ERROR_INTERNAL, message);
|
std::string message = "JSON from DBserver not parseable: "
|
||||||
|
+ resultBody + ":" + e.what();
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL, message);
|
||||||
|
}
|
||||||
|
} else if (responseCode == arangodb::rest::HttpResponse::PRECONDITION_FAILED) {
|
||||||
|
return OperationResult(TRI_ERROR_ARANGO_CONFLICT);
|
||||||
|
} else if (responseCode == arangodb::rest::HttpResponse::BAD) {
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL,
|
||||||
|
"JSON sent to DBserver was bad");
|
||||||
|
} else if (responseCode == arangodb::rest::HttpResponse::NOT_FOUND) {
|
||||||
|
return OperationResult(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);
|
||||||
|
} else {
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OperationResult(res);
|
return OperationResult(res);
|
||||||
|
@ -805,8 +826,52 @@ OperationResult Transaction::updateCoordinator(std::string const& collectionName
|
||||||
VPackSlice const& oldValue,
|
VPackSlice const& oldValue,
|
||||||
VPackSlice const& newValue,
|
VPackSlice const& newValue,
|
||||||
OperationOptions& options) {
|
OperationOptions& options) {
|
||||||
// TODO
|
auto headers = std::make_unique<std::map<std::string, std::string>>();
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
|
arangodb::rest::HttpResponse::HttpResponseCode responseCode;
|
||||||
|
std::map<std::string, std::string> resultHeaders;
|
||||||
|
std::string resultBody;
|
||||||
|
|
||||||
|
std::string key(Transaction::extractKey(&oldValue));
|
||||||
|
if (key.empty()) {
|
||||||
|
return OperationResult(TRI_ERROR_ARANGO_DOCUMENT_KEY_BAD);
|
||||||
|
}
|
||||||
|
TRI_voc_rid_t expectedRevision = Transaction::extractRevisionId(&oldValue);
|
||||||
|
|
||||||
|
int res = arangodb::modifyDocumentOnCoordinator(
|
||||||
|
_vocbase->_name, collectionName, key, expectedRevision,
|
||||||
|
TRI_DOC_UPDATE_ERROR, options.waitForSync, true /* isPatch */,
|
||||||
|
options.keepNull, options.mergeObjects, newValue,
|
||||||
|
headers, responseCode, resultHeaders, resultBody);
|
||||||
|
|
||||||
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
|
if (responseCode == arangodb::rest::HttpResponse::ACCEPTED ||
|
||||||
|
responseCode == arangodb::rest::HttpResponse::CREATED ||
|
||||||
|
responseCode == arangodb::rest::HttpResponse::PRECONDITION_FAILED) {
|
||||||
|
VPackParser parser;
|
||||||
|
try {
|
||||||
|
parser.parse(resultBody);
|
||||||
|
auto bui = parser.steal();
|
||||||
|
auto buf = bui->steal();
|
||||||
|
return OperationResult(buf, nullptr, "",
|
||||||
|
responseCode == arangodb::rest::HttpResponse::PRECONDITION_FAILED ?
|
||||||
|
TRI_ERROR_ARANGO_CONFLICT : TRI_ERROR_NO_ERROR,
|
||||||
|
responseCode == arangodb::rest::HttpResponse::CREATED);
|
||||||
|
}
|
||||||
|
catch (VPackException& e) {
|
||||||
|
std::string message = "JSON from DBserver not parseable: "
|
||||||
|
+ resultBody + ":" + e.what();
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL, message);
|
||||||
|
}
|
||||||
|
} else if (responseCode == arangodb::rest::HttpResponse::BAD) {
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL,
|
||||||
|
"JSON sent to DBserver was bad");
|
||||||
|
} else if (responseCode == arangodb::rest::HttpResponse::NOT_FOUND) {
|
||||||
|
return OperationResult(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);
|
||||||
|
} else {
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return OperationResult(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -873,7 +938,17 @@ OperationResult Transaction::updateLocal(std::string const& collectionName,
|
||||||
|
|
||||||
res = document->update(this, &oldValue, &sanitized, &mptr, &policy, options, !isLocked(document, TRI_TRANSACTION_WRITE));
|
res = document->update(this, &oldValue, &sanitized, &mptr, &policy, options, !isLocked(document, TRI_TRANSACTION_WRITE));
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_ARANGO_CONFLICT) {
|
||||||
|
// still return
|
||||||
|
VPackBuilder resultBuilder;
|
||||||
|
buildDocumentIdentity(resultBuilder, cid,
|
||||||
|
oldValue.get("_key").copyString(),
|
||||||
|
mptr._rid, "");
|
||||||
|
|
||||||
|
return OperationResult(resultBuilder.steal(), nullptr, "",
|
||||||
|
TRI_ERROR_ARANGO_CONFLICT,
|
||||||
|
options.waitForSync || document->_info.waitForSync());
|
||||||
|
} else if (res != TRI_ERROR_NO_ERROR) {
|
||||||
return OperationResult(res);
|
return OperationResult(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -956,17 +1031,31 @@ OperationResult Transaction::replaceCoordinator(std::string const& collectionNam
|
||||||
headers, responseCode, resultHeaders, resultBody);
|
headers, responseCode, resultHeaders, resultBody);
|
||||||
|
|
||||||
if (res == TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
VPackParser parser;
|
if (responseCode == arangodb::rest::HttpResponse::ACCEPTED ||
|
||||||
try {
|
responseCode == arangodb::rest::HttpResponse::CREATED ||
|
||||||
parser.parse(resultBody);
|
responseCode == arangodb::rest::HttpResponse::PRECONDITION_FAILED) {
|
||||||
auto bui = parser.steal();
|
VPackParser parser;
|
||||||
auto buf = bui->steal();
|
try {
|
||||||
return OperationResult(buf, nullptr, "", TRI_ERROR_NO_ERROR, true);
|
parser.parse(resultBody);
|
||||||
}
|
auto bui = parser.steal();
|
||||||
catch (VPackException& e) {
|
auto buf = bui->steal();
|
||||||
std::string message = "JSON from DBserver not parseable: "
|
return OperationResult(buf, nullptr, "",
|
||||||
+ resultBody + ":" + e.what();
|
responseCode == arangodb::rest::HttpResponse::PRECONDITION_FAILED ?
|
||||||
return OperationResult(TRI_ERROR_INTERNAL, message);
|
TRI_ERROR_ARANGO_CONFLICT : TRI_ERROR_NO_ERROR,
|
||||||
|
responseCode == arangodb::rest::HttpResponse::CREATED);
|
||||||
|
}
|
||||||
|
catch (VPackException& e) {
|
||||||
|
std::string message = "JSON from DBserver not parseable: "
|
||||||
|
+ resultBody + ":" + e.what();
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL, message);
|
||||||
|
}
|
||||||
|
} else if (responseCode == arangodb::rest::HttpResponse::BAD) {
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL,
|
||||||
|
"JSON sent to DBserver was bad");
|
||||||
|
} else if (responseCode == arangodb::rest::HttpResponse::NOT_FOUND) {
|
||||||
|
return OperationResult(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);
|
||||||
|
} else {
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OperationResult(res);
|
return OperationResult(res);
|
||||||
|
@ -1036,7 +1125,17 @@ OperationResult Transaction::replaceLocal(std::string const& collectionName,
|
||||||
|
|
||||||
res = document->replace(this, &oldValue, &sanitized, &mptr, &policy, options, !isLocked(document, TRI_TRANSACTION_WRITE));
|
res = document->replace(this, &oldValue, &sanitized, &mptr, &policy, options, !isLocked(document, TRI_TRANSACTION_WRITE));
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_ARANGO_CONFLICT) {
|
||||||
|
// still return
|
||||||
|
VPackBuilder resultBuilder;
|
||||||
|
buildDocumentIdentity(resultBuilder, cid,
|
||||||
|
oldValue.get("_key").copyString(),
|
||||||
|
mptr._rid, "");
|
||||||
|
|
||||||
|
return OperationResult(resultBuilder.steal(), nullptr, "",
|
||||||
|
TRI_ERROR_ARANGO_CONFLICT,
|
||||||
|
options.waitForSync || document->_info.waitForSync());
|
||||||
|
} else if (res != TRI_ERROR_NO_ERROR) {
|
||||||
return OperationResult(res);
|
return OperationResult(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,8 +1193,48 @@ OperationResult Transaction::remove(std::string const& collectionName,
|
||||||
OperationResult Transaction::removeCoordinator(std::string const& collectionName,
|
OperationResult Transaction::removeCoordinator(std::string const& collectionName,
|
||||||
VPackSlice const& value,
|
VPackSlice const& value,
|
||||||
OperationOptions& options) {
|
OperationOptions& options) {
|
||||||
// TODO
|
auto headers = std::make_unique<std::map<std::string, std::string>>();
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
|
arangodb::rest::HttpResponse::HttpResponseCode responseCode;
|
||||||
|
std::map<std::string, std::string> resultHeaders;
|
||||||
|
std::string resultBody;
|
||||||
|
|
||||||
|
std::string key(Transaction::extractKey(&value));
|
||||||
|
if (key.empty()) {
|
||||||
|
return OperationResult(TRI_ERROR_ARANGO_DOCUMENT_KEY_BAD);
|
||||||
|
}
|
||||||
|
TRI_voc_rid_t expectedRevision = Transaction::extractRevisionId(&value);
|
||||||
|
|
||||||
|
int res = arangodb::deleteDocumentOnCoordinator(
|
||||||
|
_vocbase->_name, collectionName, key, expectedRevision,
|
||||||
|
TRI_DOC_UPDATE_ERROR, options.waitForSync,
|
||||||
|
headers, responseCode, resultHeaders, resultBody);
|
||||||
|
|
||||||
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
|
if (responseCode == arangodb::rest::HttpResponse::OK ||
|
||||||
|
responseCode == arangodb::rest::HttpResponse::ACCEPTED ||
|
||||||
|
responseCode == arangodb::rest::HttpResponse::PRECONDITION_FAILED) {
|
||||||
|
VPackParser parser;
|
||||||
|
try {
|
||||||
|
parser.parse(resultBody);
|
||||||
|
auto bui = parser.steal();
|
||||||
|
auto buf = bui->steal();
|
||||||
|
return OperationResult(buf, nullptr, "", TRI_ERROR_NO_ERROR, true);
|
||||||
|
}
|
||||||
|
catch (VPackException& e) {
|
||||||
|
std::string message = "JSON from DBserver not parseable: "
|
||||||
|
+ resultBody + ":" + e.what();
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL, message);
|
||||||
|
}
|
||||||
|
} else if (responseCode == arangodb::rest::HttpResponse::BAD) {
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL,
|
||||||
|
"JSON sent to DBserver was bad");
|
||||||
|
} else if (responseCode == arangodb::rest::HttpResponse::NOT_FOUND) {
|
||||||
|
return OperationResult(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);
|
||||||
|
} else {
|
||||||
|
return OperationResult(TRI_ERROR_INTERNAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return OperationResult(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1178,8 +1317,9 @@ OperationResult Transaction::truncate(std::string const& collectionName,
|
||||||
|
|
||||||
OperationResult Transaction::truncateCoordinator(std::string const& collectionName,
|
OperationResult Transaction::truncateCoordinator(std::string const& collectionName,
|
||||||
OperationOptions& options) {
|
OperationOptions& options) {
|
||||||
// TODO
|
return OperationResult(
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
|
arangodb::truncateCollectionOnCoordinator(_vocbase->_name,
|
||||||
|
collectionName));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -445,7 +445,6 @@ void ApplicationV8::exitContext(V8Context* context) {
|
||||||
TRI_ASSERT(context->_locker->IsLocked(isolate));
|
TRI_ASSERT(context->_locker->IsLocked(isolate));
|
||||||
TRI_ASSERT(v8::Locker::IsLocked(isolate));
|
TRI_ASSERT(v8::Locker::IsLocked(isolate));
|
||||||
|
|
||||||
TRI_vocbase_t* vocbase = nullptr;
|
|
||||||
bool canceled = false;
|
bool canceled = false;
|
||||||
|
|
||||||
// update data for later garbage collection
|
// update data for later garbage collection
|
||||||
|
@ -453,11 +452,11 @@ void ApplicationV8::exitContext(V8Context* context) {
|
||||||
TRI_GET_GLOBALS();
|
TRI_GET_GLOBALS();
|
||||||
context->_hasActiveExternals = v8g->hasActiveExternals();
|
context->_hasActiveExternals = v8g->hasActiveExternals();
|
||||||
++context->_numExecutions;
|
++context->_numExecutions;
|
||||||
vocbase = v8g->_vocbase;
|
TRI_vocbase_t* vocbase = v8g->_vocbase;
|
||||||
|
|
||||||
TRI_ASSERT(vocbase != nullptr);
|
TRI_ASSERT(vocbase != nullptr);
|
||||||
// release last recently used vocbase
|
// release last recently used vocbase
|
||||||
TRI_ReleaseVocBase(static_cast<TRI_vocbase_t*>(v8g->_vocbase));
|
TRI_ReleaseVocBase(vocbase);
|
||||||
|
|
||||||
// check for cancelation requests
|
// check for cancelation requests
|
||||||
canceled = v8g->_canceled;
|
canceled = v8g->_canceled;
|
||||||
|
|
|
@ -5256,7 +5256,7 @@ int TRI_document_collection_t::update(Transaction* trx, VPackSlice const* slice,
|
||||||
TRI_ASSERT(mptr != nullptr);
|
TRI_ASSERT(mptr != nullptr);
|
||||||
mptr->setDataPtr(nullptr);
|
mptr->setDataPtr(nullptr);
|
||||||
|
|
||||||
TRI_voc_rid_t revisionId = Transaction::extractRevisionId(slice);
|
TRI_voc_rid_t revisionId = Transaction::extractRevisionId(newSlice);
|
||||||
|
|
||||||
TRI_voc_tick_t markerTick = 0;
|
TRI_voc_tick_t markerTick = 0;
|
||||||
int res;
|
int res;
|
||||||
|
@ -5330,7 +5330,7 @@ int TRI_document_collection_t::replace(Transaction* trx, VPackSlice const* slice
|
||||||
TRI_ASSERT(mptr != nullptr);
|
TRI_ASSERT(mptr != nullptr);
|
||||||
mptr->setDataPtr(nullptr);
|
mptr->setDataPtr(nullptr);
|
||||||
|
|
||||||
TRI_voc_rid_t revisionId = Transaction::extractRevisionId(slice);
|
TRI_voc_rid_t revisionId = Transaction::extractRevisionId(newSlice);
|
||||||
|
|
||||||
TRI_voc_tick_t markerTick = 0;
|
TRI_voc_tick_t markerTick = 0;
|
||||||
int res;
|
int res;
|
||||||
|
|
|
@ -437,28 +437,6 @@
|
||||||
|
|
||||||
isSystemCollection: function (val) {
|
isSystemCollection: function (val) {
|
||||||
return val.name.substr(0, 1) === '_';
|
return val.name.substr(0, 1) === '_';
|
||||||
// the below code is completely inappropriate as it will
|
|
||||||
// load the collection just for the check whether it
|
|
||||||
// is a system collection. as a consequence, the below
|
|
||||||
// code would load ALL collections when the web interface
|
|
||||||
// is called
|
|
||||||
/*
|
|
||||||
var returnVal = false;
|
|
||||||
$.ajax({
|
|
||||||
type: "GET",
|
|
||||||
url: "/_api/collection/" + encodeURIComponent(val) + "/properties",
|
|
||||||
contentType: "application/json",
|
|
||||||
processData: false,
|
|
||||||
async: false,
|
|
||||||
success: function(data) {
|
|
||||||
returnVal = data.isSystem;
|
|
||||||
},
|
|
||||||
error: function(data) {
|
|
||||||
returnVal = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return returnVal;
|
|
||||||
*/
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setDocumentStore : function (a) {
|
setDocumentStore : function (a) {
|
||||||
|
|
Binary file not shown.
|
@ -10787,28 +10787,6 @@ function GraphViewer(svg, width, height, adapterConfig, config) {
|
||||||
|
|
||||||
isSystemCollection: function (val) {
|
isSystemCollection: function (val) {
|
||||||
return val.name.substr(0, 1) === '_';
|
return val.name.substr(0, 1) === '_';
|
||||||
// the below code is completely inappropriate as it will
|
|
||||||
// load the collection just for the check whether it
|
|
||||||
// is a system collection. as a consequence, the below
|
|
||||||
// code would load ALL collections when the web interface
|
|
||||||
// is called
|
|
||||||
/*
|
|
||||||
var returnVal = false;
|
|
||||||
$.ajax({
|
|
||||||
type: "GET",
|
|
||||||
url: "/_api/collection/" + encodeURIComponent(val) + "/properties",
|
|
||||||
contentType: "application/json",
|
|
||||||
processData: false,
|
|
||||||
async: false,
|
|
||||||
success: function(data) {
|
|
||||||
returnVal = data.isSystem;
|
|
||||||
},
|
|
||||||
error: function(data) {
|
|
||||||
returnVal = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return returnVal;
|
|
||||||
*/
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setDocumentStore : function (a) {
|
setDocumentStore : function (a) {
|
||||||
|
@ -17347,7 +17325,7 @@ window.Users = Backbone.Model.extend({
|
||||||
case 3:
|
case 3:
|
||||||
return 'loaded';
|
return 'loaded';
|
||||||
case 4:
|
case 4:
|
||||||
return 'will be unloaded';
|
return 'in the process of being unloaded';
|
||||||
case 5:
|
case 5:
|
||||||
return 'deleted';
|
return 'deleted';
|
||||||
case 6:
|
case 6:
|
||||||
|
@ -20364,6 +20342,9 @@ window.ArangoUsers = Backbone.Collection.extend({
|
||||||
$('#collection_' + model.get("name") + ' .corneredBadge').removeClass('inProgress');
|
$('#collection_' + model.get("name") + ' .corneredBadge').removeClass('inProgress');
|
||||||
$('#collection_' + model.get("name") + ' .corneredBadge').addClass('loaded');
|
$('#collection_' + model.get("name") + ' .corneredBadge').addClass('loaded');
|
||||||
}
|
}
|
||||||
|
if (model.get('status') === 'unloaded') {
|
||||||
|
$('#collection_' + model.get("name") + ' .icon_arangodb_info').addClass('disabled');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22283,40 +22264,67 @@ window.ArangoUsers = Backbone.Collection.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
saveDocument: function () {
|
saveDocument: function () {
|
||||||
|
if ($('#saveDocumentButton').attr('disabled') === undefined) {
|
||||||
|
if (this.collection.first().attributes._id.substr(0, 1) === '_') {
|
||||||
|
|
||||||
|
var buttons = [], tableContent = [];
|
||||||
|
tableContent.push(
|
||||||
|
window.modalView.createReadOnlyEntry(
|
||||||
|
'doc-save-system-button',
|
||||||
|
'Caution',
|
||||||
|
'You are modifying a system collection. Really continue?',
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
false,
|
||||||
|
/[<>&'"]/
|
||||||
|
)
|
||||||
|
);
|
||||||
|
buttons.push(
|
||||||
|
window.modalView.createSuccessButton('Save', this.confirmSaveDocument.bind(this))
|
||||||
|
);
|
||||||
|
window.modalView.show('modalTable.ejs', 'Modify System Collection', buttons, tableContent);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.confirmSaveDocument();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
confirmSaveDocument: function () {
|
||||||
|
|
||||||
|
window.modalView.hide();
|
||||||
|
|
||||||
var model, result;
|
var model, result;
|
||||||
|
|
||||||
if ($('#saveDocumentButton').attr('disabled') === undefined) {
|
try {
|
||||||
|
model = this.editor.get();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
this.errorConfirmation(e);
|
||||||
|
this.disableSaveButton();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
model = JSON.stringify(model);
|
||||||
model = this.editor.get();
|
|
||||||
}
|
if (this.type === 'document') {
|
||||||
catch (e) {
|
result = this.collection.saveDocument(this.colid, this.docid, model);
|
||||||
this.errorConfirmation(e);
|
if (result === false) {
|
||||||
this.disableSaveButton();
|
arangoHelper.arangoError('Document error:','Could not save');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
model = JSON.stringify(model);
|
else if (this.type === 'edge') {
|
||||||
|
result = this.collection.saveEdge(this.colid, this.docid, model);
|
||||||
if (this.type === 'document') {
|
if (result === false) {
|
||||||
result = this.collection.saveDocument(this.colid, this.docid, model);
|
arangoHelper.arangoError('Edge error:', 'Could not save');
|
||||||
if (result === false) {
|
return;
|
||||||
arangoHelper.arangoError('Document error:','Could not save');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (this.type === 'edge') {
|
|
||||||
result = this.collection.saveEdge(this.colid, this.docid, model);
|
|
||||||
if (result === false) {
|
|
||||||
arangoHelper.arangoError('Edge error:', 'Could not save');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
this.successConfirmation();
|
this.successConfirmation();
|
||||||
this.disableSaveButton();
|
this.disableSaveButton();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -25866,11 +25874,29 @@ window.ArangoUsers = Backbone.Collection.extend({
|
||||||
templateSlow: templateEngine.createTemplate("queryManagementViewSlow.ejs"),
|
templateSlow: templateEngine.createTemplate("queryManagementViewSlow.ejs"),
|
||||||
table: templateEngine.createTemplate("arangoTable.ejs"),
|
table: templateEngine.createTemplate("arangoTable.ejs"),
|
||||||
tabbar: templateEngine.createTemplate("arangoTabbar.ejs"),
|
tabbar: templateEngine.createTemplate("arangoTabbar.ejs"),
|
||||||
|
active: true,
|
||||||
|
shouldRender: true,
|
||||||
|
timer: 0,
|
||||||
|
refreshRate: 2000,
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
|
var self = this;
|
||||||
this.activeCollection = new window.QueryManagementActive();
|
this.activeCollection = new window.QueryManagementActive();
|
||||||
this.slowCollection = new window.QueryManagementSlow();
|
this.slowCollection = new window.QueryManagementSlow();
|
||||||
this.convertModelToJSON(true);
|
this.convertModelToJSON(true);
|
||||||
|
|
||||||
|
window.setInterval(function() {
|
||||||
|
if (window.location.hash === '#queryManagement' && window.VISIBLE && self.shouldRender) {
|
||||||
|
if (self.active) {
|
||||||
|
self.convertModelToJSON(true);
|
||||||
|
self.renderActive();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.convertModelToJSON(false);
|
||||||
|
self.renderSlow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, self.refreshRate);
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
|
@ -25896,9 +25922,11 @@ window.ArangoUsers = Backbone.Collection.extend({
|
||||||
|
|
||||||
switchTab: function(e) {
|
switchTab: function(e) {
|
||||||
if (e.currentTarget.id === 'activequeries') {
|
if (e.currentTarget.id === 'activequeries') {
|
||||||
|
this.active = true;
|
||||||
this.convertModelToJSON(true);
|
this.convertModelToJSON(true);
|
||||||
}
|
}
|
||||||
else if (e.currentTarget.id === 'slowqueries') {
|
else if (e.currentTarget.id === 'slowqueries') {
|
||||||
|
this.active = false;
|
||||||
this.convertModelToJSON(false);
|
this.convertModelToJSON(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -25985,11 +26013,25 @@ window.ArangoUsers = Backbone.Collection.extend({
|
||||||
this.convertModelToJSON(true);
|
this.convertModelToJSON(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addEvents: function() {
|
||||||
|
var self = this;
|
||||||
|
$('#queryManagementContent tbody').on('mousedown', function() {
|
||||||
|
clearTimeout(self.timer);
|
||||||
|
self.shouldRender = false;
|
||||||
|
});
|
||||||
|
$('#queryManagementContent tbody').on('mouseup', function() {
|
||||||
|
self.timer = window.setTimeout(function() {
|
||||||
|
self.shouldRender = true;
|
||||||
|
}, 3000);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
renderActive: function() {
|
renderActive: function() {
|
||||||
this.$el.html(this.templateActive.render({}));
|
this.$el.html(this.templateActive.render({}));
|
||||||
$(this.id).html(this.tabbar.render({content: this.tabbarElements}));
|
$(this.id).html(this.tabbar.render({content: this.tabbarElements}));
|
||||||
$(this.id).append(this.table.render({content: this.tableDescription}));
|
$(this.id).append(this.table.render({content: this.tableDescription}));
|
||||||
$('#activequeries').addClass("arango-active-tab");
|
$('#activequeries').addClass("arango-active-tab");
|
||||||
|
this.addEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
renderSlow: function() {
|
renderSlow: function() {
|
||||||
|
@ -25999,6 +26041,7 @@ window.ArangoUsers = Backbone.Collection.extend({
|
||||||
content: this.tableDescription,
|
content: this.tableDescription,
|
||||||
}));
|
}));
|
||||||
$('#slowqueries').addClass("arango-active-tab");
|
$('#slowqueries').addClass("arango-active-tab");
|
||||||
|
this.addEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
convertModelToJSON: function (active) {
|
convertModelToJSON: function (active) {
|
||||||
|
|
Binary file not shown.
|
@ -268,6 +268,10 @@
|
||||||
<div class="corneredBadge <%= model.get('status') %>">
|
<div class="corneredBadge <%= model.get('status') %>">
|
||||||
<%= model.get('status') %>
|
<%= model.get('status') %>
|
||||||
</div>
|
</div>
|
||||||
|
<% } else { %>
|
||||||
|
<div class="corneredBadge inProgress">
|
||||||
|
<%= model.get('status') %>
|
||||||
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
</span>
|
</span>
|
||||||
|
|
Binary file not shown.
|
@ -304,6 +304,10 @@
|
||||||
<div class="corneredBadge <%= model.get('status') %>">
|
<div class="corneredBadge <%= model.get('status') %>">
|
||||||
<%= model.get('status') %>
|
<%= model.get('status') %>
|
||||||
</div>
|
</div>
|
||||||
|
<% } else { %>
|
||||||
|
<div class="corneredBadge inProgress">
|
||||||
|
<%= model.get('status') %>
|
||||||
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -437,28 +437,6 @@
|
||||||
|
|
||||||
isSystemCollection: function (val) {
|
isSystemCollection: function (val) {
|
||||||
return val.name.substr(0, 1) === '_';
|
return val.name.substr(0, 1) === '_';
|
||||||
// the below code is completely inappropriate as it will
|
|
||||||
// load the collection just for the check whether it
|
|
||||||
// is a system collection. as a consequence, the below
|
|
||||||
// code would load ALL collections when the web interface
|
|
||||||
// is called
|
|
||||||
/*
|
|
||||||
var returnVal = false;
|
|
||||||
$.ajax({
|
|
||||||
type: "GET",
|
|
||||||
url: "/_api/collection/" + encodeURIComponent(val) + "/properties",
|
|
||||||
contentType: "application/json",
|
|
||||||
processData: false,
|
|
||||||
async: false,
|
|
||||||
success: function(data) {
|
|
||||||
returnVal = data.isSystem;
|
|
||||||
},
|
|
||||||
error: function(data) {
|
|
||||||
returnVal = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return returnVal;
|
|
||||||
*/
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setDocumentStore : function (a) {
|
setDocumentStore : function (a) {
|
||||||
|
|
|
@ -154,21 +154,20 @@
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
newCollection: function (collName, wfs, isSystem, journalSize, collType, shards, keys) {
|
newCollection: function (object, callback) {
|
||||||
var returnobj = {};
|
|
||||||
var data = {};
|
var data = {};
|
||||||
data.name = collName;
|
data.name = object.collName;
|
||||||
data.waitForSync = wfs;
|
data.waitForSync = object.wfs;
|
||||||
if (journalSize > 0) {
|
if (object.journalSize > 0) {
|
||||||
data.journalSize = journalSize;
|
data.journalSize = object.journalSize;
|
||||||
}
|
}
|
||||||
data.isSystem = isSystem;
|
data.isSystem = object.isSystem;
|
||||||
data.type = parseInt(collType, 10);
|
data.type = parseInt(object.collType, 10);
|
||||||
if (shards) {
|
if (object.shards) {
|
||||||
data.numberOfShards = shards;
|
data.numberOfShards = object.shards;
|
||||||
data.shardKeys = keys;
|
data.shardKeys = object.keys;
|
||||||
}
|
}
|
||||||
returnobj.status = false;
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
cache: false,
|
cache: false,
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
@ -176,17 +175,13 @@
|
||||||
data: JSON.stringify(data),
|
data: JSON.stringify(data),
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
processData: false,
|
processData: false,
|
||||||
async: false,
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
returnobj.status = true;
|
callback(false, data);
|
||||||
returnobj.data = data;
|
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
returnobj.status = false;
|
callback(false, data);
|
||||||
returnobj.errorMessage = JSON.parse(data.responseText).errorMessage;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return returnobj;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
window.arangoCollectionModel = Backbone.Model.extend({
|
window.arangoCollectionModel = Backbone.Model.extend({
|
||||||
initialize: function () {
|
|
||||||
},
|
|
||||||
|
|
||||||
idAttribute: "name",
|
idAttribute: "name",
|
||||||
|
|
||||||
|
@ -74,26 +72,22 @@
|
||||||
return data2;
|
return data2;
|
||||||
},
|
},
|
||||||
|
|
||||||
getIndex: function () {
|
getIndex: function (callback) {
|
||||||
var data2;
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
cache: false,
|
cache: false,
|
||||||
url: "/_api/index/?collection=" + this.get("id"),
|
url: "/_api/index/?collection=" + this.get("id"),
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
processData: false,
|
processData: false,
|
||||||
async: false,
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
data2 = data;
|
callback(false, data);
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
data2 = data;
|
callback(true, data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return data2;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
createIndex: function (postParameter, callback) {
|
createIndex: function (postParameter, callback) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -163,15 +157,14 @@
|
||||||
|
|
||||||
truncateCollection: function () {
|
truncateCollection: function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
async: false,
|
|
||||||
cache: false,
|
cache: false,
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
url: "/_api/collection/" + this.get("id") + "/truncate",
|
url: "/_api/collection/" + this.get("id") + "/truncate",
|
||||||
success: function () {
|
success: function () {
|
||||||
arangoHelper.arangoNotification('Collection truncated');
|
arangoHelper.arangoNotification('Collection truncated.');
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
arangoHelper.arangoError('Collection error');
|
arangoHelper.arangoError('Collection error.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -207,36 +200,27 @@
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
|
|
||||||
renameCollection: function (name) {
|
renameCollection: function (name, callback) {
|
||||||
var self = this,
|
var self = this;
|
||||||
result = false;
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
cache: false,
|
cache: false,
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
async: false, // sequential calls!
|
|
||||||
url: "/_api/collection/" + this.get("id") + "/rename",
|
url: "/_api/collection/" + this.get("id") + "/rename",
|
||||||
data: JSON.stringify({ name: name }),
|
data: JSON.stringify({ name: name }),
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
processData: false,
|
processData: false,
|
||||||
success: function() {
|
success: function() {
|
||||||
self.set("name", name);
|
self.set("name", name);
|
||||||
result = true;
|
callback(false);
|
||||||
},
|
},
|
||||||
error: function(/*data*/) {
|
error: function(data) {
|
||||||
try {
|
callback(true, data);
|
||||||
console.log("error");
|
|
||||||
//var parsed = JSON.parse(data.responseText);
|
|
||||||
//result = parsed.errorMessage;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return result;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
changeCollection: function (wfs, journalSize, indexBuckets) {
|
changeCollection: function (wfs, journalSize, indexBuckets, callback) {
|
||||||
var result = false;
|
var result = false;
|
||||||
if (wfs === "true") {
|
if (wfs === "true") {
|
||||||
wfs = true;
|
wfs = true;
|
||||||
|
@ -253,22 +237,15 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
cache: false,
|
cache: false,
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
async: false, // sequential calls!
|
|
||||||
url: "/_api/collection/" + this.get("id") + "/properties",
|
url: "/_api/collection/" + this.get("id") + "/properties",
|
||||||
data: JSON.stringify(data),
|
data: JSON.stringify(data),
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
processData: false,
|
processData: false,
|
||||||
success: function() {
|
success: function() {
|
||||||
result = true;
|
callback(false);
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
try {
|
callback(false, data);
|
||||||
var parsed = JSON.parse(data.responseText);
|
|
||||||
result = parsed.errorMessage;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -138,7 +138,6 @@
|
||||||
|
|
||||||
truncateCollection: function () {
|
truncateCollection: function () {
|
||||||
this.model.truncateCollection();
|
this.model.truncateCollection();
|
||||||
this.render();
|
|
||||||
window.modalView.hide();
|
window.modalView.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -189,40 +188,42 @@
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result;
|
var callbackChange = function(error) {
|
||||||
if (this.model.get('name') !== newname) {
|
if (error) {
|
||||||
result = this.model.renameCollection(newname);
|
arangoHelper.arangoError("Collection error: " + error.responseText);
|
||||||
}
|
|
||||||
|
|
||||||
if (result !== true) {
|
|
||||||
if (result !== undefined) {
|
|
||||||
arangoHelper.arangoError("Collection error: " + result);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
|
|
||||||
var wfs = $('#change-collection-sync').val();
|
|
||||||
var changeResult = this.model.changeCollection(wfs, journalSize, indexBuckets);
|
|
||||||
|
|
||||||
if (changeResult !== true) {
|
|
||||||
arangoHelper.arangoNotification("Collection error", changeResult);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.collectionsView.render();
|
|
||||||
window.modalView.hide();
|
|
||||||
}
|
|
||||||
else if (status === 'unloaded') {
|
|
||||||
if (this.model.get('name') !== newname) {
|
|
||||||
var result2 = this.model.renameCollection(newname);
|
|
||||||
|
|
||||||
if (result2 === true) {
|
|
||||||
this.collectionsView.render();
|
this.collectionsView.render();
|
||||||
window.modalView.hide();
|
window.modalView.hide();
|
||||||
}
|
}
|
||||||
else {
|
}.bind(this);
|
||||||
arangoHelper.arangoError("Collection error: " + result2);
|
|
||||||
|
var callbackRename = function(error) {
|
||||||
|
if (error) {
|
||||||
|
arangoHelper.arangoError("Collection error: " + error.responseText);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
var wfs = $('#change-collection-sync').val();
|
||||||
|
this.model.changeCollection(wfs, journalSize, indexBuckets, callbackChange);
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
this.model.renameCollection(newname, callbackRename);
|
||||||
|
}
|
||||||
|
else if (status === 'unloaded') {
|
||||||
|
if (this.model.get('name') !== newname) {
|
||||||
|
|
||||||
|
var callbackRename2 = function(error, data) {
|
||||||
|
if (error) {
|
||||||
|
arangoHelper.arangoError("Collection error: " + data.responseText);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.collectionsView.render();
|
||||||
|
window.modalView.hide();
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
this.model.renameCollection(newname, callbackRename2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
window.modalView.hide();
|
window.modalView.hide();
|
||||||
|
@ -230,10 +231,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//modal dialogs
|
|
||||||
|
|
||||||
createEditPropertiesModal: function() {
|
createEditPropertiesModal: function() {
|
||||||
|
|
||||||
var collectionIsLoaded = false;
|
var collectionIsLoaded = false;
|
||||||
|
@ -392,7 +389,6 @@
|
||||||
else {
|
else {
|
||||||
$($('#infoTab').children()[1]).remove();
|
$($('#infoTab').children()[1]).remove();
|
||||||
}
|
}
|
||||||
this.bindIndexEvents();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
bindIndexEvents: function() {
|
bindIndexEvents: function() {
|
||||||
|
@ -419,6 +415,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.deleteIndex').bind('click', function(e) {
|
$('.deleteIndex').bind('click', function(e) {
|
||||||
|
console.log("asdasd");
|
||||||
self.prepDeleteIndex(e);
|
self.prepDeleteIndex(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -643,7 +640,23 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
getIndex: function () {
|
getIndex: function () {
|
||||||
this.index = this.model.getIndex();
|
|
||||||
|
var callback = function(error, data) {
|
||||||
|
if (error) {
|
||||||
|
window.arangoHelper.arangoError('Index', data.errorMessage);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.renderIndex(data);
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
this.model.getIndex(callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
renderIndex: function(data) {
|
||||||
|
|
||||||
|
this.index = data;
|
||||||
|
|
||||||
var cssClass = 'collectionInfoTh modal-text';
|
var cssClass = 'collectionInfoTh modal-text';
|
||||||
if (this.index) {
|
if (this.index) {
|
||||||
var fieldString = '';
|
var fieldString = '';
|
||||||
|
@ -686,6 +699,7 @@
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.bindIndexEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleNewIndexView: function () {
|
toggleNewIndexView: function () {
|
||||||
|
|
|
@ -358,14 +358,27 @@
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var returnobj = this.collection.newCollection(
|
var callback = function(error, data) {
|
||||||
collName, wfs, isSystem, collSize, collType, shards, shardBy
|
|
||||||
);
|
if (error) {
|
||||||
if (returnobj.status !== true) {
|
arangoHelper.arangoError("Collection error", data.errorMessage);
|
||||||
arangoHelper.arangoError("Collection error", returnobj.errorMessage);
|
}
|
||||||
}
|
else {
|
||||||
this.updateCollectionsView();
|
this.updateCollectionsView();
|
||||||
window.modalView.hide();
|
}
|
||||||
|
window.modalView.hide();
|
||||||
|
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
this.collection.newCollection({
|
||||||
|
collName: collName,
|
||||||
|
wfs: wfs,
|
||||||
|
isSystem: isSystem,
|
||||||
|
collSize: collSize,
|
||||||
|
collType: collType,
|
||||||
|
shards: shards,
|
||||||
|
shardBy: shardBy
|
||||||
|
}, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
createNewCollectionModal: function() {
|
createNewCollectionModal: function() {
|
||||||
|
|
|
@ -188,40 +188,67 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
saveDocument: function () {
|
saveDocument: function () {
|
||||||
|
if ($('#saveDocumentButton').attr('disabled') === undefined) {
|
||||||
|
if (this.collection.first().attributes._id.substr(0, 1) === '_') {
|
||||||
|
|
||||||
|
var buttons = [], tableContent = [];
|
||||||
|
tableContent.push(
|
||||||
|
window.modalView.createReadOnlyEntry(
|
||||||
|
'doc-save-system-button',
|
||||||
|
'Caution',
|
||||||
|
'You are modifying a system collection. Really continue?',
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
false,
|
||||||
|
/[<>&'"]/
|
||||||
|
)
|
||||||
|
);
|
||||||
|
buttons.push(
|
||||||
|
window.modalView.createSuccessButton('Save', this.confirmSaveDocument.bind(this))
|
||||||
|
);
|
||||||
|
window.modalView.show('modalTable.ejs', 'Modify System Collection', buttons, tableContent);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.confirmSaveDocument();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
confirmSaveDocument: function () {
|
||||||
|
|
||||||
|
window.modalView.hide();
|
||||||
|
|
||||||
var model, result;
|
var model, result;
|
||||||
|
|
||||||
if ($('#saveDocumentButton').attr('disabled') === undefined) {
|
try {
|
||||||
|
model = this.editor.get();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
this.errorConfirmation(e);
|
||||||
|
this.disableSaveButton();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
model = JSON.stringify(model);
|
||||||
model = this.editor.get();
|
|
||||||
}
|
if (this.type === 'document') {
|
||||||
catch (e) {
|
result = this.collection.saveDocument(this.colid, this.docid, model);
|
||||||
this.errorConfirmation(e);
|
if (result === false) {
|
||||||
this.disableSaveButton();
|
arangoHelper.arangoError('Document error:','Could not save');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
model = JSON.stringify(model);
|
else if (this.type === 'edge') {
|
||||||
|
result = this.collection.saveEdge(this.colid, this.docid, model);
|
||||||
if (this.type === 'document') {
|
if (result === false) {
|
||||||
result = this.collection.saveDocument(this.colid, this.docid, model);
|
arangoHelper.arangoError('Edge error:', 'Could not save');
|
||||||
if (result === false) {
|
return;
|
||||||
arangoHelper.arangoError('Document error:','Could not save');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (this.type === 'edge') {
|
|
||||||
result = this.collection.saveEdge(this.colid, this.docid, model);
|
|
||||||
if (result === false) {
|
|
||||||
arangoHelper.arangoError('Edge error:', 'Could not save');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
this.successConfirmation();
|
this.successConfirmation();
|
||||||
this.disableSaveButton();
|
this.disableSaveButton();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,29 @@
|
||||||
templateSlow: templateEngine.createTemplate("queryManagementViewSlow.ejs"),
|
templateSlow: templateEngine.createTemplate("queryManagementViewSlow.ejs"),
|
||||||
table: templateEngine.createTemplate("arangoTable.ejs"),
|
table: templateEngine.createTemplate("arangoTable.ejs"),
|
||||||
tabbar: templateEngine.createTemplate("arangoTabbar.ejs"),
|
tabbar: templateEngine.createTemplate("arangoTabbar.ejs"),
|
||||||
|
active: true,
|
||||||
|
shouldRender: true,
|
||||||
|
timer: 0,
|
||||||
|
refreshRate: 2000,
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
|
var self = this;
|
||||||
this.activeCollection = new window.QueryManagementActive();
|
this.activeCollection = new window.QueryManagementActive();
|
||||||
this.slowCollection = new window.QueryManagementSlow();
|
this.slowCollection = new window.QueryManagementSlow();
|
||||||
this.convertModelToJSON(true);
|
this.convertModelToJSON(true);
|
||||||
|
|
||||||
|
window.setInterval(function() {
|
||||||
|
if (window.location.hash === '#queryManagement' && window.VISIBLE && self.shouldRender) {
|
||||||
|
if (self.active) {
|
||||||
|
self.convertModelToJSON(true);
|
||||||
|
self.renderActive();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.convertModelToJSON(false);
|
||||||
|
self.renderSlow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, self.refreshRate);
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
|
@ -44,9 +62,11 @@
|
||||||
|
|
||||||
switchTab: function(e) {
|
switchTab: function(e) {
|
||||||
if (e.currentTarget.id === 'activequeries') {
|
if (e.currentTarget.id === 'activequeries') {
|
||||||
|
this.active = true;
|
||||||
this.convertModelToJSON(true);
|
this.convertModelToJSON(true);
|
||||||
}
|
}
|
||||||
else if (e.currentTarget.id === 'slowqueries') {
|
else if (e.currentTarget.id === 'slowqueries') {
|
||||||
|
this.active = false;
|
||||||
this.convertModelToJSON(false);
|
this.convertModelToJSON(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -133,11 +153,25 @@
|
||||||
this.convertModelToJSON(true);
|
this.convertModelToJSON(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addEvents: function() {
|
||||||
|
var self = this;
|
||||||
|
$('#queryManagementContent tbody').on('mousedown', function() {
|
||||||
|
clearTimeout(self.timer);
|
||||||
|
self.shouldRender = false;
|
||||||
|
});
|
||||||
|
$('#queryManagementContent tbody').on('mouseup', function() {
|
||||||
|
self.timer = window.setTimeout(function() {
|
||||||
|
self.shouldRender = true;
|
||||||
|
}, 3000);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
renderActive: function() {
|
renderActive: function() {
|
||||||
this.$el.html(this.templateActive.render({}));
|
this.$el.html(this.templateActive.render({}));
|
||||||
$(this.id).html(this.tabbar.render({content: this.tabbarElements}));
|
$(this.id).html(this.tabbar.render({content: this.tabbarElements}));
|
||||||
$(this.id).append(this.table.render({content: this.tableDescription}));
|
$(this.id).append(this.table.render({content: this.tableDescription}));
|
||||||
$('#activequeries').addClass("arango-active-tab");
|
$('#activequeries').addClass("arango-active-tab");
|
||||||
|
this.addEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
renderSlow: function() {
|
renderSlow: function() {
|
||||||
|
@ -147,6 +181,7 @@
|
||||||
content: this.tableDescription,
|
content: this.tableDescription,
|
||||||
}));
|
}));
|
||||||
$('#slowqueries').addClass("arango-active-tab");
|
$('#slowqueries').addClass("arango-active-tab");
|
||||||
|
this.addEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
convertModelToJSON: function (active) {
|
convertModelToJSON: function (active) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"license": "Apache License, Version 2.0",
|
"license": "Apache License, Version 2.0",
|
||||||
"isSystem": true,
|
"isSystem": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"arangodb": "^3.0.0"
|
"arangodb": "^2.8.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"license": "Apache License, Version 2.0",
|
"license": "Apache License, Version 2.0",
|
||||||
"isSystem": true,
|
"isSystem": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"arangodb": "^3.0.0"
|
"arangodb": "^2.8.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"license": "Apache License, Version 2.0",
|
"license": "Apache License, Version 2.0",
|
||||||
"isSystem": true,
|
"isSystem": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"arangodb": "^3.0.0"
|
"arangodb": "^2.8.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"license": "Apache License, Version 2.0",
|
"license": "Apache License, Version 2.0",
|
||||||
"isSystem": true,
|
"isSystem": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"arangodb": "^3.0.0"
|
"arangodb": "^2.8.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"license": "Apache License, Version 2.0",
|
"license": "Apache License, Version 2.0",
|
||||||
"isSystem": true,
|
"isSystem": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"arangodb": "^3.0.0"
|
"arangodb": "^2.8.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"license": "Apache License, Version 2.0",
|
"license": "Apache License, Version 2.0",
|
||||||
"isSystem": true,
|
"isSystem": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"arangodb": "^3.0.0"
|
"arangodb": "^2.8.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
Loading…
Reference in New Issue