This commit takes care of the following issues/improvements.
* Adding missing imports for unauthorised in database module
* Node under Servers Nodes (i.e. Databases, tablespaces, roles nodes)
need to be inherited from PGChildNodeView (and, not from NodeView) for
adding server version check for their children.
* Adding statistics for database, and tablespaces in its node (not, yet
in UI)
* Renaming the camel case methods with proper name.
(i.e. getSQL -> get_sql, getNewSQL -> get_new_sql, etc.)
* Fixed the functions going beyond the text limit (column: 80) in
Databases, Roles & Tablespaces modules.
* Fixed the node method of Database module, which was not tested ever.
* We do not need separate SQL template for fetching the name (i.e.
get_name.sql), using the 'nodes.sql' for the same.
* Optimise the query for fetching ACLs for the database node, we didn't
require to join certain tables, while fetching only the ACLs.
* Introduced the list of the ACLs (regular and default ACLs for
different type) supported by each version [Databases Module].
* Renamed the templates 'get_nodes.sql' to' nodes.sql' to make it
consistent with other modules.
* Removed the checks for the authentication table use, as we don't need
to expose the password to the users (even the encrypted MD5). Using
the pg_roles view always for fetching roles/users information now.
* Resolved some typos in unreachable (specially the exceptions
catchment area.)
* Logging the exception in the application.
* Using qtLiteral, qtIdent properly in the templates (do not assume
about the types of data.)
* Using tsid as identifier instead of did for the tablespaces.
* Using nodes method of tablespace view for fetching individual node
information.
* Removing the hardcoded node information from the 'parse_priv_to_db'
function, and pass on allowed ACLs by the caller nodes.
* Using 'nodes.sql' to fetch name of the template instead of writing
that in the delete.sql template, which is definitely wrong place to
fetch the name of the object. [Tablespace Module]
called while initialing the CollectionNodeModule, as
super(..).__init__(..) does not call __init__ function of all parent
classes. Please refer to method resolution order (MRO) in python for
more information.
This patch also includes some typo resolution in PGNdoeModule. Also,
removed the AddAttr(..) at the moment, because - it is not going
anywhere at the moment.
of double quote within it.
The 'replace' function of immutable type string do create a new
instance of type string, which needed to be reassgined to the variable
'value'.
Reported By: Murtuza Zabuawala
It will be used by the nodes like view, which require to show the code
inside as one parameter.
Also, override the events for the Backform.TextareaControl in order
handle some cases, which were not handling the change in textarea
properly in all situations.
Also, we need to show the error message around the input control with
name attribute only.
Author: Surinder Kumar (small twicks by me).
Reviewed by: Ashesh Vashi
We know that current implemenation have some limitations:
i.e.
* We should not show the template0 in the browser tree.
* Should not connect to the database which does not have permission to connect the server by the current user.
* Show default previlige for PUBLIC in creation mode.
* Allow to create/database database only if current user have sufficient permission.
* Do not show reversed engineered SQL in all supported version.
* Do not showing system database or not.
Author: Khushboo Vashi, Harshal Dhumal, Murtuza Zabuawala
Reviewed by: Neel Patel, Akshay Joshi
It was due to wrong index used for the COL_NAME_KEYWORD, used by the
'needsQuoting' function.
Also, replaced a tab with a space in the generate_keyword.py file.
Reported by: Sanket Mehta, Khushboo Vashi
Also - includes:
* Added 'parent_id' in the 'generate_browser_node' function of the Nodes
to allow them to move around the parents objects (specially through
update/save functionality).
* Handles the issue related to adding the older object back to the
collection (DataModel).
Author: Ashesh Vashi
Reviewed by: Neel Patel, and Akshay Joshi.
from the user.
i.e.
Set the uniqueCol as ['name', 'role'] in case of hasRole is set to true
in schema for it, ['name', ['database'] in case of hasDatabase is set to
true, otherwise ['name'].
Also - fixed a typo in the callback function headerDataChanged(..).
trivial bugs within the privilige control.
i.e.
- Do not show 'ALL' for only one privilege type.
- Show correct privilege label in PrivilegeEditor.
- Typo in TEMPORARY privilege.
- Added missing toJSON function call, while calling the parent's toJSON
function.
known events, when any activity happens on the browser layout.
The following types of events will be triggered through the browser
event manager.
- pgadmin-browser:frame:* [1]
- pgadmin-browser:frame-<name>:* [1]
- pgadmin-browser:panel:* [1]
- pgadmin-browser:panel-<name>:* [1]
- pgadmin-browser:panel
- pgadmin-browser:frame
- pgadmin-browser:tree
- pgadmin-browser:tree:* [2]
[1] The '*' denotes some of the events generated by the wcDocker, which
can be useful to do some operations.
These events are:
+ wcDocker.EVENT.UPDATED
+ wcDocker.EVENT.VISIBILITY_CHANGED
+ wcDocker.EVENT.BEGIN_DOCK
+ wcDocker.EVENT.END_DOCK
+ wcDocker.EVENT.GAIN_FOCUS,
+ wcDocker.EVENT.LOST_FOCUS
+ wcDocker.EVENT.CLOSED
+ wcDocker.EVENT.BUTTON
+ wcDocker.EVENT.ATTACHED
+ wcDocker.EVENT.DETACHED
+ wcDocker.EVENT.MOVE_STARTED
+ wcDocker.EVENT.MOVE_ENDED
+ wcDocker.EVENT.MOVED
+ wcDocker.EVENT.RESIZE_STARTED
+ wcDocker.EVENT.RESIZE_ENDED
+ wcDocker.EVENT.RESIZED
+ wcDocker.EVENT.SCROLLED
[2] The '*' denotes all the events generated by the Browser Tree
(aciTree).
The extension modules can utilize these events to do some operations on
nodes, and panels.
This patch includes showing 'Reversed Engineered Query' for the selected
node (if allowed) using the above approch.
The ShowNodeSQL module looks for two events.
1. SQL Panel Visibility change.
- Based on the visibility of that panel, we start/stop listening the
node selection event.
2. Node Selection in Browser tree
- Based on the selected node type, it will look for 'hasSQL'
parameter of the node, and fetch the Query from the server, and
show it in the SQL editor.
show) for both control and cell, while generating the columns and field
Schema. And, it was resulting into wrong behaviour because of that.
Also - includes the server changes, which was using 'show' parameter
earlier for showing version, when server was connected.
NodeListByNameCell for selecting the grantee.
This patch includes:
- Change the RolePrivilegesModel schema to allow to use the
NodeListByNameCell for showing grantee, and granter information.
- When setting some value - do not use the silent flag in Select2Cell, which
will allow the session manager to take the value in account, which is
used by the NodeListByNameCell.
- Set the top object in the children of the UniqueControl collections.
[Ashesh Vashi]
- Pass on the node information to the actual data model, so that - we can use
node information by the control itself. [Ashesh Vashi]
- While adding the new privilege, set the granter to the current user.
[Ashesh Vashi]
for using them with Backgrid.
It has similar functionality which we have done for fetching node
options for select2 cell using ajax at the time of initialization to use
it with Backgrid.
variable control, privilege control, which specifies the keys - which
helps identify the data from the collection. Also, resolved an version
compatibility issue with the variable control.
done using the Backbone event management.
Emitting 'pgadmin-session:*' for different operations, when we
create/modify the data within the properties dialog.
We will keep track of each child node using the handler object within
the Model, and Collection objects, also - provides them the name of the
attribute, it represents. It will be used to identify the invalid nested
objects within the existing object.
Also, provide the array of modified variables, which were modified in
the validation function to avoid checking each, and every thing in the
validation function. We will need to validate that particular and the
dependent attributes only.
Also - avoid multiple validation operations from the parent object to
improve performance. And, depends on the event based operations for
validation, instead of integrate the data operation and view operation
within one operation. We do maintain the invalid objects, and validate
them only from the collection objects, which also helps improve the
performance during validation.
1. NodeAjaxOtions needs to check 'version_compability' in field, and not
'ver_in_limit' variable. (Thanks Murtuza for pointing that out.)
2. Override the input control to catch the change properly in it.
3. Updated the UniqueCollectionControl and Variable Control to render
proper template in the header.
other.
i.e.
While fetching the database nodes from the role nodes, it was generating
the wrong URL.
Used the parent_type in each node to identify maximum node URL level
using the priority set in the tree node hearachy information, and
generate URL up to that level only.
database(s), and tablespace(s).
Thanks Harshal Dhumal for sharing the original patch.
I've modified a lot to work by fetching the variables later by giving a
url.
Also,
- Introduced the template macros for SECURITY LABELS and VARIABLES.
- Improvised the Backform.Control with better syntactic approach.
- Introduced a jquery function pgMakeVisible(..) to make it visible
under any obj which can be identified by unique class.
properly.
Also, takes care of setting options to empty array, when it couldn't
fetch the options for the NodeAjaxOptionsControl.
And, generating proper url for 'msql' url in the SQL tab, when creating
new node from the same type of node.
* Start tracking changes immediatedly depends on the handler.
* Attaching control with the filter in the NodeListByNameControl.
* Generating proper data for the NodeListByNameControl.
Some data will be applicable to parent level, even though - it has
been fetched it from a particular node.
i.e.
roles will be applicable to server level (not particular role level).
such situation. This has been modified specifically for the children
under the schema, and catalog nodes.
Also, override the Backform.Control.prototype.render function to allow
to provide the control data to the evaluable functions (i.e. disabled,
visible, required).
with schema specified object name. This will also works with
EntepriseDB's package too.
Also, added dependency on the current connection object, it will allow
us to use the keywords list specific to the database server in futuer.
You can use the qtIdent template filter as:
conn|qtIdent(name)
or,
conn|qtIdent(schema_name, name)
of (label, value) tuple in the SelectControl.
We will apply the transform function, while rendering the control, and
not during intialization. This will allow us to generate different
options data based on the dependent values.
inputs.
In order to do the proper quoting around the identifier, different type,
and literal, we introduced respective functions qtIdent, qtTypeIdent,
qtLiteral in psycopg2 driver. Also, introduced them as the Jinja's
custom filter for using it directly inside the templates.
Also, created an utility - generate_keywords.py in order to generate
keyword lists from the latest PostgreSQL installation.
create/edit mode. It will fetch the modified sql using the 'msql' url
specific to that node.
Also, modified by Ashesh before committing it.
i.e. Added code comments, cleanup code for the control, etc.
- Fixed the server backend version check for any schema object.
- Fixed the switch control, it was not enable to toggle the values properly.
- Fixed the editableCell to work properly in the collection properties.
boolean values. (Modified quite a lot by Ashesh, before committing).
This patch also allow to set the header class in the backgrid through
setting 'cellHeaderClass' property of the schema object for any of the
node. It will allow us to set the different behaviour of the cell in the
list. One of the test case for it is: this will allow us to set the
different width of each column in the list using CSS class(es).
Introduced a new ajax function to return the HTTP Status code 410 (GONE).
Changed the location of the javascript from each modules, it loads.
Added .swp, .swo files in the .gitignore file
- Renamed the URL 'nodes' to 'children', because - we'll return the
children for the current node.
- Using the URL 'nodes' to fetch all nodes of its type, when not
specified the node-id, otherwise regenerate that node info using the
node-id (it will be used by the refresh function).
- Added the URL 'msql' for fetching modified SQL for the modified
objects.
- Separated the URL 'deps' (GET/POST methods) to 'dependency' and
'dependent', because - it will be used to fetch the properties of the
object, not manipulate it. (as suggested by Dave).
This commit includes the changes related to it in the specific nodes.
(i.e. server-group, and server).
Also, includes a javascript change to ask the user (if they really want
to leave the page, and it is not an accidental navigation by keyboard
shortcuts).
- Allow to release connection using the database OID (did).
- Generate correct url for the collection nodes.
- Removed the server-type from the collection node module, from the
generate_browser_collection_node(...) function.
- Show version string, and not version integer in the server properties
(when connected).
Also, resolved an issue related showing the correct server variant in
properties dialog, it is a regression introduced by the patch server
version check.
i.e.
'server-connect' and 'server-disconnected' events will be generated
while server gets connected and disconnected respectively.
For demo purpose - listening to the server connection from the test
script.
connect to the database server. Also, added modified the way, we do
check the node is supported by the server.
Instead of creating separate blueprint for the server types, they will
be independently works. In order to add different variant of the
PostgreSQL, we need to extend the ServerType class, and override the
'instanceOf' function for identification using version string. Please
take a look at the ppas.py for the example.
During checking the back-end support for the node, we will also check
the server type (variant) along with the version within the range of
maximum and minimum version for the node. And, the same support added
for the schema attributes in front-end (JavaScript).
Really thankful to Khushboo Vashi for her initial work in front-end. I
took it further from there.
driver)
1. Update correct variable for database information in the connection
manager.
2. Raise exception, when database not found, instead of return the
(boolean, error message) tupple.
manager, once the connection to the maintenance database has been made,
because - we will have did (i.e. Database OID) most of the time for the
any node, and not its name as identifier.
This will allow us to work directly with OID, and we will not need to
bother about renaming of the database name.
during undo-redo action. Also, resolved the focus losing issue, which
closing the subnode editor using undo action.
Also, resolved an issue related to 'beforeopen' failed on server node,
due to api changes on tree events.
i.e. Switch between the tabs, opening/closing the subnode in edit mode.
Also, removed the Save, Cancel buttons from the subnode editor, it was
looking very redudant. Ctrl+Z for undo, Ctrl+Shift+Z/Ctrl+Y for Redo
shortcut will be good enough for undoing all the changes in the
properties panel.
creation, and editing within the properties panel infrastructure.
We do use the backgrid.js for listing the subnode collection, and for
editing/creating new object for the subnode, we do use the same
infrastructure using the backform.
server connection.
The BaseDriver and BaseConnection are two abstract classes, which allows
us to replace the existing driver with the currently used. The current
implementation supports to connect the PostgreSQL and Postgres Plus
Advanced Server using the psycopg2 driver.
(tabbed) UI.
Also, fixed few bugs pointed by Dave:
* Open the URL in separate browser tab/window.
* Fixed few CSS changes for look and feel for the dialog view
* Some of the panels were not listed in the context menu for the
wcDocker.
(lazy loading) using the require.js. This allows us to load the
javascript required for any node, only when it was loaded in the browser
tree. Also, introduced the mechanism to show/edit/create of any node in
a tab panel (wcDocker.Panel).
PostgreSQL node(s).
Browser Tree Node (PostgreSQL object) requires more than just CRUD.
i.e.
- CRUD (Create, Read, Update & Delete)
- Reversed Engineered SQL for the object
- Modified Query in edit mode
i.e. ALTER TABLE ...
- Statistics
- List of dependents
- List of dependencies
- Children node list
This class can be inherited to achieve the different routes for each of
the object types/collections.
OPERATION | URL | Method
---------------+------------------------+--------
List | /obj/[Parent URL]/ | GET
Properties | /obj/[Parent URL]/id | GET
Create | /obj/[Parent URL]/ | POST
Delete | /obj/[Parent URL]/id | DELETE
Update | /obj/[Parent URL]/id | PUT
SQL (Reversed | /sql/[Parent URL]/id | GET
Engineering) |
SQL (Modified | /sql/[Parent URL]/id | POST
Properties) |
Statistics | /stats/[Parent URL]/id | GET
Dependencies | /deps/[Parent URL]/id | GET
Dependents | /deps/[Parent URL]/id | POST
Children Nodes | /nodes/[Parent URL]/id | GET
NOTE:
Parent URL can be seen as the path to identify the particular node.
i.e.
In order to identify the TABLE object, we requires information
about the server -> database -> schema objects.
Hence, the Parent URL for the TABLE object will be something like
this as below:
<int:sid>/<str:database>/<str:schema>
Inherited a new classes ServerGroupView and ServerView, which are
inherited from the NodeView for the implementation of above operations.
submodules inherited from the PgAdminModule instead of regular
Blueprint. This allows us to load the module automatically from the
under the pgadmin directory, and will work to extend the pgAdmin
extension module.
PgAdminModule is inherited from the Blueprint, and bring several
methods:
- get_own_stylesheets, which returns the stylesheets used by the module
(excluding its submodules stylesheets)
- get_own_javascripts
- menu_items, which returns a dictionray mapping the old hook names
(context_items etc) to a list of MenuItem instances
For more specialized modules (as for now, any module that should be part
of the browser tree construction), one can define an abstract base class
defining additional methods.
For example, the BrowserPluginModule abstract base class defines the
following methods:
- jssnippets
- csssnipeets
- node_type
- get_nodes
The File menu now includes a "Create" submenu, and Delete/Rename
options. Nodes can offer Delete/Rename functionality, and the
options on the menu are automatically enabled/disabled based on
the selected node. Each node can also offer Create functionality,
and specify a list of node types (including itself) from which the
option should be made available. The menu is dynamically generated
based on the selected node.
The Context menu on the treeview works in a similar way, except that
nodes can offer any context menu items (we don't allow this on the
top menu, as that should stay consistent to avoid user confusion).
This allows us to update the configuration database schema as needed,
and use the setup script to update it to the current version.
NOTE: Existing databases will need to be recreated once following
this commit. It doesn't seem worth handling the "upgrade from v0"
case when I'm probably the only active developer right now.
This commit adds the following:
- Storage of server groups in the configuration database
- Creation of a default server group on in the database
- A mechanism for plugging in treeview node types
- A node type for server groups with:
- Treeview display
- Custom per-node javascript implementing a menu option/dialogue to add new groups
- Custom per-node CSS to style the treeview node
- JSON formatted data in response to AJAX requests, including:
- Success/failure indication
- Error message
- Extra info (e.g. stack trace)
- The original request data
- Additional return data, e.g. node ID and label etc.
Still needs some work to:
- Minimise AJAX calls by writing multiple settings at once.
- Move the settings storage/retrieval JS code into a global file
- Avoid using synchronous AJAX calls in the main thread
This adds bootstrap-dialog to help with creation of nice dialogs,
and adds the ability for modules to render Javascript into the
browser, and specify onclick handlers in the menu system.
Also add a basic About dialog, using the new infrastructure and
showing some useful info about the application.
Modules may now include functions that return lists of menu items
that will be included on the main browser window menu. While we're
at it, move the test views into a separate module.
This uses a single default user in the config database, which is
auto-logged into the app when SERVER_MODE = False. In this mode we
also hide/remove user-related functions in the UI.
A user authentication module based on flask-security is added, which
allows users to login and change/recover passwords etc. Custom templates
are included for the user/password UIs.
A new setup script will initialise the user (and later settings) DB,
adding the first user and granting them an Administrator role.
A redirects blueprint module is added to handle simple URL redirects.
A browser module is added and currently renders a skeleton page with
a menu bar, gravatar and jumbotron.
NOTE FOR LATER: Currently this code might make the nice basis for any
web app that needs user management and plugins. Hmmm....