1
0
Fork 0

#1198 - added caching for user defined queries

This commit is contained in:
Heiko Kernbach 2014-12-23 09:47:50 +01:00
parent 2d09d6d97e
commit bf076c8255
1 changed files with 22 additions and 0 deletions

View File

@ -9,6 +9,7 @@
el: '#content',
id: '#customsDiv',
tabArray: [],
cachedQuery: "",
initialize: function () {
this.getAQL();
@ -140,6 +141,7 @@
clearInput: function () {
var inputEditor = ace.edit("aqlEditor");
this.setCachedQuery(inputEditor.getValue());
inputEditor.setValue('');
},
@ -178,6 +180,7 @@
table: templateEngine.createTemplate("arangoTable.ejs"),
render: function () {
var self = this;
this.$el.html(this.template.render({}));
this.$(this.id).html(this.table.render({content: this.tableDescription}));
// fill select box with # of results
@ -210,6 +213,12 @@
multiSelectAction: "forEach"
});
//get cached query if available
var query = this.getCachedQuery();
if (query !== null && query !== undefined && query !== "") {
inputEditor.setValue(query);
}
inputEditor.getSession().selection.on('changeCursor', function (e) {
var inputEditor = ace.edit("aqlEditor");
var session = inputEditor.getSession();
@ -228,6 +237,8 @@
.attr("data-original-title", "Comment");
}
}
//cache query in localstorage
self.setCachedQuery(inputEditor.getValue());
});
$('#queryOutput').resizable({
handles: "s",
@ -266,6 +277,17 @@
return this;
},
getCachedQuery: function() {
var query = JSON.parse(localStorage.getItem("cachedQuery"));
return query;
},
setCachedQuery: function(query) {
if(typeof(Storage) !== "undefined") {
localStorage.setItem("cachedQuery", JSON.stringify(query));
}
},
initQueryImport: function () {
var self = this;
self.allowUpload = false;