Moved the javascripts of the following browser node modules to the

'static' directory from 'templates' in the respective module directory:
- Server Group
- Server
- Database
- Schema
- Cast
- Event trigger
- Extension
- Foreign data wrapper
- Language
- Catalog Object
- Collation
- Domain Constraint
- Domain
- Foreign server
- FTS Configuration
- FTS Dictionary
- FTS Parser
- FTS Template
- Function
- Procedure
- Trigger Function
- Package
- Sequence
- Catalog
- Schema
- Synonym
- Table
- Type
- Materialized View
- View
- pgAgent Modules
  + Job (pga_job)
  + Schedule (pga_schedule)
  + Steps (pga_jobstep)

Added new dynanic modules for listing the supported server types, and
current user information.

NOTE: We've not yet moved the javascripts for the children of the table
module.
This commit is contained in:
Ashesh Vashi 2017-06-22 15:56:45 +05:30
parent 67fd119de8
commit d26337a1ba
54 changed files with 255 additions and 259 deletions

View File

@ -259,6 +259,14 @@ class BrowserPluginModule(PgAdminModule):
"""
return []
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
def get_own_javascripts(self):
"""
Returns the list of javascripts information used by the module.
@ -280,14 +288,26 @@ class BrowserPluginModule(PgAdminModule):
"""
scripts = []
scripts.extend([{
'name': 'pgadmin.node.%s' % self.node_type,
'path': url_for('browser.index') + '%s/module' % self.node_type,
'when': self.script_load
}])
if self.module_use_template_javascript:
scripts.extend([{
'name': 'pgadmin.node.%s' % self.node_type,
'path': url_for('browser.index') + '%s/module' % self.node_type,
'when': self.script_load,
'is_template': True
}])
else:
scripts.extend([{
'name': 'pgadmin.node.%s' % self.node_type,
'path': url_for(
'%s.static'% self.name, filename=('js/%s' % self.node_type)
),
'when': self.script_load,
'is_template': False
}])
for module in self.submodules:
scripts.extend(module.get_own_javascripts())
return scripts
def generate_browser_node(

View File

@ -45,14 +45,34 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
"""
return []
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return True
def get_own_javascripts(self):
scripts = []
scripts.extend([{
'name': 'pgadmin.node.%s' % self.node_type,
'path': url_for('browser.index') + '%s/module' % self.node_type,
'when': self.script_load
}])
if self.module_use_template_javascript:
scripts.extend([{
'name': 'pgadmin.node.%s' % self.node_type,
'path': url_for('browser.index') + '%s/module' % self.node_type,
'when': self.script_load,
'is_template': True
}])
else:
scripts.extend([{
'name': 'pgadmin.node.%s' % self.node_type,
'path': url_for(
'%s.static'% self.name, filename=('js/%s' % self.node_type)
),
'when': self.script_load,
'is_template': False
}])
for module in self.submodules:
scripts.extend(module.get_own_javascripts())

View File

@ -87,7 +87,7 @@ class ServerGroupPluginModule(BrowserPluginModule):
pass
blueprint = ServerGroupModule(__name__, static_url_path='')
blueprint = ServerGroupModule(__name__)
class ServerGroupView(NodeView):
@ -276,16 +276,6 @@ class ServerGroupView(NodeView):
def dependents(self, gid):
return make_json_response(status=422)
def module_js(self, **kwargs):
"""
This property defines (if javascript) exists for this node.
Override this property for your own logic.
"""
return make_response(
render_template("server_groups/server_groups.js"),
200, {'Content-Type': 'application/x-javascript'}
)
def nodes(self, gid=None):
"""Return a JSON document listing the server groups for the user"""
nodes = []

View File

