mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-07 22:53:45 -06:00
Allow multiple settings to be stored at once to avoid multiple requests.
This commit is contained in:
parent
e995104000
commit
adeb2f9e84
@ -34,12 +34,19 @@
|
||||
|
||||
function storeLayout(pane, $pane, paneState, paneOptions) {
|
||||
state = layout.readState();
|
||||
$.post("{{ url_for('settings.store') }}", { setting: "Browser/SQL-Pane/Size", value: state.center.children.layout1.south.size });
|
||||
$.post("{{ url_for('settings.store') }}", { setting: "Browser/SQL-Pane/Hidden", value: state.center.children.layout1.south.initHidden });
|
||||
$.post("{{ url_for('settings.store') }}", { setting: "Browser/SQL-Pane/Closed", value: state.center.children.layout1.south.initClosed });
|
||||
$.post("{{ url_for('settings.store') }}", { setting: "Browser/Browser-Pane/Size", value: state.west.size });
|
||||
$.post("{{ url_for('settings.store') }}", { setting: "Browser/Browser-Pane/Hidden", value: state.west.initHidden });
|
||||
$.post("{{ url_for('settings.store') }}", { setting: "Browser/Browser-Pane/Closed", value: state.west.initClosed });
|
||||
settings = { setting1: "Browser/SQLPane/Size",
|
||||
value1: state.center.children.layout1.south.size,
|
||||
setting2: "Browser/SQLPane/Closed",
|
||||
value2: state.center.children.layout1.south.initClosed,
|
||||
setting3: "Browser/BrowserPane/Size",
|
||||
value3: state.west.size,
|
||||
setting4: "Browser/BrowserPane/Closed",
|
||||
value4: state.west.initClosed,
|
||||
count: 4
|
||||
}
|
||||
|
||||
$.post("{{ url_for('settings.store') }}", settings);
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@ -62,12 +69,10 @@ function getSetting(setting, defval) {
|
||||
}
|
||||
|
||||
// Get the previous settings
|
||||
var sqlPaneSize = getSetting("Browser/SQL-Pane/Size", "250")
|
||||
var sqlPaneHidden = (getSetting("Browser/SQL-Pane/Hidden", "false") == "true" ? true : false)
|
||||
var sqlPaneClosed = (getSetting("Browser/SQL-Pane/Closed", "false") == "true" ? true : false)
|
||||
var browserPaneSize = getSetting("Browser/Browser-Pane/Size", "250")
|
||||
var browserPaneHidden = (getSetting("Browser/Browser-Pane/Hidden", "false") == "true" ? true : false)
|
||||
var browserPaneClosed = (getSetting("Browser/Browser-Pane/Closed", "false") == "true" ? true : false)
|
||||
var sqlPaneSize = getSetting("Browser/SQLPane/Size", "250")
|
||||
var sqlPaneClosed = (getSetting("Browser/SQLPane/Closed", "false") == "true" ? true : false)
|
||||
var browserPaneSize = getSetting("Browser/BrowserPane/Size", "250")
|
||||
var browserPaneClosed = (getSetting("Browser/BrowserPane/Closed", "false") == "true" ? true : false)
|
||||
|
||||
var layout
|
||||
var layoutDefault = {
|
||||
@ -80,7 +85,6 @@ var layoutDefault = {
|
||||
center__onresize: "storeLayout",
|
||||
south__maskContents: true,
|
||||
south__size: sqlPaneSize,
|
||||
south__initHidden: sqlPaneHidden,
|
||||
south__initClosed: sqlPaneClosed,
|
||||
south__spacing_closed: 22,
|
||||
south__togglerLength_closed: 140,
|
||||
@ -92,7 +96,6 @@ var layoutDefault = {
|
||||
}],
|
||||
west__maskContents: true,
|
||||
west__size: browserPaneSize,
|
||||
west__initHidden: browserPaneHidden,
|
||||
west__initClosed: browserPaneClosed,
|
||||
west__spacing_closed: 22,
|
||||
west__togglerLength_closed: 140,
|
||||
|
@ -23,12 +23,16 @@ blueprint = Blueprint(MODULE_NAME, __name__, url_prefix='/' + MODULE_NAME)
|
||||
@blueprint.route("/store/<setting>/<value>", methods=['GET'])
|
||||
@login_required
|
||||
def store(setting=None, value=None):
|
||||
"""Store a configuration setting."""
|
||||
"""Store a configuration setting, or if this is a POST request and a
|
||||
count value is present, store multiple settings at once."""
|
||||
if request.method == 'POST':
|
||||
setting = request.form['setting']
|
||||
value = request.form['value']
|
||||
|
||||
store_setting(setting, value)
|
||||
if 'count' in request.form:
|
||||
for x in range(int(request.form['count'])):
|
||||
store_setting(request.form['setting%d' % (x+1)], request.form['value%d' % (x+1)])
|
||||
else:
|
||||
store_setting(request.form['setting'], request.form['value'])
|
||||
else:
|
||||
store_setting(setting, value)
|
||||
|
||||
return ''
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user