public inbox for [email protected]  
help / color / mirror / Atom feed
From: Nikhil Mohite <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: New connection issue.
Date: Mon, 12 Oct 2020 16:59:22 +0530
Message-ID: <CAOBg0AOb56CCi3sSBz2WK7j3TEE0uTztBZsey-0FYextztQj3w@mail.gmail.com> (raw)

Hi Team,

I have fixed an issue on a new connection.
When the server is disconnected and we try to connect it through a new
connection model dialog it is falling for every 3rd connection attempt.

-- 
*Thanks & Regards,*
*Nikhil Mohite*
*Software Engineer.*
*EDB Postgres* <https://www.enterprisedb.com/;
*Mob.No: +91-7798364578.*


Attachments:

  [application/octet-stream] new_connection_issue.patch (7.3K, 3-new_connection_issue.patch)
  download | inline diff:
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 9e03051..09b2979 100644
--- a/web/pgadmin/static/js/sqleditor/new_connection_dialog_model.js
+++ b/web/pgadmin/static/js/sqleditor/new_connection_dialog_model.js
@@ -95,79 +95,85 @@ export default function newConnectionDialogModel(response, sgid, sid) {
       control: Backform.Select2Control.extend({
         connect: function(self) {
           let local_self = self;
-          if(!alertify.connectServer){
-            alertify.dialog('connectServer', function factory() {
-              return {
-                main: function(
-                  title, message, server_id, submit_password=true
-                ) {
-                  this.set('title', title);
-                  this.message = message;
-                  this.server_id = server_id;
-                  this.submit_password = submit_password;
-                },
-                setup:function() {
-                  return {
-                    buttons:[{
-                      text: gettext('Cancel'), className: 'btn btn-secondary fa fa-times pg-alertify-button',
-                      key: 27,
-                    },{
-                      text: gettext('OK'), key: 13, className: 'btn btn-primary fa fa-check pg-alertify-button',
-                    }],
-                    focus: {element: '#password', select: true},
-                    options: {
-                      modal: 0, resizable: false, maximizable: false, pinnable: false,
-                    },
-                  };
-                },
-                build:function() {
-                },
-                prepare:function() {
-                  this.setContent(this.message);
-                },
-                callback: function(closeEvent) {
 
-                  if (closeEvent.button.text == gettext('OK')) {
-                    if(this.submit_password) {
-                      var _url = url_for('sqleditor.connect_server', {'sid': this.server_id});
-                      var loadingDiv = $('#show_filter_progress');
-                      loadingDiv.removeClass('d-none');
-                      $.ajax({
-                        type: 'POST',
-                        timeout: 30000,
-                        url: _url,
-                        data: $('#frmPassword').serialize(),
-                      })
-                        .done(function() {
-                          local_self.model.attributes.database = null;
-                          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;
-                            }
-                          });
-                          loadingDiv.addClass('d-none');
-                        })
-                        .fail(function(xhr) {
-                          loadingDiv.addClass('d-none');
-                          alertify.connectServer('Connect to server', xhr.responseJSON.result, local_self.getValueFromDOM());
+          if(alertify.connectServer) {
+            delete alertify.connectServer;
+          }
+
+          alertify.dialog('connectServer', function factory() {
+            return {
+              main: function(
+                title, message, server_id, submit_password=true
+              ) {
+                this.set('title', title);
+                this.message = message;
+                this.server_id = server_id;
+                this.submit_password = submit_password;
+              },
+              setup:function() {
+                return {
+                  buttons:[{
+                    text: gettext('Cancel'), className: 'btn btn-secondary fa fa-times pg-alertify-button',
+                    key: 27,
+                  },{
+                    text: gettext('OK'), key: 13, className: 'btn btn-primary fa fa-check pg-alertify-button',
+                  }],
+                  focus: {element: '#password', select: true},
+                  options: {
+                    modal: 0, resizable: false, maximizable: false, pinnable: false,
+                  },
+                };
+              },
+              build:function() {
+              },
+              prepare:function() {
+                this.setContent(this.message);
+              },
+              callback: function(closeEvent) {
+
+                if (closeEvent.button.text == gettext('OK')) {
+                  if(this.submit_password) {
+                    var _url = url_for('sqleditor.connect_server', {'sid': this.server_id});
+                    var loadingDiv = $('#show_filter_progress');
+                    loadingDiv.removeClass('d-none');
+                    $.ajax({
+                      type: 'POST',
+                      timeout: 30000,
+                      url: _url,
+                      data: $('#frmPassword').serialize(),
+                    })
+                      .done(function() {
+                        local_self.model.attributes.database = null;
+                        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;
+                          }
                         });
-                    } else {
-                      response.password = $('#password').val();
-                    }
+                        loadingDiv.addClass('d-none');
+                        alertify.connectServer().destroy();
+                      })
+                      .fail(function(xhr) {
+                        loadingDiv.addClass('d-none');
+                        alertify.connectServer().destroy();
+                        alertify.connectServer('Connect to server', xhr.responseJSON.result, local_self.getValueFromDOM());
+                      });
                   } else {
-                    local_self.model.attributes.database = null;
-                    local_self.model.attributes.user = null;
-                    local_self.model.attributes.role = null;
-                    Backform.Select2Control.prototype.onChange.apply(local_self, arguments);
+                    response.password = $('#password').val();
                   }
-                  closeEvent.close = true;
-                },
-              };
-            });
-          }
+                } else {
+                  local_self.model.attributes.database = null;
+                  local_self.model.attributes.user = null;
+                  local_self.model.attributes.role = null;
+                  Backform.Select2Control.prototype.onChange.apply(local_self, arguments);
+                  alertify.connectServer().destroy();
+                }
+                closeEvent.close = true;
+              },
+            };
+          });
         },
         render: function() {
           let self = this;


view thread (2+ 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]
  Subject: Re: New connection issue.
  In-Reply-To: <CAOBg0AOb56CCi3sSBz2WK7j3TEE0uTztBZsey-0FYextztQj3w@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