@ -128,24 +128,23 @@ class ServerModule(sg.ServerGroupPluginModule):
scripts = []
scripts.extend([{
'name': 'pgadmin.node.server',
'path': url_for('browser.index') + '%s/module' % self.node_type,
'when': self.script_load
},
{
'name': 'pgadmin.browser.server.privilege',
'path': url_for('browser.index') + 'server/static/js/privilege',
'when': self.node_type,
'deps': ['pgadmin.browser.node.ui']
},
{
'name': 'pgadmin.browser.server.variable',
'path': url_for('browser.index') + 'server/static/js/variable',
'when': self.node_type
}])
for module in self.submodules:
scripts.extend(module.get_own_javascripts())
'name': 'pgadmin.browser.server.privilege',
'path': url_for('%s.static'% self.name, filename='js/privilege'),
'when': self.node_type,
'is_template': False,
'deps': ['pgadmin.browser.node.ui']
}, {
'name': 'pgadmin.browser.server.variable',
'path': url_for('%s.static'% self.name, filename='js/variable'),
'when': self.node_type,
'is_template': False
},{
'name': 'pgadmin.server.supported_servers',
'path': url_for('browser.index') + 'server/supported_servers',
'is_template': True,
'when': self.node_type
}])
scripts.extend(sg.ServerGroupPluginModule.get_own_javascripts(self))
return scripts
@ -199,7 +198,7 @@ class ServerNode(PGChildNodeView):
'dependency': [{'get': 'dependencies'}],
'dependent': [{'get': 'dependents'}],
'children': [{'get': 'children'}],
'module.js': [{}, {}, {'get': 'module_js'}],
'supported_servers.js': [{}, {}, {'get': 'supported_servers'}],
'reload':
[{'get': 'reload_configuration'}],
'restore_point':
@ -561,7 +560,6 @@ class ServerNode(PGChildNodeView):
db.session.commit()
connected = False
icon = "icon-server-not-connected"
user = None
manager = None
@ -663,21 +661,16 @@ class ServerNode(PGChildNodeView):
def dependents(self, gid, sid):
return make_json_response(data='')
def module_js(self, **kwargs):
def supported_servers(self, **kwargs):
"""
This property defines (if javascript) exists for this node.
Override this property for your own logic.
"""
username = 'postgres'
if config.SERVER_MODE is True:
username = current_user.email.split('@')[0]
return make_response(
render_template(
"servers/servers.js",
server_types=ServerType.types(),
_=gettext,
username=username,
"servers/supported_servers.js",
server_types=ServerType.types()
),
200, {'Content-Type': 'application/x-javascript'}
)

View File

@ -14,7 +14,7 @@ import re
from functools import wraps
import pgadmin.browser.server_groups.servers as servers
from flask import render_template, make_response, current_app, request, jsonify
from flask import render_template, current_app, request, jsonify
from flask_babel import gettext as _
from pgadmin.browser.collection import CollectionNodeModule
from pgadmin.browser.server_groups.servers.databases.utils import \
@ -78,6 +78,13 @@ class DatabaseModule(CollectionNodeModule):
return snippets
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
blueprint = DatabaseModule(__name__)
@ -106,7 +113,6 @@ class DatabaseView(PGChildNodeView):
'dependency': [{'get': 'dependencies'}],
'dependent': [{'get': 'dependents'}],
'children': [{'get': 'children'}],
'module.js': [{}, {}, {'get': 'module_js'}],
'connect': [{
'get': 'connect_status', 'post': 'connect', 'delete': 'disconnect'
}],
@ -345,19 +351,6 @@ class DatabaseView(PGChildNodeView):
res['rows'][0].setdefault(row['deftype'], []).append(priv)
return res
def module_js(self):
"""
This property defines (if javascript) exists for this node.
Override this property for your own logic.
"""
return make_response(
render_template(
"databases/js/databases.js",
_=_
),
200, {'Content-Type': 'application/x-javascript'}
)
def connect(self, gid, sid, did):
"""Connect the Database."""
from pgadmin.utils.driver import get_driver

View File

