public inbox for [email protected]
help / color / mirror / Atom feed[pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default
6+ messages / 2 participants
[nested] [flat]
* [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default
@ 2021-04-07 07:47 Pradip Parkale <[email protected]>
2021-04-07 10:14 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Akshay Joshi <[email protected]>
0 siblings, 1 reply; 6+ messages in thread
From: Pradip Parkale @ 2021-04-07 07:47 UTC (permalink / raw)
To: pgadmin-hackers
Hi Hackers,
Please find the attached patch for #6325 - Tools > Storage Manager should
have file type as "All files" by default.
--
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation
Attachments:
[application/octet-stream] RM6325.patch (5.9K, 3-RM6325.patch)
download | inline diff:
diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js
index 67c4be047..562fca252 100644
--- a/web/pgadmin/misc/file_manager/static/js/utility.js
+++ b/web/pgadmin/misc/file_manager/static/js/utility.js
@@ -52,6 +52,19 @@ define([
});
};
+ var getFileFormat = function(data) {
+ // Get last selected file format
+ }
+ return $.ajax({
+ async: false,
+ cache: false,
+ url: url_for('settings.get_file_format_setting'),
+ data : $.extend({}, data),
+ dataType: 'json',
+ contentType: 'application/json; charset=utf-8',
+ });
+ };
+
// Set enable/disable state of list and grid view
var setViewButtonsFor = function(viewMode) {
if (viewMode == 'grid') {
@@ -1330,18 +1343,22 @@ define([
if (types_len > 0) {
var i = 0,
t,
- selected = false,
have_all_types = false;
let fileFormats = '';
+ let response = getFileFormat(config.options.allowed_file_types);
+ let lastSelectedFormat = response.responseJSON.info;
+
while (i < types_len) {
t = allowed_types[i];
- if (!selected && (types_len == 1 || t != '*')) {
- fileFormats += '<option value=' + t + ' selected>' + t + '</option>';
- selected = true;
+ if ((types_len == 1 || t != '*')) {
+ if(t === lastSelectedFormat)
+ fileFormats += '<option value=' + t + ' selected >' + t + '</option>';
+ else
+ fileFormats += '<option value=' + t + ' >' + t + '</option>';
have_all_types = (have_all_types || (t == '*'));
- } else {
- fileFormats += '<option value="' + t + '">' +
+ } else if ((lastSelectedFormat === '*')) {
+ fileFormats += '<option value="' + t + '" selected >' +
(t == '*' ? gettext('All Files') : t) + '</option>';
have_all_types = (have_all_types || (t == '*'));
}
@@ -1370,6 +1387,13 @@ define([
curr_path = $('.currentpath').val(),
user_input_file = null,
input_path = $('.storage_dialog #uploader .input-path').val();
+ config.options.selectedFormat = selected_val;
+ $.ajax({
+ url: url_for('settings.save_file_format_setting'),
+ type: 'POST',
+ contentType: 'application/json',
+ data: JSON.stringify(config.options),
+ });
if (curr_path.endsWith('/')) {
user_input_file = input_path.substring(curr_path.lastIndexOf('/')+1);
} else {
@@ -1928,10 +1952,15 @@ define([
getDetailView: function(path) {
if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
var allowed_types = this.config.options.allowed_file_types;
- var set_type = allowed_types[0];
- if (allowed_types[0] == '*') {
- set_type = allowed_types[1];
- }
+
+ let set_type;
+
+ let response = getFileFormat(this.config.options.allowed_file_types);
+ let lastSelectedFormat = response.responseJSON.info;
+ if (_.isUndefined(lastSelectedFormat))
+ set_type = allowed_types[0];
+ else
+ set_type = lastSelectedFormat;
getFolderInfo(path, set_type);
}
},
diff --git a/web/pgadmin/settings/__init__.py b/web/pgadmin/settings/__init__.py
index c49feea41..bc49721c0 100644
--- a/web/pgadmin/settings/__init__.py
+++ b/web/pgadmin/settings/__init__.py
@@ -57,7 +57,9 @@ class SettingsModule(PgAdminModule):
return [
'settings.store', 'settings.store_bulk', 'settings.reset_layout',
'settings.save_tree_state', 'settings.get_tree_state',
- 'settings.reset_tree_state'
+ 'settings.reset_tree_state',
+ 'settings.save_file_format_setting',
+ 'settings.get_file_format_setting'
]
@@ -218,3 +220,63 @@ def get_browser_tree_state():
return Response(response=data,
status=200,
mimetype="application/json")
+
+
+def _get_dialog_type(file_type):
+ """
+ This function return dialog type
+ :param file_type:
+ :return: dialog type.
+ """
+ if 'pgerd' in file_type:
+ return 'erd_file_type'
+ elif 'backup' in file_type:
+ return 'backup_file_type'
+ elif 'csv' in file_type:
+ return 'import_export_file_type'
+ else:
+ return 'sqleditor_file_format'
+
+
[email protected]("/save_file_format_setting/",
+ endpoint="save_file_format_setting",
+ methods=['POST'])
+@login_required
+def save_file_format_setting():
+ """
+ This function save the selected file format.
+ :return: save file format response
+ """
+ data = request.form if request.form else json.loads(
+ request.data.decode('utf-8'))
+ file_type = _get_dialog_type(data['allowed_file_types'])
+
+ store_setting(file_type, data['selectedFormat'])
+ return make_json_response(success=True,
+ info=data,
+ result=request.form)
+
+
[email protected]("/get_file_format_setting/",
+ endpoint="get_file_format_setting",
+ methods=['GET'])
+@login_required
+def get_file_format_setting():
+ """
+ This function return the last selected file format
+ :return: last selected file format
+ """
+ data = dict()
+ for k, v in request.args.items():
+ try:
+ data[k] = json.loads(v, encoding='utf-8')
+ except ValueError:
+ data[k] = v
+
+ file_type = _get_dialog_type(list(data.values()))
+
+ data = Setting.query.filter_by(
+ user_id=current_user.id, setting=file_type).first()
+
+ return make_json_response(success=True,
+ info=data.value)
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default
2021-04-07 07:47 [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
@ 2021-04-07 10:14 ` Akshay Joshi <[email protected]>
2021-04-07 11:14 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
0 siblings, 1 reply; 6+ messages in thread
From: Akshay Joshi @ 2021-04-07 10:14 UTC (permalink / raw)
To: Pradip Parkale <[email protected]>; +Cc: pgadmin-hackers
Hi Pradip
The issue is not fixed as per the expectation. Please fix and resend the
patch.
On Wed, Apr 7, 2021 at 1:17 PM Pradip Parkale <
[email protected]> wrote:
> Hi Hackers,
>
> Please find the attached patch for #6325 - Tools > Storage Manager should
> have file type as "All files" by default.
>
>
> --
> Thanks & Regards,
> Pradip Parkale
> Software Engineer | EnterpriseDB Corporation
>
--
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*
*Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default
2021-04-07 07:47 [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
2021-04-07 10:14 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Akshay Joshi <[email protected]>
@ 2021-04-07 11:14 ` Pradip Parkale <[email protected]>
2021-04-07 12:13 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Akshay Joshi <[email protected]>
0 siblings, 1 reply; 6+ messages in thread
From: Pradip Parkale @ 2021-04-07 11:14 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers
Hi Akshay,
Please find an updated patch. I missed few lines in my previous patch.
On Wed, Apr 7, 2021 at 3:45 PM Akshay Joshi <[email protected]>
wrote:
> Hi Pradip
>
> The issue is not fixed as per the expectation. Please fix and resend the
> patch.
>
> On Wed, Apr 7, 2021 at 1:17 PM Pradip Parkale <
> [email protected]> wrote:
>
>> Hi Hackers,
>>
>> Please find the attached patch for #6325 - Tools > Storage Manager should
>> have file type as "All files" by default.
>>
>>
>> --
>> Thanks & Regards,
>> Pradip Parkale
>> Software Engineer | EnterpriseDB Corporation
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Principal Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>
--
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation
Attachments:
[application/x-patch] RM6325_v2.patch (6.0K, 3-RM6325_v2.patch)
download | inline diff:
diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js
index 67c4be047..2766ee957 100644
--- a/web/pgadmin/misc/file_manager/static/js/utility.js
+++ b/web/pgadmin/misc/file_manager/static/js/utility.js
@@ -52,6 +52,18 @@ define([
});
};
+ var getFileFormat = function(data) {
+ // Get last selected file format
+ return $.ajax({
+ async: false,
+ cache: false,
+ url: url_for('settings.get_file_format_setting'),
+ data : $.extend({}, data),
+ dataType: 'json',
+ contentType: 'application/json; charset=utf-8',
+ });
+ };
+
// Set enable/disable state of list and grid view
var setViewButtonsFor = function(viewMode) {
if (viewMode == 'grid') {
@@ -1330,18 +1342,22 @@ define([
if (types_len > 0) {
var i = 0,
t,
- selected = false,
have_all_types = false;
let fileFormats = '';
+ let response = getFileFormat(config.options.allowed_file_types);
+ let lastSelectedFormat = response.responseJSON.info;
+
while (i < types_len) {
t = allowed_types[i];
- if (!selected && (types_len == 1 || t != '*')) {
- fileFormats += '<option value=' + t + ' selected>' + t + '</option>';
- selected = true;
+ if ((types_len == 1 || t != '*')) {
+ if(t === lastSelectedFormat)
+ fileFormats += '<option value=' + t + ' selected >' + t + '</option>';
+ else
+ fileFormats += '<option value=' + t + ' >' + t + '</option>';
have_all_types = (have_all_types || (t == '*'));
- } else {
- fileFormats += '<option value="' + t + '">' +
+ } else if ((lastSelectedFormat === '*')) {
+ fileFormats += '<option value="' + t + '" selected >' +
(t == '*' ? gettext('All Files') : t) + '</option>';
have_all_types = (have_all_types || (t == '*'));
}
@@ -1370,6 +1386,13 @@ define([
curr_path = $('.currentpath').val(),
user_input_file = null,
input_path = $('.storage_dialog #uploader .input-path').val();
+ config.options.selectedFormat = selected_val;
+ $.ajax({
+ url: url_for('settings.save_file_format_setting'),
+ type: 'POST',
+ contentType: 'application/json',
+ data: JSON.stringify(config.options),
+ });
if (curr_path.endsWith('/')) {
user_input_file = input_path.substring(curr_path.lastIndexOf('/')+1);
} else {
@@ -1928,10 +1951,15 @@ define([
getDetailView: function(path) {
if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
var allowed_types = this.config.options.allowed_file_types;
- var set_type = allowed_types[0];
- if (allowed_types[0] == '*') {
- set_type = allowed_types[1];
- }
+
+ let set_type;
+
+ let response = getFileFormat(this.config.options.allowed_file_types);
+ let lastSelectedFormat = response.responseJSON.info;
+ if (_.isUndefined(lastSelectedFormat))
+ set_type = allowed_types[0];
+ else
+ set_type = lastSelectedFormat;
getFolderInfo(path, set_type);
}
},
diff --git a/web/pgadmin/settings/__init__.py b/web/pgadmin/settings/__init__.py
index c49feea41..9723f9af9 100644
--- a/web/pgadmin/settings/__init__.py
+++ b/web/pgadmin/settings/__init__.py
@@ -57,7 +57,9 @@ class SettingsModule(PgAdminModule):
return [
'settings.store', 'settings.store_bulk', 'settings.reset_layout',
'settings.save_tree_state', 'settings.get_tree_state',
- 'settings.reset_tree_state'
+ 'settings.reset_tree_state',
+ 'settings.save_file_format_setting',
+ 'settings.get_file_format_setting'
]
@@ -218,3 +220,66 @@ def get_browser_tree_state():
return Response(response=data,
status=200,
mimetype="application/json")
+
+
+def _get_dialog_type(file_type):
+ """
+ This function return dialog type
+ :param file_type:
+ :return: dialog type.
+ """
+ if 'pgerd' in file_type:
+ return 'erd_file_type'
+ elif 'backup' in file_type:
+ return 'backup_file_type'
+ elif 'csv' in file_type and 'txt' in file_type:
+ return 'import_export_file_type'
+ elif 'csv' in file_type and 'txt' not in file_type:
+ return 'storage_manager_file_type'
+ else:
+ return 'sqleditor_file_format'
+
+
[email protected]("/save_file_format_setting/",
+ endpoint="save_file_format_setting",
+ methods=['POST'])
+@login_required
+def save_file_format_setting():
+ """
+ This function save the selected file format.
+ :return: save file format response
+ """
+ data = request.form if request.form else json.loads(
+ request.data.decode('utf-8'))
+ file_type = _get_dialog_type(data['allowed_file_types'])
+
+ store_setting(file_type, data['selectedFormat'])
+ return make_json_response(success=True,
+ info=data,
+ result=request.form)
+
+
[email protected]("/get_file_format_setting/",
+ endpoint="get_file_format_setting",
+ methods=['GET'])
+@login_required
+def get_file_format_setting():
+ """
+ This function return the last selected file format
+ :return: last selected file format
+ """
+ data = dict()
+ for k, v in request.args.items():
+ try:
+ data[k] = json.loads(v, encoding='utf-8')
+ except ValueError:
+ data[k] = v
+
+ file_type = _get_dialog_type(list(data.values()))
+
+ data = Setting.query.filter_by(
+ user_id=current_user.id, setting=file_type).first()
+ if data is None:
+ return make_json_response(success=True, info='*')
+ else:
+ return make_json_response(success=True, info=data.value)
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default
2021-04-07 07:47 [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
2021-04-07 10:14 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Akshay Joshi <[email protected]>
2021-04-07 11:14 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
@ 2021-04-07 12:13 ` Akshay Joshi <[email protected]>
2021-04-07 13:48 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
0 siblings, 1 reply; 6+ messages in thread
From: Akshay Joshi @ 2021-04-07 12:13 UTC (permalink / raw)
To: Pradip Parkale <[email protected]>; +Cc: pgadmin-hackers
Hi Pradip
I am getting the error with Python 3.9. It is working fine with Python 3.8.
Please fix the issue on Python 3.9 and resend the patch again
On Wed, Apr 7, 2021 at 4:44 PM Pradip Parkale <
[email protected]> wrote:
> Hi Akshay,
>
> Please find an updated patch. I missed few lines in my previous patch.
>
> On Wed, Apr 7, 2021 at 3:45 PM Akshay Joshi <[email protected]>
> wrote:
>
>> Hi Pradip
>>
>> The issue is not fixed as per the expectation. Please fix and resend the
>> patch.
>>
>> On Wed, Apr 7, 2021 at 1:17 PM Pradip Parkale <
>> [email protected]> wrote:
>>
>>> Hi Hackers,
>>>
>>> Please find the attached patch for #6325 - Tools > Storage Manager
>>> should have file type as "All files" by default.
>>>
>>>
>>> --
>>> Thanks & Regards,
>>> Pradip Parkale
>>> Software Engineer | EnterpriseDB Corporation
>>>
>>
>>
>> --
>> *Thanks & Regards*
>> *Akshay Joshi*
>> *pgAdmin Hacker | Principal Software Architect*
>> *EDB Postgres <http://edbpostgres.com>*
>>
>> *Mobile: +91 976-788-8246*
>>
>
>
> --
> Thanks & Regards,
> Pradip Parkale
> Software Engineer | EnterpriseDB Corporation
>
--
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*
*Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default
2021-04-07 07:47 [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
2021-04-07 10:14 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Akshay Joshi <[email protected]>
2021-04-07 11:14 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
2021-04-07 12:13 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Akshay Joshi <[email protected]>
@ 2021-04-07 13:48 ` Pradip Parkale <[email protected]>
2021-04-08 06:58 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Akshay Joshi <[email protected]>
0 siblings, 1 reply; 6+ messages in thread
From: Pradip Parkale @ 2021-04-07 13:48 UTC (permalink / raw)
To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers
Hi Akshay,
Please find the attached patch. I have added the check to handle the
exception for Python 3.9.
On Wed, Apr 7, 2021 at 5:43 PM Akshay Joshi <[email protected]>
wrote:
> Hi Pradip
>
> I am getting the error with Python 3.9. It is working fine with Python
> 3.8. Please fix the issue on Python 3.9 and resend the patch again
>
> On Wed, Apr 7, 2021 at 4:44 PM Pradip Parkale <
> [email protected]> wrote:
>
>> Hi Akshay,
>>
>> Please find an updated patch. I missed few lines in my previous patch.
>>
>> On Wed, Apr 7, 2021 at 3:45 PM Akshay Joshi <
>> [email protected]> wrote:
>>
>>> Hi Pradip
>>>
>>> The issue is not fixed as per the expectation. Please fix and resend the
>>> patch.
>>>
>>> On Wed, Apr 7, 2021 at 1:17 PM Pradip Parkale <
>>> [email protected]> wrote:
>>>
>>>> Hi Hackers,
>>>>
>>>> Please find the attached patch for #6325 - Tools > Storage Manager
>>>> should have file type as "All files" by default.
>>>>
>>>>
>>>> --
>>>> Thanks & Regards,
>>>> Pradip Parkale
>>>> Software Engineer | EnterpriseDB Corporation
>>>>
>>>
>>>
>>> --
>>> *Thanks & Regards*
>>> *Akshay Joshi*
>>> *pgAdmin Hacker | Principal Software Architect*
>>> *EDB Postgres <http://edbpostgres.com>*
>>>
>>> *Mobile: +91 976-788-8246*
>>>
>>
>>
>> --
>> Thanks & Regards,
>> Pradip Parkale
>> Software Engineer | EnterpriseDB Corporation
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Principal Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>
--
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation
Attachments:
[application/octet-stream] RM6325_v3.patch (6.1K, 3-RM6325_v3.patch)
download | inline diff:
diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js
index 67c4be047..2766ee957 100644
--- a/web/pgadmin/misc/file_manager/static/js/utility.js
+++ b/web/pgadmin/misc/file_manager/static/js/utility.js
@@ -52,6 +52,18 @@ define([
});
};
+ var getFileFormat = function(data) {
+ // Get last selected file format
+ return $.ajax({
+ async: false,
+ cache: false,
+ url: url_for('settings.get_file_format_setting'),
+ data : $.extend({}, data),
+ dataType: 'json',
+ contentType: 'application/json; charset=utf-8',
+ });
+ };
+
// Set enable/disable state of list and grid view
var setViewButtonsFor = function(viewMode) {
if (viewMode == 'grid') {
@@ -1330,18 +1342,22 @@ define([
if (types_len > 0) {
var i = 0,
t,
- selected = false,
have_all_types = false;
let fileFormats = '';
+ let response = getFileFormat(config.options.allowed_file_types);
+ let lastSelectedFormat = response.responseJSON.info;
+
while (i < types_len) {
t = allowed_types[i];
- if (!selected && (types_len == 1 || t != '*')) {
- fileFormats += '<option value=' + t + ' selected>' + t + '</option>';
- selected = true;
+ if ((types_len == 1 || t != '*')) {
+ if(t === lastSelectedFormat)
+ fileFormats += '<option value=' + t + ' selected >' + t + '</option>';
+ else
+ fileFormats += '<option value=' + t + ' >' + t + '</option>';
have_all_types = (have_all_types || (t == '*'));
- } else {
- fileFormats += '<option value="' + t + '">' +
+ } else if ((lastSelectedFormat === '*')) {
+ fileFormats += '<option value="' + t + '" selected >' +
(t == '*' ? gettext('All Files') : t) + '</option>';
have_all_types = (have_all_types || (t == '*'));
}
@@ -1370,6 +1386,13 @@ define([
curr_path = $('.currentpath').val(),
user_input_file = null,
input_path = $('.storage_dialog #uploader .input-path').val();
+ config.options.selectedFormat = selected_val;
+ $.ajax({
+ url: url_for('settings.save_file_format_setting'),
+ type: 'POST',
+ contentType: 'application/json',
+ data: JSON.stringify(config.options),
+ });
if (curr_path.endsWith('/')) {
user_input_file = input_path.substring(curr_path.lastIndexOf('/')+1);
} else {
@@ -1928,10 +1951,15 @@ define([
getDetailView: function(path) {
if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
var allowed_types = this.config.options.allowed_file_types;
- var set_type = allowed_types[0];
- if (allowed_types[0] == '*') {
- set_type = allowed_types[1];
- }
+
+ let set_type;
+
+ let response = getFileFormat(this.config.options.allowed_file_types);
+ let lastSelectedFormat = response.responseJSON.info;
+ if (_.isUndefined(lastSelectedFormat))
+ set_type = allowed_types[0];
+ else
+ set_type = lastSelectedFormat;
getFolderInfo(path, set_type);
}
},
diff --git a/web/pgadmin/settings/__init__.py b/web/pgadmin/settings/__init__.py
index c49feea41..91ff3204f 100644
--- a/web/pgadmin/settings/__init__.py
+++ b/web/pgadmin/settings/__init__.py
@@ -57,7 +57,9 @@ class SettingsModule(PgAdminModule):
return [
'settings.store', 'settings.store_bulk', 'settings.reset_layout',
'settings.save_tree_state', 'settings.get_tree_state',
- 'settings.reset_tree_state'
+ 'settings.reset_tree_state',
+ 'settings.save_file_format_setting',
+ 'settings.get_file_format_setting'
]
@@ -218,3 +220,66 @@ def get_browser_tree_state():
return Response(response=data,
status=200,
mimetype="application/json")
+
+
+def _get_dialog_type(file_type):
+ """
+ This function return dialog type
+ :param file_type:
+ :return: dialog type.
+ """
+ if 'pgerd' in file_type:
+ return 'erd_file_type'
+ elif 'backup' in file_type:
+ return 'backup_file_type'
+ elif 'csv' in file_type and 'txt' in file_type:
+ return 'import_export_file_type'
+ elif 'csv' in file_type and 'txt' not in file_type:
+ return 'storage_manager_file_type'
+ else:
+ return 'sqleditor_file_format'
+
+
[email protected]("/save_file_format_setting/",
+ endpoint="save_file_format_setting",
+ methods=['POST'])
+@login_required
+def save_file_format_setting():
+ """
+ This function save the selected file format.
+ :return: save file format response
+ """
+ data = request.form if request.form else json.loads(
+ request.data.decode('utf-8'))
+ file_type = _get_dialog_type(data['allowed_file_types'])
+
+ store_setting(file_type, data['selectedFormat'])
+ return make_json_response(success=True,
+ info=data,
+ result=request.form)
+
+
[email protected]("/get_file_format_setting/",
+ endpoint="get_file_format_setting",
+ methods=['GET'])
+@login_required
+def get_file_format_setting():
+ """
+ This function return the last selected file format
+ :return: last selected file format
+ """
+ data = dict()
+ for k, v in request.args.items():
+ try:
+ data[k] = json.loads(v, encoding='utf-8')
+ except (ValueError, TypeError, KeyError):
+ data[k] = v
+
+ file_type = _get_dialog_type(list(data.values()))
+
+ data = Setting.query.filter_by(
+ user_id=current_user.id, setting=file_type).first()
+ if data is None:
+ return make_json_response(success=True, info='*')
+ else:
+ return make_json_response(success=True, info=data.value)
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default
2021-04-07 07:47 [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
2021-04-07 10:14 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Akshay Joshi <[email protected]>
2021-04-07 11:14 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
2021-04-07 12:13 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Akshay Joshi <[email protected]>
2021-04-07 13:48 ` Re: [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
@ 2021-04-08 06:58 ` Akshay Joshi <[email protected]>
0 siblings, 0 replies; 6+ messages in thread
From: Akshay Joshi @ 2021-04-08 06:58 UTC (permalink / raw)
To: Pradip Parkale <[email protected]>; +Cc: pgadmin-hackers
Thanks, patch applied.
On Wed, Apr 7, 2021 at 7:19 PM Pradip Parkale <
[email protected]> wrote:
> Hi Akshay,
>
> Please find the attached patch. I have added the check to handle the
> exception for Python 3.9.
>
>
> On Wed, Apr 7, 2021 at 5:43 PM Akshay Joshi <[email protected]>
> wrote:
>
>> Hi Pradip
>>
>> I am getting the error with Python 3.9. It is working fine with Python
>> 3.8. Please fix the issue on Python 3.9 and resend the patch again
>>
>> On Wed, Apr 7, 2021 at 4:44 PM Pradip Parkale <
>> [email protected]> wrote:
>>
>>> Hi Akshay,
>>>
>>> Please find an updated patch. I missed few lines in my previous patch.
>>>
>>> On Wed, Apr 7, 2021 at 3:45 PM Akshay Joshi <
>>> [email protected]> wrote:
>>>
>>>> Hi Pradip
>>>>
>>>> The issue is not fixed as per the expectation. Please fix and resend
>>>> the patch.
>>>>
>>>> On Wed, Apr 7, 2021 at 1:17 PM Pradip Parkale <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi Hackers,
>>>>>
>>>>> Please find the attached patch for #6325 - Tools > Storage Manager
>>>>> should have file type as "All files" by default.
>>>>>
>>>>>
>>>>> --
>>>>> Thanks & Regards,
>>>>> Pradip Parkale
>>>>> Software Engineer | EnterpriseDB Corporation
>>>>>
>>>>
>>>>
>>>> --
>>>> *Thanks & Regards*
>>>> *Akshay Joshi*
>>>> *pgAdmin Hacker | Principal Software Architect*
>>>> *EDB Postgres <http://edbpostgres.com>*
>>>>
>>>> *Mobile: +91 976-788-8246*
>>>>
>>>
>>>
>>> --
>>> Thanks & Regards,
>>> Pradip Parkale
>>> Software Engineer | EnterpriseDB Corporation
>>>
>>
>>
>> --
>> *Thanks & Regards*
>> *Akshay Joshi*
>> *pgAdmin Hacker | Principal Software Architect*
>> *EDB Postgres <http://edbpostgres.com>*
>>
>> *Mobile: +91 976-788-8246*
>>
>
>
> --
> Thanks & Regards,
> Pradip Parkale
> Software Engineer | EnterpriseDB Corporation
>
--
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*
*Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2021-04-08 06:58 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 07:47 [pgAdmin][RM6325]:Tools > Storage Manager should have file type as "All files" by default Pradip Parkale <[email protected]>
2021-04-07 10:14 ` Akshay Joshi <[email protected]>
2021-04-07 11:14 ` Pradip Parkale <[email protected]>
2021-04-07 12:13 ` Akshay Joshi <[email protected]>
2021-04-07 13:48 ` Pradip Parkale <[email protected]>
2021-04-08 06:58 ` Akshay Joshi <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox