public inbox for [email protected]  
help / color / mirror / Atom feed
New connection issue.
2+ messages / 2 participants
[nested] [flat]

* New connection issue.
@ 2020-10-12 11:29 Nikhil Mohite <[email protected]>
  2020-10-12 11:46 ` Re: New connection issue. Akshay Joshi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Nikhil Mohite @ 2020-10-12 11:29 UTC (permalink / raw)
  To: pgadmin-hackers

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;


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: New connection issue.
  2020-10-12 11:29 New connection issue. Nikhil Mohite <[email protected]>
@ 2020-10-12 11:46 ` Akshay Joshi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2020-10-12 11:46 UTC (permalink / raw)
  To: Nikhil Mohite <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Mon, Oct 12, 2020 at 4:59 PM Nikhil Mohite <
[email protected]> wrote:

> 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.*
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-10-12 11:46 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-10-12 11:29 New connection issue. Nikhil Mohite <[email protected]>
2020-10-12 11:46 ` 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