mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into spdvpk
This commit is contained in:
commit
d1aaddd8c3
|
@ -3,21 +3,28 @@
|
|||
|
||||
(function() {
|
||||
"use strict";
|
||||
var isCoordinator;
|
||||
var isCoordinator = null;
|
||||
|
||||
window.isCoordinator = function() {
|
||||
if (isCoordinator === undefined) {
|
||||
window.isCoordinator = function(callback) {
|
||||
if (isCoordinator === null) {
|
||||
$.ajax(
|
||||
"cluster/amICoordinator",
|
||||
{
|
||||
async: false,
|
||||
async: true,
|
||||
success: function(d) {
|
||||
isCoordinator = d;
|
||||
callback(false, d);
|
||||
},
|
||||
error: function(d) {
|
||||
isCoordinator = d;
|
||||
callback(true, d);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return isCoordinator;
|
||||
else {
|
||||
callback(false, isCoordinator);
|
||||
}
|
||||
};
|
||||
|
||||
window.versionHelper = {
|
||||
|
@ -93,23 +100,20 @@
|
|||
});
|
||||
},
|
||||
|
||||
currentDatabase: function () {
|
||||
var returnVal = false;
|
||||
currentDatabase: function (callback) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
cache: false,
|
||||
url: "/_api/database/current",
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
returnVal = data.result.name;
|
||||
callback(false, data.result.name);
|
||||
},
|
||||
error: function() {
|
||||
returnVal = false;
|
||||
error: function(data) {
|
||||
callback(true, data);
|
||||
}
|
||||
});
|
||||
return returnVal;
|
||||
},
|
||||
|
||||
allHotkeys: {
|
||||
|
@ -199,24 +203,30 @@
|
|||
}
|
||||
},
|
||||
|
||||
databaseAllowed: function () {
|
||||
var currentDB = this.currentDatabase(),
|
||||
returnVal = false;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
cache: false,
|
||||
url: "/_db/"+ encodeURIComponent(currentDB) + "/_api/database/",
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
async: false,
|
||||
success: function() {
|
||||
returnVal = true;
|
||||
},
|
||||
error: function() {
|
||||
returnVal = false;
|
||||
databaseAllowed: function (callback) {
|
||||
|
||||
var dbCallback = function(error, db) {
|
||||
if (error) {
|
||||
arangoHelper.arangoError("","");
|
||||
}
|
||||
});
|
||||
return returnVal;
|
||||
else {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
cache: false,
|
||||
url: "/_db/"+ encodeURIComponent(db) + "/_api/database/",
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
success: function() {
|
||||
callback(false, true);
|
||||
},
|
||||
error: function() {
|
||||
callback(true, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
this.currentDatabase(dbCallback);
|
||||
},
|
||||
|
||||
arangoNotification: function (title, content, info) {
|
||||
|
@ -344,20 +354,16 @@
|
|||
},
|
||||
|
||||
getAardvarkJobs: function (callback) {
|
||||
var result;
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "GET",
|
||||
url: "/_admin/aardvark/job",
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
async: false,
|
||||
success: function (data) {
|
||||
if (callback) {
|
||||
callback(false, data);
|
||||
}
|
||||
result = data;
|
||||
},
|
||||
error: function(data) {
|
||||
if (callback) {
|
||||
|
@ -365,11 +371,9 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
},
|
||||
|
||||
getPendingJobs: function() {
|
||||
var result;
|
||||
getPendingJobs: function(callback) {
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
|
@ -377,53 +381,67 @@
|
|||
url: "/_api/job/pending",
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
async: false,
|
||||
success: function (data) {
|
||||
result = data;
|
||||
callback(false, data);
|
||||
},
|
||||
error: function(data) {
|
||||
console.log("pending jobs error: " + data);
|
||||
callback(true, data);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
},
|
||||
|
||||
syncAndReturnUninishedAardvarkJobs: function(type) {
|
||||
syncAndReturnUninishedAardvarkJobs: function(type, callback) {
|
||||
|
||||
var AaJobs = this.getAardvarkJobs(),
|
||||
pendingJobs = this.getPendingJobs(),
|
||||
array = [];
|
||||
var callbackInner = function(error, AaJobs) {
|
||||
if (error) {
|
||||
callback(true);
|
||||
}
|
||||
else {
|
||||
|
||||
if (pendingJobs.length > 0) {
|
||||
_.each(AaJobs, function(aardvark) {
|
||||
if (aardvark.type === type || aardvark.type === undefined) {
|
||||
|
||||
var found = false;
|
||||
_.each(pendingJobs, function(pending) {
|
||||
if (aardvark.id === pending) {
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (found) {
|
||||
array.push({
|
||||
collection: aardvark.collection,
|
||||
id: aardvark.id,
|
||||
type: aardvark.type,
|
||||
desc: aardvark.desc
|
||||
});
|
||||
var callbackInner2 = function(error, pendingJobs) {
|
||||
if (error) {
|
||||
arangoHelper.arangoError("", "");
|
||||
}
|
||||
else {
|
||||
window.arangoHelper.deleteAardvarkJob(aardvark.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.deleteAllAardvarkJobs();
|
||||
}
|
||||
var array = [];
|
||||
if (pendingJobs.length > 0) {
|
||||
_.each(AaJobs, function(aardvark) {
|
||||
if (aardvark.type === type || aardvark.type === undefined) {
|
||||
|
||||
return array;
|
||||
var found = false;
|
||||
_.each(pendingJobs, function(pending) {
|
||||
if (aardvark.id === pending) {
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (found) {
|
||||
array.push({
|
||||
collection: aardvark.collection,
|
||||
id: aardvark.id,
|
||||
type: aardvark.type,
|
||||
desc: aardvark.desc
|
||||
});
|
||||
}
|
||||
else {
|
||||
window.arangoHelper.deleteAardvarkJob(aardvark.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.deleteAllAardvarkJobs();
|
||||
}
|
||||
callback(false, array);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
this.getPendingJobs(callbackInner2);
|
||||
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
this.getAardvarkJobs(callbackInner);
|
||||
},
|
||||
|
||||
getRandomToken: function () {
|
||||
|
|
|
@ -179,7 +179,7 @@
|
|||
callback(false, data);
|
||||
},
|
||||
error: function(data) {
|
||||
callback(false, data);
|
||||
callback(true, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,18 +7,18 @@
|
|||
window.ArangoQueries = Backbone.Collection.extend({
|
||||
|
||||
initialize: function(models, options) {
|
||||
var result;
|
||||
$.ajax("whoAmI?_=" + Date.now(), {async:false}).done(
|
||||
var self = this;
|
||||
|
||||
$.ajax("whoAmI?_=" + Date.now(), {async: true}).done(
|
||||
function(data) {
|
||||
result = data.user;
|
||||
if (this.activeUser === false) {
|
||||
self.activeUser = "root";
|
||||
}
|
||||
else {
|
||||
self.activeUser = data.user;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
this.activeUser = result;
|
||||
|
||||
if (this.activeUser === false) {
|
||||
this.activeUser = "root";
|
||||
}
|
||||
},
|
||||
|
||||
url: '/_api/user/',
|
||||
|
|
|
@ -70,7 +70,7 @@ window.ArangoUsers = Backbone.Collection.extend({
|
|||
this.activeUserSettings.identifier = content;
|
||||
},
|
||||
|
||||
loadUserSettings: function () {
|
||||
loadUserSettings: function (callback) {
|
||||
var self = this;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
|
@ -78,28 +78,30 @@ window.ArangoUsers = Backbone.Collection.extend({
|
|||
url: "/_api/user/" + encodeURIComponent(self.activeUser),
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
self.activeUserSettings = data.extra;
|
||||
callback(false, data);
|
||||
},
|
||||
error: function(data) {
|
||||
callback(true, data);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
saveUserSettings: function () {
|
||||
saveUserSettings: function (callback) {
|
||||
var self = this;
|
||||
$.ajax({
|
||||
cache: false,
|
||||
type: "PUT",
|
||||
async: false, // sequential calls!
|
||||
url: "/_api/user/" + encodeURIComponent(self.activeUser),
|
||||
data: JSON.stringify({ extra: self.activeUserSettings }),
|
||||
contentType: "application/json",
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
callback(false, data);
|
||||
},
|
||||
error: function(data) {
|
||||
callback(true, data);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -99,7 +99,7 @@ function WebWorkerWrapper(Class, callback) {
|
|||
return new window.Blob(code.split());
|
||||
},
|
||||
worker,
|
||||
url = window.webkitURL || window.URL,
|
||||
url = window.URL,
|
||||
blobPointer = new BlobObject(Class);
|
||||
worker = new window.Worker(url.createObjectURL(blobPointer));
|
||||
worker.onmessage = callback;
|
||||
|
|
|
@ -191,8 +191,8 @@ function GraphViewerPreview(container, viewerConfig) {
|
|||
* Execution start
|
||||
*******************************************************************************/
|
||||
|
||||
width = container.offsetWidth;
|
||||
height = container.offsetHeight;
|
||||
width = container.getBoundingClientRect().width;
|
||||
height = container.getBoundingClientRect().height;
|
||||
adapterConfig = {
|
||||
type: "preview"
|
||||
};
|
||||
|
|
|
@ -43,8 +43,8 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
|
|||
}
|
||||
|
||||
var graphViewer,
|
||||
width = (optWidth + 20 || container.offsetWidth - 81 + 20),
|
||||
height = optHeight || container.offsetHeight,
|
||||
width = (optWidth + 20 || container.getBoundingClientRect().width - 81 + 20),
|
||||
height = optHeight || container.getBoundingClientRect().height,
|
||||
menubar = document.createElement("ul"),
|
||||
background = document.createElement("div"),
|
||||
colourList,
|
||||
|
|
|
@ -168,8 +168,8 @@ function GraphViewerWidget(viewerConfig, startNode) {
|
|||
*******************************************************************************/
|
||||
|
||||
container = document.body;
|
||||
width = container.offsetWidth;
|
||||
height = container.offsetHeight;
|
||||
width = container.getBoundingClientRect().width;
|
||||
height = container.getBoundingClientRect().height;
|
||||
adapterConfig = {
|
||||
type: "foxx",
|
||||
route: "."
|
||||
|
|
|
@ -343,19 +343,26 @@
|
|||
this.waitForInit(this.databases.bind(this));
|
||||
return;
|
||||
}
|
||||
if (arangoHelper.databaseAllowed() === true) {
|
||||
if (! this.databaseView) {
|
||||
this.databaseView = new window.databaseView({
|
||||
users: this.userCollection,
|
||||
collection: this.arangoDatabase
|
||||
});
|
||||
|
||||
var callback = function(error) {
|
||||
if (error) {
|
||||
arangoHelper.arangoError("DB","Could not get list of allowed databases");
|
||||
this.navigate("#", {trigger: true});
|
||||
$('#databaseNavi').css('display', 'none');
|
||||
$('#databaseNaviSelect').css('display', 'none');
|
||||
}
|
||||
this.databaseView.render();
|
||||
} else {
|
||||
this.navigate("#", {trigger: true});
|
||||
$('#databaseNavi').css('display', 'none');
|
||||
$('#databaseNaviSelect').css('display', 'none');
|
||||
}
|
||||
else {
|
||||
if (! this.databaseView) {
|
||||
this.databaseView = new window.databaseView({
|
||||
users: this.userCollection,
|
||||
collection: this.arangoDatabase
|
||||
});
|
||||
}
|
||||
this.databaseView.render();
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
arangoHelper.databaseAllowed(callback);
|
||||
},
|
||||
|
||||
dashboard: function (initialized) {
|
||||
|
@ -407,9 +414,11 @@
|
|||
collectionCollection: this.arangoCollectionsStore
|
||||
}
|
||||
);
|
||||
this.graphManagementView.render(name, true);
|
||||
}
|
||||
else {
|
||||
this.graphManagementView.loadGraphViewer(name);
|
||||
}
|
||||
this.graphManagementView.render();
|
||||
this.graphManagementView.loadGraphViewer(name);
|
||||
},
|
||||
|
||||
applications: function (initialized) {
|
||||
|
|
|
@ -186,35 +186,53 @@
|
|||
|
||||
render: function(mode) {
|
||||
|
||||
var self = this;
|
||||
var callback = function(error, db) {
|
||||
var self = this;
|
||||
if (error) {
|
||||
arangoHelper.arangoError("DB","Could not get current database");
|
||||
}
|
||||
else {
|
||||
$(this.el).html(this.template.render({
|
||||
app: this.model,
|
||||
db: db,
|
||||
mode: mode
|
||||
}));
|
||||
|
||||
$(this.el).html(this.template.render({
|
||||
app: this.model,
|
||||
db: arangoHelper.currentDatabase(),
|
||||
mode: mode
|
||||
}));
|
||||
$.get(this.appUrl(db)).success(function () {
|
||||
$(".open", this.el).prop('disabled', false);
|
||||
}.bind(this));
|
||||
|
||||
$.get(this.appUrl()).success(function () {
|
||||
$(".open", this.el).prop('disabled', false);
|
||||
}.bind(this));
|
||||
this.updateConfig();
|
||||
this.updateDeps();
|
||||
|
||||
this.updateConfig();
|
||||
this.updateDeps();
|
||||
|
||||
if (mode === 'swagger') {
|
||||
$.get( "./foxxes/docs/swagger.json?mount=" + encodeURIComponent(this.model.get('mount')), function(data) {
|
||||
if (Object.keys(data.paths).length < 1) {
|
||||
self.render('readme');
|
||||
$('#app-show-swagger').attr('disabled', 'true');
|
||||
if (mode === 'swagger') {
|
||||
$.get( "./foxxes/docs/swagger.json?mount=" + encodeURIComponent(this.model.get('mount')), function(data) {
|
||||
if (Object.keys(data.paths).length < 1) {
|
||||
self.render('readme');
|
||||
$('#app-show-swagger').attr('disabled', 'true');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
arangoHelper.currentDatabase(callback);
|
||||
|
||||
return $(this.el);
|
||||
},
|
||||
|
||||
openApp: function() {
|
||||
window.open(this.appUrl(), this.model.get('title')).focus();
|
||||
|
||||
var callback = function(error, db) {
|
||||
if (error) {
|
||||
arangoHelper.arangoError("DB","Could not get current database");
|
||||
}
|
||||
else {
|
||||
window.open(this.appUrl(db), this.model.get('title')).focus();
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
arangoHelper.currentDatabase(callback);
|
||||
},
|
||||
|
||||
deleteApp: function() {
|
||||
|
@ -249,9 +267,9 @@
|
|||
);
|
||||
},
|
||||
|
||||
appUrl: function () {
|
||||
appUrl: function (currentDB) {
|
||||
return window.location.origin + '/_db/'
|
||||
+ encodeURIComponent(arangoHelper.currentDatabase())
|
||||
+ encodeURIComponent(currentDB)
|
||||
+ this.model.get('mount');
|
||||
},
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,54 +24,58 @@
|
|||
},
|
||||
|
||||
checkLockedCollections: function() {
|
||||
|
||||
var self = this,
|
||||
lockedCollections = window.arangoHelper.syncAndReturnUninishedAardvarkJobs('index');
|
||||
|
||||
this.collection.each(function(model) {
|
||||
model.set('locked', false);
|
||||
});
|
||||
|
||||
_.each(lockedCollections, function(locked) {
|
||||
var model = self.collection.findWhere({
|
||||
id: locked.collection
|
||||
});
|
||||
model.set('locked', true);
|
||||
model.set('lockType', locked.type);
|
||||
model.set('desc', locked.desc);
|
||||
});
|
||||
|
||||
this.collection.each(function(model) {
|
||||
|
||||
if (!model.get("locked")) {
|
||||
$('#collection_' + model.get("name")).find('.corneredBadge').removeClass('loaded unloaded');
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').text(model.get("status"));
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').addClass(model.get("status"));
|
||||
}
|
||||
|
||||
if (model.get("locked") || model.get("status") === 'loading') {
|
||||
$('#collection_' + model.get("name")).addClass('locked');
|
||||
if (model.get("locked")) {
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').text(model.get("desc"));
|
||||
}
|
||||
else {
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').text(model.get("status"));
|
||||
}
|
||||
var callback = function(error, lockedCollections) {
|
||||
var self = this;
|
||||
if (error) {
|
||||
arangoHelper.arangoError("Collections", "Could not check locked collections");
|
||||
}
|
||||
else {
|
||||
$('#collection_' + model.get("name")).removeClass('locked');
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').text(model.get("status"));
|
||||
if ($('#collection_' + model.get("name") + ' .corneredBadge').hasClass('inProgress')) {
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').text(model.get("status"));
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').removeClass('inProgress');
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').addClass('loaded');
|
||||
}
|
||||
if (model.get('status') === 'unloaded') {
|
||||
$('#collection_' + model.get("name") + ' .icon_arangodb_info').addClass('disabled');
|
||||
}
|
||||
}
|
||||
});
|
||||
this.collection.each(function(model) {
|
||||
model.set('locked', false);
|
||||
});
|
||||
|
||||
_.each(lockedCollections, function(locked) {
|
||||
var model = self.collection.findWhere({
|
||||
id: locked.collection
|
||||
});
|
||||
model.set('locked', true);
|
||||
model.set('lockType', locked.type);
|
||||
model.set('desc', locked.desc);
|
||||
});
|
||||
|
||||
this.collection.each(function(model) {
|
||||
if (!model.get("locked")) {
|
||||
$('#collection_' + model.get("name")).find('.corneredBadge').removeClass('loaded unloaded');
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').text(model.get("status"));
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').addClass(model.get("status"));
|
||||
}
|
||||
|
||||
if (model.get("locked") || model.get("status") === 'loading') {
|
||||
$('#collection_' + model.get("name")).addClass('locked');
|
||||
if (model.get("locked")) {
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').text(model.get("desc"));
|
||||
}
|
||||
else {
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').text(model.get("status"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#collection_' + model.get("name")).removeClass('locked');
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').text(model.get("status"));
|
||||
if ($('#collection_' + model.get("name") + ' .corneredBadge').hasClass('inProgress')) {
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').text(model.get("status"));
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').removeClass('inProgress');
|
||||
$('#collection_' + model.get("name") + ' .corneredBadge').addClass('loaded');
|
||||
}
|
||||
if (model.get('status') === 'unloaded') {
|
||||
$('#collection_' + model.get("name") + ' .icon_arangodb_info').addClass('disabled');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
window.arangoHelper.syncAndReturnUninishedAardvarkJobs('index', callback);
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
|
@ -313,178 +317,205 @@
|
|||
},
|
||||
|
||||
submitCreateCollection: function() {
|
||||
var collName = $('#new-collection-name').val();
|
||||
var collSize = $('#new-collection-size').val();
|
||||
var collType = $('#new-collection-type').val();
|
||||
var collSync = $('#new-collection-sync').val();
|
||||
var shards = 1;
|
||||
var shardBy = [];
|
||||
if (window.isCoordinator()) {
|
||||
shards = $('#new-collection-shards').val();
|
||||
if (shards === "") {
|
||||
shards = 1;
|
||||
}
|
||||
shards = parseInt(shards, 10);
|
||||
if (shards < 1) {
|
||||
arangoHelper.arangoError(
|
||||
"Number of shards has to be an integer value greater or equal 1"
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
shardBy = _.pluck($('#new-collection-shardBy').select2("data"), "text");
|
||||
if (shardBy.length === 0) {
|
||||
shardBy.push("_key");
|
||||
}
|
||||
}
|
||||
//no new system collections via webinterface
|
||||
//var isSystem = (collName.substr(0, 1) === '_');
|
||||
if (collName.substr(0, 1) === '_') {
|
||||
arangoHelper.arangoError('No "_" allowed as first character!');
|
||||
return 0;
|
||||
}
|
||||
var isSystem = false;
|
||||
var wfs = (collSync === "true");
|
||||
if (collSize > 0) {
|
||||
try {
|
||||
collSize = JSON.parse(collSize) * 1024 * 1024;
|
||||
}
|
||||
catch (e) {
|
||||
arangoHelper.arangoError('Please enter a valid number');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (collName === '') {
|
||||
arangoHelper.arangoError('No collection name entered!');
|
||||
return 0;
|
||||
}
|
||||
|
||||
var callback = function(error, data) {
|
||||
|
||||
var callbackCoord = function(error, isCoordinator) {
|
||||
if (error) {
|
||||
arangoHelper.arangoError("Collection error", data.errorMessage);
|
||||
arangoHelper.arangoError("DB","Could not check coordinator state");
|
||||
}
|
||||
else {
|
||||
this.updateCollectionsView();
|
||||
}
|
||||
window.modalView.hide();
|
||||
var collName = $('#new-collection-name').val(),
|
||||
collSize = $('#new-collection-size').val(),
|
||||
collType = $('#new-collection-type').val(),
|
||||
collSync = $('#new-collection-sync').val(),
|
||||
shards = 1,
|
||||
shardBy = [];
|
||||
|
||||
if (isCoordinator) {
|
||||
shards = $('#new-collection-shards').val();
|
||||
|
||||
if (shards === "") {
|
||||
shards = 1;
|
||||
}
|
||||
shards = parseInt(shards, 10);
|
||||
if (shards < 1) {
|
||||
arangoHelper.arangoError(
|
||||
"Number of shards has to be an integer value greater or equal 1"
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
shardBy = _.pluck($('#new-collection-shardBy').select2("data"), "text");
|
||||
if (shardBy.length === 0) {
|
||||
shardBy.push("_key");
|
||||
}
|
||||
}
|
||||
if (collName.substr(0, 1) === '_') {
|
||||
arangoHelper.arangoError('No "_" allowed as first character!');
|
||||
return 0;
|
||||
}
|
||||
var isSystem = false;
|
||||
var wfs = (collSync === "true");
|
||||
if (collSize > 0) {
|
||||
try {
|
||||
collSize = JSON.parse(collSize) * 1024 * 1024;
|
||||
}
|
||||
catch (e) {
|
||||
arangoHelper.arangoError('Please enter a valid number');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (collName === '') {
|
||||
arangoHelper.arangoError('No collection name entered!');
|
||||
return 0;
|
||||
}
|
||||
//no new system collections via webinterface
|
||||
//var isSystem = (collName.substr(0, 1) === '_');
|
||||
var callback = function(error, data) {
|
||||
if (error) {
|
||||
try {
|
||||
data = JSON.parse(data.responseText);
|
||||
arangoHelper.arangoError("Error", data.errorMessage);
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.updateCollectionsView();
|
||||
}
|
||||
window.modalView.hide();
|
||||
|
||||
}.bind(this);
|
||||
|
||||
this.collection.newCollection({
|
||||
collName: collName,
|
||||
wfs: wfs,
|
||||
isSystem: isSystem,
|
||||
collSize: collSize,
|
||||
collType: collType,
|
||||
shards: shards,
|
||||
shardBy: shardBy
|
||||
}, callback);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
this.collection.newCollection({
|
||||
collName: collName,
|
||||
wfs: wfs,
|
||||
isSystem: isSystem,
|
||||
collSize: collSize,
|
||||
collType: collType,
|
||||
shards: shards,
|
||||
shardBy: shardBy
|
||||
}, callback);
|
||||
window.isCoordinator(callbackCoord);
|
||||
},
|
||||
|
||||
createNewCollectionModal: function() {
|
||||
var buttons = [],
|
||||
tableContent = [],
|
||||
advanced = {},
|
||||
advancedTableContent = [];
|
||||
|
||||
tableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
"new-collection-name",
|
||||
"Name",
|
||||
"",
|
||||
false,
|
||||
"",
|
||||
true,
|
||||
[
|
||||
{
|
||||
rule: Joi.string().regex(/^[a-zA-Z]/),
|
||||
msg: "Collection name must always start with a letter."
|
||||
},
|
||||
{
|
||||
rule: Joi.string().regex(/^[a-zA-Z0-9\-_]*$/),
|
||||
msg: 'Only symbols, "_" and "-" are allowed.'
|
||||
},
|
||||
{
|
||||
rule: Joi.string().required(),
|
||||
msg: "No collection name given."
|
||||
}
|
||||
]
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
window.modalView.createSelectEntry(
|
||||
"new-collection-type",
|
||||
"Type",
|
||||
"",
|
||||
"The type of the collection to create.",
|
||||
[{value: 2, label: "Document"}, {value: 3, label: "Edge"}]
|
||||
)
|
||||
);
|
||||
if (window.isCoordinator()) {
|
||||
tableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
"new-collection-shards",
|
||||
"Shards",
|
||||
"",
|
||||
"The number of shards to create. You cannot change this afterwards. "
|
||||
+ "Recommended: DBServers squared",
|
||||
"",
|
||||
true
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
window.modalView.createSelect2Entry(
|
||||
"new-collection-shardBy",
|
||||
"shardBy",
|
||||
"",
|
||||
"The keys used to distribute documents on shards. "
|
||||
+ "Type the key and press return to add it.",
|
||||
"_key",
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
buttons.push(
|
||||
window.modalView.createSuccessButton(
|
||||
"Save",
|
||||
this.submitCreateCollection.bind(this)
|
||||
)
|
||||
);
|
||||
advancedTableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
"new-collection-size",
|
||||
"Journal size",
|
||||
"",
|
||||
"The maximal size of a journal or datafile (in MB). Must be at least 1.",
|
||||
"",
|
||||
false,
|
||||
[
|
||||
{
|
||||
rule: Joi.string().allow('').optional().regex(/^[0-9]*$/),
|
||||
msg: "Must be a number."
|
||||
}
|
||||
]
|
||||
)
|
||||
);
|
||||
advancedTableContent.push(
|
||||
window.modalView.createSelectEntry(
|
||||
"new-collection-sync",
|
||||
"Sync",
|
||||
"",
|
||||
"Synchronize to disk before returning from a create or update of a document.",
|
||||
[{value: false, label: "No"}, {value: true, label: "Yes"}]
|
||||
)
|
||||
);
|
||||
advanced.header = "Advanced";
|
||||
advanced.content = advancedTableContent;
|
||||
window.modalView.show(
|
||||
"modalTable.ejs",
|
||||
"New Collection",
|
||||
buttons,
|
||||
tableContent,
|
||||
advanced
|
||||
);
|
||||
var callbackCoord2 = function(error, isCoordinator) {
|
||||
if (error) {
|
||||
arangoHelper.arangoError("DB","Could not check coordinator state");
|
||||
}
|
||||
else {
|
||||
var buttons = [],
|
||||
tableContent = [],
|
||||
advanced = {},
|
||||
advancedTableContent = [];
|
||||
|
||||
tableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
"new-collection-name",
|
||||
"Name",
|
||||
"",
|
||||
false,
|
||||
"",
|
||||
true,
|
||||
[
|
||||
{
|
||||
rule: Joi.string().regex(/^[a-zA-Z]/),
|
||||
msg: "Collection name must always start with a letter."
|
||||
},
|
||||
{
|
||||
rule: Joi.string().regex(/^[a-zA-Z0-9\-_]*$/),
|
||||
msg: 'Only symbols, "_" and "-" are allowed.'
|
||||
},
|
||||
{
|
||||
rule: Joi.string().required(),
|
||||
msg: "No collection name given."
|
||||
}
|
||||
]
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
window.modalView.createSelectEntry(
|
||||
"new-collection-type",
|
||||
"Type",
|
||||
"",
|
||||
"The type of the collection to create.",
|
||||
[{value: 2, label: "Document"}, {value: 3, label: "Edge"}]
|
||||
)
|
||||
);
|
||||
|
||||
if (isCoordinator) {
|
||||
tableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
"new-collection-shards",
|
||||
"Shards",
|
||||
"",
|
||||
"The number of shards to create. You cannot change this afterwards. "
|
||||
+ "Recommended: DBServers squared",
|
||||
"",
|
||||
true
|
||||
)
|
||||
);
|
||||
tableContent.push(
|
||||
window.modalView.createSelect2Entry(
|
||||
"new-collection-shardBy",
|
||||
"shardBy",
|
||||
"",
|
||||
"The keys used to distribute documents on shards. "
|
||||
+ "Type the key and press return to add it.",
|
||||
"_key",
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
buttons.push(
|
||||
window.modalView.createSuccessButton(
|
||||
"Save",
|
||||
this.submitCreateCollection.bind(this)
|
||||
)
|
||||
);
|
||||
advancedTableContent.push(
|
||||
window.modalView.createTextEntry(
|
||||
"new-collection-size",
|
||||
"Journal size",
|
||||
"",
|
||||
"The maximal size of a journal or datafile (in MB). Must be at least 1.",
|
||||
"",
|
||||
false,
|
||||
[
|
||||
{
|
||||
rule: Joi.string().allow('').optional().regex(/^[0-9]*$/),
|
||||
msg: "Must be a number."
|
||||
}
|
||||
]
|
||||
)
|
||||
);
|
||||
advancedTableContent.push(
|
||||
window.modalView.createSelectEntry(
|
||||
"new-collection-sync",
|
||||
"Sync",
|
||||
"",
|
||||
"Synchronize to disk before returning from a create or update of a document.",
|
||||
[{value: false, label: "No"}, {value: true, label: "Yes"}]
|
||||
)
|
||||
);
|
||||
advanced.header = "Advanced";
|
||||
advanced.content = advancedTableContent;
|
||||
window.modalView.show(
|
||||
"modalTable.ejs",
|
||||
"New Collection",
|
||||
buttons,
|
||||
tableContent,
|
||||
advanced
|
||||
);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
window.isCoordinator(callbackCoord2);
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
},
|
||||
|
||||
initialize: function() {
|
||||
this.collection.fetch({async:false});
|
||||
this.collection.fetch({async: true});
|
||||
},
|
||||
|
||||
checkBoxes: function (e) {
|
||||
|
|
|
@ -46,34 +46,55 @@
|
|||
window.location = window.location + '/' + encodeURIComponent(name);
|
||||
},
|
||||
|
||||
loadGraphViewer: function(graphName) {
|
||||
var edgeDefs = this.collection.get(graphName).get("edgeDefinitions");
|
||||
if (!edgeDefs || edgeDefs.length === 0) {
|
||||
// User Info
|
||||
return;
|
||||
}
|
||||
var adapterConfig = {
|
||||
type: "gharial",
|
||||
graphName: graphName,
|
||||
baseUrl: require("internal").arango.databasePrefix("/")
|
||||
};
|
||||
var width = $("#content").width() - 75;
|
||||
$("#content").html("");
|
||||
loadGraphViewer: function(graphName, refetch) {
|
||||
|
||||
var height = arangoHelper.calculateCenterDivHeight();
|
||||
|
||||
this.ui = new GraphViewerUI($("#content")[0], adapterConfig, width, height, {
|
||||
nodeShaper: {
|
||||
label: "_key",
|
||||
color: {
|
||||
type: "attribute",
|
||||
key: "_key"
|
||||
}
|
||||
var callback = function(error) {
|
||||
if (error) {
|
||||
arangoHelper.arangoError("","");
|
||||
}
|
||||
else {
|
||||
var edgeDefs = this.collection.get(graphName).get("edgeDefinitions");
|
||||
if (!edgeDefs || edgeDefs.length === 0) {
|
||||
// User Info
|
||||
return;
|
||||
}
|
||||
var adapterConfig = {
|
||||
type: "gharial",
|
||||
graphName: graphName,
|
||||
baseUrl: require("internal").arango.databasePrefix("/")
|
||||
};
|
||||
var width = $("#content").width() - 75;
|
||||
$("#content").html("");
|
||||
|
||||
}, true);
|
||||
var height = arangoHelper.calculateCenterDivHeight();
|
||||
|
||||
$('.contentDiv').height(height);
|
||||
this.ui = new GraphViewerUI($("#content")[0], adapterConfig, width, height, {
|
||||
nodeShaper: {
|
||||
label: "_key",
|
||||
color: {
|
||||
type: "attribute",
|
||||
key: "_key"
|
||||
}
|
||||
}
|
||||
|
||||
}, true);
|
||||
|
||||
$('.contentDiv').height(height);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
console.log(refetch);
|
||||
if (refetch) {
|
||||
console.log("WARUM");
|
||||
this.collection.fetch({
|
||||
success: function() {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
callback();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
@ -187,7 +208,7 @@
|
|||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
render: function(name, refetch) {
|
||||
|
||||
var self = this;
|
||||
this.collection.fetch({
|
||||
|
@ -225,6 +246,9 @@
|
|||
}
|
||||
});
|
||||
|
||||
if (name) {
|
||||
this.loadGraphViewer(name, refetch);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
@ -43,6 +43,12 @@
|
|||
}
|
||||
|
||||
var callback = function(error, username) {
|
||||
var callback2 = function(error) {
|
||||
if (error) {
|
||||
arangoHelper.arangoError("User", "Could not fetch user settings");
|
||||
}
|
||||
};
|
||||
|
||||
if (error) {
|
||||
$('#loginForm input').addClass("form-error");
|
||||
$('.wrong-credentials').show();
|
||||
|
@ -52,7 +58,7 @@
|
|||
$(this.el3).show();
|
||||
window.location.reload();
|
||||
$('#currentUser').text(username);
|
||||
this.collection.loadUserSettings();
|
||||
this.collection.loadUserSettings(callback2);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
this.renderFirst = false;
|
||||
|
||||
var select = ((window.location.hash).substr(1, (window.location.hash).length) + '-menu');
|
||||
if (select.indexOf('/') < -1) {
|
||||
if (select.indexOf('/') === -1) {
|
||||
this.selectMenuItem(select);
|
||||
}
|
||||
|
||||
|
|
|
@ -657,7 +657,7 @@
|
|||
importSelected: function (e) {
|
||||
var inputEditor = ace.edit("aqlEditor"),
|
||||
varsEditor = ace.edit("varsEditor");
|
||||
$.each(this.queries, function (k, v) {
|
||||
_.each(this.queries, function (v) {
|
||||
if ($('#' + e.currentTarget.id).val() === v.name) {
|
||||
inputEditor.setValue(v.value);
|
||||
|
||||
|
@ -677,12 +677,15 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
$.each(this.customQueries, function (k, v) {
|
||||
_.each(this.customQueries, function (v) {
|
||||
if ($('#' + e.currentTarget.id).val() === v.name) {
|
||||
inputEditor.setValue(v.value);
|
||||
|
||||
if (v.hasOwnProperty('parameter')) {
|
||||
if (v.parameter === '' || v.parameter === undefined) {
|
||||
if (v.parameter === '' ||
|
||||
v.parameter === undefined ||
|
||||
JSON.stringify(v.parameter) === '{}')
|
||||
{
|
||||
v.parameter = '{}';
|
||||
}
|
||||
varsEditor.setValue(v.parameter);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
initialize: function () {
|
||||
this.userCollection = this.options.userCollection;
|
||||
this.userCollection.fetch({async:false});
|
||||
this.userCollection.fetch({async: true});
|
||||
this.userCollection.bind("change:extra", this.render.bind(this));
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue