[RM2551][pgAdmin4] show tablespace on partitions.

2017-07-12 Thread Harshal Dhumal
Hi,

Please find attached patch to show tablespace on partitions.
Also reformatted sql slightly in sql tab.

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/create.sql
index b5e9404..19eea8c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partition/sql/10_plus/create.sql
@@ -19,9 +19,15 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data
 {% endif %}
 {{ data.partition_value }}{% if data.is_partitioned is defined and data.is_partitioned %}
 
-PARTITION BY {{ data.partition_scheme }}{% endif %};
+PARTITION BY {{ data.partition_scheme }}{% endif %}
+{### SQL for Tablespace ###}
+{% if data.spcname %}
 
+TABLESPACE {{ conn|qtIdent(data.spcname) }};
+{% else %}
+;
 
+{% endif %}
 {### Alter SQL for Owner ###}
 {% if data.relowner %}
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
index 555133f..1b16454 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
@@ -1030,26 +1030,27 @@ class BaseTableView(PGChildNodeView):
 if not status:
 return internal_server_error(errormsg=rset)
 
-sql_header = u"\n-- Partitions SQL"
-partition_sql = ''
-for row in rset['rows']:
-part_data = dict()
-part_data['partitioned_table_name'] = data['name']
-part_data['parent_schema'] = data['schema']
-part_data['schema'] = row['schema_name']
-part_data['relispartition'] = True
-part_data['name'] = row['name']
-part_data['partition_value'] = row['partition_value']
-part_data['is_partitioned'] = row ['is_partitioned']
-part_data['partition_scheme'] = row['partition_scheme']
-
-partition_sql += render_template("/".join(
-[self.partition_template_path, 'create.sql']),
-data=part_data, conn=self.conn)
-
-# Add into main sql
-partition_sql = re.sub('\n{2,}', '\n\n', partition_sql)
-main_sql.append(sql_header + '\n\n' + partition_sql.strip('\n'))
+if len(rset['rows']):
+sql_header = u"\n-- Partitions SQL"
+partition_sql = ''
+for row in rset['rows']:
+part_data = dict()
+part_data['partitioned_table_name'] = data['name']
+part_data['parent_schema'] = data['schema']
+part_data['schema'] = row['schema_name']
+part_data['relispartition'] = True
+part_data['name'] = row['name']
+part_data['partition_value'] = row['partition_value']
+part_data['is_partitioned'] = row ['is_partitioned']
+part_data['partition_scheme'] = row['partition_scheme']
+
+partition_sql += render_template("/".join(
+[self.partition_template_path, 'create.sql']),
+data=part_data, conn=self.conn)
+
+# Add into main sql
+partition_sql = re.sub('\n{2,}', '\n\n', partition_sql)
+main_sql.append(sql_header + '\n\n' + partition_sql.strip('\n'))
 
 sql = '\n'.join(main_sql)
 


Re: More RHEL 6 build issues

2017-07-12 Thread Dave Page
Hi

On Tue, Jul 11, 2017 at 5:40 PM, Devrim Gündüz  wrote:

>
> Hi Dave,
>
> On Tue, 2017-07-11 at 12:26 +0100, Dave Page wrote:
> > Anyway; the attached patch fixes the issue for me. I wonder if this is
> some
> > CentOS weirdness...
>
> Thanks, that fixed this issue. We have now another one:
>
> Exception occurred:
>   File 
> "/usr/lib/python2.6/site-packages/pgadmin4-web/flask_sqlalchemy/__init__.py",
> line 25, in 
> from sqlalchemy import orm, event, inspect
> ImportError: cannot import name event


I have no idea what would cause that. Are you using a version of any Python
component that differs from whats in requirements.txt?

The reason I ask is that we have automated regression tests on Python 2.6,
and they're passing just fine - so whatever you do on CentOS 6 should as
well.

You can see from the test output at
https://jenkins.pgadmin.org/job/pgadmin4-master-python26/lastSuccessfulBuild/consoleText
what packages are being used (the installations are fairly near the top).

Note that the second PIP run (which starts with pyperclip) is for the
components in web/regression/requirements.txt, which are only required to
run the regression tests.

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

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


[pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-12 Thread Murtuza Zabuawala
Hi,

PFA patch which will add functionality to allow user to comment/uncomment
code in query editor.
RM#2456

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/docs/en_US/keyboard_shortcuts.rst 
b/docs/en_US/keyboard_shortcuts.rst
index 2194d63..9de6103 100644
--- a/docs/en_US/keyboard_shortcuts.rst
+++ b/docs/en_US/keyboard_shortcuts.rst
@@ -59,6 +59,8 @@ When using the syntax-highlighting SQL editors, the following 
shortcuts are avai
 
+--+--+-+
 | Shift+Tab| Shift+Tab| Un-indent selected text
 |
 
+--+--+-+
+| Shift+Ctrl+/ | Shift+Ctrl+/ | Comment/Uncomment selected 
text |
++--+--+-+
 
 **Query Tool**
 
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html 
b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index 4bb38c4..b9fe89d 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -217,6 +217,10 @@
 
 
 
+
+
+ {{ _('Comment/Uncomment Code') }} 
+
 
 
  {{ _('Clear Query Window') }} 
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js 
b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index 8a797ab..3cf9fc6 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -28,6 +28,7 @@ define([
 'codemirror/addon/search/jump-to-line',
 'codemirror/addon/edit/matchbrackets',
 'codemirror/addon/edit/closebrackets',
+'codemirror/addon/comment/comment',
 
 'backgrid.sizeable.columns',
 'slick.pgadmin.formatters',
@@ -50,7 +51,8 @@ define([
 // Define key codes for shortcut keys
 var F5_KEY = 116,
 F7_KEY = 118,
-F8_KEY = 119;
+F8_KEY = 119,
+FWD_SLASH_KEY = 191;
 
 var is_query_running = false;
 
@@ -102,6 +104,7 @@ define([
 "click #btn-explain-costs": "on_explain_costs",
 "click #btn-explain-buffers": "on_explain_buffers",
 "click #btn-explain-timing": "on_explain_timing",
+"click #btn-toggle-comment": "on_toggle_comment_code",
 "change .limit": "on_limit_change",
 "keydown": "keyAction"
   },
@@ -1288,6 +1291,17 @@ define([
 );
   },
 
+  // Callback function for the comment/uncomment selected code
+  on_toggle_comment_code: function() {
+var self = this;
+// Trigger the comment signal to the SqlEditorController class
+self.handler.trigger(
+'pgadmin-sqleditor:toggle_comment_code',
+self,
+self.handler
+);
+  },
+
   // Callback function for the clear button click.
   on_clear: function(ev) {
 var self = this, sql;
@@ -1498,6 +1512,10 @@ define([
   // Download query result as CSV.
   this.on_download(ev);
   ev.preventDefault();
+} else if (ev.shiftKey && ev.ctrlKey  && keyCode == FWD_SLASH_KEY ) {
+  // Toggle comments
+  this.on_toggle_comment_code(ev);
+  ev.preventDefault();
 }
   }
 });
@@ -1587,6 +1605,8 @@ define([
   self.on('pgadmin-sqleditor:button:explain-costs', 
self._explain_costs, self);
   self.on('pgadmin-sqleditor:button:explain-buffers', 
self._explain_buffers, self);
   self.on('pgadmin-sqleditor:button:explain-timing', 
self._explain_timing, self);
+  self.on('pgadmin-sqleditor:toggle_comment_code', 
self._toggle_comment_code, self);
+
 
   if (self.is_query_tool) {
 self.gridView.query_tool_obj.refresh();
@@ -3635,6 +3655,25 @@ define([
 },
 
 /*
+ * This function will comment/uncomment code
+ */
+_toggle_comment_code: function() {
+  var self = this, editor = self.gridView.query_tool_obj,
+  selected_code = editor.getSelection(),
+  sql = selected_code.length > 0 ? selected_code : editor.getValue();
+  // If it is an empty query, do nothing.
+  if (sql.length <= 0) return;
+
+  // Find the code selection range
+  var range = {
+from: editor.getCursor(true),
+to: editor.getCursor(false)
+  };
+  // Comment/Uncomment code
+  editor.toggleComment(range.from, range.to);
+},
+
+/*
  * This function get explain options and auto rollback/auto commit
  * values f

Re: [pgAdmin4][Patch]: Allow user to Comment/Uncomment code in query editor

2017-07-12 Thread Robert Eckhardt
Yay.

-- Rob

On Wed, Jul 12, 2017 at 8:16 AM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch which will add functionality to allow user to comment/uncomment
> code in query editor.
> RM#2456
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


[RM2544][pgAdmin4] Fix for malformed query generated when using custom type

2017-07-12 Thread Harshal Dhumal
Hi,

Please find attached patch to fix malformed sql for data type.


-- 
*Harshal Dhumal*
*Sr. Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/macros/get_full_type_sql_format.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/macros/get_full_type_sql_format.macros
index 4b9c0e9..c3f7707 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/macros/get_full_type_sql_format.macros
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/macros/get_full_type_sql_format.macros
@@ -13,7 +13,7 @@ time({{ type_length }}) with time zone{% endif %}{% if is_type_array %}
 {## Need to check against separate time types - END ##}
 {#}
 {% else %}
-{{ conn|qtTypeIdent(type_name) }}{% if type_length %}
+{{ type_name }}{% if type_length %}
 ({{ type_length }}{% if type_precision%}, {{ type_precision }}{% endif %}){% endif %}{% if is_type_array %}
 []{% endif %}
 {% endif %}


Design sync up meeting notes

2017-07-12 Thread Shirley Wang
Hi all,

Below are notes from our sync up today. Please reach out to me or Chethana
Kumar if you have any questions!

Shirley


*7.12 Meeting Notes*

We discussed:
- Migrating styleguide from WIP  to
pgadmin.org: working on migrating colors over first.
- Icons in pgAdmin4 menus: Inconsistent in style, some have color some
don't. Also unclear if adding value by having so many
- Process for design: documentation on the agreed upon process to help with
measuring progress and making improvements when necessary
- Inconsistencies between styleguide and application: styles are agreed
upon, but changes within the app require time to locate inconsistencies and
implement. Changes are tracked in the Trello

- Dev & Design: Different working processes, having all developers work on
styles vs one person dedicated to styles


Next steps and actions
- Continue moving styleguide over to pgadmin.org [Shirley]
- Begin working on iconography for menus [Chethana]
- Share out meeting notes from design sync ups [Chethana + Shirley]
- Continue updating styles in application [Shirley]


Re: [pgadmin-hackers][pgaweb][patch] Website patch to add SCSS

2017-07-12 Thread George Gelashvili
Hi Dave,


> Hmm, seems like the dependencies are broken. Adding them throws me down
> what seems like a rabbit hole of manual installation, starting with:
>
> (pgaweb) piranha:pgaweb dpage$ pip install -r requirements.txt
> Requirement already satisfied: Django==1.8.18 in /Users/dpage/.virtualenvs/
> pgaweb/lib/python2.7/site-packages (from -r requirements.txt (line 1))
> Requirement already satisfied: psycopg2==2.7.1 in
> /Users/dpage/.virtualenvs/pgaweb/lib/python2.7/site-packages (from -r
> requirements.txt (line 2))
> Collecting libsass==0.13.2 (from -r requirements.txt (line 3))
>   Using cached libsass-0.13.2.tar.gz
> Could not import setuptools which is required to install from a source
> distribution.
> Traceback (most recent call last):
>   File "/Users/dpage/.virtualenvs/pgaweb/lib/python2.7/site-
> packages/pip/req/req_install.py", line 387, in setup_py
> import setuptools  # noqa
>   File "/Users/dpage/.virtualenvs/pgaweb/lib/python2.7/site-
> packages/setuptools/__init__.py", line 10, in 
> from six.moves import filter, map
> ImportError: No module named six.moves
>
> Perhaps the entire dependency tree should be added to requirements.txt?
>
>

What version of pip runs in your pyenv? We're able to pip install
requirements inside a new 2.7.10 virtualenv, that gets created with pip
9.0.1 by default.


> - Scripts to yarn to compile the SCSS and run the application
>>
> - Add startapp.sh script to start the application
>>
>
> The application runs under uWSGI - it's not going to be started via a
> script. It's auto-updated periodically from git, and uWSGI will restart
> when necessary so if any pre-processing of files is required, that needs to
> be done at startup automatically.
>

Okay, so it sounds like shelling out to yarn in wsgi would resolve this.
Otherwise, what does the auto-update process look like? perhaps compilation
steps belong there rather than in app startup. Also, unless a restart needs
to pick up changes separately from those checked into the repo, the app
should be able to restart with static pre-compiled resources.


> - The "Add initial pgAdmin4 version" should be changed to describe loading
> the fixture data from each of the various modules that seed the database.
> e.g.
>
> ./manage.py loaddata ./download/fixtures/packages.json
> ./manage.py loaddata ./download/fixtures/distributions.json
> ./manage.py loaddata ./download/fixtures/versions.json
> ./manage.py loaddata ./download/fixtures/downloads.json
> ./manage.py loaddata ./faq/fixtures/categories.json
> ./manage.py loaddata ./faq/fixtures/faqs.json
> ./manage.py loaddata ./news/fixtures/news.json
> ./manage.py loaddata ./versions/fixtures/versions.json
>

>
- s/PGAdmin/pgAdmin
>
> - We can remove the part about using sqlite for the DB. This is a Postgres
> project after all :-)
>

Changed.

Thanks,
George and Shruti


02-add-scss.patch
Description: Binary data


01-add-readme.patch
Description: Binary data