diff --git a/js/apps/system/aardvark/frontend/js/collections/arangoDocuments.js b/js/apps/system/aardvark/frontend/js/collections/arangoDocuments.js index 508cf0f638..100271f821 100644 --- a/js/apps/system/aardvark/frontend/js/collections/arangoDocuments.js +++ b/js/apps/system/aardvark/frontend/js/collections/arangoDocuments.js @@ -73,7 +73,7 @@ window.arangoDocuments = Backbone.Collection.extend({ if (this.documentsCount <= sortCount) { //sorted - myQueryVal = "FOR x in @@collection SORT x._key LIMIT @offset, @count RETURN x"; + myQueryVal = "FOR x in @@collection SORT TO_NUMBER(x._key) == 0 ? x._key : TO_NUMBER(x._key) LIMIT @offset, @count RETURN x"; } else { //not sorted @@ -132,23 +132,38 @@ window.arangoDocuments = Backbone.Collection.extend({ } else { filterString = ' FILTER' + filter.join(' && '); } - var body = { - //temp solution, waiting for api with paging possibility - query: "FOR u IN " + this.collectionID + - filterString + - " LIMIT 0," + self.documentsPerPage + - " RETURN u", - bindVars: bindValues, - options: { + + var sortCount = 10000; + + var sortString = ''; + if (this.documentsCount <= sortCount) { + //sorted + sortString = " SORT TO_NUMBER(u._key) == 0 ? u._key : TO_NUMBER(u._key)"; + } + var myQueryVal = "FOR u in @@collection" + filterString + sortString + + " LIMIT 0, @count RETURN u"; + + var myQuery = { + query: myQueryVal, + bindVars: { + "@collection": this.collectionID, + "count": this.documentsPerPage + }, + options: { fullCount: true - } + } }; + + $.each(bindValues, function(k,v) { + myQuery.bindVars[k] = v; + }); + $.ajax({ cache: false, type: 'POST', async: false, url: '/_api/cursor', - data: JSON.stringify(body), + data: JSON.stringify(myQuery), contentType: "application/json", success: function(data) { self.clearDocuments(); diff --git a/js/apps/system/aardvark/frontend/js/routers/router.js b/js/apps/system/aardvark/frontend/js/routers/router.js index 5535b9df2b..658313edce 100644 --- a/js/apps/system/aardvark/frontend/js/routers/router.js +++ b/js/apps/system/aardvark/frontend/js/routers/router.js @@ -19,6 +19,7 @@ $(document).ready(function() { "logs" : "logs", "about" : "about", "api" : "api", + "databases" : "databases", "application/installed/:key" : "applicationEdit", "application/available/:key" : "applicationInstall", "applications/installed" : "applicationsInstalled", @@ -31,6 +32,8 @@ $(document).ready(function() { initialize: function () { window.activeSession = new window.ArangoSession(); + window.arangoDatabase = new window.ArangoDatabase(); + window.arangoCollectionsStore = new window.arangoCollections(); window.arangoDocumentsStore = new window.arangoDocuments(); window.arangoDocumentStore = new window.arangoDocument(); @@ -189,6 +192,16 @@ $(document).ready(function() { this.naviView.selectMenuItem('api-menu'); }, + databases: function() { + if (!this.databaseView) { + this.databaseView = new window.databaseView({ + collection: arangoDatabase + }); + } + this.databaseView.render(); + this.naviView.selectMenuItem('database-menu'); + }, + about: function() { if (!this.aboutView) { this.aboutView = new window.aboutView(); diff --git a/js/common/tests/shell-graph.js b/js/common/tests/shell-graph.js index 7d0973cc6a..43ababc2c2 100644 --- a/js/common/tests/shell-graph.js +++ b/js/common/tests/shell-graph.js @@ -68,6 +68,21 @@ function GraphCreationSuite() { graph.drop(); }, + testDroppingIfVertexCollectionIsUsedTwice : function () { + var Graph = require("org/arangodb/graph").Graph, + graph_name = "UnitTestsCollectionGraph", + other_graph_name = "UnitTestsCollectionOtherGraph", + vertex = "UnitTestsCollectionVertex", + edges = "UnitTestsCollectionEdge", + other_edges = "UnitTestsCollectionOtherEdges", + graph = new Graph(graph_name, vertex, edges), + other_graph = new Graph(other_graph_name, vertex, other_edges); + + graph.drop(); + assertTrue(arangodb.db._collection("UnitTestsCollectionVertex") !== null); + other_graph.drop(); + }, + //////////////////////////////////////////////////////////////////////////////// /// @brief test: Find Graph //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/modules/org/arangodb/graph.js b/js/server/modules/org/arangodb/graph.js index 019dedd2b7..7494379501 100644 --- a/js/server/modules/org/arangodb/graph.js +++ b/js/server/modules/org/arangodb/graph.js @@ -555,7 +555,10 @@ Graph.prototype.drop = function (waitForSync) { gdb.remove(this._properties, true, waitForSync); - this._vertices.drop(); + if (gdb.byExample({vertices: this._vertices.name()}).count() === 0) { + this._vertices.drop(); + } + this._edges.drop(); };