public inbox for [email protected]
help / color / mirror / Atom feedFrom: Harshal Dhumal <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: Fix for RM2421 [pgAdmin4][patch]
Date: Thu, 18 May 2017 15:31:19 +0530
Message-ID: <CAFiP3vx-B-8LzOQ+hiP0SNTJ22CqsXM2hLJUUgJWYm6XVtgMDQ@mail.gmail.com> (raw)
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
Hi,
Please find attached patch for RM2421
Issue fixed: 1. Integer/numeric Validation is not working properly.
2. Wrong CPU rate unit
--
*Harshal Dhumal*
*Sr. Software Engineer*
EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[text/x-patch] RM2421.patch (6.0K, 3-RM2421.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js b/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js
index 3cc822e..596a4ee 100644
--- a/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js
+++ b/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js
@@ -72,7 +72,7 @@ define(
id: 'name', label: '{{ _('Name') }}', cell: 'string',
type: 'text',
},{
- id: 'cpu_rate_limit', label:'{{ _('CPU rate limit (%%)') }}', cell: 'string',
+ id: 'cpu_rate_limit', label:'{{ _('CPU rate limit (%)') }}', cell: 'string',
type: 'numeric', min:0, max:16777216
},{
id: 'dirty_rate_limit', label:'{{ _('Dirty rate limit (KB)') }}', cell: 'string',
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 553676e..a822da8 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1528,7 +1528,18 @@
max_value = field.max,
isValid = true,
intPattern = new RegExp("^-?[0-9]*$"),
- isMatched = intPattern.test(value);
+ isMatched = intPattern.test(value),
+ trigger_invalid_event = function(msg) {
+ if (this.model.collection || this.model.handler) {
+ (this.model.collection || this.model.handler).trigger(
+ 'pgadmin-session:model:invalid', msg, this.model
+ );
+ } else {
+ (this.model).trigger(
+ 'pgadmin-session:invalid', msg, this.model
+ );
+ }
+ }.bind(this);
// Below logic will validate input
if (!isMatched) {
@@ -1573,25 +1584,23 @@
this.model.errorModel.unset(name);
this.model.set(name, value);
this.listenTo(this.model, "change:" + name, this.render);
- if (this.model.collection || this.model.handler) {
- (this.model.collection || this.model.handler).trigger(
- 'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
- );
+ // Check if other fields of same model are valid before
+ // triggering 'session:valid' event
+ if(_.size(this.model.errorModel.attributes) == 0) {
+ if (this.model.collection || this.model.handler) {
+ (this.model.collection || this.model.handler).trigger(
+ 'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
+ );
+ } else {
+ (this.model).trigger(
+ 'pgadmin-session:valid', this.model.sessChanged(), this.model
+ );
+ }
} else {
- (this.model).trigger(
- 'pgadmin-session:valid', this.model.sessChanged(), this.model
- );
+ trigger_invalid_event(_.values(this.model.errorModel.attributes)[0]);
}
} else {
- if (this.model.collection || this.model.handler) {
- (this.model.collection || this.model.handler).trigger(
- 'pgadmin-session:model:invalid', this.model.errorModel.get(name), this.model
- );
- } else {
- (this.model).trigger(
- 'pgadmin-session:invalid', this.model.errorModel.get(name), this.model
- );
- }
+ trigger_invalid_event(this.model.errorModel.get(name));
}
}
});
@@ -1631,7 +1640,18 @@
max_value = field.max,
isValid = true,
intPattern = new RegExp("^-?[0-9]+(\.?[0-9]*)?$"),
- isMatched = intPattern.test(value);
+ isMatched = intPattern.test(value),
+ trigger_invalid_event = function(msg) {
+ if (this.model.collection || this.model.handler) {
+ (this.model.collection || this.model.handler).trigger(
+ 'pgadmin-session:model:invalid', msg, this.model
+ );
+ } else {
+ (this.model).trigger(
+ 'pgadmin-session:invalid', msg, this.model
+ );
+ }
+ }.bind(this);
// Below logic will validate input
if (!isMatched) {
@@ -1676,25 +1696,23 @@
this.model.errorModel.unset(name);
this.model.set(name, value);
this.listenTo(this.model, "change:" + name, this.render);
- if (this.model.collection || this.model.handler) {
- (this.model.collection || this.model.handler).trigger(
- 'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
- );
+ // Check if other fields of same model are valid before
+ // triggering 'session:valid' event
+ if(_.size(this.model.errorModel.attributes) == 0) {
+ if (this.model.collection || this.model.handler) {
+ (this.model.collection || this.model.handler).trigger(
+ 'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
+ );
+ } else {
+ (this.model).trigger(
+ 'pgadmin-session:valid', this.model.sessChanged(), this.model
+ );
+ }
} else {
- (this.model).trigger(
- 'pgadmin-session:valid', this.model.sessChanged(), this.model
- );
+ trigger_invalid_event(_.values(this.model.errorModel.attributes)[0]);
}
} else {
- if (this.model.collection || this.model.handler) {
- (this.model.collection || this.model.handler).trigger(
- 'pgadmin-session:model:invalid', this.model.errorModel.get(name), this.model
- );
- } else {
- (this.model).trigger(
- 'pgadmin-session:invalid', this.model.errorModel.get(name), this.model
- );
- }
+ trigger_invalid_event(this.model.errorModel.get(name));
}
}
});
view thread (11+ 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: Fix for RM2421 [pgAdmin4][patch]
In-Reply-To: <CAFiP3vx-B-8LzOQ+hiP0SNTJ22CqsXM2hLJUUgJWYm6XVtgMDQ@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