Add basic "DB picker" support, for views which allow multiple engines

i.e. whichever engine is "current" will determine where data comes from
This commit is contained in:
Lance Edgar 2019-07-09 22:14:12 -05:00
parent 0d7492f6be
commit 839f6affe2
3 changed files with 92 additions and 3 deletions

View file

@ -132,6 +132,21 @@
% endif
</div>
% if expose_db_picker is not Undefined and expose_db_picker:
<div class="level-item">
<p>DB:</p>
</div>
<div class="level-item">
${h.form(url('change_db_engine'))}
${h.csrf_token(request)}
${h.hidden('engine_type', value=master.engine_type_key)}
<div class="select">
${h.select('dbkey', db_picker_selected, db_picker_options, id='db-picker')}
</div>
${h.end_form()}
</div>
% endif
</div><!-- level-left -->
<div class="level-right">
@ -303,6 +318,13 @@
var session_timeout = ${request.get_session_timeout() or 'null'};
var logout_url = '${request.route_url('logout')}';
var noop_url = '${request.route_url('noop')}';
% if expose_db_picker is not Undefined and expose_db_picker:
$(function() {
$('#db-picker').change(function() {
$(this).parents('form:first').submit();
});
});
% endif
% if expose_theme_picker and request.has_perm('common.change_app_theme'):
$(function() {
$('#theme-picker').change(function() {