@ -13,7 +13,7 @@ import simplejson as json
from functools import wraps
import pgadmin.browser.server_groups.servers.databases as databases
from flask import render_template, make_response, request, jsonify
from flask import render_template, request, jsonify
from flask_babel import gettext
from pgadmin.browser.collection import CollectionNodeModule
from pgadmin.browser.utils import PGChildNodeView
@ -78,6 +78,14 @@ class CastModule(CollectionNodeModule):
"""
return databases.DatabaseModule.NODE_TYPE
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
blueprint = CastModule(__name__)
@ -95,10 +103,6 @@ class CastView(PGChildNodeView):
* __init__(**kwargs)
- Method is used to initialize the CastView and it's base view.
* module_js()
- This property defines (if javascript) exists for this node.
Override this property for your own logic
* check_precondition()
- This function will behave as a decorator which will checks
database connection before running view, it will also attaches
@ -166,7 +170,6 @@ class CastView(PGChildNodeView):
'stats': [{'get': 'statistics'}],
'dependency': [{'get': 'dependencies'}],
'dependent': [{'get': 'dependents'}],
'module.js': [{}, {}, {'get': 'module_js'}],
'get_type': [{'get': 'get_src_and_trg_type'}, {'get': 'get_src_and_trg_type'}],
'get_functions': [{'post': 'get_functions'}, {'post': 'get_functions'}]
})
@ -177,18 +180,6 @@ class CastView(PGChildNodeView):
self.manager = None
super(CastView, self).__init__(**kwargs)
def module_js(self):
"""
This property defines whether javascript exists for this node.
"""
return make_response(
render_template(
"cast/js/casts.js",
_=gettext
),
200, {'Content-Type': 'application/x-javascript'}
)
def check_precondition(f):
"""
This function will behave as a decorator which will check the

View File

@ -12,7 +12,7 @@ import re
from functools import wraps
import pgadmin.browser.server_groups.servers.databases as database
from flask import render_template, make_response, request, jsonify
from flask import render_template, request, jsonify
from flask_babel import gettext
from pgadmin.browser.collection import CollectionNodeModule
from pgadmin.browser.utils import PGChildNodeView
@ -83,6 +83,14 @@ class EventTriggerModule(CollectionNodeModule):
"""
return database.DatabaseModule.NODE_TYPE
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
blueprint = EventTriggerModule(__name__)
@ -101,9 +109,6 @@ class EventTriggerView(PGChildNodeView):
* __init__(**kwargs)
- Method is used to initialize the EventTriggerView and it's base view.
* module_js()
- Returns the javascript module for event trigger.
* check_precondition()
- This function will behave as a decorator which will checks
database connection before running view, it will also attaches
@ -165,22 +170,9 @@ class EventTriggerView(PGChildNodeView):
'stats': [{'get': 'statistics'}],
'dependency': [{'get': 'dependencies'}],
'dependent': [{'get': 'dependents'}],
'module.js': [{}, {}, {'get': 'module_js'}],
'fopts': [{'get': 'get_event_funcs'}, {'get': 'get_event_funcs'}]
})
def module_js(self):
"""
Returns the javascript module for event trigger.
"""
return make_response(
render_template(
"event_triggers/js/event_trigger.js",
_=gettext
),
200, {'Content-Type': 'application/x-javascript'}
)
def check_precondition(f):
"""
This function will behave as a decorator which will checks

View File

@ -13,7 +13,7 @@ import simplejson as json
from functools import wraps
import pgadmin.browser.server_groups.servers.databases as databases
from flask import render_template, make_response, request, jsonify
from flask import render_template, request, jsonify
from flask_babel import gettext
from pgadmin.browser.collection import CollectionNodeModule
from pgadmin.browser.utils import PGChildNodeView
@ -82,6 +82,14 @@ class ExtensionModule(CollectionNodeModule):
"""
return databases.DatabaseModule.NODE_TYPE
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
# Create blueprint of extension module
blueprint = ExtensionModule(__name__)
@ -123,7 +131,6 @@ class ExtensionView(PGChildNodeView):
'stats': [{'get': 'statistics'}],
'dependency': [{'get': 'dependencies'}],
'dependent': [{'get': 'dependents'}],
'module.js': [{}, {}, {'get': 'module_js'}],
'avails': [{}, {'get': 'avails'}],
'schemas': [{}, {'get': 'schemas'}],
'children': [{'get': 'children'}]
@ -450,18 +457,6 @@ class ExtensionView(PGChildNodeView):
status=200
)
def module_js(self):
"""
This property defines whether javascript exists for this node.
"""
return make_response(
render_template(
"extensions/js/extensions.js",
_=gettext
),
200, {'Content-Type': 'application/x-javascript'}
)
@check_precondition
def sql(self, gid, sid, did, eid):
"""

View File

