mirror of https://gitee.com/bigwinds/arangodb
added shellViewSpec, invertet order of logs showing up @ frontend
This commit is contained in:
parent
39a620e6d5
commit
f5c1fcd25f
|
@ -20,6 +20,7 @@
|
|||
});
|
||||
});
|
||||
this.totalAmount = response.totalAmount;
|
||||
console.log("parseamount: "+this.totalAmount);
|
||||
return myResponse;
|
||||
},
|
||||
|
||||
|
@ -33,8 +34,23 @@
|
|||
model: window.newArangoLog,
|
||||
|
||||
url: function() {
|
||||
var type, rtnStr, offset;
|
||||
var type, rtnStr, offset, size;
|
||||
offset = this.page * this.pagesize;
|
||||
console.log("page: "+this.page);
|
||||
console.log("amount: " + this.totalAmount);
|
||||
var inverseOffset = this.totalAmount % this.pagesize - (this.pagesize * this.page);
|
||||
if (inverseOffset < 0) {
|
||||
inverseOffset = 0;
|
||||
size = (this.totalAmount % this.pagesize);
|
||||
}
|
||||
else {
|
||||
size = this.pagesize;
|
||||
}
|
||||
|
||||
if (this.totalAmount === 0) {
|
||||
size = 1;
|
||||
}
|
||||
console.log("offset: " + inverseOffset);
|
||||
|
||||
if (this.upto) {
|
||||
type = 'upto';
|
||||
|
@ -42,7 +58,7 @@
|
|||
else {
|
||||
type = 'level';
|
||||
}
|
||||
rtnStr = '/_admin/log?'+type+'='+this.loglevel+'&size='+this.pagesize+'&offset='+offset;
|
||||
rtnStr = '/_admin/log?'+type+'='+this.loglevel+'&size='+size+'&offset='+inverseOffset;
|
||||
return rtnStr;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,91 +2,120 @@
|
|||
/*global Backbone, arangoHelper, $, window, templateEngine*/
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
window.LogsView = window.PaginationView.extend({
|
||||
window.LogsView = window.PaginationView.extend({
|
||||
|
||||
el: '#content',
|
||||
id: '#logContent',
|
||||
paginationDiv: "#logPaginationDiv",
|
||||
idPrefix: "logTable",
|
||||
el: '#content',
|
||||
id: '#logContent',
|
||||
paginationDiv: "#logPaginationDiv",
|
||||
idPrefix: "logTable",
|
||||
fetchedAmount: false,
|
||||
|
||||
initialize: function () {
|
||||
this.convertModelToJSON();
|
||||
},
|
||||
initialize: function () {
|
||||
this.convertModelToJSON();
|
||||
},
|
||||
|
||||
currentLoglevel: "logall",
|
||||
currentLoglevel: "logall",
|
||||
|
||||
events: {
|
||||
"click #arangoLogTabbar button": "setActiveLoglevel",
|
||||
"click #logTable_first": "firstPage",
|
||||
"click #logTable_last": "lastPage"
|
||||
},
|
||||
events: {
|
||||
"click #arangoLogTabbar button": "setActiveLoglevel",
|
||||
"click #logTable_first": "firstPage",
|
||||
"click #logTable_last": "lastPage"
|
||||
},
|
||||
|
||||
template: templateEngine.createTemplate("logsView.ejs"),
|
||||
tabbar: templateEngine.createTemplate("arangoTabbar.ejs"),
|
||||
table: templateEngine.createTemplate("arangoTable.ejs"),
|
||||
template: templateEngine.createTemplate("logsView.ejs"),
|
||||
tabbar: templateEngine.createTemplate("arangoTabbar.ejs"),
|
||||
table: templateEngine.createTemplate("arangoTable.ejs"),
|
||||
|
||||
tabbarElements: {
|
||||
id: "arangoLogTabbar",
|
||||
titles: [
|
||||
["Debug", "logdebug"],
|
||||
["Warning", "logwarning"],
|
||||
["Error", "logerror"],
|
||||
["Info", "loginfo"],
|
||||
["All", "logall"]
|
||||
]
|
||||
},
|
||||
tabbarElements: {
|
||||
id: "arangoLogTabbar",
|
||||
titles: [
|
||||
["Debug", "logdebug"],
|
||||
["Warning", "logwarning"],
|
||||
["Error", "logerror"],
|
||||
["Info", "loginfo"],
|
||||
["All", "logall"]
|
||||
]
|
||||
},
|
||||
|
||||
tableDescription: {
|
||||
id: "arangoLogTable",
|
||||
titles: ["Loglevel", "Date", "Message"],
|
||||
rows: []
|
||||
},
|
||||
tableDescription: {
|
||||
id: "arangoLogTable",
|
||||
titles: ["Loglevel", "Date", "Message"],
|
||||
rows: []
|
||||
},
|
||||
|
||||
convertedRows: null,
|
||||
convertedRows: null,
|
||||
|
||||
setActiveLoglevel: function (e) {
|
||||
$('.arangodb-tabbar').removeClass('arango-active-tab');
|
||||
setActiveLoglevel: function (e) {
|
||||
$('.arangodb-tabbar').removeClass('arango-active-tab');
|
||||
|
||||
if (this.currentLoglevel !== e.currentTarget.id) {
|
||||
this.currentLoglevel = e.currentTarget.id;
|
||||
this.convertModelToJSON();
|
||||
}
|
||||
},
|
||||
if (this.currentLoglevel !== e.currentTarget.id) {
|
||||
this.currentLoglevel = e.currentTarget.id;
|
||||
this.convertModelToJSON();
|
||||
}
|
||||
},
|
||||
|
||||
convertModelToJSON: function () {
|
||||
var self = this;
|
||||
var date;
|
||||
var rowsArray = [];
|
||||
this.collection = this.options[this.currentLoglevel];
|
||||
this.collection.fetch({
|
||||
success: function () {
|
||||
self.collection.each(function (model) {
|
||||
date = new Date(model.get('timestamp') * 1000);
|
||||
rowsArray.push([
|
||||
model.getLogStatus(),
|
||||
arangoHelper.formatDT(date),
|
||||
model.get('text')]);
|
||||
});
|
||||
self.tableDescription.rows = rowsArray;
|
||||
self.render();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
render: function () {
|
||||
$(this.el).html(this.template.render({}));
|
||||
$(this.id).html(this.tabbar.render({content: this.tabbarElements}));
|
||||
$(this.id).append(this.table.render({content: this.tableDescription}));
|
||||
$('#' + this.currentLoglevel).addClass('arango-active-tab');
|
||||
this.renderPagination();
|
||||
return this;
|
||||
},
|
||||
|
||||
rerender: function () {
|
||||
this.convertModelToJSON();
|
||||
initTotalAmount: function() {
|
||||
var self = this;
|
||||
this.collection = this.options[this.currentLoglevel];
|
||||
this.collection.fetch({
|
||||
data: $.param({ test: true}),
|
||||
success: function () {
|
||||
self.convertModelToJSON();
|
||||
}
|
||||
});
|
||||
});
|
||||
this.fetchedAmount = true;
|
||||
},
|
||||
|
||||
invertArray: function (array) {
|
||||
var rtnArr = [];
|
||||
var counter = 0;
|
||||
for (var i = array.length-1; i >= 0; i--) {
|
||||
rtnArr[counter] = array[i];
|
||||
counter++;
|
||||
}
|
||||
return rtnArr;
|
||||
},
|
||||
|
||||
convertModelToJSON: function () {
|
||||
if (!this.fetchedAmount) {
|
||||
this.initTotalAmount();
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var date;
|
||||
var rowsArray = [];
|
||||
this.collection = this.options[this.currentLoglevel];
|
||||
this.collection.fetch({
|
||||
success: function () {
|
||||
self.collection.each(function (model) {
|
||||
date = new Date(model.get('timestamp') * 1000);
|
||||
rowsArray.push([
|
||||
model.getLogStatus(),
|
||||
arangoHelper.formatDT(date),
|
||||
model.get('text')]);
|
||||
});
|
||||
self.tableDescription.rows = self.invertArray(rowsArray);
|
||||
//invert order
|
||||
self.render();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
render: function () {
|
||||
$(this.el).html(this.template.render({}));
|
||||
$(this.id).html(this.tabbar.render({content: this.tabbarElements}));
|
||||
$(this.id).append(this.table.render({content: this.tableDescription}));
|
||||
$('#' + this.currentLoglevel).addClass('arango-active-tab');
|
||||
this.renderPagination();
|
||||
return this;
|
||||
},
|
||||
|
||||
rerender: function () {
|
||||
this.convertModelToJSON();
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
|
|
|
@ -260,6 +260,7 @@
|
|||
"test/specs/views/newLogsViewSpec.js",
|
||||
"test/specs/views/notificationViewSpec.js",
|
||||
"test/specs/views/statisticBarViewSpec.js",
|
||||
"test/specs/views/shellViewSpec.js",
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true, browser: true*/
|
||||
/*global describe, beforeEach, afterEach, it, spyOn, expect*/
|
||||
/*global arangoHelper*/
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
describe("The shell view", function() {
|
||||
|
||||
var view, div;
|
||||
|
||||
beforeEach(function() {
|
||||
div = document.createElement("div");
|
||||
div.id = "content";
|
||||
document.body.appendChild(div);
|
||||
|
||||
view = new window.shellView({
|
||||
});
|
||||
|
||||
window.height = function() {
|
||||
return 400;
|
||||
}
|
||||
spyOn(window, "height");
|
||||
view.render();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
document.body.removeChild(div);
|
||||
});
|
||||
|
||||
it("assert the basics", function () {
|
||||
expect(view.resizing).toEqual(false);
|
||||
});
|
||||
|
||||
/*
|
||||
it("shortcut Ctrl+Z", function () {
|
||||
spyOn(view, "resize").andCallFake({
|
||||
});
|
||||
var press = jQuery.Event("keypress");
|
||||
press.ctrlKey = true;
|
||||
press.which = 90;
|
||||
//spyOn(window, "jqconsole");
|
||||
spyOn(jqconsole, "AbortPrompt");
|
||||
$("#replShell").focus();
|
||||
$("#replShell").trigger(press);
|
||||
});*/
|
||||
|
||||
|
||||
});
|
||||
}());
|
Loading…
Reference in New Issue