mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:arangodb/ArangoDB into pipeline
This commit is contained in:
commit
f5b9f01a13
|
@ -255,6 +255,7 @@
|
|||
);
|
||||
if (!menu.disabled) {
|
||||
$('#subNavigationBar .bottom').children().last().bind('click', function () {
|
||||
$('#subNavigationBar .breadcrumb').html('');
|
||||
window.App.navigate(menu.route, {trigger: true});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -44,9 +44,6 @@
|
|||
},
|
||||
|
||||
saveCollectionQueries: function (callback) {
|
||||
if (this.activeUser === false || this.activeUser === null) {
|
||||
return false;
|
||||
}
|
||||
if (this.activeUser === false || this.activeUser === null) {
|
||||
this.activeUser = 'root';
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
<div class="pull-left">
|
||||
<button id="toggleQueries1" class="button-primary"><i class="fa fa-star-o"></i>Queries</button>
|
||||
<button id="toggleQueries2" class="button-primary" style="display: none"><i class="fa fa-star"></i>Queries</button>
|
||||
<button id="saveCurrentQuery" class="button-success"><i class="fa fa-save"></i>Save</button>
|
||||
<button id="createNewQuery" class="button-warning">New</button>
|
||||
<button id="updateCurrentQuery" class="button-success" style="display: none"><i class="fa fa-save"></i>Save</button>
|
||||
<button id="saveCurrentQuery" class="button-success"><i class="fa fa-save"></i>Save as</button>
|
||||
</div>
|
||||
|
||||
<div class="pull-right">
|
||||
|
@ -133,4 +135,4 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
</script>
|
||||
</script>
|
|
@ -262,6 +262,7 @@
|
|||
);
|
||||
if (!menu.disabled) {
|
||||
$(self.subEl + ' .bottom').children().last().bind('click', function (elem) {
|
||||
$('#subNavigationBar .breadcrumb').html('');
|
||||
self.activeSubMenu = menu;
|
||||
self.renderSubView(menu, elem);
|
||||
});
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
outputCounter: 0,
|
||||
|
||||
allowUpload: false,
|
||||
renderComplete: false,
|
||||
|
||||
customQueries: [],
|
||||
queries: [],
|
||||
|
@ -72,7 +73,9 @@
|
|||
'click .outputEditorWrapper .fa-close': 'closeResult',
|
||||
'click #toggleQueries1': 'toggleQueries',
|
||||
'click #toggleQueries2': 'toggleQueries',
|
||||
'click #createNewQuery': 'createAQL',
|
||||
'click #saveCurrentQuery': 'addAQL',
|
||||
'click #updateCurrentQuery': 'updateAQL',
|
||||
'click #exportQuery': 'exportCustomQueries',
|
||||
'click #importQuery': 'openImportDialog',
|
||||
'click #removeResults': 'removeResults',
|
||||
|
@ -219,11 +222,16 @@
|
|||
this.queryPreview.setValue('No query selected.', 1);
|
||||
this.deselect(this.queryPreview);
|
||||
} else {
|
||||
$('#updateCurrentQuery').hide();
|
||||
if (this.settings.aqlWidth === undefined) {
|
||||
$('.aqlEditorWrapper').first().width($(window).width() * 0.33);
|
||||
} else {
|
||||
$('.aqlEditorWrapper').first().width(this.settings.aqlWidth);
|
||||
}
|
||||
|
||||
if (localStorage.getItem('lastOpenQuery') !== 'undefined') {
|
||||
$('#updateCurrentQuery').show();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.settings.aqlWidth === undefined) {
|
||||
|
@ -236,7 +244,7 @@
|
|||
|
||||
var divs = [
|
||||
'aqlEditor', 'queryTable', 'previewWrapper', 'querySpotlight',
|
||||
'bindParamEditor', 'toggleQueries1', 'toggleQueries2',
|
||||
'bindParamEditor', 'toggleQueries1', 'toggleQueries2', 'createNewQuery',
|
||||
'saveCurrentQuery', 'querySize', 'executeQuery', 'switchTypes',
|
||||
'explainQuery', 'importQuery', 'exportQuery'
|
||||
];
|
||||
|
@ -318,17 +326,39 @@
|
|||
this.fillBindParamTable(this.getCustomQueryParameterByName(name));
|
||||
this.updateBindParams();
|
||||
|
||||
this.currentQuery = this.collection.findWhere({name: name});
|
||||
|
||||
if (this.currentQuery) {
|
||||
localStorage.setItem('lastOpenQuery', this.currentQuery.get('name'));
|
||||
}
|
||||
|
||||
$('#updateCurrentQuery').show();
|
||||
|
||||
// render a button to revert back to last query
|
||||
$('#lastQuery').remove();
|
||||
|
||||
$('#queryContent .arangoToolbarTop .pull-left')
|
||||
.append('<span id="lastQuery" class="clickable">Previous Query</span>');
|
||||
|
||||
this.breadcrumb(name);
|
||||
|
||||
$('#lastQuery').hide().fadeIn(500)
|
||||
.on('click', function () {
|
||||
$('#updateCurrentQuery').hide();
|
||||
self.aqlEditor.setValue(self.state.lastQuery.query, 1);
|
||||
self.fillBindParamTable(self.state.lastQuery.bindParam);
|
||||
self.updateBindParams();
|
||||
|
||||
self.collection.each(function (model) {
|
||||
model = model.toJSON();
|
||||
|
||||
if (model.value === self.state.lastQuery.query) {
|
||||
self.breadcrumb(model.name);
|
||||
} else {
|
||||
self.breadcrumb();
|
||||
}
|
||||
});
|
||||
|
||||
$('#lastQuery').fadeOut(500, function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
@ -515,31 +545,47 @@
|
|||
},
|
||||
|
||||
getCachedQueryAfterRender: function () {
|
||||
// get cached query if available
|
||||
var queryObject = this.getCachedQuery();
|
||||
var self = this;
|
||||
if (this.renderComplete === false) {
|
||||
// get cached query if available
|
||||
var queryObject = this.getCachedQuery();
|
||||
var self = this;
|
||||
|
||||
if (queryObject !== null && queryObject !== undefined && queryObject !== '') {
|
||||
this.aqlEditor.setValue(queryObject.query, 1);
|
||||
if (queryObject !== null && queryObject !== undefined && queryObject !== '') {
|
||||
this.aqlEditor.setValue(queryObject.query, 1);
|
||||
|
||||
// reset undo history for initial text value
|
||||
this.aqlEditor.getSession().setUndoManager(new ace.UndoManager());
|
||||
var queryName = localStorage.getItem('lastOpenQuery');
|
||||
|
||||
if (queryObject.parameter !== '' || queryObject !== undefined) {
|
||||
try {
|
||||
// then fill values into input boxes
|
||||
self.bindParamTableObj = JSON.parse(queryObject.parameter);
|
||||
if (queryName !== undefined && queryName !== 'undefined') {
|
||||
try {
|
||||
var query = this.collection.findWhere({name: queryName}).toJSON();
|
||||
if (query.value === queryObject.query) {
|
||||
self.breadcrumb(queryName);
|
||||
$('#updateCurrentQuery').show();
|
||||
}
|
||||
} catch (ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
var key;
|
||||
_.each($('#arangoBindParamTable input'), function (element) {
|
||||
key = $(element).attr('name');
|
||||
$(element).val(self.bindParamTableObj[key]);
|
||||
});
|
||||
// reset undo history for initial text value
|
||||
this.aqlEditor.getSession().setUndoManager(new ace.UndoManager());
|
||||
|
||||
// resave cached query
|
||||
self.setCachedQuery(self.aqlEditor.getValue(), JSON.stringify(self.bindParamTableObj));
|
||||
} catch (ignore) {}
|
||||
if (queryObject.parameter !== '' || queryObject !== undefined) {
|
||||
try {
|
||||
// then fill values into input boxes
|
||||
self.bindParamTableObj = JSON.parse(queryObject.parameter);
|
||||
|
||||
var key;
|
||||
_.each($('#arangoBindParamTable input'), function (element) {
|
||||
key = $(element).attr('name');
|
||||
$(element).val(self.bindParamTableObj[key]);
|
||||
});
|
||||
|
||||
// resave cached query
|
||||
self.setCachedQuery(self.aqlEditor.getValue(), JSON.stringify(self.bindParamTableObj));
|
||||
} catch (ignore) {}
|
||||
}
|
||||
}
|
||||
this.renderComplete = true;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -612,7 +658,6 @@
|
|||
this.fillSelectBoxes();
|
||||
this.makeResizeable();
|
||||
this.initQueryImport();
|
||||
this.getCachedQueryAfterRender();
|
||||
|
||||
// set height of editor wrapper
|
||||
$('.inputEditorWrapper').height($(window).height() / 10 * 5 + 25);
|
||||
|
@ -1119,6 +1164,41 @@
|
|||
}, 500);
|
||||
},
|
||||
|
||||
updateAQL: function () {
|
||||
var content = this.aqlEditor.getValue();
|
||||
var queryName = localStorage.getItem('lastOpenQuery');
|
||||
var query = this.collection.findWhere({name: queryName});
|
||||
if (query) {
|
||||
query.set('value', content);
|
||||
var callback = function (error) {
|
||||
if (error) {
|
||||
arangoHelper.arangoError('Query', 'Could not save query');
|
||||
} else {
|
||||
var self = this;
|
||||
arangoHelper.arangoNotification('Queries', 'Saved query ' + queryName);
|
||||
this.collection.fetch({
|
||||
success: function () {
|
||||
self.updateLocalQueries();
|
||||
}
|
||||
});
|
||||
}
|
||||
}.bind(this);
|
||||
this.collection.saveCollectionQueries(callback);
|
||||
}
|
||||
|
||||
this.refreshAQL(true);
|
||||
},
|
||||
|
||||
createAQL: function () {
|
||||
localStorage.setItem('lastOpenQuery', undefined);
|
||||
this.aqlEditor.setValue('');
|
||||
|
||||
this.refreshAQL(true);
|
||||
|
||||
this.breadcrumb();
|
||||
$('#updateCurrentQuery').hide();
|
||||
},
|
||||
|
||||
createCustomQueryModal: function () {
|
||||
var buttons = [];
|
||||
var tableContent = [];
|
||||
|
@ -1231,6 +1311,9 @@
|
|||
this.collection.fetch({
|
||||
success: function () {
|
||||
self.updateLocalQueries();
|
||||
$('#updateCurrentQuery').show();
|
||||
|
||||
self.breadcrumb(saveName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1239,6 +1322,18 @@
|
|||
window.modalView.hide();
|
||||
},
|
||||
|
||||
breadcrumb: function (name) {
|
||||
window.setTimeout(function () {
|
||||
if (name) {
|
||||
$('#subNavigationBar .breadcrumb').html(
|
||||
'Query: ' + name
|
||||
);
|
||||
} else {
|
||||
$('#subNavigationBar .breadcrumb').html('');
|
||||
}
|
||||
}, 50);
|
||||
},
|
||||
|
||||
verifyQueryAndParams: function () {
|
||||
var quit = false;
|
||||
|
||||
|
@ -1861,6 +1956,8 @@
|
|||
|
||||
this.collection.fetch({
|
||||
success: function () {
|
||||
self.getCachedQueryAfterRender();
|
||||
|
||||
// old storage method
|
||||
var item = localStorage.getItem('customQueries');
|
||||
if (item) {
|
||||
|
|
|
@ -53,6 +53,10 @@
|
|||
font-weight: 100;
|
||||
margin-left: 10px;
|
||||
|
||||
&.toolbarText {
|
||||
top: 1px;
|
||||
}
|
||||
|
||||
&.clickable {
|
||||
cursor: pointer;
|
||||
margin-left: 0;
|
||||
|
|
Loading…
Reference in New Issue