public inbox for [email protected]
help / color / mirror / Atom feedFrom: Nikhil Mohite <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin][RM3794]:Allow User to Change Database Connection from an Open Query Tool Tab
Date: Wed, 21 Oct 2020 16:45:13 +0530
Message-ID: <CAOBg0AMeE1=Mv17m=AjSnkB-GzXiQvtOfH4zttTAVbiyNJ=45A@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDfa1oHTdieuGjAU9OsdTzeZhh7Uz4dWQ9fjzUkJHhuGrg@mail.gmail.com>
References: <CAOBg0AM=b7hfJjTJAXu=wGkKHEsV_zoZpSO-QU6Z-G9p2wVF0w@mail.gmail.com>
<CANxoLDdUj_RKgQWFE6F7noEJbDz+P_3-njnn2mf10TSa0V9wdw@mail.gmail.com>
<CAOBg0AOHJT4wUC3AXjHV2aorF8_OpP3erah8yhyi2eKwn6F_Sg@mail.gmail.com>
<CANxoLDca1AtBKrnW8rshWqsd_iwHEfXV2PeqCnUQnoEonfs52g@mail.gmail.com>
<CAOBg0APx0+twWJah7RaE9ZmDsBXUnbagikR7NyG3fUD21GYd8Q@mail.gmail.com>
<CANxoLDdkvhUE3pohPPgyyz2tYwYej+VAkxUE-e09JBxd3Aeh0w@mail.gmail.com>
<CAOBg0ANsr6eE_4+6ApKYhj5m5N+ChbQgj_yWgufh0KqiZrovsw@mail.gmail.com>
<CANxoLDfn8cm8YiK8e1rUWRZ+jU7AAr1krdwQb-giDg-B3ATzsQ@mail.gmail.com>
<CAKKotZRSjJTKzcappNGZ0yJiuiwxBfBxoex+6fXF3RzdbEKDBg@mail.gmail.com>
<CA+OCxoyfycZAT5Wc6L72HCXKrPTgkj9jcR4FgO6TKZN5KvZ_Ow@mail.gmail.com>
<CANxoLDcZYnhT0xw5SLs8VCS60LPFLW_OU+NEzcNs747uhv_a=A@mail.gmail.com>
<CAOBg0AMU_yTSrVU6Z+Q0Je4PuE3ncALdDA3Q=QUjQeXiWuHS6w@mail.gmail.com>
<CANxoLDd1M0kY4jM5Me=cUpejFt5cAQV9Uz8Sv6i7C3LgYJOLJg@mail.gmail.com>
<CAOBg0AOnEOhFV-8-M2J=PRk3KUta8nagLt-RB3pQO2JG3EEckg@mail.gmail.com>
<CANxoLDfa1oHTdieuGjAU9OsdTzeZhh7Uz4dWQ9fjzUkJHhuGrg@mail.gmail.com>
Hi Akshay,
I have fixed the review comments, PFA the updated patch for the same.
Regards,
Nikhil Mohite.
On Wed, Oct 21, 2020 at 2:55 PM Akshay Joshi <[email protected]>
wrote:
> Hi Nikhil
>
> Following are the review comments:
>
> - Connect to any server from the browser tree. Open the query tool and
> then open the new connection dialog. Click on the "OK" button without
> changing any field. It shows the popup for "Change connection" which should
> not be raised because the server is the same.
> - In the above scenario, if you click on the Yes button it is showing
> a duplicate entry for the same server.
> - The server name is not getting changed when we connect to any
> other server from the new connection. Changes needed in alertify message,
> tab title, and a combo box.
> - Remove the "." from the "Change connection." title.
> - Change the string "Change connection will lose all non committed
> changes for current connection, do you want to continue?" to "*By
> changing the connection you will lose all your unsaved data for the current
> connection.*
> *Do you want to continue?*"
>
> Please fix the above changes and send the patch again.
>
> On Wed, Oct 21, 2020 at 11:08 AM Nikhil Mohite <
> [email protected]> wrote:
>
>> Hi Akshay,
>>
>> I have updated the existing implementation as per suggestions.
>> 1. Show servers in server groups in the dropdown.
>> 2. Current selected connection in the new connection dropdown is now
>> highlighted as selected.
>> 3. Notification to the user before the change connection action.
>> 4. If we connect to the server through a new connection dialog, the tree
>> will use the same connection and it will not create a new connection.
>> (In earlier implementation it was asking for the password even we have
>> connected from a new connection dialog.)
>>
>> PFA patch
>>
>> Regards,
>> Nikhil Mohite.
>>
>> On Thu, Oct 8, 2020 at 11:39 AM Akshay Joshi <
>> [email protected]> wrote:
>>
>>> Thanks, patch applied.
>>>
>>> On Wed, Oct 7, 2020 at 12:11 PM Nikhil Mohite <
>>> [email protected]> wrote:
>>>
>>>> Hi Akshay,
>>>>
>>>> I checked the implementation and found 2 locations which I missed in
>>>> the last patch to remove async: False.
>>>> I have removed all occurrences of async: False now also added missing
>>>> loader in required places.
>>>>
>>>> PFA updated the patch for the same.
>>>>
>>>> Regards,
>>>> Nikhil Mohite.
>>>>
>>>> On Tue, Oct 6, 2020 at 6:19 PM Akshay Joshi <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi Nikhil
>>>>>
>>>>> Please verify and remove async = false wherever possible.
>>>>>
>>>>> On Tue, Oct 6, 2020 at 5:24 PM Dave Page <[email protected]>
>>>>> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, Oct 6, 2020 at 12:51 PM Murtuza Zabuawala <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Hi Akshay,
>>>>>>>
>>>>>>> We have used aysnc=False in most ajax calls with this feature, It is
>>>>>>> causing UI hang in case of slow server response.
>>>>>>> You can try adding a time.sleep() call at the python side response
>>>>>>> and check the UI hang, I think we should avoid sync calls as much as
>>>>>>> possible.
>>>>>>>
>>>>>>
>>>>>> I consider a sync ajax call to be a bug.
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Regards,
>>>>>>> Murtuza Zabuawala
>>>>>>> *EDB*
>>>>>>> *POWER TO POSTGRES*
>>>>>>> https://www.edbpostgres.com
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Oct 1, 2020 at 1:31 PM Akshay Joshi <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Thanks, patch applied.
>>>>>>>>
>>>>>>>> On Thu, Oct 1, 2020 at 10:42 AM Nikhil Mohite <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> Hi Akshay,
>>>>>>>>>
>>>>>>>>> I have resolved the sonarQube issues, PFA updated patch for the
>>>>>>>>> same.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Regards,
>>>>>>>>> Nikhil Mohite.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Sep 29, 2020 at 11:31 AM Akshay Joshi <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Hi Nikhil
>>>>>>>>>>
>>>>>>>>>> Your patch introduces 1 new Bug and 13 new code smells, please
>>>>>>>>>> fix those and resend the patch.
>>>>>>>>>>
>>>>>>>>>> On Mon, Sep 28, 2020 at 7:31 PM Nikhil Mohite <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi Akshay,
>>>>>>>>>>>
>>>>>>>>>>> I have resolved code conflict issues and sonarqube issues.
>>>>>>>>>>> PFA updated patch.
>>>>>>>>>>>
>>>>>>>>>>> Regards,
>>>>>>>>>>> Nikhil Mohite.
>>>>>>>>>>>
>>>>>>>>>>> On Mon, Sep 28, 2020 at 5:58 PM Akshay Joshi <
>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hi Nikhil
>>>>>>>>>>>>
>>>>>>>>>>>> The patch is not applying, rebase, and send it again. Please
>>>>>>>>>>>> check your code should not create any new SonarQube issues.
>>>>>>>>>>>>
>>>>>>>>>>>> On Mon, Sep 28, 2020 at 11:20 AM Nikhil Mohite <
>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hi Akshay,
>>>>>>>>>>>>>
>>>>>>>>>>>>> I have resolved all the review comments and also updated the
>>>>>>>>>>>>> test cases as per the new implementation.
>>>>>>>>>>>>>
>>>>>>>>>>>>> PFA updated patch.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Mon, Sep 21, 2020 at 5:24 PM Akshay Joshi <
>>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi Nikhil
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Following are the initial review comments:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> - Open View/Edit data on any table and click on the same
>>>>>>>>>>>>>> database connection and then click on the Execute button. Got
>>>>>>>>>>>>>> "get_primary_keys() takes 1 positional argument but 2 were given" error.
>>>>>>>>>>>>>> - In my opinion, we should hide the option to change the
>>>>>>>>>>>>>> database connection for View/Edit Data.
>>>>>>>>>>>>>> - If the user clicks on the same database connection
>>>>>>>>>>>>>> multiple times then no need to change the backend connection and
>>>>>>>>>>>>>> transaction id. Add validation at the backend, no action required in this
>>>>>>>>>>>>>> case.
>>>>>>>>>>>>>> - The role option is missing from the "connect to server"
>>>>>>>>>>>>>> dialog.
>>>>>>>>>>>>>> - The Password field should not be there on the "connect
>>>>>>>>>>>>>> to server" dialog. Sometimes we saved the password so asking a password
>>>>>>>>>>>>>> every time is not correct. Check the pgAdmin 3 behavior.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Code review still remains.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Thu, Sep 17, 2020 at 4:15 PM Nikhil Mohite <
>>>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi Team,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Regarding RM-3794
>>>>>>>>>>>>>>> <https://redmine.postgresql.org/issues/3794; allow the user
>>>>>>>>>>>>>>> to change the database connection from an open query tool:
>>>>>>>>>>>>>>> I have implemented the feature and also added documentation
>>>>>>>>>>>>>>> for it.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> PFA patch.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> *Thanks & Regards,*
>>>>>>>>>>>>>>> *Nikhil Mohite*
>>>>>>>>>>>>>>> *Software Engineer.*
>>>>>>>>>>>>>>> *EDB Postgres* <https://www.enterprisedb.com/;
>>>>>>>>>>>>>>> *Mob.No: +91-7798364578.*
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> *Thanks & Regards*
>>>>>>>>>>>>>> *Akshay Joshi*
>>>>>>>>>>>>>> *pgAdmin Hacker | Sr. Software Architect*
>>>>>>>>>>>>>> *EDB Postgres <http://edbpostgres.com>*
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> *Mobile: +91 976-788-8246*
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> *Thanks & Regards*
>>>>>>>>>>>> *Akshay Joshi*
>>>>>>>>>>>> *pgAdmin Hacker | Sr. Software Architect*
>>>>>>>>>>>> *EDB Postgres <http://edbpostgres.com>*
>>>>>>>>>>>>
>>>>>>>>>>>> *Mobile: +91 976-788-8246*
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> *Thanks & Regards*
>>>>>>>>>> *Akshay Joshi*
>>>>>>>>>> *pgAdmin Hacker | Sr. Software Architect*
>>>>>>>>>> *EDB Postgres <http://edbpostgres.com>*
>>>>>>>>>>
>>>>>>>>>> *Mobile: +91 976-788-8246*
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Thanks & Regards*
>>>>>>>> *Akshay Joshi*
>>>>>>>> *pgAdmin Hacker | Sr. Software Architect*
>>>>>>>> *EDB Postgres <http://edbpostgres.com>*
>>>>>>>>
>>>>>>>> *Mobile: +91 976-788-8246*
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> Dave Page
>>>>>> VP & Chief Architect, Database Infrastructure
>>>>>> EDB: http://www.enterprisedb.com
>>>>>>
>>>>>> Blog: http://pgsnake.blogspot.com
>>>>>> Twitter: @pgsnake
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Thanks & Regards*
>>>>> *Akshay Joshi*
>>>>> *pgAdmin Hacker | Sr. Software Architect*
>>>>> *EDB Postgres <http://edbpostgres.com>*
>>>>>
>>>>> *Mobile: +91 976-788-8246*
>>>>>
>>>>
>>>
>>> --
>>> *Thanks & Regards*
>>> *Akshay Joshi*
>>> *pgAdmin Hacker | Sr. Software Architect*
>>> *EDB Postgres <http://edbpostgres.com>*
>>>
>>> *Mobile: +91 976-788-8246*
>>>
>>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Sr. Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>
Attachments:
[application/octet-stream] RM_3794_review_comments_v2.patch (23.6K, 3-RM_3794_review_comments_v2.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index 2630d1e..ab4bea4 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -1310,7 +1310,8 @@ class ServerNode(PGChildNodeView):
# Connect the Server
manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
- manager.update(server)
+ if not manager.connection().connected():
+ manager.update(server)
conn = manager.connection()
# Get enc key
diff --git a/web/pgadmin/static/js/sqleditor/new_connection_dialog.js b/web/pgadmin/static/js/sqleditor/new_connection_dialog.js
index 10850e1..b19a50a 100644
--- a/web/pgadmin/static/js/sqleditor/new_connection_dialog.js
+++ b/web/pgadmin/static/js/sqleditor/new_connection_dialog.js
@@ -243,7 +243,6 @@ let NewConnectionDialog = {
'title': _.escape(tab_title),
'user': newConnCollectionModel['user'],
'role': newConnCollectionModel['role'],
- 'password': response.password,
'server_name': _.escape(response.server_name),
'database_name': _.escape(selected_database_name),
'is_selected': false,
@@ -260,13 +259,12 @@ let NewConnectionDialog = {
setTimeout(function(){
Alertify.newConnectionDialog('Connect to server.').resizeTo(pgAdmin.Browser.stdW.md,pgAdmin.Browser.stdH.md);
}, 500);
- }).fail(function(error) {
+ }).fail(function() {
Alertify.alert().setting({
'title': gettext('Connection lost'),
'label':gettext('Ok'),
'message': gettext('Connection to the server has been lost.'),
'onok': function(){
- alert(error);
//Close the window after connection is lost
window.close();
},
diff --git a/web/pgadmin/static/js/sqleditor/new_connection_dialog_model.js b/web/pgadmin/static/js/sqleditor/new_connection_dialog_model.js
index 09b2979..0bbda60 100644
--- a/web/pgadmin/static/js/sqleditor/new_connection_dialog_model.js
+++ b/web/pgadmin/static/js/sqleditor/new_connection_dialog_model.js
@@ -78,7 +78,6 @@ export default function newConnectionDialogModel(response, sgid, sid) {
server: parseInt(sid),
database: null,
user: null,
- password: null,
server_name: server_name,
database_name: database_name,
},
@@ -92,7 +91,63 @@ export default function newConnectionDialogModel(response, sgid, sid) {
select2: {
allowClear: false,
},
+ transform: function(data) {
+ let group_template_options = [];
+ for (let key in data) {
+ if (data.hasOwnProperty(key)) {
+ group_template_options.push({'group': key, 'optval': data[key]});
+ }
+ }
+ return group_template_options;
+ },
control: Backform.Select2Control.extend({
+ template: _.template([
+ '<% if(label == false) {} else {%>',
+ ' <label class="<%=Backform.controlLabelClassName%>"><%=label%></label>',
+ '<% }%>',
+ '<div class="<%=controlsClassName%>">',
+ ' <select class="<%=Backform.controlClassName%> <%=extraClasses.join(\' \')%>"',
+ ' name="<%=name%>" value="<%-value%>" <%=disabled ? "disabled" : ""%>',
+ ' <%=required ? "required" : ""%><%= select2.multiple ? " multiple>" : ">" %>',
+ ' <%=select2.first_empty ? " <option></option>" : ""%>',
+ ' <% for (var i=0; i < options.length; i++) {%>',
+ ' <% if (options[i].group) { %>',
+ ' <% var group = options[i].group; %>',
+ ' <% if (options[i].optval) { %> <% var option_length = options[i].optval.length; %>',
+ ' <optgroup label="<%=group%>">',
+ ' <% for (var subindex=0; subindex < option_length; subindex++) {%>',
+ ' <% var option = options[i].optval[subindex]; %>',
+ ' <option ',
+ ' <% if (option.image) { %> data-image=<%=option.image%> <%}%>',
+ ' <% if (option.connected) { %> data-connected=connected <%}%>',
+ ' value=<%- formatter.fromRaw(option.value) %>',
+ ' <% if (option.selected) {%>selected="selected"<%} else {%>',
+ ' <% if (!select2.multiple && option.value === rawValue) {%>selected="selected"<%}%>',
+ ' <% if (select2.multiple && rawValue && rawValue.indexOf(option.value) != -1){%>selected="selected" data-index="rawValue.indexOf(option.value)"<%}%>',
+ ' <%}%>',
+ ' <%= disabled ? "disabled" : ""%>><%-option.label%></option>',
+ ' <%}%>',
+ ' </optgroup>',
+ ' <%}%>',
+ ' <%} else {%>',
+ ' <% var option = options[i]; %>',
+ ' <option ',
+ ' <% if (option.image) { %> data-image=<%=option.image%> <%}%>',
+ ' <% if (option.connected) { %> data-connected=connected <%}%>',
+ ' value=<%- formatter.fromRaw(option.value) %>',
+ ' <% if (option.selected) {%>selected="selected"<%} else {%>',
+ ' <% if (!select2.multiple && option.value === rawValue) {%>selected="selected"<%}%>',
+ ' <% if (select2.multiple && rawValue && rawValue.indexOf(option.value) != -1){%>selected="selected" data-index="rawValue.indexOf(option.value)"<%}%>',
+ ' <%}%>',
+ ' <%= disabled ? "disabled" : ""%>><%-option.label%></option>',
+ ' <%}%>',
+ ' <%}%>',
+ ' </select>',
+ ' <% if (helpMessage && helpMessage.length) { %>',
+ ' <span class="<%=Backform.helpMessageClassName%>"><%=helpMessage%></span>',
+ ' <% } %>',
+ '</div>',
+ ].join('\n')),
connect: function(self) {
let local_self = self;
@@ -147,11 +202,14 @@ export default function newConnectionDialogModel(response, sgid, sid) {
local_self.model.attributes.user = null;
local_self.model.attributes.role = null;
Backform.Select2Control.prototype.onChange.apply(local_self, arguments);
- response.server_list.forEach(function(obj){
- if(obj.id==self.model.changed.server) {
- response.server_name = obj.name;
- }
+ Object.keys(response.server_list).forEach(key => {
+ response.server_list[key].forEach(option => {
+ if (option.value == local_self.getValueFromDOM()) {
+ response.server_name = option.label;
+ }
+ });
});
+
loadingDiv.addClass('d-none');
alertify.connectServer().destroy();
})
@@ -160,8 +218,6 @@ export default function newConnectionDialogModel(response, sgid, sid) {
alertify.connectServer().destroy();
alertify.connectServer('Connect to server', xhr.responseJSON.result, local_self.getValueFromDOM());
});
- } else {
- response.password = $('#password').val();
}
} else {
local_self.model.attributes.database = null;
@@ -178,6 +234,19 @@ export default function newConnectionDialogModel(response, sgid, sid) {
render: function() {
let self = this;
self.connect(self);
+ Object.keys(response.server_list).forEach(key => {
+ response.server_list[key].forEach(option => {
+ if (option.value == parseInt(sid)) {
+ response.server_name = option.label;
+ }
+ });
+ });
+ var transform = self.field.get('transform') || self.defaults.transform;
+ if (transform && _.isFunction(transform)) {
+ self.field.set('options', transform.bind(self, response.server_list));
+ } else {
+ self.field.set('options', response.server_list);
+ }
return Backform.Select2Control.prototype.render.apply(self, arguments);
},
onChange: function() {
@@ -200,10 +269,12 @@ export default function newConnectionDialogModel(response, sgid, sid) {
},
}).done(function () {
Backform.Select2Control.prototype.onChange.apply(self, arguments);
- response.server_list.forEach(function(obj){
- if(obj.id==self.model.changed.server) {
- response.server_name = obj.name;
- }
+ Object.keys(response.server_list).forEach(key => {
+ response.server_list[key].forEach(option => {
+ if (option.value == self.getValueFromDOM()) {
+ response.server_name = option.label;
+ }
+ });
});
loadingDiv.addClass('d-none');
}).fail(function(xhr){
@@ -213,17 +284,6 @@ export default function newConnectionDialogModel(response, sgid, sid) {
},
}),
- options: function() {
- return _.map(response.server_list, (obj) => {
- if (obj.id == parseInt(sid))
- response.server_name = obj.name;
-
- return {
- value: obj.id,
- label: obj.name,
- };
- });
- },
},
{
id: 'database',
@@ -302,27 +362,6 @@ export default function newConnectionDialogModel(response, sgid, sid) {
url: 'sqleditor.get_new_connection_role',
disabled: false,
},
- /*{
- id: 'password',
- name: 'password',
- label: gettext('Password'tools/sqleditor/__init__.py),
- type: 'password',
- editable: true,
- disabled: true,
- deps: ['user'],
- control: Backform.InputControl.extend({
- render: function() {
- let self = this;
- self.model.attributes.password = null;
- Backform.InputControl.prototype.render.apply(self, arguments);
- return self;
- },
- onChange: function() {
- let self = this;
- Backform.InputControl.prototype.onChange.apply(self, arguments);
- },
- }),
- },*/
],
validate: function() {
let msg = null;
@@ -336,11 +375,6 @@ export default function newConnectionDialogModel(response, sgid, sid) {
this.errorModel.set('user', msg);
return msg;
}
- /*else if((this.attributes.password == '' || _.isUndefined(this.get('password')) || _.isNull(this.get('password')))) {
- msg = gettext('Please enter password');
- this.errorModel.set('password', msg);
- return msg;
- }*/
return null;
},
});
diff --git a/web/pgadmin/tools/debugger/__init__.py b/web/pgadmin/tools/debugger/__init__.py
index 1949709..422a8ae 100644
--- a/web/pgadmin/tools/debugger/__init__.py
+++ b/web/pgadmin/tools/debugger/__init__.py
@@ -98,6 +98,18 @@ class DebuggerModule(PgAdminModule):
)
)
+ self.tab_title = self.preference.register(
+ 'display', 'debugger_tab_title_placeholder',
+ gettext("Debugger tab title placeholder"),
+ 'text', '%FUNCTION%/%SCHEMA%/%DATABASE%',
+ category_label=PREF_LABEL_DISPLAY,
+ help_str=gettext(
+ 'Supported placeholders: FUNCTION, SCHEMA and DATABASE. '
+ 'You can also provide any string with or '
+ 'without placeholders'
+ )
+ )
+
self.preference.register(
'keyboard_shortcuts', 'btn_start',
gettext('Accesskey (Continue/Start)'), 'keyboardshortcut',
diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py
index 9da8842..f9fb26f 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -46,7 +46,7 @@ from pgadmin.tools.sqleditor.utils.macros import get_macros,\
get_user_macros, set_macros
from pgadmin.utils.constants import MIMETYPE_APP_JS, \
SERVER_CONNECTION_CLOSED, ERROR_MSG_TRANS_ID_NOT_FOUND, ERROR_FETCHING_DATA
-from pgadmin.model import Server
+from pgadmin.model import Server, ServerGroup
from pgadmin.tools.schema_diff.node_registry import SchemaDiffRegistry
MODULE_NAME = 'sqleditor'
@@ -1489,10 +1489,14 @@ def get_new_connection_data(sgid, sid=None):
:extract_sql_from_network_parameters,
"""
try:
- # if sid and not did:
+ server_groups = ServerGroup.query.all()
+ server_group_data = {server_group.name: [] for server_group in
+ server_groups}
servers = Server.query.all()
- server_list = [
- {'name': server.serialize['name'], "id": server.serialize['id']}
+
+ [server_group_data[server.servers.name].append(
+ {'label': server.serialize['name'],
+ "value": server.serialize['id']})
for server in servers]
msg = "Success"
@@ -1501,7 +1505,7 @@ def get_new_connection_data(sgid, sid=None):
'status': True,
'msg': msg,
'result': {
- 'server_list': server_list
+ 'server_list': server_group_data
}
}
)
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index d3a2d25..26c88bc 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -173,8 +173,13 @@ define('tools.querytool', [
var dropdownElement = document.getElementById('connections-list');
dropdownElement.innerHTML = '';
data_list.forEach((option, index) => {
- $('#connections-list').append('<li class="connection-list-item" data-index='+ index +'><a class="dropdown-item" href="#" tabindex="0">'+ option.title +'</a></li>');
-
+ var opt = '';
+ if ('is_selected' in option && option['is_selected']) {
+ opt = '<li class="connection-list-item selected-connection" data-index='+ index +'><a class="dropdown-item" href="#" tabindex="0">'+ option.title +'</a></li>';
+ } else {
+ opt = '<li class="connection-list-item" data-index='+ index +'><a class="dropdown-item" href="#" tabindex="0">'+ option.title +'</a></li>';
+ }
+ $('#connections-list').append(opt);
});
var self = this;
$('.connection-list-item').click(function() {
@@ -2131,7 +2136,6 @@ define('tools.querytool', [
on_change_connection: function(connection_details, ref) {
if(!connection_details['is_selected']) {
var self = this;
- self.set_selected_option(connection_details);
var loadingDiv = null;
var msgDiv = null;
if(ref){
@@ -2145,66 +2149,78 @@ define('tools.querytool', [
msgDiv = loadingDiv.find('.sql-editor-busy-text');
}
- $.ajax({
- url: url_for('datagrid.update_query_tool_connection', {
- 'trans_id': self.transId,
- 'sgid': connection_details['server_group'],
- 'sid': connection_details['server'],
- 'did': connection_details['database'],
- }),
- method: 'POST',
- contentType: 'application/json',
- data: JSON.stringify(connection_details),
- })
- .done(function(res) {
- if(res.success) {
- self.transId = res.data.tran_id;
- self.handler.transId = res.data.tran_id;
- self.handler.url_params = {
- 'did': connection_details['database'],
- 'is_query_tool': self.handler.url_params.is_query_tool,
- 'server_type': self.handler.url_params.server_type,
+ alertify.confirm(gettext('Change connection'),
+ gettext('By changing the connection you will lose all your unsaved data for the current connection. <br> Do you want to continue?'),
+ function() {
+ self.set_selected_option(connection_details);
+ $.ajax({
+ url: url_for('datagrid.update_query_tool_connection', {
+ 'trans_id': self.transId,
'sgid': connection_details['server_group'],
'sid': connection_details['server'],
- 'title': connection_details['title'],
- };
- self.set_editor_title(_.unescape(self.handler.url_params.title));
- self.handler.setTitle(_.unescape(self.handler.url_params.title));
- let success_msg = connection_details['server_name'] + '/' + connection_details['database_name'] + '- Database connected';
- alertify.success(success_msg);
- if(ref){
- let connection_data = {
- 'server_group': self.handler.url_params.sgid,
- 'server': connection_details['server'],
- 'database': connection_details['database'],
- 'user': connection_details['user'],
- 'title': connection_details['title'],
- 'role': connection_details['role'],
- 'password': connection_details['password'],
- 'is_allow_new_connection': true,
- 'database_name': connection_details['database_name'],
- 'server_name': connection_details['server_name'],
- 'is_selected': true,
- };
- self.connection_list.unshift(connection_data);
- self.render_connection(self.connection_list);
- loadingDiv.addClass('d-none');
- alertify.newConnectionDialog().destroy();
- ref.close();
- } else {
- loadingDiv.addClass('d-none');
- }
- }
- return true;
- })
- .fail(function(xhr) {
+ 'did': connection_details['database'],
+ }),
+ method: 'POST',
+ contentType: 'application/json',
+ data: JSON.stringify(connection_details),
+ })
+ .done(function(res) {
+ if(res.success) {
+ self.transId = res.data.tran_id;
+ self.handler.transId = res.data.tran_id;
+ self.handler.url_params = {
+ 'did': connection_details['database'],
+ 'is_query_tool': self.handler.url_params.is_query_tool,
+ 'server_type': self.handler.url_params.server_type,
+ 'sgid': connection_details['server_group'],
+ 'sid': connection_details['server'],
+ 'title': connection_details['title'],
+ };
+ self.set_editor_title(_.unescape(self.handler.url_params.title));
+ self.handler.setTitle(_.unescape(self.handler.url_params.title));
+ let success_msg = connection_details['server_name'] + '/' + connection_details['database_name'] + '- Database connected';
+ alertify.success(success_msg);
+ if(ref){
+ let connection_data = {
+ 'server_group': self.handler.url_params.sgid,
+ 'server': connection_details['server'],
+ 'database': connection_details['database'],
+ 'user': connection_details['user'],
+ 'title': connection_details['title'],
+ 'role': connection_details['role'],
+ 'is_allow_new_connection': true,
+ 'database_name': connection_details['database_name'],
+ 'server_name': connection_details['server_name'],
+ 'is_selected': true,
+ };
+ self.connection_list.unshift(connection_data);
+ self.render_connection(self.connection_list);
+ loadingDiv.addClass('d-none');
+ alertify.newConnectionDialog().destroy();
+ ref.close();
+ } else {
+ loadingDiv.addClass('d-none');
+ }
+ }
+ return true;
+ })
+ .fail(function(xhr) {
+ if(xhr.status == 428) {
+ alertify.connectServer('Connect to server', xhr.responseJSON.result, connection_details['server'], false);
+ } else {
+ alertify.error(xhr.responseJSON['errormsg']);
+ }
+ });
+ },
+ function() {
loadingDiv.addClass('d-none');
- if(xhr.status == 428) {
- alertify.connectServer('Connect to server', xhr.responseJSON.result, connection_details['server'], false);
- } else {
- alertify.error(xhr.responseJSON['errormsg']);
- }
- });
+ alertify.newConnectionDialog().destroy();
+ return true;
+ }
+ ).set('labels', {
+ ok: gettext('Yes'),
+ cancel: gettext('No'),
+ });
}
},
});
@@ -2542,7 +2558,7 @@ define('tools.querytool', [
'server_group': self.gridView.handler.url_params.sgid,
'server': self.gridView.handler.url_params.sid,
'database': self.gridView.handler.url_params.did,
- 'user': null,
+ 'user': server_data.data.user.name,
'role': null,
'title': _.unescape(url_params.title),
'is_allow_new_connection': false,
diff --git a/web/pgadmin/tools/sqleditor/static/scss/_sqleditor.scss b/web/pgadmin/tools/sqleditor/static/scss/_sqleditor.scss
index 7fc576a..9d5ba4d 100644
--- a/web/pgadmin/tools/sqleditor/static/scss/_sqleditor.scss
+++ b/web/pgadmin/tools/sqleditor/static/scss/_sqleditor.scss
@@ -371,6 +371,9 @@ div.strikeout:after {
height: 100%;
}
+.selected-connection {
+ background-color: $color-primary-light;
+}
/* Setting it to hardcoded white as the SVG generated is having white bg
* Need to check what can be done.
diff --git a/web/pgadmin/tools/sqleditor/utils/query_tool_preferences.py b/web/pgadmin/tools/sqleditor/utils/query_tool_preferences.py
index 76523b1..642a1eb 100644
--- a/web/pgadmin/tools/sqleditor/utils/query_tool_preferences.py
+++ b/web/pgadmin/tools/sqleditor/utils/query_tool_preferences.py
@@ -326,6 +326,29 @@ def register_query_tool_preferences(self):
)
)
+ self.qt_tab_title = self.preference.register(
+ 'display', 'qt_tab_title_placeholder',
+ gettext("Query tool tab title placeholder"),
+ 'text', '%DATABASE%/%USERNAME%@%SERVER%',
+ category_label=PREF_LABEL_DISPLAY,
+ help_str=gettext(
+ 'Supported placeholders: DATABASE, USERNAME and SERVER. '
+ 'You can also provide any string with or without placeholders.'
+ )
+ )
+
+ self.ve_edt_tab_title = self.preference.register(
+ 'display', 'vw_edt_tab_title_placeholder',
+ gettext("View/Edit tab title placeholder"),
+ 'text', '%SCHEMA%.%TABLE%/%DATABASE%/%USERNAME%@%SERVER%',
+ category_label=PREF_LABEL_DISPLAY,
+ help_str=gettext(
+ 'Supported placeholders: SCHEMA, TABLE, DATABASE, USERNAME and '
+ 'SERVER. You can also provide any string with or '
+ 'without placeholders.'
+ )
+ )
+
self.connection_status = self.preference.register(
'display', 'connection_status_fetch_time',
gettext("Connection status refresh rate"), 'integer', 2,
view thread (18+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [pgAdmin][RM3794]:Allow User to Change Database Connection from an Open Query Tool Tab
In-Reply-To: <CAOBg0AMeE1=Mv17m=AjSnkB-GzXiQvtOfH4zttTAVbiyNJ=45A@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox