[pgAdmin4][Patch]: RM #2846: Add a context menu option to manually (re)count rows in tables

2017-11-07 Thread Khushboo Vashi
Hi,

Please find the attached patch for RM #2846 : Add a context menu option to
manually (re)count rows in tables, including those with >2K rows

Thanks,
Khushboo
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index 1b24ee5..aa2adc9 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -242,7 +242,8 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings):
 'select_sql': [{'get': 'select_sql'}],
 'insert_sql': [{'get': 'insert_sql'}],
 'update_sql': [{'get': 'update_sql'}],
-'delete_sql': [{'get': 'delete_sql'}]
+'delete_sql': [{'get': 'delete_sql'}],
+'count_rows': [{'get': 'count_rows'}]
 })
 
 @BaseTableView.check_precondition
@@ -346,7 +347,8 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings):
 icon="icon-partition" if 'is_partitioned' in row and row['is_partitioned'] else "icon-table",
 tigger_count=row['triggercount'],
 has_enable_triggers=row['has_enable_triggers'],
-is_partitioned=row['is_partitioned'] if 'is_partitioned' in row else False
+is_partitioned=row['is_partitioned'] if 'is_partitioned' in row else False,
+rows_cnt=0
 ))
 
 return make_json_response(
@@ -1461,4 +1463,39 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings):
 """
 return BaseTableView.get_table_statistics(self, scid, tid)
 
+@BaseTableView.check_precondition
+def count_rows(self, gid, sid, did, scid, tid):
+"""
+Count the rows of a table.
+Args:
+gid: Server Group Id
+sid: Server Id
+did: Database Id
+scid: Schema Id
+tid: Table Id
+
+Returns the total rows of a table.
+"""
+data = {}
+data['schema'], data['name'] = \
+super(TableView, self).get_schema_and_table_name(tid)
+
+SQL = render_template(
+"/".join(
+[self.table_template_path, 'get_table_row_count.sql']
+), data=data
+)
+
+status, count = self.conn.execute_scalar(SQL)
+
+if not status:
+return internal_server_error(errormsg=count)
+
+return make_json_response(
+status=200,
+info=gettext("Table rows counted"),
+data={'total_rows': count}
+)
+
+
 TableView.register_node_view(blueprint)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
index 90217e0..359a356 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
@@ -90,6 +90,11 @@ define('pgadmin.node.table', [
   applies: ['object', 'context'], callback: 'reset_table_stats',
   category: 'Reset', priority: 4, label: gettext('Reset Statistics'),
   icon: 'fa fa-bar-chart', enable : 'canCreate'
+},{
+  name: 'count_table_rows', node: 'table', module: this,
+  applies: ['object', 'context'], callback: 'count_table_rows',
+  category: 'Count', priority: 2, label: gettext('Count'),
+  enable: true
 }
 ]);
 pgBrowser.Events.on(
@@ -206,8 +211,8 @@ define('pgadmin.node.table', [
 }
   }, function() {}
 );
-   },
-   reset_table_stats: function(args) {
+},
+reset_table_stats: function(args) {
   var input = args || {},
 obj = this,
 t = pgBrowser.tree,
@@ -255,7 +260,41 @@ define('pgadmin.node.table', [
 },
 function() {}
   );
-   }
+},
+count_table_rows: function(args) {
+  var input = args || {},
+  obj = this,
+  t = pgBrowser.tree,
+  i = input.item || t.selected(),
+  d = i && i.length == 1 ? t.itemData(i) : undefined;
+  if (!d)
+return false;
+
+  // Fetch the total rows of a table
+  $.ajax({
+url: obj.generate_url(i, 'count_rows' , d, true),
+type:'GET',
+success: function(res) {
+alertify.success(res.info);
+d.rows_cnt = res.data.total_rows;
+t.unload(i);
+t.setInode(i);
+t.deselect(i);
+setTimeout(function() {
+  t.select(i);
+}, 10);
+},
+error: function(xhr, status, error) {
+  try {
+  

[pgAdmin4][Patch]: To fix overlapping of validation error on Create/Edit dialog

2017-11-07 Thread Murtuza Zabuawala
Hi,

PFA minor patch to fix the issue where user was not able to provide input
when adding new columns in Create/Edit table dialog when there is an
validation alert on dialog.
RM#2850

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/static/css/pgadmin.css 
b/web/pgadmin/static/css/pgadmin.css
index 9327793..789242b 100644
--- a/web/pgadmin/static/css/pgadmin.css
+++ b/web/pgadmin/static/css/pgadmin.css
@@ -230,6 +230,7 @@
 
 .pg-el-container[el=sm] .pg-el-sm-12 {
   width: 100%;
+  margin-bottom: 5%;
 }
 .pg-el-container[el=sm] .pg-el-sm-11 {
   width: 91.66%;
@@ -305,6 +306,7 @@
 /* Medium container */
 .pg-el-container[el=md] .pg-el-md-12 {
   width: 100%;
+  margin-bottom: 3%;
 }
 .pg-el-container[el=md] .pg-el-md-11 {
   width: 91.66%;
@@ -343,6 +345,7 @@
 /* Large container */
 .pg-el-container[el=lg] .pg-el-lg-12 {
   width: 100%;
+  margin-bottom: 2%;
 }
 .pg-el-container[el=lg] .pg-el-lg-11 {
   width: 91.66%;


Re: [pgAdmin4][patch][runtime]: RM#2443 - No prompt while exiting application

2017-11-07 Thread Dave Page
Thanks, applied.

On Tue, Nov 7, 2017 at 12:49 AM, Neel Patel 
wrote:

> Hi,
>
> Please find attached patch to fix RM#2443 - No prompt while existing from
> main pgAdmin4 runtime browser window.
>
> Do review it and let me know for comments.
>
> Thanks,
> Neel Patel
>



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

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


pgAdmin 4 commit: Confirm with the user before exiting the runtime. Fix

2017-11-07 Thread Dave Page
Confirm with the user before exiting the runtime. Fixes #2443

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=8a4b2ea95383b1505cab5b5b93220c211f71c674
Author: Neel Patel 

Modified Files
--
runtime/BrowserWindow.cpp | 17 -
1 file changed, 12 insertions(+), 5 deletions(-)



pgAdmin 4 commit: Add an option to manually count rows in tables to ren

2017-11-07 Thread Dave Page
Add an option to manually count rows in tables to render the properties. Fixes 
#2846

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=88cd68c2b9a626eee0e29242aa8ca4401a3999b6
Author: Khushboo Vashi 

Modified Files
--
.../servers/databases/schemas/tables/__init__.py   | 41 +-
.../databases/schemas/tables/static/js/table.js| 64 --
web/pgadmin/browser/static/js/node.js  |  2 +-
3 files changed, 100 insertions(+), 7 deletions(-)



Re: [pgAdmin4][Patch]: RM #2846: Add a context menu option to manually (re)count rows in tables

2017-11-07 Thread Dave Page
Thanks, patch applied.

On Tue, Nov 7, 2017 at 7:21 AM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

> Hi,
>
> Please find the attached patch for RM #2846 : Add a context menu option
> to manually (re)count rows in tables, including those with >2K rows
>
> Thanks,
> Khushboo
>



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

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


Re: [pgAdmin4][Patch]: To fix overlapping of validation error on Create/Edit dialog

2017-11-07 Thread Dave Page
Thanks, patch applied.

On Tue, Nov 7, 2017 at 10:46 AM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA minor patch to fix the issue where user was not able to provide input
> when adding new columns in Create/Edit table dialog when there is an
> validation alert on dialog.
> RM#2850
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>


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

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


pgAdmin 4 commit: Prevent error messages covering the last row in a gri

2017-11-07 Thread Dave Page
Prevent error messages covering the last row in a grid. Fixes #2850

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=be0e637718fe09a1b0915db2db12279a19c693f4
Author: Murtuza Zabuawala 

Modified Files
--
web/pgadmin/static/css/pgadmin.css | 3 +++
1 file changed, 3 insertions(+)



pgAdmin 4 commit: Remove data grid icon for consistency with other menu

2017-11-07 Thread Dave Page
Remove data grid icon for consistency with other menu options.

Branch
--
master

Details
---
https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=35b57477dec0a3d3a2fd4c0b1d33270f14e17aa5

Modified Files
--
web/pgadmin/tools/datagrid/static/js/datagrid.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)