2017-07-18 09:13:16 -05:00
|
|
|
define('pgadmin.settings',
|
2017-06-15 22:27:23 -05:00
|
|
|
[
|
2017-08-08 22:02:16 -05:00
|
|
|
'jquery', 'alertify', 'sources/pgadmin', 'underscore', 'backform',
|
2017-06-15 22:27:23 -05:00
|
|
|
'sources/gettext', 'sources/url_for', 'pgadmin.backform'
|
|
|
|
],
|
2016-06-14 09:01:15 -05:00
|
|
|
// This defines the Preference/Options Dialog for pgAdmin IV.
|
2017-06-15 22:27:23 -05:00
|
|
|
function($, alertify, pgAdmin, _, Backform, gettext, url_for) {
|
2016-06-14 09:01:15 -05:00
|
|
|
pgAdmin = pgAdmin || window.pgAdmin || {};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hmm... this module is already been initialized, we can refer to the old
|
|
|
|
* object from here.
|
|
|
|
*/
|
|
|
|
if (pgAdmin.Settings)
|
|
|
|
return pgAdmin.Settings;
|
|
|
|
|
|
|
|
pgAdmin.Settings = {
|
|
|
|
init: function() {
|
|
|
|
if (this.initialized)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.initialized = true;
|
|
|
|
},
|
|
|
|
// We will force unload method to not to save current layout
|
|
|
|
// and reload the window
|
|
|
|
show: function() {
|
|
|
|
var obj = this;
|
2017-03-28 14:21:49 -05:00
|
|
|
alertify.confirm(gettext('Reset layout'),
|
|
|
|
gettext('Are you sure you want to reset the current layout? This will cause the application to reload and any un-saved data will be lost.'),
|
2016-06-14 09:01:15 -05:00
|
|
|
function() {
|
2017-03-09 09:34:51 -06:00
|
|
|
var reloadingIndicator = $('<div id="reloading-indicator"></div>');
|
|
|
|
$('body').append(reloadingIndicator);
|
2016-06-14 09:01:15 -05:00
|
|
|
// Delete the record from database as well, then only reload page
|
|
|
|
$.ajax({
|
2017-06-15 22:27:23 -05:00
|
|
|
url: url_for('settings.reset_layout'),
|
2016-06-14 09:01:15 -05:00
|
|
|
type: 'DELETE',
|
|
|
|
async: false,
|
|
|
|
success: function() {
|
|
|
|
// Prevent saving layout on server for next page reload.
|
|
|
|
$(window).unbind('unload');
|
|
|
|
window.onbeforeunload = null;
|
|
|
|
// Now reload page
|
|
|
|
location.reload(true);
|
|
|
|
},
|
|
|
|
error: function() {
|
|
|
|
console.log('Something went wrong on server while resetting layout');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
// Do nothing as user canceled the operation.
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return pgAdmin.Settings;
|
|
|
|
});
|