1
0
Fork 0

prep for import and export of aql queries

This commit is contained in:
Heiko Kernbach 2014-08-06 09:35:45 +02:00
parent 7b3baba2e9
commit 2d1c62903d
5 changed files with 72 additions and 8 deletions

View File

@ -22,7 +22,7 @@
activeUser: 0,
parse: function(response) {
parse: function(response) {
var self = this, toReturn;
_.each(response.result, function(val) {
@ -37,6 +37,32 @@
}
});
return toReturn;
},
saveQueries: function(data) {
var returnValue = false;
$.ajax({
cache: false,
type: "PATCH",
async: false,
url: "/_api/user/" + this.activeUser,
data: {
extra: {
queries: data
}
},
contentType: "application/json",
processData: false,
success: function() {
returnValue = true;
},
error: function() {
returnValue = false;
}
});
return returnValue;
}
});

View File

@ -169,7 +169,9 @@
query: function () {
if (!this.queryView) {
this.queryView = new window.queryView();
this.queryView = new window.queryView({
collection: this.queryCollection
});
}
this.queryView.render();
this.naviView.selectMenuItem('query-menu');

View File

@ -40,7 +40,7 @@
'click #arangoQueryTable .table-cell1': 'editCustomQuery',
'click #arangoQueryTable .table-cell2 a': 'deleteAQL',
'click #confirmQueryImport': 'importCustomQueries',
'click #confirmQueryExport': 'exportCustomQueries'
'click #confirmQueryExport': 'renderExportCustomQueries'
},
createCustomQueryModal: function(){
@ -177,6 +177,7 @@
if (typeof Storage) {
if (localStorage.getItem("querySize") > 0) {
querySize = parseInt(localStorage.getItem("querySize"), 10);
}
}
@ -265,6 +266,7 @@
$("#queryDiv").show();
$("#customsDiv").show();
this.renderExportCustomQueries();
this.initQueryImport();
this.switchTab('query-switch');
@ -282,14 +284,29 @@
},
importCustomQueries: function () {
var result;
var result, fetched, self = this;
if (this.allowUpload === true) {
result = true;
this.collection.fetch({
async: true,
success: function() {
result = self.collection.saveQueries(self.file);
}
});
console.log(result);
}
},
exportCustomQueries: function () {
renderExportCustomQueries: function () {
var toExport = [];
_.each(this.customQueries, function(value, key) {
toExport.push({name: value.name, value: value.value});
});
var data = "text/json;charset=utf-8,"+ encodeURIComponent(JSON.stringify(toExport));
$('#confirmQueryExport').html('<a id="downloadQueryAsJson" href="data:'+
data+'"download="queries.json">Export</a>');
},
deselect: function (editor) {
@ -342,11 +359,17 @@
});
this.customQueries = tempArray;
localStorage.setItem("customQueries", JSON.stringify(this.customQueries));
this.updateLocalQueries();
this.renderSelectboxes();
this.updateTable();
},
updateLocalQueries: function () {
localStorage.setItem("customQueries", JSON.stringify(this.customQueries));
this.renderExportCustomQueries();
},
saveAQL: function (e) {
e.stopPropagation();
var inputEditor = ace.edit("aqlEditor");
@ -389,11 +412,13 @@
window.modalView.hide();
localStorage.setItem("customQueries", JSON.stringify(this.customQueries));
this.updateLocalQueries();
this.renderSelectboxes();
$('#querySelect').val(saveName);
},
getSystemQueries: function () {
var self = this;
$.ajax({

View File

@ -42,6 +42,14 @@
}
}
.queryMethods {
button {
a {
color: white;
}
}
}
.query-toolbar {
@extend %toolbar;
}

View File

@ -4961,6 +4961,9 @@ pre.gv-object-view {
.editor-toolbar .arango-icon-disk {
margin-top: 1px; }
.queryMethods button a {
color: white; }
.aql-editor {
border-color: #a0a0a0;
border-left: 0 !important;