mirror of https://gitee.com/bigwinds/arangodb
#1198 - added caching for user defined queries
This commit is contained in:
parent
2d09d6d97e
commit
bf076c8255
|
@ -9,6 +9,7 @@
|
||||||
el: '#content',
|
el: '#content',
|
||||||
id: '#customsDiv',
|
id: '#customsDiv',
|
||||||
tabArray: [],
|
tabArray: [],
|
||||||
|
cachedQuery: "",
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.getAQL();
|
this.getAQL();
|
||||||
|
@ -140,6 +141,7 @@
|
||||||
|
|
||||||
clearInput: function () {
|
clearInput: function () {
|
||||||
var inputEditor = ace.edit("aqlEditor");
|
var inputEditor = ace.edit("aqlEditor");
|
||||||
|
this.setCachedQuery(inputEditor.getValue());
|
||||||
inputEditor.setValue('');
|
inputEditor.setValue('');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -178,6 +180,7 @@
|
||||||
table: templateEngine.createTemplate("arangoTable.ejs"),
|
table: templateEngine.createTemplate("arangoTable.ejs"),
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
|
var self = this;
|
||||||
this.$el.html(this.template.render({}));
|
this.$el.html(this.template.render({}));
|
||||||
this.$(this.id).html(this.table.render({content: this.tableDescription}));
|
this.$(this.id).html(this.table.render({content: this.tableDescription}));
|
||||||
// fill select box with # of results
|
// fill select box with # of results
|
||||||
|
@ -210,6 +213,12 @@
|
||||||
multiSelectAction: "forEach"
|
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) {
|
inputEditor.getSession().selection.on('changeCursor', function (e) {
|
||||||
var inputEditor = ace.edit("aqlEditor");
|
var inputEditor = ace.edit("aqlEditor");
|
||||||
var session = inputEditor.getSession();
|
var session = inputEditor.getSession();
|
||||||
|
@ -228,6 +237,8 @@
|
||||||
.attr("data-original-title", "Comment");
|
.attr("data-original-title", "Comment");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//cache query in localstorage
|
||||||
|
self.setCachedQuery(inputEditor.getValue());
|
||||||
});
|
});
|
||||||
$('#queryOutput').resizable({
|
$('#queryOutput').resizable({
|
||||||
handles: "s",
|
handles: "s",
|
||||||
|
@ -266,6 +277,17 @@
|
||||||
return this;
|
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 () {
|
initQueryImport: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.allowUpload = false;
|
self.allowUpload = false;
|
||||||
|
|
Loading…
Reference in New Issue