Subject: pgadmin4 new server host rule is missing

From: Seçkin Alan <[email-masked]>
Date: Thu, 14 Apr 2016 23:18:32 +0300

Hi,
In model Server.host field is nullable=False but, UI Hostname/address
field can accept null value.
So,
When I click save button, in that time throw error like NOT NULL
constraint failed: server.host .

-- 
Seçkin ALAN
http://sckn.org
diff --git a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
index 32e9399..ed9b7dc 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
+++ b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
@@ -215,6 +215,11 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
             err['name'] = '{{ _('Name can be empty!') }}';
             errmsg = errmsg || err['name'];
           }
+          if (_.isUndefined(this.get('host')) ||this.get('host') == null || String(this.get('host')).replace(/^\s+|\s+$/g, '') == '') {
+            err['host'] = '{{ _('Host can be empty!') }}';
+            errmsg = errmsg || err['host'];
+          }
+
           this.errorModel.set(err);

-- 
Sent via pgadmin-hackers mailing list ([email-masked])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

---

From: Seçkin Alan <[email-masked]>
Date: Thu, 14 Apr 2016 23:46:24 +0300

++
change node js

full patch is attached

-- 
Seçkin ALAN
http://sckn.org
diff --git a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
index 32e9399..ed9b7dc 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
+++ b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
@@ -215,6 +215,11 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
             err['name'] = '{{ _('Name can be empty!') }}';
             errmsg = errmsg || err['name'];
           }
+          if (_.isUndefined(this.get('host')) ||this.get('host') == null || String(this.get('host')).replace(/^\s+|\s+$/g, '') == '') {
+            err['host'] = '{{ _('Host can be empty!') }}';
+            errmsg = errmsg || err['host'];
+          }
+
           this.errorModel.set(err);
diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js
index 98f774b..a0e071a 100644
--- a/web/pgadmin/browser/templates/browser/js/node.js
+++ b/web/pgadmin/browser/templates/browser/js/node.js
@@ -851,7 +851,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
                   if (d && !_.isEmpty(d)) {
                     m.save({}, {
                       attrs: d,
-                      validate: true,
+                      validate: false,
                       cache: false,
                       success: function() {
                         onSaveFunc.call();

---

From: Dave Page <[email-masked]>
Date: Thu, 14 Apr 2016 21:46:46 +0100

Thanks - patch applied, with some improved messages for this check and
the name check..

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

---

From: Dave Page <[email-masked]>
Date: Thu, 14 Apr 2016 21:51:21 +0100

Updated as well - thanks.