@ -13,7 +13,7 @@ import simplejson as json
from functools import wraps
import pgadmin.browser.server_groups.servers.databases as databases
from flask import render_template, make_response, request, jsonify
from flask import render_template, request, jsonify
from flask_babel import gettext
from pgadmin.browser.collection import CollectionNodeModule
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
@ -85,6 +85,14 @@ class ForeignDataWrapperModule(CollectionNodeModule):
"""
return databases.DatabaseModule.NODE_TYPE
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
blueprint = ForeignDataWrapperModule(__name__)
@ -102,10 +110,6 @@ class ForeignDataWrapperView(PGChildNodeView):
* __init__(**kwargs)
- Method is used to initialize the ForeignDataWrapperView and it's base view.
* module_js()
- This property defines (if javascript) exists for this node.
Override this property for your own logic
* check_precondition()
- This function will behave as a decorator which will checks
database connection before running view, it will also attaches
@ -178,24 +182,10 @@ class ForeignDataWrapperView(PGChildNodeView):
'stats': [{'get': 'statistics'}],
'dependency': [{'get': 'dependencies'}],
'dependent': [{'get': 'dependents'}],
'module.js': [{}, {}, {'get': 'module_js'}],
'get_handlers': [{}, {'get': 'get_handlers'}],
'get_validators': [{}, {'get': 'get_validators'}]
})
def module_js(self):
"""
This property defines (if javascript) exists for this node.
Override this property for your own logic.
"""
return make_response(
render_template(
"foreign_data_wrappers/js/foreign_data_wrappers.js",
_=gettext
),
200, {'Content-Type': 'application/x-javascript'}
)
def check_precondition(f):
"""
This function will behave as a decorator which will checks

View File

@ -13,7 +13,7 @@ import simplejson as json
from functools import wraps
import pgadmin.browser.server_groups.servers.databases as databases
from flask import render_template, make_response, request, jsonify
from flask import render_template, request, jsonify
from flask_babel import gettext
from pgadmin.browser.collection import CollectionNodeModule
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
@ -96,6 +96,14 @@ class LanguageModule(CollectionNodeModule):
"""
return databases.DatabaseModule.NODE_TYPE
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
blueprint = LanguageModule(__name__)
@ -113,10 +121,6 @@ class LanguageView(PGChildNodeView):
* __init__(**kwargs)
- Method is used to initialize the LanguageView and it's base view.
* module_js()
- This property defines (if javascript) exists for this node.
Override this property for your own logic
* check_precondition()
- This function will behave as a decorator which will checks
database connection before running view, it will also attaches
@ -185,7 +189,6 @@ class LanguageView(PGChildNodeView):
'stats': [{'get': 'statistics'}],
'dependency': [{'get': 'dependencies'}],
'dependent': [{'get': 'dependents'}],
'module.js': [{}, {}, {'get': 'module_js'}],
'get_functions': [{}, {'get': 'get_functions'}],
'get_templates': [{}, {'get': 'get_templates'}],
'delete': [{'delete': 'delete'}]
@ -205,18 +208,6 @@ class LanguageView(PGChildNodeView):
super(LanguageView, self).__init__(**kwargs)
def module_js(self):
"""
This property defines whether javascript exists for this node.
"""
return make_response(
render_template(
"languages/js/languages.js",
_=gettext
),
200, {'Content-Type': 'application/x-javascript'}
)
def check_precondition(f):
"""
This function will behave as a decorator which will check the

View File

@ -93,6 +93,14 @@ class SchemaModule(CollectionNodeModule):
"""
return servers.ServerModule.NODE_TYPE
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
class CatalogModule(SchemaModule):
"""
@ -151,10 +159,6 @@ class SchemaView(PGChildNodeView):
* __init__(**kwargs)
- Method is used to initialize the SchemaView and it's base view.
* module_js()
- Request handler for module.js routes for the schema node module
javascript, which returns javscript for this module.
* list()
- This function is used to list all the schema nodes within the
collection.
@ -217,7 +221,6 @@ class SchemaView(PGChildNodeView):
'stats': [{'get': 'statistics'}],
'dependency': [{'get': 'dependencies'}],
'dependent': [{'get': 'dependents'}],
'module.js': [{}, {}, {'get': 'module_js'}],
'delete': [{'delete': 'delete'}]
})
@ -901,10 +904,6 @@ class CatalogView(SchemaView):
* __init__(**kwargs)
- Method is used to initialize the CatalogView and it's base view.
* module_js()
- This property defines (if javascript) exists for this node.
Override this property for your own logic
* create(gid, sid, did, scid)
- Raise an error - we cannot create a catalog.

