From: | Rahul Soshte <rahulsoshte360(at)gmail(dot)com> |
---|---|
To: | Khushboo Vashi <khushboo(dot)vashi(at)enterprisedb(dot)com> |
Cc: | Murtuza Zabuawala <murtuza(dot)zabuawala(at)enterprisedb(dot)com>, Joao De Almeida Pereira <jdealmeidapereira(at)pivotal(dot)io>, pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org> |
Subject: | Re: [pgAdmin4][Patch][Feature #1998] Appends .sql if extension not given when using 'save' or 'save as' feature |
Date: | 2018-04-16 12:20:40 |
Message-ID: | CAKyzeV3FnE3XEoSmKyoN=w0NCP7nXq0AiahUPkBOq2FAQgkWEg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgadmin-hackers |
Hi,
I have attached the WIP Patch.
Regards,
Rahul Soshte
On Mon, Apr 16, 2018 at 4:13 PM, Khushboo Vashi <
khushboo(dot)vashi(at)enterprisedb(dot)com> wrote:
> Hi Rahul,
>
> Instead of partial code, please send WIP patch, so I can look into this
> and help you.
>
> Thanks,
> Khushboo
>
>
> On Sat, Apr 14, 2018 at 4:51 PM, Rahul Soshte <rahulsoshte360(at)gmail(dot)com>
> wrote:
>
>> // read data from codemirror and write to file
>> _save_file_handler: function(e) {
>> var self = this,
>> _e = e,
>> data = {
>> 'file_name': decodeURI(e[0]),
>> 'file_content': self.gridView.query_tool_obj.getValue(),
>> 'file_type': e[1],
>> };
>> self.trigger(
>> 'pgadmin-sqleditor:loading-icon:show',
>> gettext('Saving the queries in the file...')
>> );
>>
>> // Make ajax call to save the data to file
>> $.ajax({
>> url: url_for('sqleditor.save_file'),
>> method: 'POST',
>> contentType: 'application/json',
>> data: JSON.stringify(data),
>> success: function(res) {
>> if (res.data.status) {
>> alertify.success(res.data.result);
>> alertify.success(gettext('File saved successfully.'));
>> self.gridView.current_file = res.data.result;
>> self.gridView.current_file_type = e[1];
>> self.setTitle(self.gridView.cu
>> rrent_file.replace(/^.*[\\\/]/g, ''), true);
>> // disable save button on file save
>> $('#btn-save').prop('disabled', true);
>>
>> On Sat, Apr 14, 2018 at 4:50 PM, Rahul Soshte <rahulsoshte360(at)gmail(dot)com>
>> wrote:
>>
>>>
>>>
>>>
>>> On Sat, Apr 14, 2018 at 4:49 PM, Rahul Soshte <rahulsoshte360(at)gmail(dot)com>
>>> wrote:
>>>
>>>> Also attaching my web/pgadmin/tools/sqleditor/static/sqleditor.js
>>>> my _save_file_handler code
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Sat, Apr 14, 2018 at 4:46 PM, Rahul Soshte <rahulsoshte360(at)gmail(dot)com
>>>> > wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I have been partially able to solve the problem as you can see in the
>>>>> image. When I select sql in format combobox then only the .sql extension is
>>>>> added.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> But another issue has arisen. Once the file is saved and now When I
>>>>> change the text in the CodeMirror , the save button is enabled and then
>>>>> when I click on it , a error message pops.The problem is whenever I try to
>>>>> save a file for the first time the code works ,but the 2nd time
>>>>> I try to save it,the code faulters.
>>>>>
>>>>> Error message is as follows:
>>>>>
>>>>> Traceback (most recent call last):
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/flask/app.py",
>>>>> line 1997, in __call__
>>>>> return self.wsgi_app(environ, start_response)
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/flask/app.py",
>>>>> line 1985, in wsgi_app
>>>>> response = self.handle_exception(e)
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/flask/app.py",
>>>>> line 1540, in handle_exception
>>>>> reraise(exc_type, exc_value, tb)
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/flask/app.py",
>>>>> line 1982, in wsgi_app
>>>>> response = self.full_dispach_request()
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/flask/app.py",
>>>>> line 1614, in full_dispatch_request
>>>>> rv = self.handle_user_exception(e)
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/flask/app.py",
>>>>> line 1517, in handle_user_exception
>>>>> reraise(exc_type, exc_value, tb)
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/flask/app.py",
>>>>> line 1612, in full_dispatch_request
>>>>> rv = self.dispatch_request()
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/flask/app.py",
>>>>> line 1598, in dispatch_request
>>>>> return self.view_functions[rule.endpoint](**req.view_args)
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/flask_login.py",
>>>>> line 792, in decorated_view
>>>>> return func(*args, **kwargs)
>>>>> File "/var/www/flask/pgadmin4/pgadmin4/web/pgadmin/tools/sqleditor/__init__.py",
>>>>> line 1314, in save_file
>>>>> 'file_path': file_path
>>>>> File "/var/www/flask/pgadmin4/pgadmin4/web/pgadmin/utils/ajax.py",
>>>>> line 61, in make_json_response
>>>>> separators=(',', ':')),
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/simplejson/__init__.py",
>>>>> line 399, in dumps
>>>>> **kw).encode(obj)
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/simplejson/encoder.py",
>>>>> line 291, in encode
>>>>> chunks = self.iterencode(o, _one_shot=True)
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/simplejson/encoder.py",
>>>>> line 373, in iterencode
>>>>> return _iterencode(o, 0)
>>>>> File "/var/www/flask/pgadmin4/pgadmin4/web/pgadmin/utils/ajax.py",
>>>>> line 30, in default
>>>>> return json.JSONEncoder.default(self, obj)
>>>>> File "/var/www/flask/pgadmin4/lib/python2.7/site-packages/simplejson/encoder.py",
>>>>> line 268, in default
>>>>> o.__class__.__name__)
>>>>> TypeError: Object of type Response is not JSON serializable
>>>>>
>>>>> I pass an array which contains the file_name and file_type in
>>>>> /pgadmin/misc/file_manager/static/js/file_manager.js
>>>>>
>>>>>
>>>>>
>>>>> Also I have done similar changes around line 678.
>>>>>
>>>>> Also in web/pgadmin/tools/sqleditor/__init__.py I have made the
>>>>> folllowing changes
>>>>>
>>>>>
>>>>>
>>>>> Also I have attached my web/pgadmin/tools/sqleditor/ut
>>>>> ils/save_file_query_to_file_utils.py
>>>>>
>>>>
>>>>
>>>
>>
>
Attachment | Content-Type | Size |
---|---|---|
WIPPatch.diff | text/x-patch | 12.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Identifier Anonymous | 2018-04-16 12:49:56 | Re: Updated Japanese translation for v3 |
Previous Message | Khushboo Vashi | 2018-04-16 10:43:52 | Re: [pgAdmin4][Patch][Feature #1998] Appends .sql if extension not given when using 'save' or 'save as' feature |