mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-09 15:43:47 -06:00
Factor out client side settings functions into their own JS file,
and add additional variations for getting ints, floats and bools.
This commit is contained in:
parent
adeb2f9e84
commit
afb029e284
@ -50,29 +50,11 @@ function storeLayout(pane, $pane, paneState, paneOptions) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSetting(setting, defval) {
|
|
||||||
var value
|
|
||||||
$.ajaxSetup({
|
|
||||||
async: false
|
|
||||||
});
|
|
||||||
|
|
||||||
$.post("{{ url_for('settings.get') }}", { setting: setting, default: defval })
|
|
||||||
.done(function(data) {
|
|
||||||
value = data
|
|
||||||
});
|
|
||||||
|
|
||||||
$.ajaxSetup({
|
|
||||||
async: true
|
|
||||||
});
|
|
||||||
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the previous settings
|
// Get the previous settings
|
||||||
var sqlPaneSize = getSetting("Browser/SQLPane/Size", "250")
|
var sqlPaneSize = getIntegerSetting("Browser/SQLPane/Size", 250)
|
||||||
var sqlPaneClosed = (getSetting("Browser/SQLPane/Closed", "false") == "true" ? true : false)
|
var sqlPaneClosed = getBooleanSetting("Browser/SQLPane/Closed", false)
|
||||||
var browserPaneSize = getSetting("Browser/BrowserPane/Size", "250")
|
var browserPaneSize = getIntegerSetting("Browser/BrowserPane/Size", 250)
|
||||||
var browserPaneClosed = (getSetting("Browser/BrowserPane/Closed", "false") == "true" ? true : false)
|
var browserPaneClosed = getBooleanSetting("Browser/BrowserPane/Closed", false)
|
||||||
|
|
||||||
var layout
|
var layout
|
||||||
var layoutDefault = {
|
var layoutDefault = {
|
||||||
|
@ -1 +0,0 @@
|
|||||||
|
|
@ -42,7 +42,9 @@
|
|||||||
<script src="{{ url_for('static', filename='js/vendor/jquery-ui/jquery-ui.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/vendor/jquery-ui/jquery-ui.min.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/vendor/jquery-layout/jquery.layout.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/vendor/jquery-layout/jquery.layout.min.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/vendor/jquery-layout/plugins/jquery.layout.state.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/vendor/jquery-layout/plugins/jquery.layout.state.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
|
<script>
|
||||||
|
{% include "js/settings.js" %}
|
||||||
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
alertify.defaults.transition = "zoom";
|
alertify.defaults.transition = "zoom";
|
||||||
|
47
web/pgadmin/templates/js/settings.js
Normal file
47
web/pgadmin/templates/js/settings.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Get a setting from the server. Returns a string value
|
||||||
|
function getSetting(setting, defval) {
|
||||||
|
var value
|
||||||
|
$.ajaxSetup({
|
||||||
|
async: false
|
||||||
|
});
|
||||||
|
|
||||||
|
$.post("{{ url_for('settings.get') }}", { setting: setting, default: defval })
|
||||||
|
.done(function(data) {
|
||||||
|
value = data
|
||||||
|
});
|
||||||
|
|
||||||
|
$.ajaxSetup({
|
||||||
|
async: true
|
||||||
|
});
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a setting from the server. Returns a boolean value
|
||||||
|
function getBooleanSetting(setting, defval) {
|
||||||
|
return (getSetting(setting, defval) == "true" ? true : false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a setting from the server. Returns an integer value
|
||||||
|
function getIntegerSetting(setting, defval) {
|
||||||
|
return parseInt(getSetting(setting, defval))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a setting from the server. Returns an float value
|
||||||
|
function getFloatSetting(setting, defval) {
|
||||||
|
return parseFloat(getSetting(setting, defval))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store a single setting
|
||||||
|
function storeSetting(setting, value) {
|
||||||
|
$.post("{{ url_for('settings.store') }}", { setting: setting, value: value });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store a number of settings.
|
||||||
|
// settings is a javascript object containing values for settingX and valueX,
|
||||||
|
// along with a count value which equals the number of setting/value pairs.
|
||||||
|
// X is 1 based.
|
||||||
|
function storeSetting(settings) {
|
||||||
|
$.post("{{ url_for('settings.store') }}", settings);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user