View File

@ -14,7 +14,7 @@ from functools import wraps
import pgadmin.browser.server_groups.servers.databases.schemas.domains \
as domains
from flask import render_template, make_response, request, jsonify
from flask import render_template, request, jsonify
from flask_babel import gettext
from pgadmin.browser.collection import CollectionNodeModule
from pgadmin.browser.utils import PGChildNodeView
@ -86,6 +86,14 @@ class DomainConstraintModule(CollectionNodeModule):
)
]
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
blueprint = DomainConstraintModule(__name__)
@ -103,9 +111,6 @@ class DomainConstraintView(PGChildNodeView):
Methods:
-------
* module_js():
- Load JS file (domain_constraints.js) for this module.
* check_precondition(f):
- Works as a decorator.
- Checks database connection status.
@ -170,8 +175,7 @@ class DomainConstraintView(PGChildNodeView):
'msql': [{'get': 'msql'}, {'get': 'msql'}],
'stats': [{'get': 'statistics'}],
'dependency': [{'get': 'dependencies'}],
'dependent': [{'get': 'dependents'}],
'module.js': [{}, {}, {'get': 'module_js'}]
'dependent': [{'get': 'dependents'}]
})
def validate_request(f):
@ -227,18 +231,6 @@ class DomainConstraintView(PGChildNodeView):
return wrap
def module_js(self):
"""
Load JS file (domain_constraints.js) for this module.
"""
return make_response(
render_template(
"domain_constraints/js/domain_constraints.js",
_=gettext
),
200, {'Content-Type': 'application/x-javascript'}
)
def check_precondition(f):
"""
Works as a decorator.
@ -338,7 +330,6 @@ class DomainConstraintView(PGChildNodeView):
doid: Domain Id
coid: Domain Constraint Id
"""
res = []
SQL = render_template("/".join([self.template_path,
'properties.sql']),
coid=coid)

View File

