mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel
This commit is contained in:
commit
46c27efbfe
|
@ -14,8 +14,8 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
setPage: function(counter) {
|
setPage: function(counter) {
|
||||||
if (counter > this.getLastPageNumber()) {
|
if (counter >= this.getLastPageNumber()) {
|
||||||
this.page = this.getLastPageNumber();
|
this.page = this.getLastPageNumber()-1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (counter < 1) {
|
if (counter < 1) {
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.page = counter - 1;
|
this.page = counter - 1;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getLastPageNumber: function() {
|
getLastPageNumber: function() {
|
||||||
|
@ -42,7 +43,9 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
setToLast: function() {
|
setToLast: function() {
|
||||||
|
console.log("lpn " , this.getLastPageNumber());
|
||||||
this.setPage(this.getLastPageNumber());
|
this.setPage(this.getLastPageNumber());
|
||||||
|
console.log(this.getPage());
|
||||||
},
|
},
|
||||||
|
|
||||||
setToPrev: function() {
|
setToPrev: function() {
|
||||||
|
|
|
@ -91,7 +91,6 @@
|
||||||
query: query,
|
query: query,
|
||||||
bindVars: bindVars
|
bindVars: bindVars
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
cache: false,
|
cache: false,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
|
|
@ -105,7 +105,9 @@
|
||||||
collection: window.arangoCollectionsStore
|
collection: window.arangoCollectionsStore
|
||||||
});
|
});
|
||||||
window.arangoCollectionsStore.fetch();
|
window.arangoCollectionsStore.fetch();
|
||||||
window.documentsView = new window.DocumentsView();
|
window.documentsView = new window.DocumentsView({
|
||||||
|
collection: window.arangoDocumentsStore
|
||||||
|
});
|
||||||
window.documentView = new window.DocumentView({
|
window.documentView = new window.DocumentView({
|
||||||
collection: window.arangoDocumentStore
|
collection: window.arangoDocumentStore
|
||||||
});
|
});
|
||||||
|
@ -295,13 +297,13 @@
|
||||||
if (!window.documentsView) {
|
if (!window.documentsView) {
|
||||||
window.documentsView.initTable(colid, pageid);
|
window.documentsView.initTable(colid, pageid);
|
||||||
}
|
}
|
||||||
window.documentsView.collectionID = colid;
|
|
||||||
var type = arangoHelper.collectionApiType(colid);
|
var type = arangoHelper.collectionApiType(colid);
|
||||||
window.documentsView.colid = colid;
|
|
||||||
window.documentsView.pageid = pageid;
|
window.documentsView.pageid = pageid;
|
||||||
window.documentsView.type = type;
|
window.documentsView.type = type;
|
||||||
window.documentsView.render();
|
window.documentsView.setCollectionId(colid);
|
||||||
window.arangoDocumentsStore.getDocuments(colid, pageid);
|
window.arangoDocumentsStore.getDocuments(colid, pageid);
|
||||||
|
window.documentsView.render();
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
document: function (colid, docid) {
|
document: function (colid, docid) {
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */
|
||||||
|
/*global require, exports, Backbone, EJS, $, window, arangoHelper, templateEngine */
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
"use strict";
|
||||||
|
window.PaginationView = Backbone.View.extend({
|
||||||
|
|
||||||
|
// Subclasses need to overwrite this
|
||||||
|
collection : null,
|
||||||
|
paginationDiv : "",
|
||||||
|
idPrefix : "",
|
||||||
|
|
||||||
|
|
||||||
|
rerender : function () {},
|
||||||
|
|
||||||
|
jumpTo: function(page) {
|
||||||
|
var self = this;
|
||||||
|
this.collection.setPage(page);
|
||||||
|
this.rerender();
|
||||||
|
},
|
||||||
|
|
||||||
|
firstPage: function() {
|
||||||
|
this.jumpTo(1);
|
||||||
|
},
|
||||||
|
|
||||||
|
lastPage: function() {
|
||||||
|
this.jumpTo(this.collection.getLastPageNumber());
|
||||||
|
},
|
||||||
|
|
||||||
|
firstDocuments: function () {
|
||||||
|
this.jumpTo(1);
|
||||||
|
},
|
||||||
|
lastDocuments: function () {
|
||||||
|
this.jumpTo(this.collection.getLastPageNumber());
|
||||||
|
},
|
||||||
|
prevDocuments: function () {
|
||||||
|
this.jumpTo(this.collection.getPage() - 1);
|
||||||
|
},
|
||||||
|
nextDocuments: function () {
|
||||||
|
this.jumpTo(this.collection.getPage() + 1);
|
||||||
|
},
|
||||||
|
|
||||||
|
renderPagination: function () {
|
||||||
|
$(this.paginationDiv).html("");
|
||||||
|
var self = this;
|
||||||
|
var currentPage = this.collection.getPage();
|
||||||
|
var totalPages = this.collection.getLastPageNumber();
|
||||||
|
var target = $(this.paginationDiv),
|
||||||
|
options = {
|
||||||
|
page: currentPage,
|
||||||
|
lastPage: totalPages,
|
||||||
|
click: function(i) {
|
||||||
|
self.jumpTo(i);
|
||||||
|
options.page = i;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
target.html("");
|
||||||
|
target.pagination(options);
|
||||||
|
$(this.paginationDiv).prepend(
|
||||||
|
'<ul class="pre-pagi"><li><a id="' + this.idPrefix + '_first" class="pagination-button">'+
|
||||||
|
'<span><i class="fa fa-angle-double-left"/></span></a></li></ul>'
|
||||||
|
);
|
||||||
|
$(this.paginationDiv).append(
|
||||||
|
'<ul class="las-pagi"><li><a id="' + this.idPrefix + '_last" class="pagination-button">'+
|
||||||
|
'<span><i class="fa fa-angle-double-right"/></span></a></li></ul>'
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}());
|
|
@ -1,5 +1,5 @@
|
||||||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||||
/*global Backbone, EJS, $, window, arangoHelper, templateEngine, _, console */
|
/*global Backbone, $, window, arangoHelper, templateEngine, _*/
|
||||||
|
|
||||||
window.ApplicationsView = Backbone.View.extend({
|
window.ApplicationsView = Backbone.View.extend({
|
||||||
el: '#content',
|
el: '#content',
|
||||||
|
@ -43,7 +43,6 @@ window.ApplicationsView = Backbone.View.extend({
|
||||||
data: res.responseText,
|
data: res.responseText,
|
||||||
contentType: "application/json"
|
contentType: "application/json"
|
||||||
}).done(function(res) {
|
}).done(function(res) {
|
||||||
console.log(res);
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
async: false,
|
async: false,
|
||||||
|
|
|
@ -166,7 +166,7 @@
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// TODO: needs to be refactored. move getProperties into model
|
// needs to be refactored. move getProperties into model
|
||||||
var journalSize = this.model.collection.getProperties(this.model.get('id')).journalSize;
|
var journalSize = this.model.collection.getProperties(this.model.get('id')).journalSize;
|
||||||
journalSize = journalSize/(1024*1024);
|
journalSize = journalSize/(1024*1024);
|
||||||
tableContent.push(
|
tableContent.push(
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
"use strict";
|
"use strict";
|
||||||
window.DocumentsView = Backbone.View.extend({
|
window.DocumentsView = window.PaginationView.extend({
|
||||||
collectionID: 0,
|
collectionID: 0,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
documentsPerPage: 10,
|
documentsPerPage: 10,
|
||||||
totalPages: 1,
|
totalPages: 1,
|
||||||
filters : { "0" : true },
|
filters : { "0" : true },
|
||||||
filterId : 0,
|
filterId : 0,
|
||||||
|
paginationDiv : "#documentsToolbarF",
|
||||||
|
idPrefix : "documents",
|
||||||
|
|
||||||
addDocumentSwitch: true,
|
addDocumentSwitch: true,
|
||||||
|
|
||||||
|
@ -20,6 +22,12 @@
|
||||||
next: null
|
next: null
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setCollectionId : function (colid) {
|
||||||
|
this.collectionID = colid;
|
||||||
|
this.colid = colid;
|
||||||
|
this.collection.setCollection(colid);
|
||||||
|
},
|
||||||
|
|
||||||
alreadyClicked: false,
|
alreadyClicked: false,
|
||||||
|
|
||||||
el: '#content',
|
el: '#content',
|
||||||
|
@ -221,7 +229,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
getFilterContent: function () {
|
getFilterContent: function () {
|
||||||
var filters = [ ], bindValues = { };
|
var filters = [ ];
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
for (i in this.filters) {
|
for (i in this.filters) {
|
||||||
|
@ -236,23 +244,26 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#attribute_name' + i).val() !== ''){
|
if ($('#attribute_name' + i).val() !== ''){
|
||||||
filters.push(" u.`"+ $('#attribute_name'+i).val() + "`" +
|
filters.push({
|
||||||
$('#operator' + i).val() +
|
attribute : $('#attribute_name'+i).val(),
|
||||||
"@param" + i);
|
operator : $('#operator'+i).val(),
|
||||||
bindValues["param" + i] = value;
|
value : value
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return [filters, bindValues];
|
return filters;
|
||||||
},
|
},
|
||||||
|
|
||||||
sendFilter : function () {
|
sendFilter : function () {
|
||||||
var filterArray = this.getFilterContent();
|
var filters = this.getFilterContent();
|
||||||
var filters = filterArray[0];
|
|
||||||
var bindValues = filterArray[1];
|
|
||||||
this.addDocumentSwitch = false;
|
this.addDocumentSwitch = false;
|
||||||
window.documentsView.clearTable();
|
_.each(filters, function (f) {
|
||||||
window.arangoDocumentsStore.getFilteredDocuments(this.colid, 1, filters, bindValues);
|
this.collection.addFilter((f.attribute, f.operator, f.value));
|
||||||
|
})
|
||||||
|
this.clearTable();
|
||||||
|
this.collection.setToFirst();
|
||||||
|
this.collection.getDocuments();
|
||||||
|
|
||||||
//Hide first/last pagination
|
//Hide first/last pagination
|
||||||
$('#documents_last').css("visibility", "hidden");
|
$('#documents_last').css("visibility", "hidden");
|
||||||
|
@ -355,18 +366,7 @@
|
||||||
arangoHelper.arangoError('Creating edge failed');
|
arangoHelper.arangoError('Creating edge failed');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
firstDocuments: function () {
|
|
||||||
window.arangoDocumentsStore.getFirstDocuments();
|
|
||||||
},
|
|
||||||
lastDocuments: function () {
|
|
||||||
window.arangoDocumentsStore.getLastDocuments();
|
|
||||||
},
|
|
||||||
prevDocuments: function () {
|
|
||||||
window.arangoDocumentsStore.getPrevDocuments();
|
|
||||||
},
|
|
||||||
nextDocuments: function () {
|
|
||||||
window.arangoDocumentsStore.getNextDocuments();
|
|
||||||
},
|
|
||||||
remove: function (a) {
|
remove: function (a) {
|
||||||
this.target = a.currentTarget;
|
this.target = a.currentTarget;
|
||||||
var thiselement = a.currentTarget.parentElement;
|
var thiselement = a.currentTarget.parentElement;
|
||||||
|
@ -472,13 +472,14 @@
|
||||||
$(this.table).dataTable().fnClearTable();
|
$(this.table).dataTable().fnClearTable();
|
||||||
},
|
},
|
||||||
drawTable: function() {
|
drawTable: function() {
|
||||||
|
this.clearTable();
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (window.arangoDocumentsStore.models.length === 0) {
|
if (this.collection.size() === 0) {
|
||||||
$('.dataTables_empty').text('No documents');
|
$('.dataTables_empty').text('No documents');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$.each(window.arangoDocumentsStore.models, function(key, value) {
|
this.collection.each(function(value, key) {
|
||||||
var tempObj = {};
|
var tempObj = {};
|
||||||
$.each(value.attributes.content, function(k, v) {
|
$.each(value.attributes.content, function(k, v) {
|
||||||
if (! (k === '_id' || k === '_rev' || k === '_key')) {
|
if (! (k === '_id' || k === '_rev' || k === '_key')) {
|
||||||
|
@ -546,67 +547,34 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
arangoHelper.fixTooltips(".icon_arangodb, .arangoicon", "top");
|
arangoHelper.fixTooltips(".icon_arangodb, .arangoicon", "top");
|
||||||
|
this.drawTable();
|
||||||
|
this.renderPaginationElements();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
showLoadingState: function () {
|
|
||||||
$('.dataTables_empty').text('Loading...');
|
|
||||||
},
|
|
||||||
renderPagination: function (totalPages, checkFilter) {
|
|
||||||
$('#documentsToolbarF').html("");
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
var currentPage;
|
rerender : function () {
|
||||||
if (checkFilter) {
|
this.clearTable();
|
||||||
currentPage = window.arangoDocumentsStore.currentFilterPage;
|
this.collection.getDocuments();
|
||||||
}
|
this.drawTable();
|
||||||
else {
|
|
||||||
currentPage = JSON.parse(this.pageid);
|
|
||||||
}
|
|
||||||
var target = $('#documentsToolbarF'),
|
|
||||||
options = {
|
|
||||||
left: 2,
|
|
||||||
right: 2,
|
|
||||||
page: currentPage,
|
|
||||||
lastPage: totalPages,
|
|
||||||
click: function(i) {
|
|
||||||
options.page = i;
|
|
||||||
if (checkFilter) {
|
|
||||||
var filterArray = self.getFilterContent();
|
|
||||||
var filters = filterArray[0];
|
|
||||||
var bindValues = filterArray[1];
|
|
||||||
self.addDocumentSwitch = false;
|
|
||||||
|
|
||||||
window.documentsView.clearTable();
|
|
||||||
window.arangoDocumentsStore.getFilteredDocuments(self.colid, i, filters, bindValues);
|
|
||||||
|
|
||||||
//Hide first/last pagination
|
|
||||||
$('#documents_last').css("visibility", "hidden");
|
$('#documents_last').css("visibility", "hidden");
|
||||||
$('#documents_first').css("visibility", "hidden");
|
$('#documents_first').css("visibility", "hidden");
|
||||||
}
|
this.renderPagination()
|
||||||
else {
|
},
|
||||||
var windowLocationHash = '#collection/' + self.colid + '/documents/' + options.page;
|
|
||||||
window.location.hash = windowLocationHash;
|
renderPaginationElements: function () {
|
||||||
}
|
|
||||||
}
|
this.renderPagination();
|
||||||
};
|
|
||||||
target.pagination(options);
|
|
||||||
$('#documentsToolbarF').prepend(
|
|
||||||
'<ul class="pre-pagi"><li><a id="documents_first" class="pagination-button">'+
|
|
||||||
'<span><i class="fa fa-angle-double-left"/></span></a></li></ul>');
|
|
||||||
$('#documentsToolbarF').append(
|
|
||||||
'<ul class="las-pagi"><li><a id="documents_last" class="pagination-button">'+
|
|
||||||
'<span><i class="fa fa-angle-double-right"/></span></a></li></ul>');
|
|
||||||
var total = $('#totalDocuments');
|
var total = $('#totalDocuments');
|
||||||
if (total.length > 0) {
|
if (total.length > 0) {
|
||||||
total.html("Total: " + this.documentsCount + " documents");
|
total.html("Total: " + this.documentsCount + " documents");
|
||||||
} else {
|
} else {
|
||||||
$('#documentsToolbarFL').append(
|
$('#documentsToolbarFL').append(
|
||||||
'<a id="totalDocuments" class="totalDocuments">Total: ' + this.documentsCount +
|
'<a id="totalDocuments" class="totalDocuments">Total: ' + this.collection.getTotal() +
|
||||||
' document(s) </a>'
|
' document(s) </a>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
breadcrumb: function () {
|
breadcrumb: function () {
|
||||||
this.collectionName = window.location.hash.split("/")[1];
|
this.collectionName = window.location.hash.split("/")[1];
|
||||||
$('#transparentHeader').append(
|
$('#transparentHeader').append(
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
"use strict";
|
"use strict";
|
||||||
window.NewLogsView = Backbone.View.extend({
|
window.NewLogsView = window.PaginationView.extend({
|
||||||
el: '#content',
|
el: '#content',
|
||||||
id: '#logContent',
|
id: '#logContent',
|
||||||
|
paginationDiv : "#logPaginationDiv",
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.convertModelToJSON();
|
this.convertModelToJSON();
|
||||||
|
@ -80,22 +81,8 @@
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
jumpTo: function(page) {
|
rerender : function () {
|
||||||
var self = this;
|
this.convertModelToJSON();
|
||||||
this.activeCollection.setPage(page);
|
|
||||||
this.activeCollection.fetch({
|
|
||||||
success: function() {
|
|
||||||
self.convertModelToJSON();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
firstPage: function() {
|
|
||||||
this.jumpTo(1);
|
|
||||||
},
|
|
||||||
|
|
||||||
lastPage: function() {
|
|
||||||
this.jumpTo(this.activeCollection.getLastPageNumber());
|
|
||||||
},
|
},
|
||||||
|
|
||||||
renderPagination: function () {
|
renderPagination: function () {
|
||||||
|
|
|
@ -135,6 +135,7 @@
|
||||||
"frontend/js/collections/_paginatedCollection.js",
|
"frontend/js/collections/_paginatedCollection.js",
|
||||||
"frontend/js/collections/newArangoLogs.js",
|
"frontend/js/collections/newArangoLogs.js",
|
||||||
|
|
||||||
|
"frontend/js/views/_paginationView.js",
|
||||||
"frontend/js/views/modalView.js",
|
"frontend/js/views/modalView.js",
|
||||||
"frontend/js/views/navigationView.js",
|
"frontend/js/views/navigationView.js",
|
||||||
"frontend/js/views/notificationView.js",
|
"frontend/js/views/notificationView.js",
|
||||||
|
|
|
@ -47,12 +47,12 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getting documents", function() {
|
describe("getting documents", function() {
|
||||||
var colId, queryStart, queryEnd, sortStatement, filter1, filter2;
|
var colId, queryStart, queryEnd, sortStatement, filter1, filter2, ajaxCB;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
colId = "12345";
|
colId = "12345";
|
||||||
col.setPage(5);
|
col.setPage(5);
|
||||||
spyOn($, "ajax").andCallFake(function(obj) {
|
ajaxCB = function(obj) {
|
||||||
expect(_.isFunction(obj.success)).toBeTruthy();
|
expect(_.isFunction(obj.success)).toBeTruthy();
|
||||||
expect(obj.url).toEqual("/_api/collection/" + colId + "/count");
|
expect(obj.url).toEqual("/_api/collection/" + colId + "/count");
|
||||||
expect(obj.type).toEqual("GET");
|
expect(obj.type).toEqual("GET");
|
||||||
|
@ -60,6 +60,9 @@
|
||||||
obj.success({
|
obj.success({
|
||||||
count: 1000
|
count: 1000
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
spyOn($, "ajax").andCallFake(function(req) {
|
||||||
|
ajaxCB(req);
|
||||||
});
|
});
|
||||||
col.setCollection(colId);
|
col.setCollection(colId);
|
||||||
expect(col.getPage()).toEqual(1);
|
expect(col.getPage()).toEqual(1);
|
||||||
|
@ -69,10 +72,11 @@
|
||||||
filter1 = " FILTER x.`test` == @param0";
|
filter1 = " FILTER x.`test` == @param0";
|
||||||
filter2 = " && x.`second` < @param1";
|
filter2 = " && x.`second` < @param1";
|
||||||
queryEnd = " LIMIT @offset, @count RETURN x";
|
queryEnd = " LIMIT @offset, @count RETURN x";
|
||||||
|
$.ajax.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should start using first page", function() {
|
it("should start using first page", function() {
|
||||||
spyOn($, "ajax").andCallFake(function(req) {
|
ajaxCB = function(req) {
|
||||||
expect(req.url).toEqual('/_api/cursor');
|
expect(req.url).toEqual('/_api/cursor');
|
||||||
expect(req.type).toEqual("POST");
|
expect(req.type).toEqual("POST");
|
||||||
expect(req.cache).toEqual(false);
|
expect(req.cache).toEqual(false);
|
||||||
|
@ -84,14 +88,14 @@
|
||||||
expect(data.bindVars.offset).toEqual(0);
|
expect(data.bindVars.offset).toEqual(0);
|
||||||
expect(data.bindVars.count).toEqual(10);
|
expect(data.bindVars.count).toEqual(10);
|
||||||
expect(req.success).toEqual(jasmine.any(Function));
|
expect(req.success).toEqual(jasmine.any(Function));
|
||||||
});
|
};
|
||||||
col.getDocuments();
|
col.getDocuments();
|
||||||
expect($.ajax).toHaveBeenCalled();
|
expect($.ajax).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should react to page changes", function() {
|
it("should react to page changes", function() {
|
||||||
col.setPage(3);
|
col.setPage(3);
|
||||||
spyOn($, "ajax").andCallFake(function(req) {
|
ajaxCB = function(req) {
|
||||||
expect(req.url).toEqual('/_api/cursor');
|
expect(req.url).toEqual('/_api/cursor');
|
||||||
expect(req.type).toEqual("POST");
|
expect(req.type).toEqual("POST");
|
||||||
expect(req.cache).toEqual(false);
|
expect(req.cache).toEqual(false);
|
||||||
|
@ -103,14 +107,14 @@
|
||||||
expect(data.bindVars.offset).toEqual(20);
|
expect(data.bindVars.offset).toEqual(20);
|
||||||
expect(data.bindVars.count).toEqual(10);
|
expect(data.bindVars.count).toEqual(10);
|
||||||
expect(req.success).toEqual(jasmine.any(Function));
|
expect(req.success).toEqual(jasmine.any(Function));
|
||||||
});
|
};
|
||||||
col.getDocuments();
|
col.getDocuments();
|
||||||
expect($.ajax).toHaveBeenCalled();
|
expect($.ajax).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not sort large collections", function() {
|
it("should not sort large collections", function() {
|
||||||
col.setTotal(10000);
|
col.setTotal(10000);
|
||||||
spyOn($, "ajax").andCallFake(function(req) {
|
ajaxCB = function(req) {
|
||||||
expect(req.url).toEqual('/_api/cursor');
|
expect(req.url).toEqual('/_api/cursor');
|
||||||
expect(req.type).toEqual("POST");
|
expect(req.type).toEqual("POST");
|
||||||
expect(req.cache).toEqual(false);
|
expect(req.cache).toEqual(false);
|
||||||
|
@ -122,14 +126,14 @@
|
||||||
expect(data.bindVars.offset).toEqual(0);
|
expect(data.bindVars.offset).toEqual(0);
|
||||||
expect(data.bindVars.count).toEqual(10);
|
expect(data.bindVars.count).toEqual(10);
|
||||||
expect(req.success).toEqual(jasmine.any(Function));
|
expect(req.success).toEqual(jasmine.any(Function));
|
||||||
});
|
};
|
||||||
col.getDocuments();
|
col.getDocuments();
|
||||||
expect($.ajax).toHaveBeenCalled();
|
expect($.ajax).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to use one filter", function() {
|
it("should be able to use one filter", function() {
|
||||||
col.addFilter("test", "==", "foxx");
|
col.addFilter("test", "==", "foxx");
|
||||||
spyOn($, "ajax").andCallFake(function(req) {
|
ajaxCB = function(req) {
|
||||||
expect(req.url).toEqual('/_api/cursor');
|
expect(req.url).toEqual('/_api/cursor');
|
||||||
expect(req.type).toEqual("POST");
|
expect(req.type).toEqual("POST");
|
||||||
expect(req.cache).toEqual(false);
|
expect(req.cache).toEqual(false);
|
||||||
|
@ -142,7 +146,7 @@
|
||||||
expect(data.bindVars.count).toEqual(10);
|
expect(data.bindVars.count).toEqual(10);
|
||||||
expect(data.bindVars.param0).toEqual("foxx");
|
expect(data.bindVars.param0).toEqual("foxx");
|
||||||
expect(req.success).toEqual(jasmine.any(Function));
|
expect(req.success).toEqual(jasmine.any(Function));
|
||||||
});
|
};
|
||||||
col.getDocuments();
|
col.getDocuments();
|
||||||
expect($.ajax).toHaveBeenCalled();
|
expect($.ajax).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -150,7 +154,7 @@
|
||||||
it("should be able to use a second filter", function() {
|
it("should be able to use a second filter", function() {
|
||||||
col.addFilter("test", "==", "other");
|
col.addFilter("test", "==", "other");
|
||||||
col.addFilter("second", "<", "params");
|
col.addFilter("second", "<", "params");
|
||||||
spyOn($, "ajax").andCallFake(function(req) {
|
ajaxCB = function(req) {
|
||||||
expect(req.url).toEqual('/_api/cursor');
|
expect(req.url).toEqual('/_api/cursor');
|
||||||
expect(req.type).toEqual("POST");
|
expect(req.type).toEqual("POST");
|
||||||
expect(req.cache).toEqual(false);
|
expect(req.cache).toEqual(false);
|
||||||
|
@ -164,7 +168,7 @@
|
||||||
expect(data.bindVars.param0).toEqual("other");
|
expect(data.bindVars.param0).toEqual("other");
|
||||||
expect(data.bindVars.param1).toEqual("params");
|
expect(data.bindVars.param1).toEqual("params");
|
||||||
expect(req.success).toEqual(jasmine.any(Function));
|
expect(req.success).toEqual(jasmine.any(Function));
|
||||||
});
|
};
|
||||||
col.getDocuments();
|
col.getDocuments();
|
||||||
expect($.ajax).toHaveBeenCalled();
|
expect($.ajax).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -172,10 +176,10 @@
|
||||||
it("should insert the result of the query appropriatly", function() {
|
it("should insert the result of the query appropriatly", function() {
|
||||||
var f = {_id: "1/1", _rev: 2, _key: 1},
|
var f = {_id: "1/1", _rev: 2, _key: 1},
|
||||||
s = {_id: "1/2", _rev: 2, _key: 2},
|
s = {_id: "1/2", _rev: 2, _key: 2},
|
||||||
t = {_id: "1/3", _rev: 2, _key: 3}
|
t = {_id: "1/3", _rev: 2, _key: 3};
|
||||||
spyOn($, "ajax").andCallFake(function(req) {
|
ajaxCB = function(req) {
|
||||||
req.success({result: [f, s, t], extra: {fullCount: 3}});
|
req.success({result: [f, s, t], extra: {fullCount: 3}});
|
||||||
});
|
};
|
||||||
expect(col.getTotal()).not.toEqual(3);
|
expect(col.getTotal()).not.toEqual(3);
|
||||||
col.getDocuments();
|
col.getDocuments();
|
||||||
expect(col.getTotal()).toEqual(3);
|
expect(col.getTotal()).toEqual(3);
|
||||||
|
@ -287,6 +291,7 @@
|
||||||
expect(res).toEqual("Upload error");
|
expect(res).toEqual("Upload error");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
it("start succesful Upload mit XHR ready state = 4, " +
|
it("start succesful Upload mit XHR ready state = 4, " +
|
||||||
"XHR status = 201 and not parseable JSON", function () {
|
"XHR status = 201 and not parseable JSON", function () {
|
||||||
spyOn($, "ajax").andCallFake(function (opt) {
|
spyOn($, "ajax").andCallFake(function (opt) {
|
||||||
|
@ -305,6 +310,7 @@
|
||||||
var res = col.updloadDocuments("a");
|
var res = col.updloadDocuments("a");
|
||||||
expect(res).toEqual('Error: SyntaxError: Unable to parse JSON string');
|
expect(res).toEqual('Error: SyntaxError: Unable to parse JSON string');
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
|
|
||||||
var cols = [edgeCol, docCol, sysCol];
|
var cols = [edgeCol, docCol, sysCol];
|
||||||
spyOn($, "ajax").andCallFake(function (url) {
|
spyOn($, "ajax").andCallFake(function (url) {
|
||||||
console.log(url);
|
|
||||||
return {done:function() {}};
|
return {done:function() {}};
|
||||||
});
|
});
|
||||||
myStore = new window.arangoCollections(cols);
|
myStore = new window.arangoCollections(cols);
|
||||||
|
|
|
@ -60,22 +60,21 @@
|
||||||
_key: "123",
|
_key: "123",
|
||||||
_rev: "adasda",
|
_rev: "adasda",
|
||||||
_id: "paosdjfp1321"
|
_id: "paosdjfp1321"
|
||||||
}
|
},
|
||||||
|
shouldObject = {
|
||||||
var shouldObject = {
|
|
||||||
hello: 123,
|
hello: 123,
|
||||||
wrong: true
|
wrong: true
|
||||||
}
|
},
|
||||||
|
result = view.removeReadonlyKeys(object);
|
||||||
|
|
||||||
var result = view.removeReadonlyKeys(object);
|
|
||||||
expect(result).toEqual(shouldObject);
|
expect(result).toEqual(shouldObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should modify the breadcrumb", function () {
|
it("should modify the breadcrumb", function () {
|
||||||
var bar = document.createElement("div");
|
var bar = document.createElement("div"),
|
||||||
|
emptyBar = document.createElement("div");
|
||||||
bar.id = 'transparentHeader';
|
bar.id = 'transparentHeader';
|
||||||
|
|
||||||
var emptyBar = document.createElement("div");
|
|
||||||
|
|
||||||
view.breadcrumb();
|
view.breadcrumb();
|
||||||
expect(emptyBar).not.toBe(bar);
|
expect(emptyBar).not.toBe(bar);
|
||||||
|
|
Loading…
Reference in New Issue