@ -235,7 +235,7 @@ define('pgadmin.node.sequence', [
if (!this.isNew()) {
if (_.isUndefined(this.get('current_value'))
|| String(this.get('current_value')).replace(/^\s+|\s+$/g, '') == '') {
msg = '{{ _('Current value cannot be empty.') }}';
msg = gettext('Current value cannot be empty.');
this.errorModel.set('current_value', msg);
return msg;
} else {
@ -244,7 +244,7 @@ define('pgadmin.node.sequence', [
if (_.isUndefined(this.get('increment'))
|| String(this.get('increment')).replace(/^\s+|\s+$/g, '') == '') {
msg = '{{ _('Increment value cannot be empty.') }}';
msg = gettext('Increment value cannot be empty.');
this.errorModel.set('increment', msg);
return msg;
} else {
@ -253,7 +253,7 @@ define('pgadmin.node.sequence', [
if (_.isUndefined(this.get('minimum'))
|| String(this.get('minimum')).replace(/^\s+|\s+$/g, '') == '') {
msg = '{{ _('Minimum value cannot be empty.') }}';
msg = gettext('Minimum value cannot be empty.');
this.errorModel.set('minimum', msg);
return msg;
} else {
@ -262,7 +262,7 @@ define('pgadmin.node.sequence', [
if (_.isUndefined(this.get('maximum'))
|| String(this.get('maximum')).replace(/^\s+|\s+$/g, '') == '') {
msg = '{{ _('Maximum value cannot be empty.') }}';
msg = gettext('Maximum value cannot be empty.');
this.errorModel.set('maximum', msg);
return msg;
} else {
@ -271,7 +271,7 @@ define('pgadmin.node.sequence', [
if (_.isUndefined(this.get('cache'))
|| String(this.get('cache')).replace(/^\s+|\s+$/g, '') == '') {
msg = '{{ _('Cache value cannot be empty.') }}';
msg = gettext('Cache value cannot be empty.');
this.errorModel.set('cache', msg);
return msg;
} else {

View File

@ -14,7 +14,6 @@ import json
from flask import render_template
from pgadmin.browser.collection import CollectionNodeModule
from pgadmin.utils.ajax import internal_server_error
from config import PG_DEFAULT_DRIVER
class SchemaChildModule(CollectionNodeModule):
"""
@ -62,6 +61,14 @@ class SchemaChildModule(CollectionNodeModule):
self, manager, **kwargs
)
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
class DataTypeReader:
"""
@ -165,7 +172,6 @@ class DataTypeReader:
conn: Connection Object
condition: condition to restrict SQL statement
"""
needSchema = isDup
schema = nsp if nsp is not None else ''
name = ''
array = ''

View File

@ -11,7 +11,7 @@
from functools import wraps
import json
from flask import render_template, make_response, request, jsonify
from flask import render_template, request, jsonify
from flask_babel import gettext as _
from config import PG_DEFAULT_DRIVER
@ -98,6 +98,14 @@ SELECT EXISTS(
return snippets
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
blueprint = JobModule(__name__)
@ -124,8 +132,7 @@ class JobView(PGChildNodeView):
'run_now': [{'put': 'run_now'}],
'classes': [{}, {'get': 'job_classes'}],
'children': [{'get': 'children'}],
'stats': [{'get': 'statistics'}],
'module.js': [{}, {}, {'get': 'module_js'}]
'stats': [{'get': 'statistics'}]
})
def check_precondition(f):
@ -249,19 +256,6 @@ SELECT EXISTS(
status=200
)
def module_js(self):
"""
This property defines (if javascript) exists for this node.
Override this property for your own logic.
"""
return make_response(
render_template(
"pga_job/js/pga_job.js",
_=_
),
200, {'Content-Type': 'application/x-javascript'}
)
@check_precondition
def create(self, gid, sid):
"""Create the pgAgent job."""

View File

@ -12,7 +12,7 @@
import json
from functools import wraps
from flask import render_template, make_response, request, jsonify
from flask import render_template, request, jsonify
from flask_babel import gettext
from pgadmin.browser.collection import CollectionNodeModule
from pgadmin.browser.utils import PGChildNodeView
@ -71,6 +71,14 @@ class JobScheduleModule(CollectionNodeModule):
"""
return 'pga_job'
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
blueprint = JobScheduleModule(__name__)
@ -88,10 +96,6 @@ class JobScheduleView(PGChildNodeView):
* __init__(**kwargs)
- Method is used to initialize the JobScheduleView and it's base view.
* module_js()
- This property defines (if javascript) exists for this node.
Override this property for your own logic
* check_precondition()
- This function will behave as a decorator which will checks
database connection before running view, it will also attaches
@ -140,8 +144,7 @@ class JobScheduleView(PGChildNodeView):
],
'nodes': [{'get': 'nodes'}, {'get': 'nodes'}],
'msql': [{'get': 'msql'}, {'get': 'msql'}],
'sql': [{'get': 'sql'}],
'module.js': [{}, {}, {'get': 'module_js'}]
'sql': [{'get': 'sql'}]
})
def _init_(self, **kwargs):
@ -159,18 +162,6 @@ class JobScheduleView(PGChildNodeView):
super(JobScheduleView, self).__init__(**kwargs)
def module_js(self):
"""
This property defines whether javascript exists for this node.
"""
return make_response(
render_template(
"pga_schedule/js/pga_schedule.js",
_=gettext
),
200, {'Content-Type': 'application/x-javascript'}
)
def check_precondition(f):
"""
This function will behave as a decorator which will check the

View File

@ -337,7 +337,10 @@ define('pgadmin.node.pga_schedule', [
);
this.$el.prepend(
'<div class="' + Backform.helpMessageClassName + ' set-group pg-el-xs-12">{{ _("Schedules are specified using a <b>cron-style</b> format.<br/><ul><li>For each selected time or date element, the schedule will execute.<br/>e.g. To execute at 5 minutes past every hour, simply select 05 in the Minutes list box.<br/></li><li>Values from more than one field may be specified in order to further control the schedule.<br/>e.g. To execute at 12:05 and 14:05 every Monday and Thursday, you would click minute 05, hours 12 and 14, and weekdays Monday and Thursday.</li><li>For additional flexibility, the Month Days check list includes an extra Last Day option. This matches the last day of the month, whether it happens to be the 28th, 29th, 30th or 31st.</li></ul>") }}</div>'
'<div class="set-group pg-el-xs-12 ' +
Backform.helpMessageClassName + '">' +
gettext('Schedules are specified using a <b>cron-style</b> format.<br/><ul><li>For each selected time or date element, the schedule will execute.<br/>e.g. To execute at 5 minutes past every hour, simply select 05 in the Minutes list box.<br/></li><li>Values from more than one field may be specified in order to further control the schedule.<br/>e.g. To execute at 12:05 and 14:05 every Monday and Thursday, you would click minute 05, hours 12 and 14, and weekdays Monday and Thursday.</li><li>For additional flexibility, the Month Days check list includes an extra Last Day option. This matches the last day of the month, whether it happens to be the 28th, 29th, 30th or 31st.</li></ul>') +
'</div>'
);
return res;

View File

@ -12,7 +12,7 @@
import json
from functools import wraps
from flask import render_template, make_response, request, jsonify
from flask import render_template, request, jsonify
from flask_babel import gettext
from pgadmin.browser.collection import CollectionNodeModule
from pgadmin.browser.utils import PGChildNodeView
@ -71,6 +71,14 @@ class JobStepModule(CollectionNodeModule):
"""
return 'pga_job'
@property
def module_use_template_javascript(self):
"""
Returns whether Jinja2 template is used for generating the javascript
module.
"""
return False
blueprint = JobStepModule(__name__)
@ -88,10 +96,6 @@ class JobStepView(PGChildNodeView):
* __init__(**kwargs)
- Method is used to initialize the JobStepView and it's base view.
* module_js()
- This property defines (if javascript) exists for this node.
Override this property for your own logic
* check_precondition()
- This function will behave as a decorator which will checks
database connection before running view, it will also attaches
@ -142,8 +146,7 @@ class JobStepView(PGChildNodeView):
'nodes': [{'get': 'nodes'}, {'get': 'nodes'}],
'msql': [{'get': 'msql'}, {'get': 'msql'}],
'sql': [{'get': 'sql'}],
'stats': [{'get': 'statistics'}],
'module.js': [{}, {}, {'get': 'module_js'}]
'stats': [{'get': 'statistics'}]
})
def _init_(self, **kwargs):
@ -161,18 +164,6 @@ class JobStepView(PGChildNodeView):
super(JobStepView, self).__init__(**kwargs)
def module_js(self):
"""
This property defines whether javascript exists for this node.
"""
return make_response(
render_template(
"pga_jobstep/js/pga_jobstep.js",
_=gettext
),
200, {'Content-Type': 'application/x-javascript'}
)
def check_precondition(f):
"""
This function will behave as a decorator which will check the

View File

@ -1,7 +1,12 @@
define('pgadmin.node.server', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify'
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify',
'pgadmin.server.supported_servers',
'pgadmin.user_management.current_user'
], function(
gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify,
supported_servers, current_user
) {
if (!pgBrowser.Nodes['server']) {
@ -599,7 +604,7 @@ define('pgadmin.node.server', [
host: '',
port: 5432,
db: 'postgres',
username: '{{ username }}',
username: current_user.name,
role: null,
connect_now: true,
password: undefined,
@ -626,10 +631,7 @@ define('pgadmin.node.server', [
},{
id: 'server_type', label: gettext('Server type'), type: 'options',
mode: ['properties'], visible: 'isConnected',
'options': [{% for st in server_types %}
{label: '{{ st.description }}', value: '{{ st.server_type }}'},{% endfor %}
{label: gettext('Unknown'), value: ''}
]
'options': supported_servers
},{
id: 'connected', label: gettext('Connected?'), type: 'switch',
mode: ['properties'], group: gettext('Connection'), 'options': {
@ -670,7 +672,7 @@ define('pgadmin.node.server', [
return m.get('connect_now') && m.isNew();
},
disabled: function(m) {
return {% if config.ALLOW_SAVE_PASSWORD %}false{% else %}true{% endif %};
return current_user.allow_save_password;
}
},{
id: 'role', label: gettext('Role'), type: 'text', group: gettext('Connection'),
@ -721,9 +723,7 @@ define('pgadmin.node.server', [
check_for_empty(
'username', gettext('Username must be specified.')
);
check_for_empty(
'port', '{{ _('Port must be specified.') }}'
);
check_for_empty('port', gettext('Port must be specified.'));
this.errorModel.set(err);
if (_.size(err)) {

View File

@ -0,0 +1,13 @@
define(
'pgadmin.server.supported_servers',
['sources/gettext'],
function(gettext) {
return [
{% for st in server_types %}
{label: '{{ st.description }}', value: '{{ st.server_type }}'},{% endfor %}
{label: gettext('Unknown'), value: ''}
];
}
);

View File

@ -120,7 +120,9 @@ function(_, S, pgAdmin, $) {
this.$el.removeClass('disabled');
}
this.applyStyle();
if(this.$el) {
this.applyStyle();
}
this.context = {
name: this.label,

View File

@ -127,8 +127,7 @@ class NodeView(with_metaclass(MethodViewType, View)):
'stats': [{'get': 'statistics'}],
'dependency': [{'get': 'dependencies'}],
'dependent': [{'get': 'dependents'}],
'children': [{'get': 'children'}],
'module.js': [{}, {}, {'get': 'module_js'}]
'children': [{'get': 'children'}]
})
@classmethod

View File

@ -165,7 +165,6 @@
'pgadmin.alertifyjs': "{{ url_for('static', filename='js/alertify.pgadmin.defaults') }}",
"pgadmin.backgrid": "{{ url_for('static', filename='js/backgrid.pgadmin') }}",
'pgadmin.backform': "{{ url_for('static', filename='js/backform.pgadmin') }}",
modernizr: "{{ url_for('static', filename='vendor/modernizr/modernizr-2.6.2-respond-1.1.0.min') }}",
jquery: "{{ url_for('static', filename='vendor/jquery/jquery-1.11.2' + ('' if config.DEBUG else '.min')) }}",
select2: "{{ url_for('static', filename='vendor/select2/select2.full'+ ('' if config.DEBUG else '.min')) }}",
@ -190,10 +189,9 @@
"jquery.ui": "{{ url_for('static', filename='vendor/jquery-ui/jquery-ui-1.11.3' + ('' if config.DEBUG else '.min')) }}",
"bignumber": "{{ url_for('static', filename='vendor/bignumber/bignumber' if config.DEBUG else 'vendor/bignumber/bignumber.min') }}",
bean :"{{ url_for('static', filename='vendor/flotr2/bean' + ('' if config.DEBUG else '-min')) }}",
flotr2 :"{{ url_for('static', filename='vendor/flotr2/flotr2.amd') }}"
{% for script in current_app.javascripts %}
,'{{ script.name }}': "{{ script.path }}"
{% endfor %}
flotr2 :"{{ url_for('static', filename='vendor/flotr2/flotr2.amd') }}"{% for script in current_app.javascripts %},
'{{ script.name }}': "{{ script.path }}"{% endfor %}
}
});

View File

@ -17,6 +17,8 @@ from flask import render_template, request, \
from flask_babel import gettext as _
from flask_security import login_required, roles_required, current_user
from flask_security.utils import encrypt_password
import config
from pgadmin.utils import PgAdminModule
from pgadmin.utils.ajax import make_response as ajax_response, \
make_json_response, bad_request, internal_server_error
@ -49,6 +51,11 @@ class UserManagementModule(PgAdminModule):
'name': 'pgadmin.tools.user_management',
'path': url_for('user_management.index') + 'user_management',
'when': None
},{
'name': 'pgadmin.user_management.current_user',
'path': url_for('user_management.index') + 'current_user',
'when': None,
'is_template': True
}]
def show_system_objects(self):
@ -120,7 +127,25 @@ def script():
"user_management/js/user_management.js", _=_,
is_admin=current_user.has_role("Administrator"),
user_id=current_user.id
),
status=200,
mimetype="application/javascript"
)
@blueprint.route("/current_user.js")
@login_required
def current_user_info():
return Response(
response=render_template(
"user_management/js/current_user.js",
is_admin='true' if current_user.has_role("Administrator") else 'false',
user_id=current_user.id,
email=current_user.email,
name=(
current_user.email.split('@')[0] if config.SERVER_MODE is True
else 'postgres'
),
allow_save_password='true' if config.ALLOW_SAVE_PASSWORD else 'false'
),
status=200,
mimetype="application/javascript"

View File

@ -0,0 +1,9 @@
define('pgadmin.user_management.current_user', [], function() {
return {
'id': {{ user_id }},
'email': '{{ email }}',
'is_admin': {{ is_admin }},
'name': '{{ name }}',
'allow_save_password': {{ allow_save_password }}
}
});