Update all Python and JS dependencies. Fixes #4019

This commit is contained in:
Khushboo Vashi 2019-03-14 15:11:16 +00:00 committed by Dave Page
parent c7b29d35ae
commit e4417229aa
133 changed files with 8649 additions and 8569 deletions

View File

@ -19,6 +19,7 @@ Bug fixes
********* *********
| `Bug #3995 <https://redmine.postgresql.org/issues/3995>`_ - Avoid 'bogus varno' message from Postgres when viewing the SQL for a table with triggers. | `Bug #3995 <https://redmine.postgresql.org/issues/3995>`_ - Avoid 'bogus varno' message from Postgres when viewing the SQL for a table with triggers.
| `Bug #4019 <https://redmine.postgresql.org/issues/4019>`_ - Update all Python and JavaScript dependencies.
| `Bug #4052 <https://redmine.postgresql.org/issues/4052>`_ - Fix the online help button on the resource group dialogue. | `Bug #4052 <https://redmine.postgresql.org/issues/4052>`_ - Fix the online help button on the resource group dialogue.
| `Bug #4053 <https://redmine.postgresql.org/issues/4053>`_ - Enable the online help button on the index dialogue. | `Bug #4053 <https://redmine.postgresql.org/issues/4053>`_ - Enable the online help button on the index dialogue.
| `Bug #4054 <https://redmine.postgresql.org/issues/4054>`_ - Handle resultsets with zero columns correctly in the Query Tool. | `Bug #4054 <https://redmine.postgresql.org/issues/4054>`_ - Handle resultsets with zero columns correctly in the Query Tool.

File diff suppressed because it is too large Load Diff

View File

@ -4,32 +4,33 @@
# ignored when building a PIP Wheel. # ignored when building a PIP Wheel.
############################################################################## ##############################################################################
blinker==1.4 blinker==1.4
Flask==0.12.4 Flask==1.0.2
Flask-Gravatar==0.5.0 Flask-Gravatar==0.5.0
Flask-Login==0.3.2 Flask-Login==0.4.1
Flask-Mail==0.9.1 Flask-Mail==0.9.1
Flask-Migrate==2.1.1 Flask-Migrate==2.4.0
Flask-Principal==0.4.0 Flask-Principal==0.4.0
Flask-SQLAlchemy==2.3.2 Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2 Flask-WTF==0.14.2
passlib==1.7.1 passlib==1.7.1
pytz==2018.3 pytz==2018.9
simplejson==3.13.2 simplejson==3.16.0
six>=1.11.0 six>=1.12.0
speaklater==1.3 speaklater==1.3
sqlparse==0.2.4 sqlparse==0.2.4
WTForms==2.1 WTForms==2.2.1
Flask-Paranoid==0.2.0 Flask-Paranoid==0.2.0
psutil==5.4.7 psutil==5.5.1
psycopg2>=2.7.4 psycopg2>=2.7.7
python-dateutil>=2.7.1 python-dateutil>=2.8.0
htmlmin==0.1.12 htmlmin==0.1.12
Flask-HTMLmin==1.3.2 Flask-HTMLmin==1.5.0
SQLAlchemy>=1.2.5 SQLAlchemy>=1.2.18
Flask-Security>=3.0.0 Flask-Security>=3.0.0
sshtunnel>=0.1.3 sshtunnel>=0.1.4
############################################################### ###############################################################
# Modules specifically required for Python2.7 # Modules specifically required for Python2.7
############################################################### ###############################################################
importlib==1.0.3; python_version <= '2.7' importlib==1.0.4; python_version <= '2.7'

View File

@ -14,14 +14,9 @@ module.exports = {
'amd': true, 'amd': true,
'jasmine': true, 'jasmine': true,
}, },
'extends': [
'eslint:recommended',
],
'parserOptions': { 'parserOptions': {
'ecmaFeatures': { 'ecmaVersion': 2018,
'experimentalObjectRestSpread': true, 'sourceType': 'module',
},
'sourceType': 'module'
}, },
'plugins': [ 'plugins': [
], ],

View File

@ -1,96 +1,98 @@
{ {
"license": "PostgreSQL", "license": "PostgreSQL",
"devDependencies": { "devDependencies": {
"axios-mock-adapter": "^1.14.1", "@babel/core": "~7.3.4",
"babel-core": "~6.24.0", "@babel/preset-env": "~7.3.4",
"babel-loader": "~7.1.2", "axios-mock-adapter": "^1.16.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-loader": "~8.0.5",
"babel-preset-es2015": "~6.24.0", "babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3",
"cross-env": "^5.0.1", "cross-env": "^5.2.0",
"eclint": "^2.3.0", "eclint": "^2.8.1",
"eslint": "3.19.0", "eslint": "5.15.1",
"extract-text-webpack-plugin": "^3.0.2", "file-loader": "^3.0.1",
"file-loader": "^0.11.2", "image-webpack-loader": "^4.6.0",
"image-webpack-loader": "^3.3.1",
"is-docker": "^1.1.0", "is-docker": "^1.1.0",
"jasmine-core": "~2.99.0", "jasmine-core": "~3.3.0",
"karma": "~2.0.0", "karma": "^4.0.1",
"karma-babel-preprocessor": "^7.0.0", "karma-babel-preprocessor": "^8.0.0",
"karma-browserify": "~5.2.0", "karma-browserify": "~6.0.0",
"karma-chrome-launcher": "^2.2.0", "karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "~1.1.1", "karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^0.2.2", "karma-jasmine-html-reporter": "^1.4.0",
"karma-requirejs": "~1.1.0", "karma-requirejs": "~1.1.0",
"karma-source-map-support": "^1.3.0", "karma-source-map-support": "^1.4.0",
"karma-sourcemap-loader": "^0.3.7", "karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "~2.0.13", "karma-webpack": "~4.0.0-rc.6",
"node-sass": "^4.5.3", "mini-css-extract-plugin": "^0.5.0",
"optimize-css-assets-webpack-plugin": "^2.0.0", "node-sass": "^4.11.0",
"popper.js": "^1.14.4", "optimize-css-assets-webpack-plugin": "^5.0.1",
"raw-loader": "^0.5.1", "popper.js": "^1.14.7",
"raw-loader": "^1.0.0",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"sass-resources-loader": "^1.3.3", "sass-resources-loader": "^2.0.0",
"style-loader": "^0.18.2", "style-loader": "^0.23.1",
"uglifyjs-webpack-plugin": "^0.4.6", "uglifyjs-webpack-plugin": "^2.1.2",
"url-loader": "^0.5.9", "url-loader": "^1.1.2",
"webpack": "^3.0.0" "webpack": "^4.29.6",
"webpack-cli": "^3.2.3"
}, },
"dependencies": { "dependencies": {
"@babel/polyfill": "^7.2.5",
"acitree": "git+https://github.com/imsurinder90/jquery-aciTree.git#rc.7", "acitree": "git+https://github.com/imsurinder90/jquery-aciTree.git#rc.7",
"alertifyjs": "1.7.1", "alertifyjs": "1.7.1",
"axios": "^0.18.0", "axios": "^0.18.0",
"babel-plugin-transform-es2015-modules-amd": "^6.24.1", "babel-plugin-transform-es2015-modules-amd": "^6.24.1",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015-without-strict": "~0.0.4", "babel-preset-es2015-without-strict": "~0.0.4",
"babelify": "~7.3.0", "babelify": "~10.0.0",
"backbone": "1.3.3", "backbone": "1.4.0",
"backform": "^0.2.0", "backform": "^0.2.0",
"backgrid": "^0.3.8", "backgrid": "^0.3.8",
"backgrid-filter": "^0.3.7", "backgrid-filter": "^0.3.7",
"backgrid-select-all": "^0.3.5", "backgrid-select-all": "^0.3.5",
"backgrid-sizeable-columns": "^0.1.1", "backgrid-sizeable-columns": "^0.1.1",
"bignumber.js": "^6.0.0", "bignumber.js": "^8.1.1",
"bootstrap": "^4.1.3", "bootstrap": "^4.3.1",
"bootstrap-datepicker": "^1.7.0", "bootstrap-datepicker": "^1.8.0",
"bootstrap4-toggle": "3.4.0", "bootstrap4-toggle": "3.4.0",
"bowser": "1.6.1", "bowser": "2.1.2",
"browserify": "~14.1.0", "browserify": "~16.2.3",
"codemirror": "^5.43.0", "codemirror": "^5.44.0",
"css-loader": "0.14.0", "css-loader": "2.1.0",
"cssnano": "^3.10.0", "cssnano": "^4.1.10",
"dropzone": "^5.1.1", "dropzone": "^5.5.1",
"exports-loader": "~0.6.4", "exports-loader": "~0.7.0",
"flotr2": "git+https://github.com/EnterpriseDB/Flotr2.git", "flotr2": "git+https://github.com/EnterpriseDB/Flotr2.git",
"font-awesome": "^4.7.0", "font-awesome": "^4.7.0",
"hard-source-webpack-plugin": "0.12.0", "fsevents": "^1.2.7",
"immutability-helper": "^2.2.0", "hard-source-webpack-plugin": "0.13.1",
"imports-loader": "^0.7.1", "immutability-helper": "^3.0.0",
"imports-loader": "^0.8.0",
"ip-address": "^5.8.9", "ip-address": "^5.8.9",
"jquery": "3.3.1", "jquery": "3.3.1",
"jquery-contextmenu": "^2.6.4", "jquery-contextmenu": "^2.8.0",
"jquery-ui": "^1.12.1", "jquery-ui": "^1.12.1",
"json-bignumber": "^1.0.1", "json-bignumber": "^1.0.1",
"leaflet": "^1.3.3", "leaflet": "^1.4.0",
"moment": "^2.20.1", "moment": "^2.24.0",
"moment-timezone": "^0.5.21", "moment-timezone": "^0.5.23",
"mousetrap": "^1.6.1", "mousetrap": "^1.6.3",
"prop-types": "^15.5.10", "prop-types": "^15.7.2",
"requirejs": "~2.3.3", "requirejs": "~2.3.6",
"select2": "^4.0.6-rc.1", "select2": "^4.0.6-rc.1",
"shim-loader": "^1.0.1", "shim-loader": "^1.0.1",
"slickgrid": "git+https://github.com/6pac/SlickGrid.git#2.3.16", "slickgrid": "git+https://github.com/6pac/SlickGrid.git#2.3.16",
"snapsvg": "^0.5.1", "snapsvg": "^0.5.1",
"spectrum-colorpicker": "^1.8.0", "spectrum-colorpicker": "^1.8.0",
"split.js": "^1.5.10", "split.js": "^1.5.10",
"sprintf-js": "^1.1.1", "sprintf-js": "^1.1.2",
"tablesorter": "^2.30.6", "tablesorter": "^2.31.1",
"tempusdominus-bootstrap-4": "^5.1.2", "tempusdominus-bootstrap-4": "^5.1.2",
"tempusdominus-core": "^5.0.3", "tempusdominus-core": "^5.0.3",
"underscore": "^1.8.3", "underscore": "^1.9.1",
"underscore.string": "^3.3.4", "underscore.string": "^3.3.5",
"watchify": "~3.9.0", "watchify": "~3.11.1",
"webcabin-docker": "git+https://github.com/EnterpriseDB/wcDocker/#9cf81f03bb350b76b77a264f1db5d55391d5e424", "webcabin-docker": "git+https://github.com/EnterpriseDB/wcDocker/#9cf81f03bb350b76b77a264f1db5d55391d5e424",
"wkx": "^0.4.5" "wkx": "^0.4.6"
}, },
"scripts": { "scripts": {
"linter": "yarn eslint --no-eslintrc -c .eslintrc.js --ext .js .", "linter": "yarn eslint --no-eslintrc -c .eslintrc.js --ext .js .",

View File

@ -51,11 +51,11 @@ define(
} }
$.get(url_for('about.index'), $.get(url_for('about.index'),
function(data) { function(data) {
alertify.aboutDialog( alertify.aboutDialog(
S(gettext('About %s')).sprintf(pgAdmin.Browser.utils.app_name).value(), data S(gettext('About %s')).sprintf(pgAdmin.Browser.utils.app_name).value(), data
).resizeTo(pgAdmin.Browser.stdW.md, pgAdmin.Browser.stdH.md); ).resizeTo(pgAdmin.Browser.stdW.md, pgAdmin.Browser.stdH.md);
}); });
}, },
}; };

View File

@ -12,7 +12,7 @@ define('pgadmin.node.cast', [
'underscore.string', 'sources/pgadmin', 'pgadmin.browser', 'underscore.string', 'sources/pgadmin', 'pgadmin.browser',
'pgadmin.alertifyjs', 'pgadmin.backform', 'pgadmin.browser.collection', 'pgadmin.alertifyjs', 'pgadmin.backform', 'pgadmin.browser.collection',
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, Backform) { ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, Backform) {
// Extend the collection class for cast // Extend the collection class for cast
if (!pgBrowser.Nodes['coll-cast']) { if (!pgBrowser.Nodes['coll-cast']) {
pgAdmin.Browser.Nodes['coll-cast'] = pgAdmin.Browser.Nodes['coll-cast'] =
pgAdmin.Browser.Collection.extend({ pgAdmin.Browser.Collection.extend({
@ -23,7 +23,7 @@ define('pgadmin.node.cast', [
}); });
} }
// Extend the node class for cast // Extend the node class for cast
if (!pgBrowser.Nodes['cast']) { if (!pgBrowser.Nodes['cast']) {
pgAdmin.Browser.Nodes['cast'] = pgAdmin.Browser.Node.extend({ pgAdmin.Browser.Nodes['cast'] = pgAdmin.Browser.Node.extend({
parent_type: 'database', parent_type: 'database',
@ -38,13 +38,13 @@ define('pgadmin.node.cast', [
hasDepends: true, hasDepends: true,
Init: function() { Init: function() {
// Avoid multiple registration of menus // Avoid multiple registration of menus
if (this.initialized) if (this.initialized)
return; return;
this.initialized = true; this.initialized = true;
// Add context menus for cast // Add context menus for cast
pgBrowser.add_menus([{ pgBrowser.add_menus([{
name: 'create_cast_on_database', node: 'database', module: this, name: 'create_cast_on_database', node: 'database', module: this,
applies: ['object', 'context'], callback: 'show_obj_properties', applies: ['object', 'context'], callback: 'show_obj_properties',
@ -65,7 +65,7 @@ define('pgadmin.node.cast', [
}, },
// Define the backform model for cast node // Define the backform model for cast node
model: pgAdmin.Browser.Node.Model.extend({ model: pgAdmin.Browser.Node.Model.extend({
idAttribute: 'oid', idAttribute: 'oid',
defaults: { defaults: {
@ -79,7 +79,7 @@ define('pgadmin.node.cast', [
description: undefined, // Comment on the cast description: undefined, // Comment on the cast
}, },
// Define the schema for cast // Define the schema for cast
schema: [{ schema: [{
id: 'name', label: gettext('Name'), cell: 'string', id: 'name', label: gettext('Name'), cell: 'string',
editable: false, type: 'text', disabled: true, cellHeaderClasses: 'width_percent_50', editable: false, type: 'text', disabled: true, cellHeaderClasses: 'width_percent_50',
@ -99,7 +99,7 @@ define('pgadmin.node.cast', [
return rows; return rows;
}, },
/* /*
* Control is extended to create cast name from source type and destination type * Control is extended to create cast name from source type and destination type
* once their values are changed * once their values are changed
*/ */
@ -107,10 +107,10 @@ define('pgadmin.node.cast', [
onChange: function() { onChange: function() {
Backform.NodeAjaxOptionsControl.prototype.onChange.apply( Backform.NodeAjaxOptionsControl.prototype.onChange.apply(
this, arguments this, arguments
); );
/* /*
* On source type change, check if both source type and * On source type change, check if both source type and
* target type are set, if yes then fetch values from both * target type are set, if yes then fetch values from both
* controls and generate cast name * controls and generate cast name
@ -121,12 +121,12 @@ define('pgadmin.node.cast', [
trgtype != undefined && trgtype != '') trgtype != undefined && trgtype != '')
this.model.set('name', srctype+'->'+trgtype); this.model.set('name', srctype+'->'+trgtype);
else else
this.model.unset('name'); this.model.unset('name');
}, },
}), }),
}, },
/* /*
* Text control for viewing source type in properties and * Text control for viewing source type in properties and
* edit mode only * edit mode only
*/ */
@ -145,7 +145,7 @@ define('pgadmin.node.cast', [
return rows; return rows;
}, },
/* /*
* Control is extended to create cast name from source type and destination type * Control is extended to create cast name from source type and destination type
* once their values are changed * once their values are changed
*/ */
@ -153,10 +153,10 @@ define('pgadmin.node.cast', [
onChange: function() { onChange: function() {
Backform.NodeAjaxOptionsControl.prototype.onChange.apply( Backform.NodeAjaxOptionsControl.prototype.onChange.apply(
this, arguments this, arguments
); );
/* /*
* on target type change, check if both source type and * on target type change, check if both source type and
* target type are set, if yes then fetch values from both * target type are set, if yes then fetch values from both
* controls and generate cast name * controls and generate cast name
@ -167,11 +167,11 @@ define('pgadmin.node.cast', [
trgtype != undefined && trgtype != '') trgtype != undefined && trgtype != '')
this.model.set('name', srcType+'->'+trgtype); this.model.set('name', srcType+'->'+trgtype);
else else
this.model.unset('name'); this.model.unset('name');
}, },
}), }),
}, },
/* /*
* Text control for viewing target type in properties and * Text control for viewing target type in properties and
* edit mode only * edit mode only
*/ */
@ -180,7 +180,7 @@ define('pgadmin.node.cast', [
group: gettext('Definition'), disabled: true, mode:['properties','edit'], group: gettext('Definition'), disabled: true, mode:['properties','edit'],
}, },
/* /*
* Proname field is dependent on source type and target type. * Proname field is dependent on source type and target type.
* On source and target type changed event, * On source and target type changed event,
* associated functions will be fetch using ajax call * associated functions will be fetch using ajax call
@ -197,13 +197,13 @@ define('pgadmin.node.cast', [
if(srcTyp != undefined && srcTyp != '' && if(srcTyp != undefined && srcTyp != '' &&
trgtyp != undefined && trgtyp != '') trgtyp != undefined && trgtyp != '')
{ {
var node = control.field.get('schema_node'), var node = control.field.get('schema_node'),
_url = node.generate_url.apply( _url = node.generate_url.apply(
node, [ node, [
null, 'get_functions', control.field.get('node_data'), false, null, 'get_functions', control.field.get('node_data'), false,
control.field.get('node_info'), control.field.get('node_info'),
]); ]);
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
timeout: 30000, timeout: 30000,
@ -212,15 +212,15 @@ define('pgadmin.node.cast', [
async: false, async: false,
data: {'srctyp' : srcTyp, 'trgtyp' : trgtyp}, data: {'srctyp' : srcTyp, 'trgtyp' : trgtyp},
}) })
// On success return function list from server // On success return function list from server
.done(function(result) { .done(function(result) {
res = result.data; res = result.data;
return res; return res;
}) })
// On failure show error appropriate error message to user // On failure show error appropriate error message to user
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error); alertify.pgRespErrorNotify(xhr, error);
}); });
} }
return res; return res;
}, },

View File

@ -21,18 +21,18 @@ define('pgadmin.node.foreign_server', [
fsrvvalue: undefined, fsrvvalue: undefined,
}, },
// Defining schema for the Options model // Defining schema for the Options model
schema: [ schema: [
{id: 'fsrvoption', label: gettext('Options'), type:'text', cellHeaderClasses:'width_percent_50', group: null, editable: true}, {id: 'fsrvoption', label: gettext('Options'), type:'text', cellHeaderClasses:'width_percent_50', group: null, editable: true},
{id: 'fsrvvalue', label: gettext('Value'), type: 'text', cellHeaderClasses:'width_percent_50', group:null, editable: true}, {id: 'fsrvvalue', label: gettext('Value'), type: 'text', cellHeaderClasses:'width_percent_50', group:null, editable: true},
], ],
/* validate function is used to validate the input given by /* validate function is used to validate the input given by
* the user. In case of error, message will be displayed on * the user. In case of error, message will be displayed on
* the browser for the respective control. * the browser for the respective control.
*/ */
validate: function() { validate: function() {
// Validation for the option name // Validation for the option name
if (_.isUndefined(this.get('fsrvoption')) || if (_.isUndefined(this.get('fsrvoption')) ||
_.isNull(this.get('fsrvoption')) || _.isNull(this.get('fsrvoption')) ||
String(this.get('fsrvoption')).replace(/^\s+|\s+$/g, '') == '') { String(this.get('fsrvoption')).replace(/^\s+|\s+$/g, '') == '') {

View File

@ -13,7 +13,7 @@ define('pgadmin.node.user_mapping', [
'pgadmin.backform', 'pgadmin.browser.collection', 'pgadmin.backform', 'pgadmin.browser.collection',
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform) { ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform) {
// Extend the browser's node model class to create a Options model // Extend the browser's node model class to create a Options model
var OptionsModel = pgAdmin.Browser.Node.Model.extend({ var OptionsModel = pgAdmin.Browser.Node.Model.extend({
idAttribute: 'umoption', idAttribute: 'umoption',
defaults: { defaults: {
@ -21,7 +21,7 @@ define('pgadmin.node.user_mapping', [
umvalue: undefined, umvalue: undefined,
}, },
// Defining schema for the Options model // Defining schema for the Options model
schema: [{ schema: [{
id: 'umoption', label: gettext('Options'), type:'text', id: 'umoption', label: gettext('Options'), type:'text',
cellHeaderClasses:'width_percent_50', group: null, editable: true, cellHeaderClasses:'width_percent_50', group: null, editable: true,
@ -30,12 +30,12 @@ define('pgadmin.node.user_mapping', [
cellHeaderClasses:'width_percent_50', group:null, editable: true, cellHeaderClasses:'width_percent_50', group:null, editable: true,
}], }],
/* validate function is used to validate the input given by /* validate function is used to validate the input given by
* the user. In case of error, message will be displayed on * the user. In case of error, message will be displayed on
* the browser for the respective control. * the browser for the respective control.
*/ */
validate: function() { validate: function() {
// Validation for the option value // Validation for the option value
if (_.isUndefined(this.get('umoption')) || if (_.isUndefined(this.get('umoption')) ||
_.isNull(this.get('umoption')) || _.isNull(this.get('umoption')) ||
String(this.get('umoption')).replace(/^\s+|\s+$/g, '') == '') { String(this.get('umoption')).replace(/^\s+|\s+$/g, '') == '') {

View File

@ -13,14 +13,14 @@ define('pgadmin.node.foreign_data_wrapper', [
'pgadmin.browser.collection', 'pgadmin.browser.server.privilege', 'pgadmin.browser.collection', 'pgadmin.browser.server.privilege',
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform) { ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform) {
// Extend the browser's node model class to create a Options model // Extend the browser's node model class to create a Options model
var OptionsModel = pgBrowser.Node.Model.extend({ var OptionsModel = pgBrowser.Node.Model.extend({
idAttribute: 'fdwoption', idAttribute: 'fdwoption',
defaults: { defaults: {
fdwoption: undefined, fdwoption: undefined,
fdwvalue: undefined, fdwvalue: undefined,
}, },
// Defining schema for the Options model // Defining schema for the Options model
schema: [{ schema: [{
id: 'fdwoption', label: gettext('Option'), type:'text', id: 'fdwoption', label: gettext('Option'), type:'text',
cellHeaderClasses:'width_percent_50', editable: true, cellHeaderClasses:'width_percent_50', editable: true,
@ -28,12 +28,12 @@ define('pgadmin.node.foreign_data_wrapper', [
id: 'fdwvalue', label: gettext('Value'), type: 'text', id: 'fdwvalue', label: gettext('Value'), type: 'text',
cellHeaderClasses:'width_percent_50', group:null, editable: true, cellHeaderClasses:'width_percent_50', group:null, editable: true,
}], }],
/* validate function is used to validate the input given by /* validate function is used to validate the input given by
* the user. In case of error, message will be displayed on * the user. In case of error, message will be displayed on
* the browser for the respective control. * the browser for the respective control.
*/ */
validate: function() { validate: function() {
// Validation for the option name // Validation for the option name
if (_.isUndefined(this.get('fdwoption')) || if (_.isUndefined(this.get('fdwoption')) ||
_.isNull(this.get('fdwoption')) || _.isNull(this.get('fdwoption')) ||
String(this.get('fdwoption')).replace(/^\s+|\s+$/g, '') == '') { String(this.get('fdwoption')).replace(/^\s+|\s+$/g, '') == '') {
@ -170,7 +170,7 @@ define('pgadmin.node.foreign_data_wrapper', [
id: 'acl', label: gettext('Privileges'), type: 'text', id: 'acl', label: gettext('Privileges'), type: 'text',
group: gettext('Security'), mode: ['properties'], disabled: true, group: gettext('Security'), mode: ['properties'], disabled: true,
}], }],
/* validate function is used to validate the input given by /* validate function is used to validate the input given by
* the user. In case of error, message will be displayed on * the user. In case of error, message will be displayed on
* the browser for the respective control. * the browser for the respective control.
*/ */

View File

@ -13,7 +13,7 @@ define('pgadmin.node.collation', [
'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node',
'pgadmin.browser.collection', 'pgadmin.browser.collection',
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, schemaChild, ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, schemaChild,
schemaChildTreeNode) { schemaChildTreeNode) {
if (!pgBrowser.Nodes['coll-collation']) { if (!pgBrowser.Nodes['coll-collation']) {
pgAdmin.Browser.Nodes['coll-collation'] = pgAdmin.Browser.Nodes['coll-collation'] =

View File

@ -209,10 +209,10 @@ define('pgadmin.node.domain', [
_.each(m.type_options, function(o) { _.each(m.type_options, function(o) {
// if type from selected from combobox matches in options // if type from selected from combobox matches in options
if ( of_type == o.value ) { if ( of_type == o.value ) {
// if length is allowed for selected type // if length is allowed for selected type
if(o.length) if(o.length)
{ {
// set the values in model // set the values in model
m.set('is_tlength', true, {silent: true}); m.set('is_tlength', true, {silent: true});
m.set('min_val', o.min_val, {silent: true}); m.set('min_val', o.min_val, {silent: true});
m.set('max_val', o.max_val, {silent: true}); m.set('max_val', o.max_val, {silent: true});
@ -236,10 +236,10 @@ define('pgadmin.node.domain', [
_.each(m.type_options, function(o) { _.each(m.type_options, function(o) {
// if type from selected from combobox matches in options // if type from selected from combobox matches in options
if ( of_type == o.value ) { if ( of_type == o.value ) {
// if precession is allowed for selected type // if precession is allowed for selected type
if(o.precision) if(o.precision)
{ {
// set the values in model // set the values in model
m.set('is_precision', true, {silent: true}); m.set('is_precision', true, {silent: true});
m.set('min_val', o.min_val, {silent: true}); m.set('min_val', o.min_val, {silent: true});
m.set('max_val', o.max_val, {silent: true}); m.set('max_val', o.max_val, {silent: true});
@ -269,7 +269,7 @@ define('pgadmin.node.domain', [
model: ConstraintModel, canAdd: true, canDelete: true, model: ConstraintModel, canAdd: true, canDelete: true,
canEdit: false, columns: ['conname','consrc', 'convalidated'], canEdit: false, columns: ['conname','consrc', 'convalidated'],
}, },
pgBrowser.SecurityGroupSchema, pgBrowser.SecurityGroupSchema,
{ {
id: 'seclabels', label: gettext('Security labels'), id: 'seclabels', label: gettext('Security labels'),
model: pgBrowser.SecLabelModel, type: 'collection', model: pgBrowser.SecLabelModel, type: 'collection',
@ -301,7 +301,7 @@ define('pgadmin.node.domain', [
if (!m.isNew()) { if (!m.isNew()) {
var server = this.node_info.server; var server = this.node_info.server;
if (server.version < 90200) if (server.version < 90200)
{ {
return false; return false;
} }
} }

View File

@ -96,7 +96,7 @@ define('pgadmin.node.foreign_table', [
type: 'int', deps: ['datatype'], type: 'int', deps: ['datatype'],
disabled: function(m) { disabled: function(m) {
var val = m.get('typlen'); var val = m.get('typlen');
// We will store type from selected from combobox // We will store type from selected from combobox
if(!(_.isUndefined(m.get('inheritedid')) if(!(_.isUndefined(m.get('inheritedid'))
|| _.isNull(m.get('inheritedid')) || _.isNull(m.get('inheritedid'))
|| _.isUndefined(m.get('inheritedfrom')) || _.isUndefined(m.get('inheritedfrom'))
@ -115,14 +115,14 @@ define('pgadmin.node.foreign_table', [
if(m.type_options) { if(m.type_options) {
m.set('is_tlength', false, {silent: true}); m.set('is_tlength', false, {silent: true});
// iterating over all the types // iterating over all the types
_.each(m.type_options, function(o) { _.each(m.type_options, function(o) {
// if type from selected from combobox matches in options // if type from selected from combobox matches in options
if ( of_type == o.value ) { if ( of_type == o.value ) {
// if length is allowed for selected type // if length is allowed for selected type
if(o.length) if(o.length)
{ {
// set the values in model // set the values in model
has_length = true; has_length = true;
m.set('is_tlength', true, {silent: true}); m.set('is_tlength', true, {silent: true});
m.set('min_val', o.min_val, {silent: true}); m.set('min_val', o.min_val, {silent: true});
@ -171,15 +171,15 @@ define('pgadmin.node.foreign_table', [
if(m.type_options) { if(m.type_options) {
m.set('is_precision', false, {silent: true}); m.set('is_precision', false, {silent: true});
// iterating over all the types // iterating over all the types
_.each(m.type_options, function(o) { _.each(m.type_options, function(o) {
// if type from selected from combobox matches in options // if type from selected from combobox matches in options
if ( of_type == o.value ) { if ( of_type == o.value ) {
// if precession is allowed for selected type // if precession is allowed for selected type
if(o.precision) if(o.precision)
{ {
has_precision = true; has_precision = true;
// set the values in model // set the values in model
m.set('is_precision', true, {silent: true}); m.set('is_precision', true, {silent: true});
m.set('min_val', o.min_val, {silent: true}); m.set('min_val', o.min_val, {silent: true});
m.set('max_val', o.max_val, {silent: true}); m.set('max_val', o.max_val, {silent: true});
@ -263,7 +263,7 @@ define('pgadmin.node.foreign_table', [
} }
if (_.isUndefined(this.get('datatype')) || String(this.get('datatype')) if (_.isUndefined(this.get('datatype')) || String(this.get('datatype'))
.replace(/^\s+|\s+$/g, '') == '') { .replace(/^\s+|\s+$/g, '') == '') {
errmsg = gettext('Column Datatype cannot be empty.'); errmsg = gettext('Column Datatype cannot be empty.');
this.errorModel.set('datatype', errmsg); this.errorModel.set('datatype', errmsg);
} else { } else {
@ -345,10 +345,10 @@ define('pgadmin.node.foreign_table', [
var node = this.field.get('schema_node'), var node = this.field.get('schema_node'),
node_info = this.field.get('node_info'), node_info = this.field.get('node_info'),
full_url = node.generate_url.apply( full_url = node.generate_url.apply(
node, [ node, [
null, url, this.field.get('node_data'), null, url, this.field.get('node_data'),
this.field.get('url_with_id') || false, node_info, this.field.get('url_with_id') || false, node_info,
]), ]),
cache_level = this.field.get('cache_level') || node.type, cache_level = this.field.get('cache_level') || node.type,
cache_node = this.field.get('cache_node'); cache_node = this.field.get('cache_node');
@ -363,17 +363,17 @@ define('pgadmin.node.foreign_table', [
url: full_url, url: full_url,
data: data, data: data,
}) })
.done(function(res) { .done(function(res) {
/* /*
* We will cache this data for short period of time for avoiding * We will cache this data for short period of time for avoiding
* same calls. * same calls.
*/ */
data = cache_node.cache(url, node_info, cache_level, res.data); data = cache_node.cache(url, node_info, cache_level, res.data);
}) })
.fail(function() { .fail(function() {
m.trigger('pgadmin:view:fetch:error', m, self.field); m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
// To fetch only options from cache, we do not need time from 'at' // To fetch only options from cache, we do not need time from 'at'
@ -444,7 +444,7 @@ define('pgadmin.node.foreign_table', [
} }
if (_.isUndefined(this.get('consrc')) || String(this.get('consrc')) if (_.isUndefined(this.get('consrc')) || String(this.get('consrc'))
.replace(/^\s+|\s+$/g, '') == '') { .replace(/^\s+|\s+$/g, '') == '') {
err['consrc'] = gettext('Constraint Check cannot be empty.'); err['consrc'] = gettext('Constraint Check cannot be empty.');
errmsg = errmsg || err['consrc']; errmsg = errmsg || err['consrc'];
} }
@ -631,8 +631,8 @@ define('pgadmin.node.foreign_table', [
mode: ['properties'], min_version: 90200, mode: ['properties'], min_version: 90200,
}, pgBrowser.SecurityGroupSchema, { }, pgBrowser.SecurityGroupSchema, {
id: 'acl', label: gettext('Privileges'), model: pgAdmin id: 'acl', label: gettext('Privileges'), model: pgAdmin
.Browser.Node.PrivilegeRoleModel.extend( .Browser.Node.PrivilegeRoleModel.extend(
{privileges: ['a','r','w','x']}), uniqueCol : ['grantee', 'grantor'], {privileges: ['a','r','w','x']}), uniqueCol : ['grantee', 'grantor'],
editable: false, type: 'collection', group: 'security', editable: false, type: 'collection', group: 'security',
mode: ['edit', 'create'], mode: ['edit', 'create'],
canAdd: true, canDelete: true, control: 'unique-col-collection', canAdd: true, canDelete: true, control: 'unique-col-collection',
@ -657,7 +657,7 @@ define('pgadmin.node.foreign_table', [
} }
if (_.isUndefined(this.get('basensp')) || String(this.get('basensp')) if (_.isUndefined(this.get('basensp')) || String(this.get('basensp'))
.replace(/^\s+|\s+$/g, '') == '') { .replace(/^\s+|\s+$/g, '') == '') {
err['basensp'] = gettext('Schema cannot be empty.'); err['basensp'] = gettext('Schema cannot be empty.');
errmsg = errmsg || err['basensp']; errmsg = errmsg || err['basensp'];
} }

View File

@ -24,7 +24,7 @@ define('pgadmin.node.fts_configuration', [
dictname: undefined, dictname: undefined,
}, },
keys: ['token'], keys: ['token'],
// Define the schema for the token/dictionary list // Define the schema for the token/dictionary list
schema: [{ schema: [{
id: 'token', label: gettext('Token'), type:'text', group: null, id: 'token', label: gettext('Token'), type:'text', group: null,
cellHeaderClasses:'width_percent_50', cellHeaderClasses:'width_percent_50',
@ -34,9 +34,9 @@ define('pgadmin.node.fts_configuration', [
cellHeaderClasses:'width_percent_50', editable: true, cellHeaderClasses:'width_percent_50', editable: true,
cell:Backgrid.Extension.MultiSelectAjaxCell, url: 'dictionaries', cell:Backgrid.Extension.MultiSelectAjaxCell, url: 'dictionaries',
}], }],
// Validation for token and dictionary list // Validation for token and dictionary list
validate: function() { validate: function() {
// Clear any existing errors. // Clear any existing errors.
var msg; var msg;
this.errorModel.clear(); this.errorModel.clear();
var token = this.get('token'); var token = this.get('token');
@ -61,14 +61,14 @@ define('pgadmin.node.fts_configuration', [
}, },
}); });
// Customized control for token control // Customized control for token control
var TokenControl = Backform.TokenControl = var TokenControl = Backform.TokenControl =
Backform.UniqueColCollectionControl.extend({ Backform.UniqueColCollectionControl.extend({
initialize: function() { initialize: function() {
Backform.UniqueColCollectionControl.prototype.initialize.apply( Backform.UniqueColCollectionControl.prototype.initialize.apply(
this, arguments this, arguments
); );
var self = this, var self = this,
headerSchema = [{ headerSchema = [{
@ -82,7 +82,7 @@ define('pgadmin.node.fts_configuration', [
Backform.NodeAjaxOptionsControl.prototype.initialize.apply( Backform.NodeAjaxOptionsControl.prototype.initialize.apply(
this, this,
arguments arguments
); );
var self = this, var self = this,
url = self.field.get('url') || self.defaults.url, url = self.field.get('url') || self.defaults.url,
m = self.model.top || self.model; m = self.model.top || self.model;
@ -122,20 +122,20 @@ define('pgadmin.node.fts_configuration', [
async: false, async: false,
url: full_url, url: full_url,
}) })
.done(function(res) { .done(function(res) {
/* /*
* We will cache this data for short period of time for * We will cache this data for short period of time for
* avoiding same calls. * avoiding same calls.
*/ */
data = cache_node.cache(url, data = cache_node.cache(url,
node_info, node_info,
cache_level, cache_level,
res.data res.data
); );
}) })
.fail(function() { .fail(function() {
m.trigger('pgadmin:view:fetch:error', m, self.field); m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
} }
@ -169,16 +169,16 @@ define('pgadmin.node.fts_configuration', [
// Grid columns backgrid // Grid columns backgrid
gridCols = ['token', 'dictname']; gridCols = ['token', 'dictname'];
// Creating model for header control which is used to add new tokens // Creating model for header control which is used to add new tokens
self.headerData = new (Backbone.Model.extend({ self.headerData = new (Backbone.Model.extend({
defaults: headerDefaults, defaults: headerDefaults,
schema: headerSchema, schema: headerSchema,
}))({}); }))({});
// Creating view from header schema in tokens control // Creating view from header schema in tokens control
var headerGroups = Backform.generateViewSchema( var headerGroups = Backform.generateViewSchema(
self.field.get('node_info'), self.headerData, 'create', self.field.get('node_info'), self.headerData, 'create',
self.field.get('schema_node'), self.field.get('node_data') self.field.get('schema_node'), self.field.get('node_data')
), ),
fields = []; fields = [];
@ -187,13 +187,13 @@ define('pgadmin.node.fts_configuration', [
}); });
self.headerFields = new Backform.Fields(fields); self.headerFields = new Backform.Fields(fields);
// creating grid using grid columns // creating grid using grid columns
self.gridSchema = Backform.generateGridColumnsFromModel( self.gridSchema = Backform.generateGridColumnsFromModel(
self.field.get('node_info'), self.field.get('model'), self.field.get('node_info'), self.field.get('model'),
'edit', gridCols, self.field.get('schema_node') 'edit', gridCols, self.field.get('schema_node')
); );
// Providing behaviour control functions to header and grid control // Providing behaviour control functions to header and grid control
self.controls = []; self.controls = [];
self.listenTo(self.headerData, 'change', self.headerDataChanged); self.listenTo(self.headerData, 'change', self.headerDataChanged);
self.listenTo(self.headerData, 'select2', self.headerDataChanged); self.listenTo(self.headerData, 'select2', self.headerDataChanged);
@ -201,7 +201,7 @@ define('pgadmin.node.fts_configuration', [
self.listenTo(self.collection, 'remove', self.onAddorRemoveTokens); self.listenTo(self.collection, 'remove', self.onAddorRemoveTokens);
}, },
// Template for creating header view // Template for creating header view
generateHeader: function(data) { generateHeader: function(data) {
var header = [ var header = [
'<div class="subnode-header-form">', '<div class="subnode-header-form">',
@ -234,19 +234,19 @@ define('pgadmin.node.fts_configuration', [
}); });
$header.find('div[header="' + field.get('name') + '"]').append( $header.find('div[header="' + field.get('name') + '"]').append(
control.render().$el control.render().$el
); );
control.$el.find('.control-label').remove(); control.$el.find('.control-label').remove();
controls.push(control); controls.push(control);
}); });
// We should not show add button in properties mode // We should not show add button in properties mode
if (data.mode == 'properties') { if (data.mode == 'properties') {
$header.find('button.add').remove(); $header.find('button.add').remove();
} }
// Disable add button in token control in create mode // Disable add button in token control in create mode
if(data.mode == 'create') { if(data.mode == 'create') {
$header.find('button.add').attr('disabled', true); $header.find('button.add').attr('disabled', true);
} }
@ -255,13 +255,13 @@ define('pgadmin.node.fts_configuration', [
return $header; return $header;
}, },
// Providing event handler for add button in header // Providing event handler for add button in header
events: _.extend( events: _.extend(
{}, Backform.UniqueColCollectionControl.prototype.events, {}, Backform.UniqueColCollectionControl.prototype.events,
{'click button.add': 'addTokens'} {'click button.add': 'addTokens'}
), ),
// Show token/dictionary grid // Show token/dictionary grid
showGridControl: function(data) { showGridControl: function(data) {
var self = this, var self = this,
@ -269,14 +269,14 @@ define('pgadmin.node.fts_configuration', [
$gridBody = $('<div></div>', { $gridBody = $('<div></div>', {
class:'pgadmin-control-group backgrid form-group col-12 object subnode', class:'pgadmin-control-group backgrid form-group col-12 object subnode',
}).append( }).append(
titleTmpl({label: data.label}) titleTmpl({label: data.label})
); );
$gridBody.append(self.generateHeader(data)); $gridBody.append(self.generateHeader(data));
var gridColumns = _.clone(this.gridSchema.columns); var gridColumns = _.clone(this.gridSchema.columns);
// Insert Delete Cell into Grid // Insert Delete Cell into Grid
if (data.disabled == false && data.canDelete) { if (data.disabled == false && data.canDelete) {
gridColumns.unshift({ gridColumns.unshift({
name: 'pg-backform-delete', label: '', name: 'pg-backform-delete', label: '',
@ -289,7 +289,7 @@ define('pgadmin.node.fts_configuration', [
self.grid.remove(); self.grid.remove();
self.grid.null; self.grid.null;
} }
// Initialize a new Grid instance // Initialize a new Grid instance
var grid = self.grid = new Backgrid.Grid({ var grid = self.grid = new Backgrid.Grid({
columns: gridColumns, columns: gridColumns,
collection: self.collection, collection: self.collection,
@ -299,21 +299,21 @@ define('pgadmin.node.fts_configuration', [
$gridBody.append(self.$grid); $gridBody.append(self.$grid);
// Find selected dictionaries in grid and show it all together // Find selected dictionaries in grid and show it all together
setTimeout(function() { setTimeout(function() {
self.headerData.set({ self.headerData.set({
'token': self.$header.find( 'token': self.$header.find(
'div[header="token"] select' 'div[header="token"] select'
).val(), ).val(),
}, {silent:true} }, {silent:true}
); );
}, 10); }, 10);
// Render node grid // Render node grid
return $gridBody; return $gridBody;
}, },
// When user change the header control to add a new token // When user change the header control to add a new token
headerDataChanged: function() { headerDataChanged: function() {
var self = this, var self = this,
data = this.headerData.toJSON(), data = this.headerData.toJSON(),
@ -326,7 +326,7 @@ define('pgadmin.node.fts_configuration', [
self.$header.find('button.add').prop('disabled', inSelected); self.$header.find('button.add').prop('disabled', inSelected);
}, },
// Get called when user click on add button header // Get called when user click on add button header
addTokens: function(ev) { addTokens: function(ev) {
ev.preventDefault(); ev.preventDefault();
var self = this, var self = this,
@ -338,14 +338,14 @@ define('pgadmin.node.fts_configuration', [
var coll = self.model.get(self.field.get('name')), var coll = self.model.get(self.field.get('name')),
m = new (self.field.get('model'))( m = new (self.field.get('model'))(
self.headerData.toJSON(), { self.headerData.toJSON(), {
silent: true, top: self.model.top, silent: true, top: self.model.top,
collection: coll, handler: coll, collection: coll, handler: coll,
}), }),
checkVars = ['token'], checkVars = ['token'],
idx = -1; idx = -1;
// Find if token exists in grid // Find if token exists in grid
self.collection.each(function(m) { self.collection.each(function(m) {
_.each(checkVars, function(v) { _.each(checkVars, function(v) {
var val = m.get(v); var val = m.get(v);
@ -357,7 +357,7 @@ define('pgadmin.node.fts_configuration', [
// remove 'm' if duplicate value found. // remove 'm' if duplicate value found.
if (idx == -1) { if (idx == -1) {
coll.add(m); coll.add(m);
idx = coll.indexOf(m); idx = coll.indexOf(m);
@ -365,18 +365,18 @@ define('pgadmin.node.fts_configuration', [
self.$grid.find('.new').removeClass('new'); self.$grid.find('.new').removeClass('new');
var newRow = self.grid.body.rows[idx].$el; var newRow = self.grid.body.rows[idx].$el;
newRow.addClass('new'); newRow.addClass('new');
//$(newRow).pgMakeVisible('table-bordered'); //$(newRow).pgMakeVisible('table-bordered');
$(newRow).pgMakeVisible('backform-tab'); $(newRow).pgMakeVisible('backform-tab');
return false; return false;
}, },
// When user delete token/dictionary entry from grid // When user delete token/dictionary entry from grid
onAddorRemoveTokens: function() { onAddorRemoveTokens: function() {
var self = this; var self = this;
/* /*
* Wait for collection to be updated before checking for the button to * Wait for collection to be updated before checking for the button to
* be enabled, or not. * be enabled, or not.
*/ */
@ -386,7 +386,7 @@ define('pgadmin.node.fts_configuration', [
}, 10); }, 10);
}, },
// When control is about to destroy // When control is about to destroy
remove: function() { remove: function() {
/* /*
* Stop listening the events registered by this control. * Stop listening the events registered by this control.
@ -395,13 +395,13 @@ define('pgadmin.node.fts_configuration', [
this.listenTo(this.headerData, 'select2', this.headerDataChanged); this.listenTo(this.headerData, 'select2', this.headerDataChanged);
this.listenTo(this.collection, 'remove', this.onAddorRemoveTokens); this.listenTo(this.collection, 'remove', this.onAddorRemoveTokens);
// Remove header controls. // Remove header controls.
_.each(this.controls, function(control) { _.each(this.controls, function(control) {
control.remove(); control.remove();
}); });
TokenControl.__super__.remove.apply(this, arguments); TokenControl.__super__.remove.apply(this, arguments);
// Remove the header model // Remove the header model
delete (this.headerData); delete (this.headerData);
}, },
@ -551,7 +551,7 @@ define('pgadmin.node.fts_configuration', [
var copy_config_or_parser = !(parser === '' || var copy_config_or_parser = !(parser === '' ||
_.isUndefined(parser) || _.isUndefined(parser) ||
_.isNull(parser)) ? _.isNull(parser)) ?
this.get('prsname') : this.get('copy_config'); this.get('prsname') : this.get('copy_config');
var schema = this.get('schema'); var schema = this.get('schema');
// Clear the existing error model // Clear the existing error model

View File

@ -14,7 +14,7 @@ define('pgadmin.node.fts_dictionary', [
'pgadmin.browser.collection', 'pgadmin.browser.collection',
], function( ], function(
gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, schemaChild, gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, schemaChild,
schemaChildTreeNode schemaChildTreeNode
) { ) {
// Extend the browser's node model class to create a option/value pair // Extend the browser's node model class to create a option/value pair
@ -23,7 +23,7 @@ define('pgadmin.node.fts_dictionary', [
options: undefined, options: undefined,
value: undefined, value: undefined,
}, },
// Define the schema for the Options // Define the schema for the Options
schema: [ schema: [
{ {
id: 'option', label: gettext('Option'), type:'text', group: null, id: 'option', label: gettext('Option'), type:'text', group: null,

View File

@ -59,10 +59,10 @@ define('pgadmin.node.function', [
id: 'argmode', label: gettext('Mode'), type: 'options', id: 'argmode', label: gettext('Mode'), type: 'options',
control: 'node-ajax-options', cellHeaderClasses:'width_percent_20', control: 'node-ajax-options', cellHeaderClasses:'width_percent_20',
options:[ options:[
{'label': 'IN', 'value': 'IN'}, {'label': 'IN', 'value': 'IN'},
{'label': 'OUT', 'value': 'OUT'}, {'label': 'OUT', 'value': 'OUT'},
{'label': 'INOUT', 'value': 'INOUT'}, {'label': 'INOUT', 'value': 'INOUT'},
{'label': 'VARIADIC', 'value': 'VARIADIC'}, {'label': 'VARIADIC', 'value': 'VARIADIC'},
], editable: function(m) { ], editable: function(m) {
var node_info = this.get('node_info'); var node_info = this.get('node_info');
if(node_info && 'catalog' in node_info) { if(node_info && 'catalog' in node_info) {

View File

@ -15,7 +15,7 @@ define('pgadmin.node.procedure', [
'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.node.schema.dir/schema_child_tree_node',
'pgadmin.browser.collection', 'pgadmin.browser.server.privilege', 'pgadmin.browser.collection', 'pgadmin.browser.server.privilege',
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, Function, ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, Function,
schemaChild, schemaChildTreeNode) { schemaChild, schemaChildTreeNode) {
if (!pgBrowser.Nodes['coll-procedure']) { if (!pgBrowser.Nodes['coll-procedure']) {
pgAdmin.Browser.Nodes['coll-procedure'] = pgAdmin.Browser.Nodes['coll-procedure'] =
@ -83,7 +83,7 @@ define('pgadmin.node.procedure', [
// Procedures supported only in PPAS and PG >= 11 // Procedures supported only in PPAS and PG >= 11
return ( return (
'server' in node_hierarchy && ( 'server' in node_hierarchy && (
node_hierarchy['server'].server_type == 'ppas' || node_hierarchy['server'].server_type == 'ppas' ||
(node_hierarchy['server'].server_type == 'pg' && (node_hierarchy['server'].server_type == 'pg' &&
node_hierarchy['server'].version >= 110000) node_hierarchy['server'].version >= 110000)
) )

View File

@ -13,7 +13,7 @@ define('pgadmin.node.package', [
'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node',
'pgadmin.browser.collection', 'pgadmin.browser.collection',
], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, schemaChild, ], function(gettext, url_for, $, _, pgAdmin, pgBrowser, Backform, schemaChild,
schemaChildTreeNode) { schemaChildTreeNode) {
// Extend the browser's collection class for package collection // Extend the browser's collection class for package collection
if (!pgBrowser.Nodes['coll-package']) { if (!pgBrowser.Nodes['coll-package']) {
@ -67,7 +67,7 @@ define('pgadmin.node.package', [
}, },
canCreate: function(itemData, item, data) { canCreate: function(itemData, item, data) {
//If check is false then , we will allow create menu //If check is false then , we will allow create menu
if (data && data.check == false) if (data && data.check == false)
return true; return true;
@ -77,11 +77,11 @@ define('pgadmin.node.package', [
if (server && server.server_type === 'pg') if (server && server.server_type === 'pg')
return false; return false;
// If it is catalog then don't allow user to create package // If it is catalog then don't allow user to create package
if (treeData['catalog'] != undefined) if (treeData['catalog'] != undefined)
return false; return false;
// by default we want to allow create menu // by default we want to allow create menu
return true; return true;
}, },
// Define the model for package node. // Define the model for package node.

View File

@ -14,7 +14,7 @@ define('pgadmin.node.sequence', [
'pgadmin.browser.collection', 'pgadmin.browser.collection',
], function( ], function(
gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, schemaChild, gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, schemaChild,
schemaChildTreeNode schemaChildTreeNode
) { ) {
// Extend the browser's collection class for sequence collection // Extend the browser's collection class for sequence collection

View File

@ -36,20 +36,20 @@ define('pgadmin.node.schema', [
data; data;
m.trigger('pgadmin-view:fetching', m, self.field); m.trigger('pgadmin-view:fetching', m, self.field);
// fetch default values for autovacuum fields // fetch default values for autovacuum fields
$.ajax({ $.ajax({
async: false, async: false,
url: full_url, url: full_url,
}) })
.done(function (res) { .done(function (res) {
data = res; data = res;
}) })
.fail(function() { .fail(function() {
m.trigger('pgadmin-view:fetch:error', m, self.field); m.trigger('pgadmin-view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin-view:fetched', m, self.field); m.trigger('pgadmin-view:fetched', m, self.field);
// Add fetched models into collection // Add fetched models into collection
if (data && _.isArray(data)) { if (data && _.isArray(data)) {
m.get(self.field.get('name')).reset(data, {silent: true}); m.get(self.field.get('name')).reset(data, {silent: true});
} }
@ -60,7 +60,7 @@ define('pgadmin.node.schema', [
var self = this, var self = this,
attributes = self.field.attributes; attributes = self.field.attributes;
// remove grid // remove grid
if(self.grid) { if(self.grid) {
self.grid.remove(); self.grid.remove();
delete self.grid; delete self.grid;
@ -74,17 +74,17 @@ define('pgadmin.node.schema', [
' <label class="control-label col-sm-4"><%-label%></label>', ' <label class="control-label col-sm-4"><%-label%></label>',
'</div>'].join('\n')), '</div>'].join('\n')),
gridBody = $('<div class="pgadmin-control-group backgrid form-group col-12 object subnode"></div>').append( gridBody = $('<div class="pgadmin-control-group backgrid form-group col-12 object subnode"></div>').append(
gridHeader(attributes) gridHeader(attributes)
); );
// Initialize a new Grid instance // Initialize a new Grid instance
var grid = self.grid = new Backgrid.Grid({ var grid = self.grid = new Backgrid.Grid({
columns: self.grid_columns, columns: self.grid_columns,
collection: self.model.get(self.field.get('name')), collection: self.model.get(self.field.get('name')),
className: 'backgrid table-bordered table-noouter-border table-hover', className: 'backgrid table-bordered table-noouter-border table-hover',
}); });
// render grid // render grid
self.$el.append($(gridBody).append(grid.render().$el)); self.$el.append($(gridBody).append(grid.render().$el));
return self; return self;
@ -127,7 +127,7 @@ define('pgadmin.node.schema', [
}, },
}); });
// Extend the browser's collection class for VacuumSettingsModel // Extend the browser's collection class for VacuumSettingsModel
Backform.VacuumSettingsSchema = [{ Backform.VacuumSettingsSchema = [{
id: 'spacer_ctrl', group: gettext('Table'), mode: ['edit', 'create'], type: 'spacer', id: 'spacer_ctrl', group: gettext('Table'), mode: ['edit', 'create'], type: 'spacer',
},{ },{
@ -373,7 +373,7 @@ define('pgadmin.node.schema', [
},{ },{
id: 'nspacl', label: gettext('Privileges'), id: 'nspacl', label: gettext('Privileges'),
model: pgBrowser.Node.PrivilegeRoleModel.extend( model: pgBrowser.Node.PrivilegeRoleModel.extend(
{privileges: ['C', 'U']}), uniqueCol : ['grantee', 'grantor'], {privileges: ['C', 'U']}), uniqueCol : ['grantee', 'grantor'],
editable: false, type: 'collection', group: gettext('Security'), editable: false, type: 'collection', group: gettext('Security'),
mode: ['edit', 'create'], mode: ['edit', 'create'],
canAdd: true, canDelete: true, control: 'unique-col-collection', canAdd: true, canDelete: true, control: 'unique-col-collection',

View File

@ -13,7 +13,7 @@ define('pgadmin.node.synonym', [
'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.node.schema.dir/child', 'pgadmin.node.schema.dir/schema_child_tree_node',
'pgadmin.browser.collection', 'pgadmin.browser.collection',
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify,
schemaChild, schemaChildTreeNode) { schemaChild, schemaChildTreeNode) {
if (!pgBrowser.Nodes['coll-synonym']) { if (!pgBrowser.Nodes['coll-synonym']) {
pgAdmin.Browser.Nodes['coll-synonym'] = pgAdmin.Browser.Nodes['coll-synonym'] =
@ -110,13 +110,13 @@ define('pgadmin.node.synonym', [
select2: { width: '50%', allowClear: false }, select2: { width: '50%', allowClear: false },
options: function() { options: function() {
return [ return [
{label: gettext('Function'), value: 'f'}, {label: gettext('Function'), value: 'f'},
{label: gettext('Package'), value: 'P'}, {label: gettext('Package'), value: 'P'},
{label: gettext('Procedure'), value: 'p'}, {label: gettext('Procedure'), value: 'p'},
{label: gettext('Public Synonym'), value: 's'}, {label: gettext('Public Synonym'), value: 's'},
{label: gettext('Sequence'), value: 'S'}, {label: gettext('Sequence'), value: 'S'},
{label: gettext('Table'), value: 'r'}, {label: gettext('Table'), value: 'r'},
{label: gettext('View'), value: 'v'}, {label: gettext('View'), value: 'v'},
]; ];
}, },
control: 'select2', control: 'select2',
@ -169,14 +169,14 @@ define('pgadmin.node.synonym', [
data: {'trgTyp' : trgTyp, 'trgSchema' : trgSchema}, data: {'trgTyp' : trgTyp, 'trgSchema' : trgSchema},
}) })
// On success return function list from server // On success return function list from server
.done(function(result) { .done(function(result) {
res = result.data; res = result.data;
return res; return res;
}) })
// On failure show error appropriate error message to user // On failure show error appropriate error message to user
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error); alertify.pgRespErrorNotify(xhr, error);
}); });
return res; return res;
}, },
},{ },{
@ -228,7 +228,7 @@ define('pgadmin.node.synonym', [
}, },
}), }),
canCreate: function(itemData, item, data) { canCreate: function(itemData, item, data) {
//If check is false then , we will allow create menu //If check is false then , we will allow create menu
if (data && data.check == false) if (data && data.check == false)
return true; return true;
@ -238,11 +238,11 @@ define('pgadmin.node.synonym', [
if (server && server.server_type === 'pg') if (server && server.server_type === 'pg')
return false; return false;
// If it is catalog then don't allow user to create synonyms // If it is catalog then don't allow user to create synonyms
if (treeData['catalog'] != undefined) if (treeData['catalog'] != undefined)
return false; return false;
// by default we do not want to allow create menu // by default we do not want to allow create menu
return true; return true;
}, },
}); });

View File

@ -28,7 +28,7 @@ define('pgadmin.node.column', [
}); });
} }
// This Node model will be used for variable control for column // This Node model will be used for variable control for column
var VariablesModel = Backform.VariablesModel = pgBrowser.Node.Model.extend({ var VariablesModel = Backform.VariablesModel = pgBrowser.Node.Model.extend({
idAttribute: 'name', idAttribute: 'name',
defaults: { defaults: {
@ -39,7 +39,7 @@ define('pgadmin.node.column', [
id: 'name', label: gettext('Name'), cell: 'select2', id: 'name', label: gettext('Name'), cell: 'select2',
type: 'text', disabled: false, node: 'column', type: 'text', disabled: false, node: 'column',
options: [['n_distinct', 'n_distinct'], options: [['n_distinct', 'n_distinct'],
['n_distinct_inherited','n_distinct_inherited']], ['n_distinct_inherited','n_distinct_inherited']],
select2: {placeholder: 'Select variable'}, select2: {placeholder: 'Select variable'},
cellHeaderClasses:'width_percent_50', cellHeaderClasses:'width_percent_50',
},{ },{
@ -338,7 +338,7 @@ define('pgadmin.node.column', [
_.each(m.datatypes, function(o) { _.each(m.datatypes, function(o) {
if ( of_type == o.value ) { if ( of_type == o.value ) {
if(o.length) if(o.length)
{ {
m.set('min_val', o.min_val, {silent: true}); m.set('min_val', o.min_val, {silent: true});
m.set('max_val', o.max_val, {silent: true}); m.set('max_val', o.max_val, {silent: true});
flag = false; flag = false;
@ -355,7 +355,7 @@ define('pgadmin.node.column', [
return flag; return flag;
}, },
editable: function(m) { editable: function(m) {
// inheritedfrom has value then we should disable it // inheritedfrom has value then we should disable it
if(!_.isUndefined(m.get('inheritedfrom'))) { if(!_.isUndefined(m.get('inheritedfrom'))) {
return false; return false;
} }
@ -409,7 +409,7 @@ define('pgadmin.node.column', [
return flag; return flag;
}, },
editable: function(m) { editable: function(m) {
// inheritedfrom has value then we should disable it // inheritedfrom has value then we should disable it
if(!_.isUndefined(m.get('inheritedfrom'))) { if(!_.isUndefined(m.get('inheritedfrom'))) {
return false; return false;
} }
@ -449,7 +449,7 @@ define('pgadmin.node.column', [
_.each(m.datatypes, function(o) { _.each(m.datatypes, function(o) {
if ( of_type == o.value ) { if ( of_type == o.value ) {
if(o.is_collatable) if(o.is_collatable)
{ {
flag = false; flag = false;
} }
} }
@ -661,25 +661,25 @@ define('pgadmin.node.column', [
editable_check_for_table: function(arg) { editable_check_for_table: function(arg) {
if (arg instanceof Backbone.Collection) { if (arg instanceof Backbone.Collection) {
return !arg.model.prototype.inSchemaWithColumnCheck.apply( return !arg.model.prototype.inSchemaWithColumnCheck.apply(
this, [arg.top] this, [arg.top]
); );
} else { } else {
return !arg.inSchemaWithColumnCheck.apply( return !arg.inSchemaWithColumnCheck.apply(
this, [arg] this, [arg]
); );
} }
}, },
}), }),
// Below function will enable right click menu for creating column // Below function will enable right click menu for creating column
canCreate: function(itemData, item, data) { canCreate: function(itemData, item, data) {
// If check is false then , we will allow create menu // If check is false then , we will allow create menu
if (data && data.check == false) if (data && data.check == false)
return true; return true;
var t = pgBrowser.tree, i = item, d = itemData, parents = []; var t = pgBrowser.tree, i = item, d = itemData, parents = [];
// To iterate over tree to check parent node // To iterate over tree to check parent node
while (i) { while (i) {
// If it is schema then allow user to create table // If it is schema then allow user to create table
if (_.indexOf(['schema'], d._type) > -1) { if (_.indexOf(['schema'], d._type) > -1) {
return true; return true;
} }
@ -693,7 +693,7 @@ define('pgadmin.node.column', [
i = t.hasParent(i) ? t.parent(i) : null; i = t.hasParent(i) ? t.parent(i) : null;
d = i ? t.itemData(i) : null; d = i ? t.itemData(i) : null;
} }
// If node is under catalog then do not allow 'create' menu // If node is under catalog then do not allow 'create' menu
if (_.indexOf(parents, 'catalog') > -1 || if (_.indexOf(parents, 'catalog') > -1 ||
_.indexOf(parents, 'coll-view') > -1 || _.indexOf(parents, 'coll-view') > -1 ||
_.indexOf(parents, 'coll-mview') > -1 || _.indexOf(parents, 'coll-mview') > -1 ||

View File

@ -71,21 +71,21 @@ define('pgadmin.node.check_constraint', [
url: obj.generate_url(i, 'validate', d, true), url: obj.generate_url(i, 'validate', d, true),
type:'GET', type:'GET',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
alertify.success(res.info); alertify.success(res.info);
t.removeIcon(i); t.removeIcon(i);
data.valid = true; data.valid = true;
data.icon = 'icon-check_constraint'; data.icon = 'icon-check_constraint';
t.addIcon(i, {icon: data.icon}); t.addIcon(i, {icon: data.icon});
setTimeout(function() {t.deselect(i);}, 10); setTimeout(function() {t.deselect(i);}, 10);
setTimeout(function() {t.select(i);}, 100); setTimeout(function() {t.select(i);}, 100);
} }
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error); alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
}); });
return false; return false;
}, },
@ -127,10 +127,10 @@ define('pgadmin.node.check_constraint', [
id: 'consrc', label: gettext('Check'), type: 'multiline', cell: id: 'consrc', label: gettext('Check'), type: 'multiline', cell:
'string', group: gettext('Definition'), mode: ['properties', 'string', group: gettext('Definition'), mode: ['properties',
'create', 'edit'], disabled: function(m) { 'create', 'edit'], disabled: function(m) {
return ((_.has(m, 'handler') && return ((_.has(m, 'handler') &&
!_.isUndefined(m.handler) && !_.isUndefined(m.handler) &&
!_.isUndefined(m.get('oid'))) || (_.isFunction(m.isNew) && !m.isNew())); !_.isUndefined(m.get('oid'))) || (_.isFunction(m.isNew) && !m.isNew()));
}, editable: false, }, editable: false,
},{ },{
id: 'connoinherit', label: gettext('No inherit?'), type: id: 'connoinherit', label: gettext('No inherit?'), type:
'switch', cell: 'boolean', group: gettext('Definition'), mode: 'switch', cell: 'boolean', group: gettext('Definition'), mode:
@ -204,21 +204,21 @@ define('pgadmin.node.check_constraint', [
}), }),
// Below function will enable right click menu for creating check constraint. // Below function will enable right click menu for creating check constraint.
canCreate: function(itemData, item, data) { canCreate: function(itemData, item, data) {
// If check is false then , we will allow create menu // If check is false then , we will allow create menu
if (data && data.check == false) if (data && data.check == false)
return true; return true;
var t = pgBrowser.tree, i = item, d = itemData, parents = []; var t = pgBrowser.tree, i = item, d = itemData, parents = [];
// To iterate over tree to check parent node // To iterate over tree to check parent node
while (i) { while (i) {
// If it is schema then allow user to c reate table // If it is schema then allow user to c reate table
if (_.indexOf(['schema'], d._type) > -1) if (_.indexOf(['schema'], d._type) > -1)
return true; return true;
parents.push(d._type); parents.push(d._type);
i = t.hasParent(i) ? t.parent(i) : null; i = t.hasParent(i) ? t.parent(i) : null;
d = i ? t.itemData(i) : null; d = i ? t.itemData(i) : null;
} }
// If node is under catalog then do not allow 'create' menu // If node is under catalog then do not allow 'create' menu
if (_.indexOf(parents, 'catalog') > -1) { if (_.indexOf(parents, 'catalog') > -1) {
return false; return false;
} else { } else {

View File

@ -48,7 +48,7 @@ define('pgadmin.node.exclusion_constraint', [
!_.isUndefined(m.collection.handler) && !_.isUndefined(m.collection.handler) &&
!_.isUndefined(m.collection.handler.get('amname')) && !_.isUndefined(m.collection.handler.get('amname')) &&
m.collection.handler.get('amname') != 'btree') { m.collection.handler.get('amname') != 'btree') {
// Disable if access method is not btree // Disable if access method is not btree
return false; return false;
} }
return true; return true;
@ -67,7 +67,7 @@ define('pgadmin.node.exclusion_constraint', [
if (url && (indextype == 'btree' || _.isUndefined(indextype) || if (url && (indextype == 'btree' || _.isUndefined(indextype) ||
_.isNull(indextype) || indextype == '')) { _.isNull(indextype) || indextype == '')) {
// Set sort_order and nulls to true if access method is btree // Set sort_order and nulls to true if access method is btree
setTimeout(function() { setTimeout(function() {
m.set('order', true); m.set('order', true);
m.set('nulls_order', true); m.set('nulls_order', true);
@ -77,10 +77,10 @@ define('pgadmin.node.exclusion_constraint', [
eventHandler = m.top || m, eventHandler = m.top || m,
node_info = this.column.get('node_info'), node_info = this.column.get('node_info'),
full_url = node.generate_url.apply( full_url = node.generate_url.apply(
node, [ node, [
null, url, this.column.get('node_data'), null, url, this.column.get('node_data'),
this.column.get('url_with_id') || false, node_info, this.column.get('url_with_id') || false, node_info,
]), ]),
data = []; data = [];
indextype = 'btree'; indextype = 'btree';
@ -92,13 +92,13 @@ define('pgadmin.node.exclusion_constraint', [
data : {indextype:indextype}, data : {indextype:indextype},
url: full_url, url: full_url,
}) })
.done(function(res) { .done(function(res) {
data = res.data; data = res.data;
self.column.set('options', data); self.column.set('options', data);
}) })
.fail(function() { .fail(function() {
eventHandler.trigger('pgadmin:view:fetch:error', m, self.column); eventHandler.trigger('pgadmin:view:fetch:error', m, self.column);
}); });
eventHandler.trigger('pgadmin:view:fetched', m, self.column); eventHandler.trigger('pgadmin:view:fetched', m, self.column);
} }
} else { } else {
@ -193,13 +193,13 @@ define('pgadmin.node.exclusion_constraint', [
data : {col_type:col_type}, data : {col_type:col_type},
url: full_url, url: full_url,
}) })
.done(function(res) { .done(function(res) {
data = res.data; data = res.data;
self.column.set('options', data); self.column.set('options', data);
}) })
.fail(function() { .fail(function() {
eventHandler.trigger('pgadmin:view:fetch:error', m, self.column); eventHandler.trigger('pgadmin:view:fetch:error', m, self.column);
}); });
eventHandler.trigger('pgadmin:view:fetched', m, self.column); eventHandler.trigger('pgadmin:view:fetched', m, self.column);
} }
} }
@ -333,13 +333,13 @@ define('pgadmin.node.exclusion_constraint', [
_.each(rows, function(r) { _.each(rows, function(r) {
if (filter(r)) { if (filter(r)) {
var l = (_.isFunction(node['node_label']) ? var l = (_.isFunction(node['node_label']) ?
(node['node_label']).apply(node, [r, that.model, that]) : (node['node_label']).apply(node, [r, that.model, that]) :
r.label), r.label),
image = (_.isFunction(node['node_image']) ? image = (_.isFunction(node['node_image']) ?
(node['node_image']).apply( (node['node_image']).apply(
node, [r, that.model, that] node, [r, that.model, that]
) : ) :
(node['node_image'] || ('icon-' + node.type))); (node['node_image'] || ('icon-' + node.type)));
res.push({ res.push({
'value': r.label, 'value': r.label,
'image': image, 'image': image,
@ -374,9 +374,9 @@ define('pgadmin.node.exclusion_constraint', [
}))({}); }))({});
var headerGroups = Backform.generateViewSchema( var headerGroups = Backform.generateViewSchema(
self.field.get('node_info'), self.headerData, 'create', self.field.get('node_info'), self.headerData, 'create',
node, self.field.get('node_data') node, self.field.get('node_data')
), ),
fields = []; fields = [];
_.each(headerGroups, function(o) { _.each(headerGroups, function(o) {
@ -981,8 +981,8 @@ define('pgadmin.node.exclusion_constraint', [
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top) if (_.has(m, 'top') && !_.isUndefined(m.top)
&& !m.top.isNew()) { && !m.top.isNew()) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should be allowed for Unique // new constraint which should be allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }
@ -1024,16 +1024,16 @@ define('pgadmin.node.exclusion_constraint', [
}), }),
canCreate: function(itemData, item, data) { canCreate: function(itemData, item, data) {
// If check is false then , we will allow create menu // If check is false then , we will allow create menu
if (data && data.check == false) if (data && data.check == false)
return true; return true;
var t = pgBrowser.tree, i = item, d = itemData, parents = [], var t = pgBrowser.tree, i = item, d = itemData, parents = [],
immediate_parent_table_found = false, immediate_parent_table_found = false,
is_immediate_parent_table_partitioned = false; is_immediate_parent_table_partitioned = false;
// To iterate over tree to check parent node // To iterate over tree to check parent node
while (i) { while (i) {
// If table is partitioned table then return false // If table is partitioned table then return false
if (!immediate_parent_table_found && (d._type == 'table' || d._type == 'partition')) { if (!immediate_parent_table_found && (d._type == 'table' || d._type == 'partition')) {
immediate_parent_table_found = true; immediate_parent_table_found = true;
if ('is_partitioned' in d && d.is_partitioned) { if ('is_partitioned' in d && d.is_partitioned) {
@ -1041,14 +1041,14 @@ define('pgadmin.node.exclusion_constraint', [
} }
} }
// If it is schema then allow user to create table // If it is schema then allow user to create table
if (_.indexOf(['schema'], d._type) > -1) if (_.indexOf(['schema'], d._type) > -1)
return !is_immediate_parent_table_partitioned; return !is_immediate_parent_table_partitioned;
parents.push(d._type); parents.push(d._type);
i = t.hasParent(i) ? t.parent(i) : null; i = t.hasParent(i) ? t.parent(i) : null;
d = i ? t.itemData(i) : null; d = i ? t.itemData(i) : null;
} }
// If node is under catalog then do not allow 'create' menu // If node is under catalog then do not allow 'create' menu
if (_.indexOf(parents, 'catalog') > -1) { if (_.indexOf(parents, 'catalog') > -1) {
return false; return false;
} else { } else {

View File

@ -27,8 +27,8 @@ define('pgadmin.node.foreign_key', [
return opt.text; return opt.text;
} else { } else {
return $( return $(
'<span><span class="wcTabIcon ' + optimage + '"/>' + opt.text + '</span>' '<span><span class="wcTabIcon ' + optimage + '"/>' + opt.text + '</span>'
); );
} }
}, },
headerSelectControlTemplate = _.template([ headerSelectControlTemplate = _.template([
@ -224,15 +224,15 @@ define('pgadmin.node.foreign_key', [
data : {tid:tid}, data : {tid:tid},
url: full_url, url: full_url,
}) })
.done(function(res) { .done(function(res) {
data = res.data; data = res.data;
}) })
.fail(function() { .fail(function() {
m.trigger('pgadmin:view:fetch:error', m, self.field); m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
} }
/* /*
* Transform the data * Transform the data
*/ */
var transform = this.field.get('transform') || self.defaults.transform; var transform = this.field.get('transform') || self.defaults.transform;
@ -285,9 +285,9 @@ define('pgadmin.node.foreign_key', [
}))({}); }))({});
var headerGroups = Backform.generateViewSchema( var headerGroups = Backform.generateViewSchema(
self.field.get('node_info'), self.headerData, 'create', self.field.get('node_info'), self.headerData, 'create',
node, self.field.get('node_data') node, self.field.get('node_data')
), ),
fields = []; fields = [];
_.each(headerGroups, function(o) { _.each(headerGroups, function(o) {
@ -486,7 +486,7 @@ define('pgadmin.node.foreign_key', [
} }
var m = new (self.field.get('model'))( var m = new (self.field.get('model'))(
self.headerData.toJSON()), self.headerData.toJSON()),
coll = self.model.get(self.field.get('name')); coll = self.model.get(self.field.get('name'));
coll.add(m); coll.add(m);
@ -567,12 +567,12 @@ define('pgadmin.node.foreign_key', [
data : {cols:JSON.stringify(cols)}, data : {cols:JSON.stringify(cols)},
url: full_url, url: full_url,
}) })
.done(function(res) { .done(function(res) {
coveringindex = res.data; coveringindex = res.data;
}) })
.fail(function() { .fail(function() {
m.trigger('pgadmin:view:fetch:error', m, self.field); m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
} }
} }
@ -662,21 +662,21 @@ define('pgadmin.node.foreign_key', [
url: obj.generate_url(i, 'validate', d, true), url: obj.generate_url(i, 'validate', d, true),
type:'GET', type:'GET',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
t.removeIcon(i); t.removeIcon(i);
data.valid = true; data.valid = true;
data.icon = 'icon-foreign_key'; data.icon = 'icon-foreign_key';
t.addIcon(i, {icon: data.icon}); t.addIcon(i, {icon: data.icon});
setTimeout(function() {t.deselect(i);}, 10); setTimeout(function() {t.deselect(i);}, 10);
setTimeout(function() {t.select(i);}, 100); setTimeout(function() {t.select(i);}, 100);
} }
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
}); });
return false; return false;
}, },
@ -981,19 +981,19 @@ define('pgadmin.node.foreign_key', [
}, },
}), }),
canAdd: function(m) { canAdd: function(m) {
// We can't update columns of existing foreign key. // We can't update columns of existing foreign key.
return m.isNew(); return m.isNew();
}, canDelete: true, }, canDelete: true,
control: ForeignKeyColumnControl, control: ForeignKeyColumnControl,
model: ForeignKeyColumnModel, model: ForeignKeyColumnModel,
disabled: function(m) { disabled: function(m) {
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) { if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should allowed for Unique // new constraint which should allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }
// We can't update columns of existing foreign key. // We can't update columns of existing foreign key.
return !m.isNew(); return !m.isNew();
}, },
},{ },{
@ -1001,19 +1001,19 @@ define('pgadmin.node.foreign_key', [
type:'select2', group: gettext('Action'), mode: ['edit','create'], type:'select2', group: gettext('Action'), mode: ['edit','create'],
select2:{width:'50%', allowClear: false}, select2:{width:'50%', allowClear: false},
options: [ options: [
{label: 'NO ACTION', value: 'a'}, {label: 'NO ACTION', value: 'a'},
{label: 'RESTRICT', value: 'r'}, {label: 'RESTRICT', value: 'r'},
{label: 'CASCADE', value: 'c'}, {label: 'CASCADE', value: 'c'},
{label: 'SET NULL', value: 'n'}, {label: 'SET NULL', value: 'n'},
{label: 'SET DEFAULT', value: 'd'}, {label: 'SET DEFAULT', value: 'd'},
],disabled: function(m) { ],disabled: function(m) {
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) { if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should allowed for Unique // new constraint which should allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }
// We can't update confupdtype of existing foreign key. // We can't update confupdtype of existing foreign key.
return !m.isNew(); return !m.isNew();
}, },
},{ },{
@ -1021,19 +1021,19 @@ define('pgadmin.node.foreign_key', [
type:'select2', group: gettext('Action'), mode: ['edit','create'], type:'select2', group: gettext('Action'), mode: ['edit','create'],
select2:{width:'50%', allowClear: false}, select2:{width:'50%', allowClear: false},
options: [ options: [
{label: 'NO ACTION', value: 'a'}, {label: 'NO ACTION', value: 'a'},
{label: 'RESTRICT', value: 'r'}, {label: 'RESTRICT', value: 'r'},
{label: 'CASCADE', value: 'c'}, {label: 'CASCADE', value: 'c'},
{label: 'SET NULL', value: 'n'}, {label: 'SET NULL', value: 'n'},
{label: 'SET DEFAULT', value: 'd'}, {label: 'SET DEFAULT', value: 'd'},
],disabled: function(m) { ],disabled: function(m) {
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'handler') && !_.isUndefined(m.handler)) { if (_.has(m, 'handler') && !_.isUndefined(m.handler)) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should allowed for Unique // new constraint which should allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }
// We can't update confdeltype of existing foreign key. // We can't update confdeltype of existing foreign key.
return !m.isNew(); return !m.isNew();
}, },
}, },
@ -1064,7 +1064,7 @@ define('pgadmin.node.foreign_key', [
}), }),
canCreate: function(itemData, item, data) { canCreate: function(itemData, item, data) {
// If check is false then , we will allow create menu // If check is false then , we will allow create menu
if (data && data.check == false) if (data && data.check == false)
return true; return true;
@ -1073,9 +1073,9 @@ define('pgadmin.node.foreign_key', [
is_immediate_parent_table_partitioned = false, is_immediate_parent_table_partitioned = false,
s_version = this.getTreeNodeHierarchy(i).server.version; s_version = this.getTreeNodeHierarchy(i).server.version;
// To iterate over tree to check parent node // To iterate over tree to check parent node
while (i) { while (i) {
// If table is partitioned table then return false // If table is partitioned table then return false
if (!immediate_parent_table_found && (d._type == 'table' || d._type == 'partition')) { if (!immediate_parent_table_found && (d._type == 'table' || d._type == 'partition')) {
immediate_parent_table_found = true; immediate_parent_table_found = true;
if ('is_partitioned' in d && d.is_partitioned && s_version < 110000) { if ('is_partitioned' in d && d.is_partitioned && s_version < 110000) {
@ -1083,14 +1083,14 @@ define('pgadmin.node.foreign_key', [
} }
} }
// If it is schema then allow user to c reate table // If it is schema then allow user to c reate table
if (_.indexOf(['schema'], d._type) > -1) if (_.indexOf(['schema'], d._type) > -1)
return !is_immediate_parent_table_partitioned; return !is_immediate_parent_table_partitioned;
parents.push(d._type); parents.push(d._type);
i = t.hasParent(i) ? t.parent(i) : null; i = t.hasParent(i) ? t.parent(i) : null;
d = i ? t.itemData(i) : null; d = i ? t.itemData(i) : null;
} }
// If node is under catalog then do not allow 'create' menu // If node is under catalog then do not allow 'create' menu
if (_.indexOf(parents, 'catalog') > -1) { if (_.indexOf(parents, 'catalog') > -1) {
return false; return false;
} else { } else {

View File

@ -314,7 +314,7 @@ define('pgadmin.node.primary_key', [
this.stopListening(this.model, 'change:' + name, this.render); this.stopListening(this.model, 'change:' + name, this.render);
/* /*
* Iterate through all the values, and find out how many are already * Iterate through all the values, and find out how many are already
* present in the collection. * present in the collection.
*/ */
@ -329,7 +329,7 @@ define('pgadmin.node.primary_key', [
} }
}); });
/* /*
* Adding new values * Adding new values
*/ */
@ -344,7 +344,7 @@ define('pgadmin.node.primary_key', [
collection.add(m); collection.add(m);
}); });
/* /*
* Removing unwanted! * Removing unwanted!
*/ */
_.each(removed, function(v) { _.each(removed, function(v) {
@ -391,8 +391,8 @@ define('pgadmin.node.primary_key', [
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top) if (_.has(m, 'top') && !_.isUndefined(m.top)
&& !m.top.isNew()) { && !m.top.isNew()) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should be allowed for Unique // new constraint which should be allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }
@ -488,8 +488,8 @@ define('pgadmin.node.primary_key', [
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top) if (_.has(m, 'top') && !_.isUndefined(m.top)
&& !m.top.isNew()) { && !m.top.isNew()) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should be allowed for Unique // new constraint which should be allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }
@ -580,8 +580,8 @@ define('pgadmin.node.primary_key', [
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top) if (_.has(m, 'top') && !_.isUndefined(m.top)
&& !m.top.isNew()) { && !m.top.isNew()) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should allowed for Unique // new constraint which should allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }
@ -609,8 +609,8 @@ define('pgadmin.node.primary_key', [
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top) if (_.has(m, 'top') && !_.isUndefined(m.top)
&& !m.top.isNew()) { && !m.top.isNew()) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should allowed for Unique // new constraint which should allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }

View File

@ -300,7 +300,7 @@ define('pgadmin.node.unique_constraint', [
this.stopListening(this.model, 'change:' + name, this.render); this.stopListening(this.model, 'change:' + name, this.render);
/* /*
* Iterate through all the values, and find out how many are already * Iterate through all the values, and find out how many are already
* present in the collection. * present in the collection.
*/ */
@ -315,7 +315,7 @@ define('pgadmin.node.unique_constraint', [
} }
}); });
/* /*
* Adding new values * Adding new values
*/ */
@ -330,7 +330,7 @@ define('pgadmin.node.unique_constraint', [
collection.add(m); collection.add(m);
}); });
/* /*
* Removing unwanted! * Removing unwanted!
*/ */
_.each(removed, function(v) { _.each(removed, function(v) {
@ -377,8 +377,8 @@ define('pgadmin.node.unique_constraint', [
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top) if (_.has(m, 'top') && !_.isUndefined(m.top)
&& !m.top.isNew()) { && !m.top.isNew()) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should be allowed for Unique // new constraint which should be allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }
@ -474,8 +474,8 @@ define('pgadmin.node.unique_constraint', [
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top) if (_.has(m, 'top') && !_.isUndefined(m.top)
&& !m.top.isNew()) { && !m.top.isNew()) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should be allowed for Unique // new constraint which should be allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }
@ -566,8 +566,8 @@ define('pgadmin.node.unique_constraint', [
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top) if (_.has(m, 'top') && !_.isUndefined(m.top)
&& !m.top.isNew()) { && !m.top.isNew()) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should allowed for Unique // new constraint which should allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }
@ -595,8 +595,8 @@ define('pgadmin.node.unique_constraint', [
// If we are in table edit mode then // If we are in table edit mode then
if (_.has(m, 'top') && !_.isUndefined(m.top) if (_.has(m, 'top') && !_.isUndefined(m.top)
&& !m.top.isNew()) { && !m.top.isNew()) {
// If OID is undefined then user is trying to add // If OID is undefined then user is trying to add
// new constraint which should allowed for Unique // new constraint which should allowed for Unique
return !_.isUndefined(m.get('oid')); return !_.isUndefined(m.get('oid'));
} }

View File

@ -205,8 +205,8 @@ define('pgadmin.node.index', [
_.isNull(parent_model.get('amname')) || _.isNull(parent_model.get('amname')) ||
String(parent_model.get('amname')).replace(/^\s+|\s+$/g, '') == '' || String(parent_model.get('amname')).replace(/^\s+|\s+$/g, '') == '' ||
parent_model.get('amname') === 'btree') { parent_model.get('amname') === 'btree') {
// We need to set nulls to true if sort_order is set to desc // We need to set nulls to true if sort_order is set to desc
// nulls first is default for desc // nulls first is default for desc
if(m.get('sort_order') == true && m.previous('sort_order') == false) { if(m.get('sort_order') == true && m.previous('sort_order') == false) {
setTimeout(function() { m.set('nulls', true); }, 10); setTimeout(function() { m.set('nulls', true); }, 10);
} }

View File

@ -108,12 +108,12 @@ function(
info || {} : this.getTreeNodeHierarchy(item); info || {} : this.getTreeNodeHierarchy(item);
return S('table/%s/%s/%s/%s/%s/%s').sprintf( return S('table/%s/%s/%s/%s/%s/%s').sprintf(
encodeURIComponent(type), encodeURIComponent(info['server_group']._id), encodeURIComponent(type), encodeURIComponent(info['server_group']._id),
encodeURIComponent(info['server']._id), encodeURIComponent(info['server']._id),
encodeURIComponent(info['database']._id), encodeURIComponent(info['database']._id),
encodeURIComponent(info['partition'].schema_id), encodeURIComponent(info['partition'].schema_id),
encodeURIComponent(info['partition']._id) encodeURIComponent(info['partition']._id)
).value(); ).value();
}, },
canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema, canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema, canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
@ -146,21 +146,21 @@ function(
data: params, data: params,
dataType: 'json', dataType: 'json',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
t.unload(i);
t.setInode(i);
t.deselect(i);
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
t.setInode(i); });
t.deselect(i);
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}, },
/* Truncate table */ /* Truncate table */
truncate_table: function(args) { truncate_table: function(args) {
@ -194,25 +194,25 @@ function(
data: params, data: params,
dataType: 'json', dataType: 'json',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
t.removeIcon(i); t.removeIcon(i);
data.icon = 'icon-partition'; data.icon = 'icon-partition';
t.addIcon(i, {icon: data.icon}); t.addIcon(i, {icon: data.icon});
t.unload(i);
t.setInode(i);
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
t.setInode(i); });
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}}, }},
function() {} function() {}
); );
@ -237,25 +237,25 @@ function(
url: obj.generate_url(i, 'reset' , d, true), url: obj.generate_url(i, 'reset' , d, true),
type:'DELETE', type:'DELETE',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
t.removeIcon(i); t.removeIcon(i);
data.icon = 'icon-partition'; data.icon = 'icon-partition';
t.addIcon(i, {icon: data.icon}); t.addIcon(i, {icon: data.icon});
t.unload(i);
t.setInode(i);
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
t.setInode(i); });
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
} }
}, },
function() {} function() {}
@ -280,26 +280,26 @@ function(
url: obj.generate_url(i, 'detach' , d, true), url: obj.generate_url(i, 'detach' , d, true),
type:'PUT', type:'PUT',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
var n = t.next(i); var n = t.next(i);
if (!n || !n.length) {
n = t.prev(i);
if (!n || !n.length) { if (!n || !n.length) {
n = t.parent(i); n = t.prev(i);
t.setInode(n, true); if (!n || !n.length) {
n = t.parent(i);
t.setInode(n, true);
}
}
t.remove(i);
if (n.length) {
t.select(n);
} }
} }
t.remove(i); })
if (n.length) { .fail(function(xhr, status, error) {
t.select(n); Alertify.pgRespErrorNotify(xhr, error);
} });
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
});
} }
}, },
function() {} function() {}
@ -343,8 +343,8 @@ function(
initialize: function(attrs, args) { initialize: function(attrs, args) {
if (_.size(attrs) === 0) { if (_.size(attrs) === 0) {
var userInfo = pgBrowser.serverInfo[ var userInfo = pgBrowser.serverInfo[
args.node_info.server._id args.node_info.server._id
].user, ].user,
schemaInfo = args.node_info.schema; schemaInfo = args.node_info.schema;
this.set({ this.set({
@ -486,11 +486,11 @@ function(
if (primary_key_column_exist.length == 0) { if (primary_key_column_exist.length == 0) {
var primary_key_column = new (primary_key_column_coll.model)( var primary_key_column = new (primary_key_column_coll.model)(
{column: column_name}, { silent: true, {column: column_name}, { silent: true,
top: self.model, top: self.model,
collection: primary_key_coll, collection: primary_key_coll,
handler: primary_key_coll, handler: primary_key_coll,
}); });
primary_key_column_coll.add(primary_key_column); primary_key_column_coll.add(primary_key_column);
} }
@ -574,7 +574,7 @@ function(
return true; return true;
}, },
canAddRow: function(m) { canAddRow: function(m) {
// User can only add one primary key // User can only add one primary key
var columns = m.get('columns'); var columns = m.get('columns');
return (m.get('primary_key') && return (m.get('primary_key') &&
@ -602,7 +602,7 @@ function(
}, },
columns : ['name', 'columns'], columns : ['name', 'columns'],
canAddRow: function(m) { canAddRow: function(m) {
// User can only add if there is at least one column with name. // User can only add if there is at least one column with name.
var columns = m.get('columns'); var columns = m.get('columns');
return _.some(columns.pluck('name')); return _.some(columns.pluck('name'));
}, },
@ -637,7 +637,7 @@ function(
return true; return true;
}, },
canAddRow: function(m) { canAddRow: function(m) {
// User can only add if there is at least one column with name. // User can only add if there is at least one column with name.
var columns = m.get('columns'); var columns = m.get('columns');
return _.some(columns.pluck('name')); return _.some(columns.pluck('name'));
}, },
@ -662,7 +662,7 @@ function(
return true; return true;
}, },
canAddRow: function(m) { canAddRow: function(m) {
// User can only add if there is at least one column with name. // User can only add if there is at least one column with name.
var columns = m.get('columns'); var columns = m.get('columns');
return _.some(columns.pluck('name')); return _.some(columns.pluck('name'));
}, },
@ -679,7 +679,7 @@ function(
return data; return data;
}, },
control: Backform.NodeAjaxOptionsControl.extend({ control: Backform.NodeAjaxOptionsControl.extend({
// When of_types changes we need to clear columns collection // When of_types changes we need to clear columns collection
onChange: function() { onChange: function() {
Backform.NodeAjaxOptionsControl.prototype.onChange.apply(this, arguments); Backform.NodeAjaxOptionsControl.prototype.onChange.apply(this, arguments);
var self = this, var self = this,
@ -693,7 +693,7 @@ function(
var msg = gettext('Changing of table type will clear columns collection.'); var msg = gettext('Changing of table type will clear columns collection.');
Alertify.confirm(msg, function (e) { Alertify.confirm(msg, function (e) {
if (e) { if (e) {
// User clicks Ok, lets clear columns collection // User clicks Ok, lets clear columns collection
column_collection.reset(); column_collection.reset();
} else { } else {
return this; return this;
@ -703,11 +703,11 @@ function(
column_collection.reset(); column_collection.reset();
} }
// Run Ajax now to fetch columns // Run Ajax now to fetch columns
if (!_.isUndefined(tbl_name) && tbl_name !== '') { if (!_.isUndefined(tbl_name) && tbl_name !== '') {
arg = { 'tname': tbl_name }; arg = { 'tname': tbl_name };
data = self.model.fetch_columns_ajax.apply(self, [arg]); data = self.model.fetch_columns_ajax.apply(self, [arg]);
// Add into column collection // Add into column collection
column_collection.set(data, { merge:false,remove:false }); column_collection.set(data, { merge:false,remove:false });
} }
}, },
@ -878,27 +878,27 @@ function(
// Make ajax call to get the tables to be attached // Make ajax call to get the tables to be attached
$.ajax({ $.ajax({
url: node.generate_url.apply( url: node.generate_url.apply(
node, [ node, [
null, 'get_attach_tables', this.field.get('node_data'), null, 'get_attach_tables', this.field.get('node_data'),
true, node_info, true, node_info,
]), ]),
type: 'GET', type: 'GET',
async: false, async: false,
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
self.model.table_options = res.data; self.model.table_options = res.data;
} }
else { else {
Alertify.alert( Alertify.alert(
gettext('Error fetching tables to be attached'), res.data.result gettext('Error fetching tables to be attached'), res.data.result
); );
} }
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error, gettext('Error fetching tables to be attached')); Alertify.pgRespErrorNotify(xhr, error, gettext('Error fetching tables to be attached'));
}); });
} }
}, },
} }
@ -1143,11 +1143,11 @@ function(
node = this.field.get('schema_node'), node = this.field.get('schema_node'),
node_info = this.field.get('node_info'), node_info = this.field.get('node_info'),
full_url = node.generate_url.apply( full_url = node.generate_url.apply(
node, [ node, [
null, url, this.field.get('node_data'), null, url, this.field.get('node_data'),
this.field.get('url_with_id') || false, node_info, this.field.get('url_with_id') || false, node_info,
] ]
), ),
cache_level = this.field.get('cache_level') || node.type, cache_level = this.field.get('cache_level') || node.type,
cache_node = this.field.get('cache_node'); cache_node = this.field.get('cache_node');
@ -1160,12 +1160,12 @@ function(
url: full_url, url: full_url,
data: arg, data: arg,
}) })
.done(function(res) { .done(function(res) {
data = cache_node.cache(url, node_info, cache_level, res.data); data = cache_node.cache(url, node_info, cache_level, res.data);
}) })
.fail(function() { .fail(function() {
m.trigger('pgadmin:view:fetch:error', m, self.field); m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
data = (data && data.data) || []; data = (data && data.data) || [];
return data; return data;

View File

@ -97,12 +97,12 @@ define('pgadmin.node.table_partition_utils', [
return _.isObject(res) && !_.isArray(res) ? null : res; return _.isObject(res) && !_.isArray(res) ? null : res;
}, },
initialize: function() { initialize: function() {
// Here we will decide if we need to call URL // Here we will decide if we need to call URL
// Or fetch the data from parent columns collection // Or fetch the data from parent columns collection
var self = this; var self = this;
if(this.model.handler) { if(this.model.handler) {
Backgrid.Extension.Select2DepCell.prototype.initialize.apply(this, arguments); Backgrid.Extension.Select2DepCell.prototype.initialize.apply(this, arguments);
// Do not listen for any event(s) for existing constraint. // Do not listen for any event(s) for existing constraint.
if (_.isUndefined(self.model.get('oid'))) { if (_.isUndefined(self.model.get('oid'))) {
var tableCols = self.model.top.get('columns'); var tableCols = self.model.top.get('columns');
self.listenTo(tableCols, 'remove' , self.resetColOptions); self.listenTo(tableCols, 'remove' , self.resetColOptions);
@ -121,7 +121,7 @@ define('pgadmin.node.table_partition_utils', [
}, 50); }, 50);
}, },
custom_options: function() { custom_options: function() {
// We will add all the columns entered by user in table model // We will add all the columns entered by user in table model
var columns = this.model.top.get('columns'), var columns = this.model.top.get('columns'),
typename = this.model.top.get('typname'), typename = this.model.top.get('typname'),
of_types_tables = this.model.top.of_types_tables, of_types_tables = this.model.top.of_types_tables,
@ -132,26 +132,26 @@ define('pgadmin.node.table_partition_utils', [
var col = m.get('name'); var col = m.get('name');
if(!_.isUndefined(col) && !_.isNull(col)) { if(!_.isUndefined(col) && !_.isNull(col)) {
added_columns_from_tables.push( added_columns_from_tables.push(
{label: col, value: col, image:'icon-column'} {label: col, value: col, image:'icon-column'}
); );
} }
}); });
} else if (!_.isUndefined(typename) && !_.isNull(typename) } else if (!_.isUndefined(typename) && !_.isNull(typename)
&& !_.isUndefined(of_types_tables) && of_types_tables.length > 0) { && !_.isUndefined(of_types_tables) && of_types_tables.length > 0) {
// Iterate through all the of_type tables // Iterate through all the of_type tables
_.each(of_types_tables, function(type) { _.each(of_types_tables, function(type) {
if (type.label == typename) { if (type.label == typename) {
// Iterate all the columns of selected "OF TYPE". // Iterate all the columns of selected "OF TYPE".
_.each(type.oftype_columns, function(col) { _.each(type.oftype_columns, function(col) {
added_columns_from_tables.push( added_columns_from_tables.push(
{label: col.name, value: col.name, image:'icon-column'} {label: col.name, value: col.name, image:'icon-column'}
); );
}); });
} }
}); });
} }
// Set the values in to options so that user can select // Set the values in to options so that user can select
this.column.set('options', added_columns_from_tables); this.column.set('options', added_columns_from_tables);
}, },
remove: function() { remove: function() {

View File

@ -175,25 +175,25 @@ define('pgadmin.node.table', [
data: params, data: params,
dataType: 'json', dataType: 'json',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
t.removeIcon(i); t.removeIcon(i);
data.icon = data.is_partitioned ? 'icon-partition': 'icon-table'; data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
t.addIcon(i, {icon: data.icon}); t.addIcon(i, {icon: data.icon});
t.unload(i);
t.setInode(i);
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
t.setInode(i); });
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
} }
}, function() {} }, function() {}
); );
@ -218,25 +218,25 @@ define('pgadmin.node.table', [
url: obj.generate_url(i, 'reset' , d, true), url: obj.generate_url(i, 'reset' , d, true),
type:'DELETE', type:'DELETE',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
t.removeIcon(i); t.removeIcon(i);
data.icon = data.is_partitioned ? 'icon-partition': 'icon-table'; data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
t.addIcon(i, {icon: data.icon}); t.addIcon(i, {icon: data.icon});
t.unload(i);
t.setInode(i);
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
t.setInode(i); });
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
} }
}, },
function() {} function() {}
@ -256,20 +256,20 @@ define('pgadmin.node.table', [
url: obj.generate_url(i, 'count_rows' , d, true), url: obj.generate_url(i, 'count_rows' , d, true),
type:'GET', type:'GET',
}) })
.done(function(res) { .done(function(res) {
Alertify.success(res.info); Alertify.success(res.info);
d.rows_cnt = res.data.total_rows; d.rows_cnt = res.data.total_rows;
t.unload(i); t.unload(i);
t.setInode(i); t.setInode(i);
t.deselect(i); t.deselect(i);
setTimeout(function() { setTimeout(function() {
t.select(i); t.select(i);
}, 10); }, 10);
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
}); });
}, },
}, },
model: pgBrowser.Node.Model.extend({ model: pgBrowser.Node.Model.extend({
@ -309,8 +309,8 @@ define('pgadmin.node.table', [
initialize: function(attrs, args) { initialize: function(attrs, args) {
if (_.size(attrs) === 0) { if (_.size(attrs) === 0) {
var userInfo = pgBrowser.serverInfo[ var userInfo = pgBrowser.serverInfo[
args.node_info.server._id args.node_info.server._id
].user, ].user,
schemaInfo = args.node_info.schema; schemaInfo = args.node_info.schema;
this.set({ this.set({
@ -739,22 +739,22 @@ define('pgadmin.node.table', [
msg = gettext('Changing \'Of type\' will remove column definitions.'); msg = gettext('Changing \'Of type\' will remove column definitions.');
Alertify.confirm( Alertify.confirm(
title, msg, function () { title, msg, function () {
// User clicks Ok, lets clear columns collection // User clicks Ok, lets clear columns collection
column_collection.remove( column_collection.remove(
column_collection.filter(function() { return true; }) column_collection.filter(function() { return true; })
); );
}, },
function() { function() {
setTimeout(function() { setTimeout(function() {
self.model.set('typname', null); self.model.set('typname', null);
}, 10); }, 10);
} }
); );
} else if (!_.isUndefined(tbl_name) && tbl_name === '') { } else if (!_.isUndefined(tbl_name) && tbl_name === '') {
column_collection.remove( column_collection.remove(
column_collection.filter(function() { return true; }) column_collection.filter(function() { return true; })
); );
} }
// Run Ajax now to fetch columns // Run Ajax now to fetch columns
@ -903,7 +903,7 @@ define('pgadmin.node.table', [
if (m.get('partition_type') && m.get('partition_type') == 'list') if (m.get('partition_type') && m.get('partition_type') == 'list')
max_row_count = 1; max_row_count = 1;
/* If columns are not specified by the user then it may be /* If columns are not specified by the user then it may be
* possible that he/she selected 'OF TYPE', so we should check * possible that he/she selected 'OF TYPE', so we should check
* for that as well. * for that as well.
*/ */
@ -1011,19 +1011,19 @@ define('pgadmin.node.table', [
type: 'GET', type: 'GET',
async: false, async: false,
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
self.model.table_options = res.data; self.model.table_options = res.data;
} }
else { else {
Alertify.alert( Alertify.alert(
gettext('Error fetching tables to be attached'), res.data.result gettext('Error fetching tables to be attached'), res.data.result
); );
} }
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
}); });
} }
}, },
} }
@ -1291,12 +1291,12 @@ define('pgadmin.node.table', [
url: full_url, url: full_url,
data: arg, data: arg,
}) })
.done(function(res) { .done(function(res) {
data = cache_node.cache(url, node_info, cache_level, res.data); data = cache_node.cache(url, node_info, cache_level, res.data);
}) })
.fail(function() { .fail(function() {
m.trigger('pgadmin:view:fetch:error', m, self.field); m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
data = (data && data.data) || []; data = (data && data.data) || [];
return data; return data;

View File

@ -111,25 +111,25 @@ define('pgadmin.node.trigger', [
data: {'enable' : true}, data: {'enable' : true},
dataType: 'json', dataType: 'json',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
alertify.success(res.info); alertify.success(res.info);
t.removeIcon(i); t.removeIcon(i);
data.icon = 'icon-trigger'; data.icon = 'icon-trigger';
t.addIcon(i, {icon: data.icon}); t.addIcon(i, {icon: data.icon});
t.unload(i);
t.setInode(false);
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
t.setInode(false); });
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}, },
/* Disable trigger */ /* Disable trigger */
disable_trigger: function(args) { disable_trigger: function(args) {
@ -149,25 +149,25 @@ define('pgadmin.node.trigger', [
data: {'enable' : false}, data: {'enable' : false},
dataType: 'json', dataType: 'json',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
alertify.success(res.info); alertify.success(res.info);
t.removeIcon(i); t.removeIcon(i);
data.icon = 'icon-trigger-bad'; data.icon = 'icon-trigger-bad';
t.addIcon(i, {icon: data.icon}); t.addIcon(i, {icon: data.icon});
t.unload(i);
t.setInode(false);
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error, gettext('Disable trigger failed'));
t.unload(i); t.unload(i);
t.setInode(false); });
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error, gettext('Disable trigger failed'));
t.unload(i);
});
}, },
}, },
canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema, canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
@ -199,7 +199,7 @@ define('pgadmin.node.trigger', [
if (_.has(m, 'node_info') && _.has(m.node_info, 'table') && if (_.has(m, 'node_info') && _.has(m.node_info, 'table') &&
_.has(m.node_info.table, 'is_partitioned') && _.has(m.node_info.table, 'is_partitioned') &&
m.node_info.table.is_partitioned && m.node_info.server.version < 110000 m.node_info.table.is_partitioned && m.node_info.server.version < 110000
) )
{ {
setTimeout(function(){ setTimeout(function(){
m.set('is_row_trigger', false); m.set('is_row_trigger', false);
@ -214,7 +214,7 @@ define('pgadmin.node.trigger', [
if(!m.inSchemaWithModelCheck.apply(this, [m])) { if(!m.inSchemaWithModelCheck.apply(this, [m])) {
if(!_.isUndefined(is_constraint_trigger) && if(!_.isUndefined(is_constraint_trigger) &&
is_constraint_trigger === true) { is_constraint_trigger === true) {
// change it's model value // change it's model value
setTimeout(function() { m.set('is_row_trigger', true); }, 10); setTimeout(function() { m.set('is_row_trigger', true); }, 10);
return true; return true;
} else { } else {
@ -263,7 +263,7 @@ define('pgadmin.node.trigger', [
is_constraint_trigger === true) { is_constraint_trigger === true) {
return false; return false;
} else { } else {
// If value is already set then reset it to false // If value is already set then reset it to false
if(m.get('tgdeferrable')) { if(m.get('tgdeferrable')) {
setTimeout(function() { m.set('tgdeferrable', false); }, 10); setTimeout(function() { m.set('tgdeferrable', false); }, 10);
} }
@ -287,11 +287,11 @@ define('pgadmin.node.trigger', [
tgdeferrable) { tgdeferrable) {
return false; return false;
} else { } else {
// If value is already set then reset it to false // If value is already set then reset it to false
if(m.get('tginitdeferred')) { if(m.get('tginitdeferred')) {
setTimeout(function() { m.set('tginitdeferred', false); }, 10); setTimeout(function() { m.set('tginitdeferred', false); }, 10);
} }
// If constraint trigger is set then do not disable // If constraint trigger is set then do not disable
return m.get('is_constraint_trigger') ? false : true; return m.get('is_constraint_trigger') ? false : true;
} }
} else { } else {
@ -318,7 +318,7 @@ define('pgadmin.node.trigger', [
if(server_type === 'ppas' && if(server_type === 'ppas' &&
!_.isUndefined(tfunction) && !_.isUndefined(tfunction) &&
tfunction === 'Inline EDB-SPL') { tfunction === 'Inline EDB-SPL') {
// Disable and clear its value // Disable and clear its value
m.set('tgargs', undefined); m.set('tgargs', undefined);
return true; return true;
} else { } else {
@ -334,8 +334,8 @@ define('pgadmin.node.trigger', [
mode: ['create','edit', 'properties'], group: gettext('Events'), mode: ['create','edit', 'properties'], group: gettext('Events'),
options: function(control) { options: function(control) {
var table_options = [ var table_options = [
{label: 'BEFORE', value: 'BEFORE'}, {label: 'BEFORE', value: 'BEFORE'},
{label: 'AFTER', value: 'AFTER'}], {label: 'AFTER', value: 'AFTER'}],
view_options = [ view_options = [
{label: 'BEFORE', value: 'BEFORE'}, {label: 'BEFORE', value: 'BEFORE'},
{label: 'AFTER', value: 'AFTER'}, {label: 'AFTER', value: 'AFTER'},

View File

@ -435,12 +435,12 @@ define('pgadmin.node.type', [
cache: false, cache: false,
data: {'typname' : l_typname}, data: {'typname' : l_typname},
}) })
.done(function(res) { .done(function(res) {
result = res.data; result = res.data;
}) })
.fail(function() { .fail(function() {
self.model.trigger('pgadmin:view:fetch:error', self.model, self.field); self.model.trigger('pgadmin:view:fetch:error', self.model, self.field);
}); });
// //
} }
return result; return result;
@ -503,13 +503,13 @@ define('pgadmin.node.type', [
cache: false, cache: false,
data: {'name' : name}, data: {'name' : name},
}) })
.done(function(res) { .done(function(res) {
result = res.data; result = res.data;
}) })
.fail(function() { .fail(function() {
self.model.trigger('pgadmin:view:fetch:error', self.model.trigger('pgadmin:view:fetch:error',
self.model, self.field); self.model, self.field);
}); });
} }
return result; return result;
}, },
@ -528,24 +528,24 @@ define('pgadmin.node.type', [
!_.isUndefined(l_opcname) && l_opcname != '') { !_.isUndefined(l_opcname) && l_opcname != '') {
var node = this.field.get('schema_node'), var node = this.field.get('schema_node'),
_url = node.generate_url.apply( _url = node.generate_url.apply(
node, [ node, [
null, 'get_stypediff', null, 'get_stypediff',
this.field.get('node_data'), false, this.field.get('node_data'), false,
this.field.get('node_info'), this.field.get('node_info'),
]); ]);
$.ajax({ $.ajax({
async: false, async: false,
url: _url, url: _url,
cache: false, cache: false,
data: {'typname' : l_typname, 'opcname': l_opcname}, data: {'typname' : l_typname, 'opcname': l_opcname},
}) })
.done(function(res) { .done(function(res) {
result = res.data; result = res.data;
}) })
.fail(function() { .fail(function() {
self.model.trigger('pgadmin:view:fetch:error', self.model.trigger('pgadmin:view:fetch:error',
self.model, self.field); self.model, self.field);
}); });
} }
return result; return result;
}, },

View File

@ -267,20 +267,20 @@ define('pgadmin.node.mview', [
data: {'concurrent': args.concurrent, 'with_data': args.with_data}, data: {'concurrent': args.concurrent, 'with_data': args.with_data},
dataType: 'json', dataType: 'json',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(gettext('View refreshed successfully')); Alertify.success(gettext('View refreshed successfully'));
} }
else { else {
Alertify.alert( Alertify.alert(
gettext('Error refreshing view'), gettext('Error refreshing view'),
res.data.result res.data.result
); );
} }
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error, gettext('Error refreshing view')); Alertify.pgRespErrorNotify(xhr, error, gettext('Error refreshing view'));
}); });
}, },
is_version_supported: function(data, item) { is_version_supported: function(data, item) {

View File

@ -62,7 +62,7 @@ define('pgadmin.node.view', [
this.initialized = true; this.initialized = true;
/** /**
Add "create view" menu option into context and object menu Add "create view" menu option into context and object menu
for the following nodes: for the following nodes:
coll-view, view and schema. coll-view, view and schema.

View File

@ -197,33 +197,33 @@ define('pgadmin.node.database', [
url: obj.generate_url(i, 'connect', d, true), url: obj.generate_url(i, 'connect', d, true),
type:'DELETE', type:'DELETE',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
var prv_i = t.parent(i); var prv_i = t.parent(i);
Alertify.success(res.info); Alertify.success(res.info);
t.removeIcon(i); t.removeIcon(i);
data.connected = false; data.connected = false;
data.icon = 'icon-database-not-connected'; data.icon = 'icon-database-not-connected';
t.addIcon(i, {icon: data.icon}); t.addIcon(i, {icon: data.icon});
t.unload(i); t.unload(i);
t.setInode(i); t.setInode(i);
setTimeout(function() { setTimeout(function() {
t.select(prv_i); t.select(prv_i);
}, 10); }, 10);
} else { } else {
try { try {
Alertify.error(res.errormsg); Alertify.error(res.errormsg);
} catch (e) { } catch (e) {
console.warn(e.stack || e); console.warn(e.stack || e);
}
t.unload(i);
} }
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
} });
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}, },
function() { return true; }); function() { return true; });

View File

@ -186,11 +186,11 @@ define('pgadmin.node.pga_job', [
}) })
// 'pgagent.pga_job' table updated with current time to run the job // 'pgagent.pga_job' table updated with current time to run the job
// now. // now.
.done(function() { t.unload(i); }) .done(function() { t.unload(i); })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
alertify.pgRespErrorNotify(xhr, error); alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
}); });
return false; return false;
}, },

View File

@ -209,11 +209,11 @@ define('pgadmin.node.role', [
return opt.text; return opt.text;
} else { } else {
var d = _.extend( var d = _.extend(
{}, data, { {}, data, {
'opttext': _.escape(opt.text), 'opttext': _.escape(opt.text),
'optimage': optimage, 'optimage': optimage,
'checkbox': true, 'checkbox': true,
}), }),
j = $(self.selectionTemplate(d)); j = $(self.selectionTemplate(d));
// Update the checkbox lazy // Update the checkbox lazy
@ -255,7 +255,7 @@ define('pgadmin.node.role', [
this.stopListening(this.model, 'change:' + name, this.render); this.stopListening(this.model, 'change:' + name, this.render);
/* /*
* Iterate through all the values, and find out how many are already * Iterate through all the values, and find out how many are already
* present in the collection. * present in the collection.
*/ */
@ -270,14 +270,14 @@ define('pgadmin.node.role', [
} }
}); });
/* /*
* Adding new values * Adding new values
*/ */
_.each(vals, function(v) { _.each(vals, function(v) {
collection.add({role: v}); collection.add({role: v});
}); });
/* /*
* Removing unwanted! * Removing unwanted!
*/ */
_.each(removed, function(v) { _.each(removed, function(v) {

View File

@ -133,8 +133,8 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform',
// it is not loaded yet // it is not loaded yet
node_info = (_.has(model.top, 'node_info') node_info = (_.has(model.top, 'node_info')
&& !_.isUndefined(model.top.node_info)) ? && !_.isUndefined(model.top.node_info)) ?
model.top.node_info : model.top.node_info :
model.handler.top.node_info, model.handler.top.node_info,
curr_user = node_info.server.user.name; curr_user = node_info.server.user.name;
model.collection.each(function(m) { model.collection.each(function(m) {
@ -282,11 +282,11 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform',
this.attributes['privileges']) { this.attributes['privileges']) {
var anyPrivSelected = false; var anyPrivSelected = false;
this.attributes['privileges'].each( this.attributes['privileges'].each(
function(p) { function(p) {
if (p.get('privilege')) { if (p.get('privilege')) {
anyPrivSelected = true; anyPrivSelected = true;
} }
}); });
if (!anyPrivSelected) { if (!anyPrivSelected) {
msg = gettext('At least one privilege should be selected.'); msg = gettext('At least one privilege should be selected.');
@ -473,7 +473,7 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform',
*/ */
$allPrivileges.prop('checked', false); $allPrivileges.prop('checked', false);
$elGrant.prop('checked', false), $elGrant.prop('checked', false),
$allGrants.prop('checked', false); $allGrants.prop('checked', false);
$elGrant.prop('disabled', true); $elGrant.prop('disabled', true);
$allGrants.prop('disabled', true); $allGrants.prop('disabled', true);
} }
@ -546,8 +546,8 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform',
if (type == 'with_grant') { if (type == 'with_grant') {
$allGrants = $tbl.find( $allGrants = $tbl.find(
'input[name=with_grant][privilege!=\'ALL\']:checked' 'input[name=with_grant][privilege!=\'ALL\']:checked'
); );
if ($allGrants.length == collection.models.length) { if ($allGrants.length == collection.models.length) {
$allGrants.prop('disabled', false); $allGrants.prop('disabled', false);
$allGrants.prop('checked', true); $allGrants.prop('checked', true);
@ -616,7 +616,7 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform',
coll = this.model.get(this.column.get('name')); coll = this.model.get(this.column.get('name'));
if (command.moveUp() || command.moveDown() || command.save()) { if (command.moveUp() || command.moveDown() || command.save()) {
// backgrid vertical navigation (Up/Down arrow key) // backgrid vertical navigation (Up/Down arrow key)
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
model.trigger('backgrid:edited', model, column, command); model.trigger('backgrid:edited', model, column, command);
@ -752,7 +752,7 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform',
e.stopPropagation(); e.stopPropagation();
model.trigger('backgrid:edited', model, column, command); model.trigger('backgrid:edited', model, column, command);
} }
// esc // esc
else if (command.cancel()) { else if (command.cancel()) {
// undo // undo
e.stopPropagation(); e.stopPropagation();

View File

@ -223,38 +223,38 @@ define('pgadmin.node.server', [
url: obj.generate_url(i, 'connect', d, true), url: obj.generate_url(i, 'connect', d, true),
type:'DELETE', type:'DELETE',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
d = t.itemData(i); d = t.itemData(i);
t.removeIcon(i); t.removeIcon(i);
d.connected = false; d.connected = false;
d.icon = 'icon-server-not-connected'; d.icon = 'icon-server-not-connected';
t.addIcon(i, {icon: d.icon}); t.addIcon(i, {icon: d.icon});
obj.callbacks.refresh.apply(obj, [null, i]); obj.callbacks.refresh.apply(obj, [null, i]);
if (pgBrowser.serverInfo && d._id in pgBrowser.serverInfo) { if (pgBrowser.serverInfo && d._id in pgBrowser.serverInfo) {
delete pgBrowser.serverInfo[d._id]; delete pgBrowser.serverInfo[d._id];
}
pgBrowser.enable_disable_menus(i);
// Trigger server disconnect event
pgBrowser.Events.trigger(
'pgadmin:server:disconnect',
{item: i, data: d}, false
);
} }
pgBrowser.enable_disable_menus(i); else {
// Trigger server disconnect event try {
pgBrowser.Events.trigger( Alertify.error(res.errormsg);
'pgadmin:server:disconnect', } catch (e) {
{item: i, data: d}, false console.warn(e.stack || e);
); }
} t.unload(i);
else {
try {
Alertify.error(res.errormsg);
} catch (e) {
console.warn(e.stack || e);
} }
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
} });
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}; };
if (notify) { if (notify) {
@ -318,18 +318,18 @@ define('pgadmin.node.server', [
url: obj.generate_url(i, 'reload', d, true), url: obj.generate_url(i, 'reload', d, true),
method:'GET', method:'GET',
}) })
.done(function(res) { .done(function(res) {
if (res.data.status) { if (res.data.status) {
Alertify.success(res.data.result); Alertify.success(res.data.result);
} }
else { else {
Alertify.error(res.data.result); Alertify.error(res.data.result);
} }
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
}); });
}, },
function() { return true; } function() { return true; }
); );
@ -359,13 +359,13 @@ define('pgadmin.node.server', [
method:'POST', method:'POST',
data:{ 'value': JSON.stringify(value) }, data:{ 'value': JSON.stringify(value) },
}) })
.done(function(res) { .done(function(res) {
Alertify.success(res.data.result, 10); Alertify.success(res.data.result, 10);
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
}); });
} else { } else {
evt.cancel = true; evt.cancel = true;
Alertify.error( gettext('Please enter a valid name.'), 10); Alertify.error( gettext('Please enter a valid name.'), 10);
@ -515,27 +515,27 @@ define('pgadmin.node.server', [
method:'POST', method:'POST',
data:{'data': JSON.stringify(args) }, data:{'data': JSON.stringify(args) },
}) })
.done(function(res) { .done(function(res) {
if (res.success) { if (res.success) {
// Notify user to update pgpass file // Notify user to update pgpass file
if(is_pgpass_file_used) { if(is_pgpass_file_used) {
Alertify.alert( Alertify.alert(
gettext('Change Password'), gettext('Change Password'),
gettext('Please make sure to disconnect the server' gettext('Please make sure to disconnect the server'
+ ' and update the new password in the pgpass file' + ' and update the new password in the pgpass file'
+ ' before performing any other operation') + ' before performing any other operation')
); );
} }
Alertify.success(res.info); Alertify.success(res.info);
self.close(); self.close();
} else { } else {
Alertify.error(res.errormsg); Alertify.error(res.errormsg);
} }
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
}); });
} }
}, },
}; };
@ -547,15 +547,15 @@ define('pgadmin.node.server', [
url: check_pgpass_url, url: check_pgpass_url,
method:'GET', method:'GET',
}) })
.done(function(res) { .done(function(res) {
if (res.success && res.data.is_pgpass) { if (res.success && res.data.is_pgpass) {
is_pgpass_file_used = true; is_pgpass_file_used = true;
} }
Alertify.changeServerPassword(d).resizeTo('40%','52%'); Alertify.changeServerPassword(d).resizeTo('40%','52%');
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
}); });
return false; return false;
}, },
@ -576,23 +576,23 @@ define('pgadmin.node.server', [
type:'DELETE', type:'DELETE',
dataType: 'json', dataType: 'json',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
t.itemData(i).wal_pause=res.data.wal_pause; t.itemData(i).wal_pause=res.data.wal_pause;
t.unload(i);
t.setInode(i);
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
t.setInode(i); });
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}, },
/* Resume WAL Replay */ /* Resume WAL Replay */
@ -611,23 +611,23 @@ define('pgadmin.node.server', [
type:'PUT', type:'PUT',
dataType: 'json', dataType: 'json',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
t.itemData(i).wal_pause=res.data.wal_pause; t.itemData(i).wal_pause=res.data.wal_pause;
t.unload(i);
t.setInode(i);
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i); t.unload(i);
t.setInode(i); });
t.deselect(i);
// Fetch updated data from server
setTimeout(function() {
t.select(i);
}, 10);
}
})
.fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error);
t.unload(i);
});
}, },
/* Cleat saved database server password */ /* Cleat saved database server password */
@ -651,18 +651,18 @@ define('pgadmin.node.server', [
url: obj.generate_url(i, 'clear_saved_password', d, true), url: obj.generate_url(i, 'clear_saved_password', d, true),
method:'PUT', method:'PUT',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
t.itemData(i).is_password_saved=res.data.is_password_saved; t.itemData(i).is_password_saved=res.data.is_password_saved;
} }
else { else {
Alertify.error(res.info); Alertify.error(res.info);
} }
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
}); });
}, },
function() { return true; } function() { return true; }
); );
@ -691,18 +691,18 @@ define('pgadmin.node.server', [
url: obj.generate_url(i, 'clear_sshtunnel_password', d, true), url: obj.generate_url(i, 'clear_sshtunnel_password', d, true),
method:'PUT', method:'PUT',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 1) { if (res.success == 1) {
Alertify.success(res.info); Alertify.success(res.info);
t.itemData(i).is_tunnel_password_saved=res.data.is_tunnel_password_saved; t.itemData(i).is_tunnel_password_saved=res.data.is_tunnel_password_saved;
} }
else { else {
Alertify.error(res.info); Alertify.error(res.info);
} }
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
}); });
}, },
function() { return true; } function() { return true; }
); );
@ -1241,16 +1241,16 @@ define('pgadmin.node.server', [
url: _url, url: _url,
data: $('#frmPassword').serialize(), data: $('#frmPassword').serialize(),
}) })
.done(function(res) { .done(function(res) {
return _onSuccess( return _onSuccess(
res, _node, _data, _tree, _item, _status res, _node, _data, _tree, _item, _status
); );
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
return _onFailure( return _onFailure(
xhr, status, error, _node, _data, _tree, _item, _status xhr, status, error, _node, _data, _tree, _item, _status
); );
}); });
} else { } else {
_onCancel && typeof(_onCancel) == 'function' && _onCancel && typeof(_onCancel) == 'function' &&
_onCancel(_tree, _item, _data, _status); _onCancel(_tree, _item, _data, _status);

View File

@ -11,214 +11,214 @@ define([
'sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', 'backgrid', 'alertify', 'sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', 'backgrid', 'alertify',
'sources/pgadmin', 'pgadmin.browser.node', 'pgadmin.browser.node.ui', 'sources/pgadmin', 'pgadmin.browser.node', 'pgadmin.browser.node.ui',
], ],
function(gettext, _, $, Backbone, Backform, Backgrid, Alertify, pgAdmin, pgNode) { function(gettext, _, $, Backbone, Backform, Backgrid, Alertify, pgAdmin, pgNode) {
/* /*
* cellFunction for variable control. * cellFunction for variable control.
* This function returns cell class depending on vartype. * This function returns cell class depending on vartype.
*/ */
var cellFunction = function(model) { var cellFunction = function(model) {
var self = this, var self = this,
name = model.get('name'), name = model.get('name'),
availVariables = {}; availVariables = {};
self.collection.each(function(col) { self.collection.each(function(col) {
if (col.get('name') == 'name') { if (col.get('name') == 'name') {
availVariables = col.get('availVariables'); availVariables = col.get('availVariables');
} }
}); });
var variable = name ? availVariables[name]: undefined, var variable = name ? availVariables[name]: undefined,
value = model.get('value'); value = model.get('value');
switch(variable && variable.vartype) { switch(variable && variable.vartype) {
case 'bool': case 'bool':
/* /*
* bool cell and variable cannot be stateless (i.e undefined). * bool cell and variable cannot be stateless (i.e undefined).
* It should be either true or false. * It should be either true or false.
*/ */
model.set('value', !!model.get('value'), {silent: true}); model.set('value', !!model.get('value'), {silent: true});
return Backgrid.Extension.SwitchCell; return Backgrid.Extension.SwitchCell;
case 'enum': case 'enum':
model.set({'value': value}, {silent:true}); model.set({'value': value}, {silent:true});
var options = [], var options = [],
enumVals = variable.enumvals; enumVals = variable.enumvals;
_.each(enumVals, function(enumVal) { _.each(enumVals, function(enumVal) {
options.push([enumVal, enumVal]); options.push([enumVal, enumVal]);
}); });
return Backgrid.Extension.Select2Cell.extend({optionValues: options}); return Backgrid.Extension.Select2Cell.extend({optionValues: options});
case 'integer': case 'integer':
if (!_.isNaN(parseInt(value))) { if (!_.isNaN(parseInt(value))) {
model.set({'value': parseInt(value)}, {silent:true}); model.set({'value': parseInt(value)}, {silent:true});
} else { } else {
model.set({'value': undefined}, {silent:true});
}
return Backgrid.IntegerCell;
case 'real':
if (!_.isNaN(parseFloat(value))) {
model.set({'value': parseFloat(value)}, {silent:true});
} else {
model.set({'value': undefined}, {silent:true});
}
return Backgrid.NumberCell.extend({decimals: 0});
case 'string':
return Backgrid.StringCell;
default:
model.set({'value': undefined}, {silent:true}); model.set({'value': undefined}, {silent:true});
return Backgrid.Cell;
} }
}; return Backgrid.IntegerCell;
case 'real':
if (!_.isNaN(parseFloat(value))) {
model.set({'value': parseFloat(value)}, {silent:true});
} else {
model.set({'value': undefined}, {silent:true});
}
return Backgrid.NumberCell.extend({decimals: 0});
case 'string':
return Backgrid.StringCell;
default:
model.set({'value': undefined}, {silent:true});
return Backgrid.Cell;
}
};
/* /*
* This row will define behaviour or value column cell depending upon * This row will define behaviour or value column cell depending upon
* variable name. * variable name.
*/ */
var VariableRow = Backgrid.Row.extend({ var VariableRow = Backgrid.Row.extend({
modelDuplicateClass: 'bg-model-duplicate', modelDuplicateClass: 'bg-model-duplicate',
initialize: function () { initialize: function () {
Backgrid.Row.prototype.initialize.apply(this, arguments); Backgrid.Row.prototype.initialize.apply(this, arguments);
var self = this; var self = this;
self.model.on('change:name', function() { self.model.on('change:name', function() {
setTimeout(function() { setTimeout(function() {
self.columns.each(function(col) { self.columns.each(function(col) {
if (col.get('name') == 'value') { if (col.get('name') == 'value') {
var idx = self.columns.indexOf(col), var idx = self.columns.indexOf(col),
cf = col.get('cellFunction'), cf = col.get('cellFunction'),
cell = new (cf.apply(col, [self.model]))({ cell = new (cf.apply(col, [self.model]))({
column: col, column: col,
model: self.model, model: self.model,
}), }),
oldCell = self.cells[idx]; oldCell = self.cells[idx];
oldCell.remove(); oldCell.remove();
self.cells[idx] = cell; self.cells[idx] = cell;
self.render(); self.render();
} }
}); });
}, 10); }, 10);
}); });
self.listenTo(self.model, 'pgadmin-session:model:duplicate', self.modelDuplicate); self.listenTo(self.model, 'pgadmin-session:model:duplicate', self.modelDuplicate);
self.listenTo(self.model, 'pgadmin-session:model:unique', self.modelUnique); self.listenTo(self.model, 'pgadmin-session:model:unique', self.modelUnique);
}, },
modelDuplicate: function() { modelDuplicate: function() {
$(this.el).removeClass('new'); $(this.el).removeClass('new');
$(this.el).addClass(this.modelDuplicateClass); $(this.el).addClass(this.modelDuplicateClass);
}, },
modelUnique: function() { modelUnique: function() {
$(this.el).removeClass(this.modelDuplicateClass); $(this.el).removeClass(this.modelDuplicateClass);
}, },
}); });
/** /**
* VariableModel used to represent configuration parameters (variables tab) * VariableModel used to represent configuration parameters (variables tab)
* for database objects. * for database objects.
**/ **/
var VariableModel = pgNode.VariableModel = pgNode.Model.extend({ var VariableModel = pgNode.VariableModel = pgNode.Model.extend({
keys: ['name'], keys: ['name'],
defaults: { defaults: {
name: undefined, name: undefined,
value: undefined, value: undefined,
role: null, role: null,
database: null, database: null,
}, },
schema: [ schema: [
{ {
id: 'name', label: gettext('Name'), type:'text', cellHeaderClasses: 'width_percent_30', id: 'name', label: gettext('Name'), type:'text', cellHeaderClasses: 'width_percent_30',
editable: function(m) { editable: function(m) {
return (m instanceof Backbone.Collection) ? true : m.isNew(); return (m instanceof Backbone.Collection) ? true : m.isNew();
}, },
cell: Backgrid.Extension.NodeAjaxOptionsCell.extend({ cell: Backgrid.Extension.NodeAjaxOptionsCell.extend({
initialize: function() { initialize: function() {
Backgrid.Extension.NodeAjaxOptionsCell.prototype.initialize.apply(this, arguments); Backgrid.Extension.NodeAjaxOptionsCell.prototype.initialize.apply(this, arguments);
// Immediately process options as we need them before render. // Immediately process options as we need them before render.
var opVals = _.clone(this.optionValues || var opVals = _.clone(this.optionValues ||
(_.isFunction(this.column.get('options')) ? (_.isFunction(this.column.get('options')) ?
(this.column.get('options'))(this) : (this.column.get('options'))(this) :
this.column.get('options'))); this.column.get('options')));
this.column.set('options', opVals); this.column.set('options', opVals);
},
}),
url: 'vopts',
select2: { allowClear: false },
transform: function(vars, cell) {
var res = [],
availVariables = {};
_.each(vars, function(v) {
res.push({
'value': v.name,
'image': undefined,
'label': v.name,
});
availVariables[v.name] = v;
});
cell.column.set('availVariables', availVariables);
return res;
}, },
}, }),
{ url: 'vopts',
id: 'value', label: gettext('Value'), type: 'text', editable: true, select2: { allowClear: false },
cellFunction: cellFunction, cellHeaderClasses: 'width_percent_40', transform: function(vars, cell) {
}, var res = [],
{id: 'database', label: gettext('Database'), type: 'text', editable: true, availVariables = {};
node: 'database', cell: Backgrid.Extension.NodeListByNameCell,
},
{id: 'role', label: gettext('Role'), type: 'text', editable: true,
node: 'role', cell: Backgrid.Extension.NodeListByNameCell},
],
toJSON: function() {
var d = Backbone.Model.prototype.toJSON.apply(this);
// Remove not defined values from model values. _.each(vars, function(v) {
// i.e. res.push({
// role, database 'value': v.name,
if (_.isUndefined(d.database) || _.isNull(d.database)) { 'image': undefined,
delete d.database; 'label': v.name,
} });
availVariables[v.name] = v;
});
if (_.isUndefined(d.role) || _.isNull(d.role)) { cell.column.set('availVariables', availVariables);
delete d.role; return res;
} },
return d;
}, },
validate: function() { {
var msg = null; id: 'value', label: gettext('Value'), type: 'text', editable: true,
if (_.isUndefined(this.get('name')) || cellFunction: cellFunction, cellHeaderClasses: 'width_percent_40',
},
{id: 'database', label: gettext('Database'), type: 'text', editable: true,
node: 'database', cell: Backgrid.Extension.NodeListByNameCell,
},
{id: 'role', label: gettext('Role'), type: 'text', editable: true,
node: 'role', cell: Backgrid.Extension.NodeListByNameCell},
],
toJSON: function() {
var d = Backbone.Model.prototype.toJSON.apply(this);
// Remove not defined values from model values.
// i.e.
// role, database
if (_.isUndefined(d.database) || _.isNull(d.database)) {
delete d.database;
}
if (_.isUndefined(d.role) || _.isNull(d.role)) {
delete d.role;
}
return d;
},
validate: function() {
var msg = null;
if (_.isUndefined(this.get('name')) ||
_.isNull(this.get('name')) || _.isNull(this.get('name')) ||
String(this.get('name')).replace(/^\s+|\s+$/g, '') == '') { String(this.get('name')).replace(/^\s+|\s+$/g, '') == '') {
msg = gettext('Please select a parameter name.'); msg = gettext('Please select a parameter name.');
this.errorModel.set('name', msg); this.errorModel.set('name', msg);
} else if (_.isUndefined(this.get('value')) || } else if (_.isUndefined(this.get('value')) ||
_.isNull(this.get('value')) || _.isNull(this.get('value')) ||
String(this.get('value')).replace(/^\s+|\s+$/g, '') == '') { String(this.get('value')).replace(/^\s+|\s+$/g, '') == '') {
msg = ('Please enter a value for the parameter.'); msg = ('Please enter a value for the parameter.');
this.errorModel.set('value', msg); this.errorModel.set('value', msg);
this.errorModel.unset('name'); this.errorModel.unset('name');
} else { } else {
this.errorModel.unset('name'); this.errorModel.unset('name');
this.errorModel.unset('value'); this.errorModel.unset('value');
} }
return msg; return msg;
}, },
}); });
/** /**
* Variable Tab Control to set/update configuration values for database object. * Variable Tab Control to set/update configuration values for database object.
* *
**/ **/
Backform.VariableCollectionControl = Backform.VariableCollectionControl =
Backform.UniqueColCollectionControl.extend({ Backform.UniqueColCollectionControl.extend({
hasDatabase: false, hasDatabase: false,
@ -228,7 +228,7 @@ define([
var self = this, var self = this,
keys = ['name']; keys = ['name'];
/* /*
* Read from field schema whether user wants to use database and role * Read from field schema whether user wants to use database and role
* fields in Variable control. * fields in Variable control.
*/ */
@ -247,9 +247,9 @@ define([
opts.field.set({ opts.field.set({
model: pgNode.VariableModel.extend({keys:keys}), model: pgNode.VariableModel.extend({keys:keys}),
}, },
{ {
silent: true, silent: true,
}); });
} else { } else {
opts.field.extend({ opts.field.extend({
model: pgNode.VariableModel.extend({keys:keys}), model: pgNode.VariableModel.extend({keys:keys}),
@ -311,18 +311,18 @@ define([
async: false, async: false,
url: full_url, url: full_url,
}) })
.done(function (res) { .done(function (res) {
data = res.data; data = res.data;
}) })
.fail(function() { .fail(function() {
m.trigger('pgadmin-view:fetch:error', m, self.field); m.trigger('pgadmin-view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin-view:fetched', m, self.field); m.trigger('pgadmin-view:fetched', m, self.field);
if (data && _.isArray(data)) { if (data && _.isArray(data)) {
self.collection.reset(data, {silent: true}); self.collection.reset(data, {silent: true});
} }
/* /*
* Make sure - new data will be taken care by the session management * Make sure - new data will be taken care by the session management
*/ */
if (isTracking) { if (isTracking) {
@ -483,5 +483,5 @@ define([
}, },
}); });
return VariableModel; return VariableModel;
}); });

View File

@ -290,17 +290,17 @@ define('pgadmin.node.tablespace', [
method:'PUT', method:'PUT',
data:{'data': JSON.stringify(args) }, data:{'data': JSON.stringify(args) },
}) })
.done(function(res) { .done(function(res) {
if (res.success) { if (res.success) {
Alertify.success(res.info); Alertify.success(res.info);
self.close(); self.close();
} else { } else {
Alertify.error(res.errormsg); Alertify.error(res.errormsg);
} }
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
}); });
}, },
function() { function() {
// Do nothing as user cancel the operation // Do nothing as user cancel the operation

View File

@ -45,7 +45,7 @@ define('pgadmin.browser', [
if (d && obj.Nodes[d._type].callbacks['selected'] && if (d && obj.Nodes[d._type].callbacks['selected'] &&
_.isFunction(obj.Nodes[d._type].callbacks['selected'])) { _.isFunction(obj.Nodes[d._type].callbacks['selected'])) {
return obj.Nodes[d._type].callbacks['selected'].apply( return obj.Nodes[d._type].callbacks['selected'].apply(
obj.Nodes[d._type], [i, d, obj]); obj.Nodes[d._type], [i, d, obj]);
} }
} }
}; };
@ -492,7 +492,7 @@ define('pgadmin.browser', [
if (d && obj.Nodes[d._type]) { if (d && obj.Nodes[d._type]) {
node = obj.Nodes[d._type]; node = obj.Nodes[d._type];
/* If the node specific callback returns false, we will also return /* If the node specific callback returns false, we will also return
* false for further processing. * false for further processing.
*/ */
if (_.isObject(node.callbacks) && if (_.isObject(node.callbacks) &&
@ -535,8 +535,8 @@ define('pgadmin.browser', [
url: url_for('misc.cleanup'), url: url_for('misc.cleanup'),
type:'POST', type:'POST',
}) })
.done(function() {}) .done(function() {})
.fail(function() {}); .fail(function() {});
}, 300000); }, 300000);
obj.Events.on('pgadmin:browser:tree:add', obj.onAddTreeNode, obj); obj.Events.on('pgadmin:browser:tree:add', obj.onAddTreeNode, obj);
@ -571,13 +571,13 @@ define('pgadmin.browser', [
'management', 'tools', 'help']) >= 0) { 'management', 'tools', 'help']) >= 0) {
var menus; var menus;
// If current node is not visible in browser tree // If current node is not visible in browser tree
// then return from here // then return from here
if(!checkNodeVisibility(self, m.node)) { if(!checkNodeVisibility(self, m.node)) {
return; return;
} else if(_.has(m, 'module') && !_.isUndefined(m.module)) { } else if(_.has(m, 'module') && !_.isUndefined(m.module)) {
// If module to which this menu applies is not visible in // If module to which this menu applies is not visible in
// browser tree then also we do not display menu // browser tree then also we do not display menu
if(!checkNodeVisibility(self, m.module.type)) { if(!checkNodeVisibility(self, m.module.type)) {
return; return;
} }
@ -601,16 +601,16 @@ define('pgadmin.browser', [
target: m.target, icon: m.icon, target: m.target, icon: m.icon,
enable: (m.enable == '' ? true : (_.isString(m.enable) && enable: (m.enable == '' ? true : (_.isString(m.enable) &&
m.enable.toLowerCase() == 'false') ? m.enable.toLowerCase() == 'false') ?
false : m.enable), false : m.enable),
node: m.node, node: m.node,
}); });
} }
} else { } else {
console.warn( console.warn(
'Developer warning: Category \'' + 'Developer warning: Category \'' +
a + a +
'\' is not supported!\nSupported categories are: context, file, edit, object, tools, management, help' '\' is not supported!\nSupported categories are: context, file, edit, object, tools, management, help'
); );
} }
}); });
}); });
@ -628,17 +628,17 @@ define('pgadmin.browser', [
{menu: 'management', id: '#mnu_management'}, {menu: 'management', id: '#mnu_management'},
{menu: 'tools', id: '#mnu_tools'}, {menu: 'tools', id: '#mnu_tools'},
{menu: 'help', id:'#mnu_help'}], {menu: 'help', id:'#mnu_help'}],
function(o) { function(o) {
var $mnu = navbar.children(o.id).first(), var $mnu = navbar.children(o.id).first(),
$dropdown = $mnu.children('.dropdown-menu').first(); $dropdown = $mnu.children('.dropdown-menu').first();
$dropdown.empty(); $dropdown.empty();
if (pgAdmin.Browser.MenuCreator( if (pgAdmin.Browser.MenuCreator(
$dropdown, obj.menus[o.menu], obj.menu_categories $dropdown, obj.menus[o.menu], obj.menu_categories
)) { )) {
$mnu.removeClass('d-none'); $mnu.removeClass('d-none');
} }
}); });
navbar.children('#mnu_obj').removeClass('d-none'); navbar.children('#mnu_obj').removeClass('d-none');
obj.enable_disable_menus(); obj.enable_disable_menus();
@ -739,12 +739,12 @@ define('pgadmin.browser', [
hasId: true, hasId: true,
i: null, // current item i: null, // current item
p: _.toArray(_hierarchy || {}).sort( p: _.toArray(_hierarchy || {}).sort(
function(a, b) { function(a, b) {
return (a.priority === b.priority) ? 0 : ( return (a.priority === b.priority) ? 0 : (
a.priority < b.priority ? -1 : 1 a.priority < b.priority ? -1 : 1
); );
} }
), // path of the parent ), // path of the parent
pathOfTreeItems: [], // path Item pathOfTreeItems: [], // path Item
t: this.tree, // Tree Api t: this.tree, // Tree Api
o: _opts, o: _opts,
@ -893,8 +893,8 @@ define('pgadmin.browser', [
if( if(
is_parent_loaded_before && is_parent_loaded_before &&
_parent_data && _parent_data._type.search( _parent_data && _parent_data._type.search(
_data._type _data._type
) > -1 ) > -1
) { ) {
ctx.t.openPath(i); ctx.t.openPath(i);
ctx.t.select(i); ctx.t.select(i);
@ -988,12 +988,12 @@ define('pgadmin.browser', [
i: null, // current item i: null, // current item
hasId: true, hasId: true,
p: _.toArray(_hierarchy || {}).sort( p: _.toArray(_hierarchy || {}).sort(
function(a, b) { function(a, b) {
return (a.priority === b.priority) ? 0 : ( return (a.priority === b.priority) ? 0 : (
a.priority < b.priority ? -1 : 1 a.priority < b.priority ? -1 : 1
); );
} }
), // path of the old object ), // path of the old object
pathOfTreeItems: [], // path items pathOfTreeItems: [], // path items
t: this.tree, // Tree Api t: this.tree, // Tree Api
o: _opts, o: _opts,
@ -1035,9 +1035,9 @@ define('pgadmin.browser', [
&& this.t.hasParent(this.i) && this.t.hasParent(this.i)
&& this.t.parent(this.i)) || null, && this.t.parent(this.i)) || null,
_item_grand_parent = _item_parent ? _item_grand_parent = _item_parent ?
(this.t.hasParent(_item_parent) (this.t.hasParent(_item_parent)
&& this.t.parent(_item_parent)) && this.t.parent(_item_parent))
: null; : null;
// Remove the current node first. // Remove the current node first.
if ( if (
@ -1147,7 +1147,7 @@ define('pgadmin.browser', [
self.t.unload(_parent, {success: function() { self.t.unload(_parent, {success: function() {
setTimeout(postRemove); setTimeout(postRemove);
}} }}
); );
}, },
}); });
} else { } else {
@ -1541,73 +1541,73 @@ define('pgadmin.browser', [
cache: false, cache: false,
dataType: 'json', dataType: 'json',
}) })
.done(function(res) { .done(function(res) {
// Node information can come as result/data // Node information can come as result/data
var newData = res.result || res.data; var newData = res.result || res.data;
newData._label = newData.label; newData._label = newData.label;
newData.label = _.escape(newData.label); newData.label = _.escape(newData.label);
ctx.t.setLabel(ctx.i, {label: newData.label}); ctx.t.setLabel(ctx.i, {label: newData.label});
ctx.t.addIcon(ctx.i, {icon: newData.icon}); ctx.t.addIcon(ctx.i, {icon: newData.icon});
ctx.t.setId(ctx.i, {id: newData.id}); ctx.t.setId(ctx.i, {id: newData.id});
if (newData.inode) if (newData.inode)
ctx.t.setInode(ctx.i, {inode: true}); ctx.t.setInode(ctx.i, {inode: true});
// This will update the tree item data. // This will update the tree item data.
var itemData = ctx.t.itemData(ctx.i); var itemData = ctx.t.itemData(ctx.i);
_.extend(itemData, newData); _.extend(itemData, newData);
if ( if (
_n.can_expand && typeof(_n.can_expand) == 'function' _n.can_expand && typeof(_n.can_expand) == 'function'
) { ) {
if (!_n.can_expand(itemData)) { if (!_n.can_expand(itemData)) {
ctx.t.unload(ctx.i); ctx.t.unload(ctx.i);
return; return;
}
} }
} ctx.b._refreshNode(ctx, ctx.branch);
ctx.b._refreshNode(ctx, ctx.branch); var success = (ctx.o && ctx.o.success) || ctx.success;
var success = (ctx.o && ctx.o.success) || ctx.success; if (success && typeof(success) == 'function') {
if (success && typeof(success) == 'function') { success();
success(); }
} })
}) .fail(function(xhr, error, status) {
.fail(function(xhr, error, status) { if (
if ( !Alertify.pgHandleItemError(
!Alertify.pgHandleItemError( xhr, error, status, {item: _i, info: info}
xhr, error, status, {item: _i, info: info} )
) ) {
) { var contentType = xhr.getResponseHeader('Content-Type'),
var contentType = xhr.getResponseHeader('Content-Type'), jsonResp = (
jsonResp = ( contentType &&
contentType &&
contentType.indexOf('application/json') == 0 && contentType.indexOf('application/json') == 0 &&
JSON.parse(xhr.responseText) JSON.parse(xhr.responseText)
) || {}; ) || {};
if (xhr.status == 410 && jsonResp.success == 0) { if (xhr.status == 410 && jsonResp.success == 0) {
var p = ctx.t.parent(ctx.i); var p = ctx.t.parent(ctx.i);
ctx.t.remove(ctx.i, { ctx.t.remove(ctx.i, {
success: function() { success: function() {
if (p) { if (p) {
// Try to refresh the parent on error // Try to refresh the parent on error
try { try {
pgBrowser.Events.trigger( pgBrowser.Events.trigger(
'pgadmin:browser:tree:refresh', p 'pgadmin:browser:tree:refresh', p
); );
} catch (e) { console.warn(e.stack || e); } } catch (e) { console.warn(e.stack || e); }
} }
}, },
}); });
} }
Alertify.pgNotifier( Alertify.pgNotifier(
error, xhr, gettext('Error retrieving details for the node.'), error, xhr, gettext('Error retrieving details for the node.'),
function() { console.warn(arguments); } function() { console.warn(arguments); }
); );
} }
}); });
}.bind(this); }.bind(this);
if (n && n.collection_node) { if (n && n.collection_node) {
@ -1792,16 +1792,16 @@ define('pgadmin.browser', [
url: childNodeUrl, url: childNodeUrl,
dataType: 'json', dataType: 'json',
}) })
.done(function(res) { .done(function(res) {
if (res.success) { if (res.success) {
arrayChildNodeData.push(res.data); arrayChildNodeData.push(res.data);
} }
fetchNodeInfo(_callback); fetchNodeInfo(_callback);
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
fetchNodeInfo(_callback); fetchNodeInfo(_callback);
}); });
}; };
@ -1885,33 +1885,33 @@ define('pgadmin.browser', [
'Ctrl-Space': 'autocomplete', 'Ctrl-Space': 'autocomplete',
'Cmd-Space': 'autocomplete', 'Cmd-Space': 'autocomplete',
// Select All text // Select All text
'Ctrl-A': 'selectAll', 'Ctrl-A': 'selectAll',
'Cmd-A': 'selectAll', 'Cmd-A': 'selectAll',
// Redo text // Redo text
'Ctrl-Y': 'redo', 'Ctrl-Y': 'redo',
'Cmd-Y': 'redo', 'Cmd-Y': 'redo',
// Undo text // Undo text
'Ctrl-Z': 'undo', 'Ctrl-Z': 'undo',
'Cmd-Z': 'undo', 'Cmd-Z': 'undo',
// Delete Line // Delete Line
'Ctrl-D': 'deleteLine', 'Ctrl-D': 'deleteLine',
'Cmd-D': 'deleteLine', 'Cmd-D': 'deleteLine',
// Go to start/end of Line // Go to start/end of Line
'Alt-Left': 'goLineStart', 'Alt-Left': 'goLineStart',
'Alt-Right': 'goLineEnd', 'Alt-Right': 'goLineEnd',
// Move word by word left/right // Move word by word left/right
'Ctrl-Alt-Left': 'goGroupLeft', 'Ctrl-Alt-Left': 'goGroupLeft',
'Cmd-Alt-Left': 'goGroupLeft', 'Cmd-Alt-Left': 'goGroupLeft',
'Ctrl-Alt-Right': 'goGroupRight', 'Ctrl-Alt-Right': 'goGroupRight',
'Cmd-Alt-Right': 'goGroupRight', 'Cmd-Alt-Right': 'goGroupRight',
// Allow user to delete Tab(s) // Allow user to delete Tab(s)
'Shift-Tab': 'indentLess', 'Shift-Tab': 'indentLess',
}, },
editor_options: { editor_options: {
@ -1944,7 +1944,7 @@ define('pgadmin.browser', [
}, },
}); });
/* Remove paste event mapping from CodeMirror's emacsy KeyMap binding /* Remove paste event mapping from CodeMirror's emacsy KeyMap binding
* specific to Mac LineNumber:5797 - lib/Codemirror.js * specific to Mac LineNumber:5797 - lib/Codemirror.js
* It is preventing default paste event(Cmd-V) from triggering * It is preventing default paste event(Cmd-V) from triggering
* in runtime. * in runtime.

View File

@ -76,7 +76,7 @@ define([
j = panel.$container.find('.obj_properties').first(), j = panel.$container.find('.obj_properties').first(),
view = j.data('obj-view'), view = j.data('obj-view'),
content = $('<div></div>') content = $('<div></div>')
.addClass('pg-prop-content col-12 has-pg-prop-btn-group'), .addClass('pg-prop-content col-12 has-pg-prop-btn-group'),
node = pgBrowser.Nodes[that.node], node = pgBrowser.Nodes[that.node],
$msgContainer = '', $msgContainer = '',
// This will be the URL, used for object manipulation. // This will be the URL, used for object manipulation.
@ -136,9 +136,9 @@ define([
}))(); }))();
// Add the new column for the multi-select menus // Add the new column for the multi-select menus
if((_.isFunction(that.canDrop) ? if((_.isFunction(that.canDrop) ?
that.canDrop.apply(that, [data, item]) : that.canDrop) || that.canDrop.apply(that, [data, item]) : that.canDrop) ||
(_.isFunction(that.canDropCascade) ? (_.isFunction(that.canDropCascade) ?
that.canDropCascade.apply(that, [data, item]) : that.canDropCascade)) { that.canDropCascade.apply(that, [data, item]) : that.canDropCascade)) {
gridSchema.columns.unshift({ gridSchema.columns.unshift({
name: 'oid', name: 'oid',
cell: Backgrid.Extension.SelectRowCell.extend({ cell: Backgrid.Extension.SelectRowCell.extend({
@ -178,7 +178,7 @@ define([
headerCell: Backgrid.Extension.SelectAllHeaderCell, headerCell: Backgrid.Extension.SelectAllHeaderCell,
}); });
} }
// Initialize a new Grid instance // Initialize a new Grid instance
that.grid = new Backgrid.Grid({ that.grid = new Backgrid.Grid({
emptyText: 'No data found', emptyText: 'No data found',
columns: gridSchema.columns, columns: gridSchema.columns,
@ -224,10 +224,10 @@ define([
$msgContainer = $($msgContainer).appendTo(j); $msgContainer = $($msgContainer).appendTo(j);
that.header = $('<div></div>').addClass( that.header = $('<div></div>').addClass(
'pg-prop-header' 'pg-prop-header'
); );
// Render the buttons // Render the buttons
var buttons = []; var buttons = [];
buttons.push({ buttons.push({
@ -282,51 +282,51 @@ define([
}, 1000); }, 1000);
}, },
}) })
.done(function(res) { .done(function(res) {
clearTimeout(timer); clearTimeout(timer);
if (_.isUndefined(that.grid) || _.isNull(that.grid)) return; if (_.isUndefined(that.grid) || _.isNull(that.grid)) return;
that.data = res; that.data = res;
if (that.data.length > 0) { if (that.data.length > 0) {
if (!$msgContainer.hasClass('d-none')) { if (!$msgContainer.hasClass('d-none')) {
$msgContainer.addClass('d-none'); $msgContainer.addClass('d-none');
} }
that.header.appendTo(j); that.header.appendTo(j);
j.append(content); j.append(content);
// Listen scroll event to load more rows // Listen scroll event to load more rows
$('.pg-prop-content').on('scroll', that.__loadMoreRows.bind(that)); $('.pg-prop-content').on('scroll', that.__loadMoreRows.bind(that));
that.collection.reset(that.data.splice(0, 50)); that.collection.reset(that.data.splice(0, 50));
} else { } else {
// Do not listen the scroll event // Do not listen the scroll event
$('.pg-prop-content').off('scroll', that.__loadMoreRows); $('.pg-prop-content').off('scroll', that.__loadMoreRows);
$msgContainer.text(gettext('No properties are available for the selected object.')); $msgContainer.text(gettext('No properties are available for the selected object.'));
} }
}) })
.fail(function(xhr, error) { .fail(function(xhr, error) {
pgBrowser.Events.trigger( pgBrowser.Events.trigger(
'pgadmin:node:retrieval:error', 'properties', xhr, error.message, item, that 'pgadmin:node:retrieval:error', 'properties', xhr, error.message, item, that
); );
if (!Alertify.pgHandleItemError(xhr, error.message, { if (!Alertify.pgHandleItemError(xhr, error.message, {
item: item, item: item,
info: info, info: info,
})) { })) {
Alertify.pgNotifier( Alertify.pgNotifier(
error, xhr, error, xhr,
S(gettext('Error retrieving properties - %s')).sprintf( S(gettext('Error retrieving properties - %s')).sprintf(
error.message || that.label).value(), function() { error.message || that.label).value(), function() {
console.warn(arguments); console.warn(arguments);
}); });
} }
// show failed message. // show failed message.
$msgContainer.text(gettext('Failed to retrieve data from the server.')); $msgContainer.text(gettext('Failed to retrieve data from the server.'));
}); });
var onDrop = function(type) { var onDrop = function(type) {
let sel_row_models = this.grid.getSelectedModels(), let sel_row_models = this.grid.getSelectedModels(),
@ -366,45 +366,45 @@ define([
data: JSON.stringify({'ids': sel_rows}), data: JSON.stringify({'ids': sel_rows}),
contentType: 'application/json; charset=utf-8', contentType: 'application/json; charset=utf-8',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 0) { if (res.success == 0) {
pgBrowser.report_error(res.errormsg, res.info); pgBrowser.report_error(res.errormsg, res.info);
} else { } else {
$(pgBrowser.panels['properties'].panel).removeData('node-prop');
pgBrowser.Events.trigger(
'pgadmin:browser:tree:refresh', item || pgBrowser.tree.selected(), {
success: function() {
node.callbacks.selected.apply(node, [item]);
},
});
}
return true;
})
.fail(function(jqx) {
var msg = jqx.responseText;
/* Error from the server */
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
try {
var data = JSON.parse(jqx.responseText);
msg = data.errormsg;
} catch (e) {
console.warn(e.stack || e);
}
}
pgBrowser.report_error(
S(gettext('Error dropping %s'))
.sprintf(d._label.toLowerCase())
.value(), msg);
$(pgBrowser.panels['properties'].panel).removeData('node-prop'); $(pgBrowser.panels['properties'].panel).removeData('node-prop');
pgBrowser.Events.trigger( pgBrowser.Events.trigger(
'pgadmin:browser:tree:refresh', item || pgBrowser.tree.selected(), { 'pgadmin:browser:tree:refresh', item || pgBrowser.tree.selected(), {
success: function() { success: function() {
node.callbacks.selected.apply(node, [item]); node.callbacks.selected.apply(node, [item]);
}, },
}); }
} );
return true; });
})
.fail(function(jqx) {
var msg = jqx.responseText;
/* Error from the server */
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
try {
var data = JSON.parse(jqx.responseText);
msg = data.errormsg;
} catch (e) {
console.warn(e.stack || e);
}
}
pgBrowser.report_error(
S(gettext('Error dropping %s'))
.sprintf(d._label.toLowerCase())
.value(), msg);
$(pgBrowser.panels['properties'].panel).removeData('node-prop');
pgBrowser.Events.trigger(
'pgadmin:browser:tree:refresh', item || pgBrowser.tree.selected(), {
success: function() {
node.callbacks.selected.apply(node, [item]);
},
}
);
});
}, },
null).show(); null).show();
return; return;

View File

@ -36,7 +36,7 @@ define([
obj = new(pgBrowser.Node.Collection)(val, { obj = new(pgBrowser.Node.Collection)(val, {
model: ((_.isString(s.model) && model: ((_.isString(s.model) &&
s.model in pgBrowser.Nodes) ? s.model in pgBrowser.Nodes) ?
pgBrowser.Nodes[s.model].model : s.model), pgBrowser.Nodes[s.model].model : s.model),
top: self.top || self, top: self.top || self,
handler: self, handler: self,
parse: true, parse: true,
@ -44,7 +44,7 @@ define([
attrName: s.id, attrName: s.id,
}); });
/* /*
* Nested collection models may or may not have idAttribute. * Nested collection models may or may not have idAttribute.
* So to decide whether model is new or not set 'on_server' * So to decide whether model is new or not set 'on_server'
* flag on such models. * flag on such models.
@ -56,7 +56,7 @@ define([
on_server: true, on_server: true,
}); });
} else { } else {
/* /*
* Nested collection models may or may not have idAttribute. * Nested collection models may or may not have idAttribute.
* So to decide whether model is new or not set 'on_server' * So to decide whether model is new or not set 'on_server'
* flag on such models. * flag on such models.
@ -83,13 +83,13 @@ define([
if (_.isString(s.model) && if (_.isString(s.model) &&
s.model in pgBrowser.Nodes[s.model]) { s.model in pgBrowser.Nodes[s.model]) {
obj = new(pgBrowser.Nodes[s.model].Model)( obj = new(pgBrowser.Nodes[s.model].Model)(
obj, { obj, {
silent: true, silent: true,
top: self.top || self, top: self.top || self,
handler: self, handler: self,
attrName: s.id, attrName: s.id,
} }
); );
} else { } else {
obj = new(s.model)(obj, { obj = new(s.model)(obj, {
silent: true, silent: true,
@ -163,7 +163,7 @@ define([
self.objects = []; self.objects = [];
self.arrays = []; self.arrays = [];
self.attrName = options.attrName, self.attrName = options.attrName,
self.top = (options.top || self.collection && self.collection.top || self.collection || self); self.top = (options.top || self.collection && self.collection.top || self.collection || self);
self.handler = options.handler || self.handler = options.handler ||
(self.collection && self.collection.handler); (self.collection && self.collection.handler);
self.trackChanges = false; self.trackChanges = false;
@ -234,19 +234,19 @@ define([
if (_.isString(s.model) && if (_.isString(s.model) &&
s.model in pgBrowser.Nodes[s.model]) { s.model in pgBrowser.Nodes[s.model]) {
obj = new(pgBrowser.Nodes[s.model].Model)( obj = new(pgBrowser.Nodes[s.model].Model)(
obj, { obj, {
top: self.top || self, top: self.top || self,
handler: self, handler: self,
attrName: s.id, attrName: s.id,
} }
); );
} else { } else {
obj = new(s.model)( obj = new(s.model)(
obj, { obj, {
top: self.top || self, top: self.top || self,
handler: self, handler: self,
attrName: s.id, attrName: s.id,
}); });
} }
} }
@ -549,26 +549,26 @@ define([
typeof(obj.primary_key) === 'function'; typeof(obj.primary_key) === 'function';
var key = hasPrimaryKey ? obj.primary_key() : obj.cid, var key = hasPrimaryKey ? obj.primary_key() : obj.cid,
comparator = hasPrimaryKey ? comparator = hasPrimaryKey ?
function(k) { function(k) {
var o = self.get('k'); var o = self.get('k');
if (o && o.primary_key() === key) { if (o && o.primary_key() === key) {
objName = k; objName = k;
return true; return true;
} }
return false; return false;
} : } :
function(k) { function(k) {
var o = self.get(k); var o = self.get(k);
if (o.cid === key) { if (o.cid === key) {
objName = k; objName = k;
return true; return true;
} }
return false; return false;
}; };
_.findIndex(self.objects, comparator); _.findIndex(self.objects, comparator);
} }
@ -599,26 +599,26 @@ define([
(typeof(obj.primary_key) === 'function')); (typeof(obj.primary_key) === 'function'));
var key = hasPrimaryKey ? obj.primary_key() : obj.cid, var key = hasPrimaryKey ? obj.primary_key() : obj.cid,
comparator = hasPrimaryKey ? comparator = hasPrimaryKey ?
function(k) { function(k) {
var o = self.get('k'); var o = self.get('k');
if (o && o.primary_key() === key) { if (o && o.primary_key() === key) {
objName = k; objName = k;
return true; return true;
} }
return false; return false;
} : } :
function(k) { function(k) {
var o = self.get('k'); var o = self.get('k');
if (o && o.cid === key) { if (o && o.cid === key) {
objName = k; objName = k;
return true; return true;
} }
return false; return false;
}; };
_.findIndex(self.objects, comparator); _.findIndex(self.objects, comparator);
} }

View File

@ -8,16 +8,16 @@
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
define( define(
['sources/gettext', 'underscore', 'alertify', 'sources/pgadmin'], ['sources/gettext', 'underscore', 'alertify', 'sources/pgadmin'],
function(gettext, _, alertify, pgAdmin) { function(gettext, _, alertify, pgAdmin) {
pgAdmin.Browser = pgAdmin.Browser || {}; pgAdmin.Browser = pgAdmin.Browser || {};
_.extend(pgAdmin.Browser, { _.extend(pgAdmin.Browser, {
report_error: function(title, message, info) { report_error: function(title, message, info) {
title = _.escape(title); title = _.escape(title);
message = _.escape(message); message = _.escape(message);
info = _.escape(info); info = _.escape(info);
let text = '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">\ let text = '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">\
<div class="panel panel-default">\ <div class="panel panel-default">\
<div class="panel-heading" role="tab" id="headingOne">\ <div class="panel-heading" role="tab" id="headingOne">\
<h4 class="panel-title">\ <h4 class="panel-title">\
@ -30,8 +30,8 @@ function(gettext, _, alertify, pgAdmin) {
</div>\ </div>\
</div>'; </div>';
if (info != null && info != '') { if (info != null && info != '') {
text += '<div class="panel panel-default">\ text += '<div class="panel panel-default">\
<div class="panel-heading" role="tab" id="headingTwo">\ <div class="panel-heading" role="tab" id="headingTwo">\
<h4 class="panel-title">\ <h4 class="panel-title">\
<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">\ <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">\
@ -43,15 +43,15 @@ function(gettext, _, alertify, pgAdmin) {
</div>\ </div>\
</div>\ </div>\
</div>'; </div>';
} }
text += '</div>'; text += '</div>';
alertify.alert( alertify.alert(
title, title,
text text
).set('closable', true); ).set('closable', true);
}, },
});
return pgAdmin.Browser.report_error;
}); });
return pgAdmin.Browser.report_error;
});

View File

@ -113,8 +113,8 @@ define([
cb; cb;
if (o.module['callbacks'] && ( if (o.module['callbacks'] && (
o.callback in o.module['callbacks'] o.callback in o.module['callbacks']
)) { )) {
cb = o.module['callbacks'][o.callback]; cb = o.module['callbacks'][o.callback];
} else if (o.callback in o.module) { } else if (o.callback in o.module) {
cb = o.module[o.callback]; cb = o.module[o.callback];
@ -141,8 +141,8 @@ define([
return true; return true;
} }
if (_.isArray(this.node) ? ( if (_.isArray(this.node) ? (
_.indexOf(this.node, node) == -1 _.indexOf(this.node, node) == -1
) : (this.node != node._type)) { ) : (this.node != node._type)) {
return true; return true;
} }
} }

View File

@ -423,11 +423,11 @@ define('pgadmin.browser.node', [
xhr, error, message, item xhr, error, message, item
); );
if (!Alertify.pgHandleItemError( if (!Alertify.pgHandleItemError(
xhr, error, message, { xhr, error, message, {
item: item, item: item,
info: info, info: info,
} }
)) { )) {
Alertify.pgNotifier( Alertify.pgNotifier(
error, xhr, error, xhr,
S( S(
@ -738,10 +738,10 @@ define('pgadmin.browser.node', [
title = S(gettext('DROP CASCADE %s?')).sprintf(obj.label).value(); title = S(gettext('DROP CASCADE %s?')).sprintf(obj.label).value();
if (!(_.isFunction(obj.canDropCascade) ? if (!(_.isFunction(obj.canDropCascade) ?
obj.canDropCascade.apply(obj, [d, i]) : obj.canDropCascade)) { obj.canDropCascade.apply(obj, [d, i]) : obj.canDropCascade)) {
Alertify.error( Alertify.error(
S(gettext('The %s "%s" cannot be dropped.')) S(gettext('The %s "%s" cannot be dropped.'))
.sprintf(obj.label, d.label).value(), .sprintf(obj.label, d.label).value(),
10 10
); );
return; return;
@ -752,10 +752,10 @@ define('pgadmin.browser.node', [
title = S(gettext('DROP %s?')).sprintf(obj.label).value(); title = S(gettext('DROP %s?')).sprintf(obj.label).value();
if (!(_.isFunction(obj.canDrop) ? if (!(_.isFunction(obj.canDrop) ?
obj.canDrop.apply(obj, [d, i]) : obj.canDrop)) { obj.canDrop.apply(obj, [d, i]) : obj.canDrop)) {
Alertify.error( Alertify.error(
S(gettext('The %s "%s" cannot be dropped.')) S(gettext('The %s "%s" cannot be dropped.'))
.sprintf(obj.label, d.label).value(), .sprintf(obj.label, d.label).value(),
10 10
); );
return; return;
@ -767,30 +767,30 @@ define('pgadmin.browser.node', [
url: obj.generate_url(i, input.url, d, true), url: obj.generate_url(i, input.url, d, true),
type: 'DELETE', type: 'DELETE',
}) })
.done(function(res) { .done(function(res) {
if (res.success == 0) { if (res.success == 0) {
pgBrowser.report_error(res.errormsg, res.info); pgBrowser.report_error(res.errormsg, res.info);
} else { } else {
pgBrowser.removeTreeNode(i, true); pgBrowser.removeTreeNode(i, true);
}
return true;
})
.fail(function(jqx) {
var msg = jqx.responseText;
/* Error from the server */
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
try {
var data = JSON.parse(jqx.responseText);
msg = data.errormsg;
} catch (e) {
console.warn(e.stack || e);
} }
} return true;
pgBrowser.report_error( })
S(gettext('Error dropping %s: "%s"')) .fail(function(jqx) {
.sprintf(obj.label, objName) var msg = jqx.responseText;
.value(), msg); /* Error from the server */
}); if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
try {
var data = JSON.parse(jqx.responseText);
msg = data.errormsg;
} catch (e) {
console.warn(e.stack || e);
}
}
pgBrowser.report_error(
S(gettext('Error dropping %s: "%s"'))
.sprintf(obj.label, objName)
.value(), msg);
});
}, },
null).show(); null).show();
}, },
@ -913,7 +913,7 @@ define('pgadmin.browser.node', [
} }
pgBrowser.Events.trigger('pgadmin:browser:tree:expand-from-previous-tree-state', pgBrowser.Events.trigger('pgadmin:browser:tree:expand-from-previous-tree-state',
item); item);
pgBrowser.Node.callbacks.change_server_background(item, data); pgBrowser.Node.callbacks.change_server_background(item, data);
}, },
// Callback called - when a node is selected in browser tree. // Callback called - when a node is selected in browser tree.
@ -944,7 +944,7 @@ define('pgadmin.browser.node', [
} }
pgBrowser.Events.trigger('pgadmin:browser:tree:update-tree-state', pgBrowser.Events.trigger('pgadmin:browser:tree:update-tree-state',
item); item);
return true; return true;
}, },
removed: function(item) { removed: function(item) {
@ -1003,7 +1003,7 @@ define('pgadmin.browser.node', [
auto_expand = pgBrowser.get_preference('browser', 'auto_expand_sole_children'); auto_expand = pgBrowser.get_preference('browser', 'auto_expand_sole_children');
pgBrowser.Events.trigger('pgadmin:browser:tree:update-tree-state', pgBrowser.Events.trigger('pgadmin:browser:tree:update-tree-state',
item); item);
if (auto_expand && auto_expand.value == true && tree.children(item).length == 1) { if (auto_expand && auto_expand.value == true && tree.children(item).length == 1) {
// Automatically expand the child node, if a treeview node has only a single child. // Automatically expand the child node, if a treeview node has only a single child.
@ -1013,7 +1013,7 @@ define('pgadmin.browser.node', [
}, },
closed: function(item) { closed: function(item) {
pgBrowser.Events.trigger('pgadmin:browser:tree:remove-from-tree-state', pgBrowser.Events.trigger('pgadmin:browser:tree:remove-from-tree-state',
item); item);
}, },
}, },
/********************************************************************** /**********************************************************************
@ -1029,7 +1029,7 @@ define('pgadmin.browser.node', [
j = panel.$container.find('.obj_properties').first(), j = panel.$container.find('.obj_properties').first(),
view = j.data('obj-view'), view = j.data('obj-view'),
content = $('<div tabindex="1"></div>') content = $('<div tabindex="1"></div>')
.addClass('pg-prop-content col-12'); .addClass('pg-prop-content col-12');
// Handle key press events for Cancel, save and help button // Handle key press events for Cancel, save and help button
var handleKeyDown = function(event, context) { var handleKeyDown = function(event, context) {
@ -1041,12 +1041,12 @@ define('pgadmin.browser.node', [
closePanel(); closePanel();
break; break;
case keyCode.ENTER: case keyCode.ENTER:
// Return if event is fired from child element // Return if event is fired from child element
if (event.target !== context) return; if (event.target !== context) return;
if (view && view.model && view.model.sessChanged()) { if (view && view.model && view.model.sessChanged()) {
var btn = $(event.target).closest('.obj_properties') var btn = $(event.target).closest('.obj_properties')
.find('.pg-prop-btn-group') .find('.pg-prop-btn-group')
.find('button.btn-primary'); .find('button.btn-primary');
onSave.call(this, view, btn); onSave.call(this, view, btn);
} }
break; break;
@ -1364,8 +1364,8 @@ define('pgadmin.browser.node', [
panel.icon( panel.icon(
_.isFunction(that['node_image']) ? _.isFunction(that['node_image']) ?
(that['node_image']).apply(that, [data, view.model]) : (that['node_image']).apply(that, [data, view.model]) :
(that['node_image'] || ('icon-' + that.type)) (that['node_image'] || ('icon-' + that.type))
); );
// Create proper buttons // Create proper buttons

View File

@ -165,16 +165,16 @@ define([
async: false, async: false,
url: full_url, url: full_url,
}) })
.done(function(res) { .done(function(res) {
/* /*
* We will cache this data for short period of time for avoiding * We will cache this data for short period of time for avoiding
* same calls. * same calls.
*/ */
data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data); data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
}) })
.fail(function() { .fail(function() {
m.trigger('pgadmin:view:fetch:error', m, self.field); m.trigger('pgadmin:view:fetch:error', m, self.field);
}); });
m.trigger('pgadmin:view:fetched', m, self.field); m.trigger('pgadmin:view:fetched', m, self.field);
} }
// To fetch only options from cache, we do not need time from 'at' // To fetch only options from cache, we do not need time from 'at'
@ -406,16 +406,16 @@ define([
async: false, async: false,
url: full_url, url: full_url,
}) })
.done(function(res) { .done(function(res) {
/* /*
* We will cache this data for short period of time for avoiding * We will cache this data for short period of time for avoiding
* same calls. * same calls.
*/ */
data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data); data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
}) })
.fail(function() { .fail(function() {
eventHandler.trigger('pgadmin:view:fetch:error', m, column); eventHandler.trigger('pgadmin:view:fetch:error', m, column);
}); });
eventHandler.trigger('pgadmin:view:fetched', m, column); eventHandler.trigger('pgadmin:view:fetched', m, column);
} }
// To fetch only options from cache, we do not need time from 'at' // To fetch only options from cache, we do not need time from 'at'

View File

@ -9,10 +9,10 @@
import pgAdmin from 'sources/pgadmin'; import pgAdmin from 'sources/pgadmin';
import url_for from 'sources/url_for'; import url_for from 'sources/url_for';
import * as modifyAnimation from 'sources/modify_animation';
import $ from 'jquery'; import $ from 'jquery';
import * as Alertify from 'pgadmin.alertifyjs'; import * as Alertify from 'pgadmin.alertifyjs';
import * as SqlEditorUtils from 'sources/sqleditor_utils'; import * as SqlEditorUtils from 'sources/sqleditor_utils';
var modifyAnimation = require('sources/modify_animation');
const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {}; const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
@ -51,8 +51,8 @@ _.extend(pgBrowser, {
if(self.preferences_cache.length > 0) { if(self.preferences_cache.length > 0) {
clearInterval(preferenceTimeout); clearInterval(preferenceTimeout);
return _.findWhere( return _.findWhere(
self.preferences_cache, {'module': module, 'name': preference} self.preferences_cache, {'module': module, 'name': preference}
); );
} }
}, },
preferenceTimeout = setInterval(check_preference, 1000); preferenceTimeout = setInterval(check_preference, 1000);
@ -93,35 +93,35 @@ _.extend(pgBrowser, {
$.ajax({ $.ajax({
url: url_for('preferences.get_all'), url: url_for('preferences.get_all'),
}) })
.done(function(res) { .done(function(res) {
self.preferences_cache = res; self.preferences_cache = res;
self.preference_version(self.generate_preference_version()); self.preference_version(self.generate_preference_version());
pgBrowser.keyboardNavigation.init(); pgBrowser.keyboardNavigation.init();
if(pgBrowser.tree) { if(pgBrowser.tree) {
modifyAnimation.modifyAcitreeAnimation(self); modifyAnimation.modifyAcitreeAnimation(self);
modifyAnimation.modifyAlertifyAnimation(self); modifyAnimation.modifyAlertifyAnimation(self);
} }
// Initialize Tree saving/reloading // Initialize Tree saving/reloading
pgBrowser.browserTreeState.init(); pgBrowser.browserTreeState.init();
/* Once the cache is loaded after changing the preferences, /* Once the cache is loaded after changing the preferences,
* notify the modules of the change * notify the modules of the change
*/ */
if(modulesChanged) { if(modulesChanged) {
if(typeof modulesChanged === 'string'){ if(typeof modulesChanged === 'string'){
$.event.trigger('prefchange:'+modulesChanged); $.event.trigger('prefchange:'+modulesChanged);
} else { } else {
_.each(modulesChanged, (val, key)=> { _.each(modulesChanged, (val, key)=> {
$.event.trigger('prefchange:'+key); $.event.trigger('prefchange:'+key);
}); });
}
} }
} })
}) .fail(function(xhr, status, error) {
.fail(function(xhr, status, error) { Alertify.pgRespErrorNotify(xhr, error);
Alertify.pgRespErrorNotify(xhr, error); });
});
}, 500); }, 500);
}, },

View File

@ -95,17 +95,17 @@ define('pgadmin.dashboard', [
url: action_url, url: action_url,
type: 'DELETE', type: 'DELETE',
}) })
.done(function(res) { .done(function(res) {
if (res == gettext('Success')) { if (res == gettext('Success')) {
Alertify.success(txtSuccess); Alertify.success(txtSuccess);
refresh_grid(); refresh_grid();
} else { } else {
Alertify.error(txtError); Alertify.error(txtError);
} }
}) })
.fail(function(xhr, status, error) { .fail(function(xhr, status, error) {
Alertify.pgRespErrorNotify(xhr, error); Alertify.pgRespErrorNotify(xhr, error);
}); });
}, },
function() { function() {
return true; return true;
@ -228,14 +228,14 @@ define('pgadmin.dashboard', [
type: 'GET', type: 'GET',
dataType: 'html', dataType: 'html',
}) })
.done(function(data) { .done(function(data) {
$(div).html(data); $(div).html(data);
}) })
.fail(function() { .fail(function() {
$(div).html( $(div).html(
'<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>' '<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>'
); );
}); });
// Cache the current IDs for next time // Cache the current IDs for next time
$(dashboardPanel).data('sid', -1); $(dashboardPanel).data('sid', -1);
@ -342,15 +342,15 @@ define('pgadmin.dashboard', [
type: 'GET', type: 'GET',
dataType: 'html', dataType: 'html',
}) })
.done(function(data) { .done(function(data) {
$(div).html(data); $(div).html(data);
self.init_dashboard(); self.init_dashboard();
}) })
.fail(function() { .fail(function() {
$(div).html( $(div).html(
'<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>' '<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>'
); );
}); });
$(dashboardPanel).data('server_status', true); $(dashboardPanel).data('server_status', true);
} }
} else { } else {
@ -536,45 +536,45 @@ define('pgadmin.dashboard', [
url: path, url: path,
type: 'GET', type: 'GET',
}) })
.done(function(resp) { .done(function(resp) {
last_poll_wait_counter = 0; last_poll_wait_counter = 0;
for(let chart_name in resp) { for(let chart_name in resp) {
let chart_obj = chart_store[chart_name].chart_obj; let chart_obj = chart_store[chart_name].chart_obj;
$(chart_obj.getContainer()).removeClass('graph-error'); $(chart_obj.getContainer()).removeClass('graph-error');
self.updateChart(chart_obj, resp[chart_name]); self.updateChart(chart_obj, resp[chart_name]);
}
})
.fail(function(xhr) {
last_poll_wait_counter = 0;
let err = '';
let msg = '';
let cls = 'info';
if (xhr.readyState === 0) {
msg = gettext('Not connected to the server or the connection to the server has been closed.');
} else {
err = JSON.parse(xhr.responseText);
msg = err.errormsg;
// If we get a 428, it means the server isn't connected
if (xhr.status === 428) {
if (_.isUndefined(msg) || _.isNull(msg)) {
msg = gettext('Please connect to the selected server to view the graph.');
}
} else {
msg = gettext('An error occurred whilst rendering the graph.');
cls = 'danger';
} }
} })
.fail(function(xhr) {
last_poll_wait_counter = 0;
let err = '';
let msg = '';
let cls = 'info';
for(let chart_name in chart_store) { if (xhr.readyState === 0) {
let chart_obj = chart_store[chart_name].chart_obj; msg = gettext('Not connected to the server or the connection to the server has been closed.');
$(chart_obj.getContainer()).addClass('graph-error'); } else {
$(chart_obj.getContainer()).html( err = JSON.parse(xhr.responseText);
'<div class="alert alert-' + cls + ' pg-panel-message" role="alert">' + msg + '</div>' msg = err.errormsg;
);
} // If we get a 428, it means the server isn't connected
}); if (xhr.status === 428) {
if (_.isUndefined(msg) || _.isNull(msg)) {
msg = gettext('Please connect to the selected server to view the graph.');
}
} else {
msg = gettext('An error occurred whilst rendering the graph.');
cls = 'danger';
}
}
for(let chart_name in chart_store) {
let chart_obj = chart_store[chart_name].chart_obj;
$(chart_obj.getContainer()).addClass('graph-error');
$(chart_obj.getContainer()).html(
'<div class="alert alert-' + cls + ' pg-panel-message" role="alert">' + msg + '</div>'
);
}
});
last_poll_wait_counter = WAIT_COUNTER; last_poll_wait_counter = WAIT_COUNTER;
}; };
/* Execute once for the first time as setInterval will not do */ /* Execute once for the first time as setInterval will not do */
@ -586,8 +586,8 @@ define('pgadmin.dashboard', [
add_new_server: function() { add_new_server: function() {
if (pgBrowser && pgBrowser.tree) { if (pgBrowser && pgBrowser.tree) {
var i = pgBrowser.tree.selected().length != 0 ? var i = pgBrowser.tree.selected().length != 0 ?
pgBrowser.tree.selected() : pgBrowser.tree.selected() :
pgBrowser.tree.first(null, false), pgBrowser.tree.first(null, false),
serverModule = require('pgadmin.node.server'), serverModule = require('pgadmin.node.server'),
itemData = pgBrowser.tree.itemData(i); itemData = pgBrowser.tree.itemData(i);

View File

@ -112,12 +112,12 @@ define('misc.bgprocess', [
case 'status': case 'status':
if (this.details && this.out != -1 && this.err != -1) { if (this.details && this.out != -1 && this.err != -1) {
return url_for( return url_for(
'bgprocess.detailed_status', { 'bgprocess.detailed_status', {
'pid': this.id, 'pid': this.id,
'out': this.out, 'out': this.out,
'err': this.err, 'err': this.err,
} }
); );
} }
return url_for('bgprocess.status', { return url_for('bgprocess.status', {
'pid': this.id, 'pid': this.id,
@ -270,18 +270,18 @@ define('misc.bgprocess', [
async: true, async: true,
contentType: 'application/json', contentType: 'application/json',
}) })
.done(function(res) { .done(function(res) {
setTimeout(function() {
self.update(res);
}, 10);
})
.fail(function(res) {
// Try after some time only if job id present
if (res.status != 410)
setTimeout(function() { setTimeout(function() {
self.update(res); self.update(res);
}, 10000); }, 10);
}); })
.fail(function(res) {
// Try after some time only if job id present
if (res.status != 410)
setTimeout(function() {
self.update(res);
}, 10000);
});
}, },
show: function() { show: function() {
@ -477,12 +477,12 @@ define('misc.bgprocess', [
async: true, async: true,
contentType: 'application/json', contentType: 'application/json',
}) })
.done(function() { .done(function() {
return; return;
}) })
.fail(function() { .fail(function() {
console.warn(arguments); console.warn(arguments);
}); });
}, },
stop_process: function() { stop_process: function() {
@ -497,12 +497,12 @@ define('misc.bgprocess', [
async: true, async: true,
contentType: 'application/json', contentType: 'application/json',
}) })
.done(function() { .done(function() {
return; return;
}) })
.fail(function() { .fail(function() {
console.warn(arguments); console.warn(arguments);
}); });
}, },
}); });
@ -547,31 +547,31 @@ define('misc.bgprocess', [
async: true, async: true,
contentType: 'application/json', contentType: 'application/json',
}) })
.done(function(res) { .done(function(res) {
if (!res || !_.isArray(res)) { if (!res || !_.isArray(res)) {
return; return;
} }
for (var idx in res) { for (var idx in res) {
var process = res[idx]; var process = res[idx];
if ('id' in process) { if ('id' in process) {
if (!(process.id in observer.bgprocesses)) { if (!(process.id in observer.bgprocesses)) {
observer.bgprocesses[process.id] = new BGProcess(process); observer.bgprocesses[process.id] = new BGProcess(process);
}
} }
} }
} if (recheck && res.length == 0) {
if (recheck && res.length == 0) {
// Recheck after some more time // Recheck after some more time
setTimeout( setTimeout(
function() { function() {
observer.update_process_list(false); observer.update_process_list(false);
}, 3000 }, 3000
); );
} }
}) })
.fail(function() { .fail(function() {
// FIXME:: What to do now? // FIXME:: What to do now?
console.warn(arguments); console.warn(arguments);
}); });
}, },
create_panel: function() { create_panel: function() {

View File

@ -47,8 +47,8 @@ define('misc.dependencies', [
parse: function(res) { parse: function(res) {
var node = pgBrowser.Nodes[res.type]; var node = pgBrowser.Nodes[res.type];
res.icon = node ? (_.isFunction(node['node_image']) ? res.icon = node ? (_.isFunction(node['node_image']) ?
(node['node_image']).apply(node, [null, null]) : (node['node_image']).apply(node, [null, null]) :
(node['node_image'] || ('icon-' + res.type))) : (node['node_image'] || ('icon-' + res.type))) :
('icon-' + res.type); ('icon-' + res.type);
res.type = S.titleize(res.type.replace(/_/g, ' '), true); res.type = S.titleize(res.type.replace(/_/g, ' '), true);
return res; return res;
@ -76,7 +76,7 @@ define('misc.dependencies', [
columns: [{ columns: [{
name: 'type', name: 'type',
label: gettext('Type'), label: gettext('Type'),
// Extend it to render the icon as per the type. // Extend it to render the icon as per the type.
cell: Backgrid.Cell.extend({ cell: Backgrid.Cell.extend({
render: function() { render: function() {
Backgrid.Cell.prototype.render.apply(this, arguments); Backgrid.Cell.prototype.render.apply(this, arguments);
@ -162,65 +162,65 @@ define('misc.dependencies', [
}, 1000); }, 1000);
}, },
}) })
.done(function(res) { .done(function(res) {
clearTimeout(timer); clearTimeout(timer);
if (res.length > 0) { if (res.length > 0) {
if (!$msgContainer.hasClass('d-none')) { if (!$msgContainer.hasClass('d-none')) {
$msgContainer.addClass('d-none'); $msgContainer.addClass('d-none');
} }
$gridContainer.removeClass('d-none'); $gridContainer.removeClass('d-none');
self.dependenciesData = res; self.dependenciesData = res;
// Load only 100 rows // Load only 100 rows
self.dependenciesCollection.reset(self.dependenciesData.splice(0, 100), {parse: true}); self.dependenciesCollection.reset(self.dependenciesData.splice(0, 100), {parse: true});
// Load more rows on scroll down // Load more rows on scroll down
pgBrowser.Events.on( pgBrowser.Events.on(
'pgadmin-browser:panel-dependencies:' + 'pgadmin-browser:panel-dependencies:' +
wcDocker.EVENT.SCROLLED, wcDocker.EVENT.SCROLLED,
self.__loadMoreRows self.__loadMoreRows
); );
} else { } else {
// Do not listen the scroll event // Do not listen the scroll event
pgBrowser.Events.off( pgBrowser.Events.off(
'pgadmin-browser:panel-dependencies:' + 'pgadmin-browser:panel-dependencies:' +
wcDocker.EVENT.SCROLLED wcDocker.EVENT.SCROLLED
); );
self.dependenciesCollection.reset({silent: true}); self.dependenciesCollection.reset({silent: true});
$msgContainer.text(msg); $msgContainer.text(msg);
$msgContainer.removeClass('d-none'); $msgContainer.removeClass('d-none');
if (!$gridContainer.hasClass('d-none')) { if (!$gridContainer.hasClass('d-none')) {
$gridContainer.addClass('d-none'); $gridContainer.addClass('d-none');
}
} }
}
}) })
.fail(function(xhr, error, message) { .fail(function(xhr, error, message) {
var _label = treeHierarchy[n_type].label; var _label = treeHierarchy[n_type].label;
pgBrowser.Events.trigger( pgBrowser.Events.trigger(
'pgadmin:node:retrieval:error', 'depends', xhr, error, message 'pgadmin:node:retrieval:error', 'depends', xhr, error, message
); );
if (!Alertify.pgHandleItemError(xhr, error, message, { if (!Alertify.pgHandleItemError(xhr, error, message, {
item: item, item: item,
info: treeHierarchy, info: treeHierarchy,
})) { })) {
Alertify.pgNotifier( Alertify.pgNotifier(
error, xhr, error, xhr,
S(gettext('Error retrieving data from the server: %s')).sprintf( S(gettext('Error retrieving data from the server: %s')).sprintf(
message || _label).value(), function() { message || _label).value(), function() {
console.warn(arguments); console.warn(arguments);
}); });
} }
// show failed message. // show failed message.
$msgContainer.text(gettext('Failed to retrieve data from the server.')); $msgContainer.text(gettext('Failed to retrieve data from the server.'));
}); });
} }
} if (msg != '') { } if (msg != '') {
$msgContainer.text(msg); $msgContainer.text(msg);

View File

@ -47,8 +47,8 @@ define('misc.dependents', [
parse: function(res) { parse: function(res) {
var node = pgBrowser.Nodes[res.type]; var node = pgBrowser.Nodes[res.type];
res.icon = node ? (_.isFunction(node['node_image']) ? res.icon = node ? (_.isFunction(node['node_image']) ?
(node['node_image']).apply(node, [null, null]) : (node['node_image']).apply(node, [null, null]) :
(node['node_image'] || ('icon-' + res.type))) : (node['node_image'] || ('icon-' + res.type))) :
('icon-' + res.type); ('icon-' + res.type);
res.type = S.titleize(res.type.replace(/_/g, ' '), true); res.type = S.titleize(res.type.replace(/_/g, ' '), true);
return res; return res;
@ -77,7 +77,7 @@ define('misc.dependents', [
columns: [{ columns: [{
name: 'type', name: 'type',
label: gettext('Type'), label: gettext('Type'),
// Extend it to render the icon as per the type. // Extend it to render the icon as per the type.
cell: Backgrid.Cell.extend({ cell: Backgrid.Cell.extend({
render: function() { render: function() {
Backgrid.Cell.prototype.render.apply(this, arguments); Backgrid.Cell.prototype.render.apply(this, arguments);
@ -168,65 +168,65 @@ define('misc.dependents', [
}, 1000); }, 1000);
}, },
}) })
.done(function(res) { .done(function(res) {
clearTimeout(timer); clearTimeout(timer);
if (res.length > 0) { if (res.length > 0) {
if (!$msgContainer.hasClass('d-none')) { if (!$msgContainer.hasClass('d-none')) {
$msgContainer.addClass('d-none'); $msgContainer.addClass('d-none');
} }
$gridContainer.removeClass('d-none'); $gridContainer.removeClass('d-none');
self.dependentData = res; self.dependentData = res;
// Load only 100 rows // Load only 100 rows
self.dependentCollection.reset(self.dependentData.splice(0, 100), {parse: true}); self.dependentCollection.reset(self.dependentData.splice(0, 100), {parse: true});
// Load more rows on scroll down // Load more rows on scroll down
pgBrowser.Events.on( pgBrowser.Events.on(
'pgadmin-browser:panel-dependents:' + 'pgadmin-browser:panel-dependents:' +
wcDocker.EVENT.SCROLLED, wcDocker.EVENT.SCROLLED,
self.__loadMoreRows self.__loadMoreRows
); );
} else { } else {
// Do not listen the scroll event // Do not listen the scroll event
pgBrowser.Events.off( pgBrowser.Events.off(
'pgadmin-browser:panel-dependents:' + 'pgadmin-browser:panel-dependents:' +
wcDocker.EVENT.SCROLLED wcDocker.EVENT.SCROLLED
); );
self.dependentCollection.reset({silent: true}); self.dependentCollection.reset({silent: true});
$msgContainer.text(msg); $msgContainer.text(msg);
$msgContainer.removeClass('d-none'); $msgContainer.removeClass('d-none');
if (!$gridContainer.hasClass('d-none')) { if (!$gridContainer.hasClass('d-none')) {
$gridContainer.addClass('d-none'); $gridContainer.addClass('d-none');
}
} }
}
}) })
.fail(function(xhr, error, message) { .fail(function(xhr, error, message) {
var _label = treeHierarchy[n_type].label; var _label = treeHierarchy[n_type].label;
pgBrowser.Events.trigger( pgBrowser.Events.trigger(
'pgadmin:node:retrieval:error', 'depends', xhr, error, message 'pgadmin:node:retrieval:error', 'depends', xhr, error, message
); );
if (!Alertify.pgHandleItemError(xhr, error, message, { if (!Alertify.pgHandleItemError(xhr, error, message, {
item: item, item: item,
info: treeHierarchy, info: treeHierarchy,
})) { })) {
Alertify.pgNotifier( Alertify.pgNotifier(
error, xhr, error, xhr,
S(gettext('Error retrieving data from the server: %s')).sprintf( S(gettext('Error retrieving data from the server: %s')).sprintf(
message || _label).value(), function() { message || _label).value(), function() {
console.warn(arguments); console.warn(arguments);
}); });
} }
// show failed message. // show failed message.
$msgContainer.text(gettext('Failed to retrieve data from the server.')); $msgContainer.text(gettext('Failed to retrieve data from the server.'));
}); });
} }
} if (msg != '') { } if (msg != '') {
$msgContainer.text(msg); $msgContainer.text(msg);

View File

@ -98,14 +98,14 @@ module.exports = Alertify.dialog('createModeDlg', function() {
contentType: 'application/x-download; charset=utf-8', contentType: 'application/x-download; charset=utf-8',
async: false, async: false,
}) })
.done(function(resp) { .done(function(resp) {
var data = resp.data.result; var data = resp.data.result;
if (data['Code'] === 1) { if (data['Code'] === 1) {
is_exist = true; is_exist = true;
} else { } else {
is_exist = false; is_exist = false;
} }
}); });
return is_exist; return is_exist;
}, },
check_permission: function(path) { check_permission: function(path) {
@ -125,19 +125,19 @@ module.exports = Alertify.dialog('createModeDlg', function() {
contentType: 'application/json; charset=utf-8', contentType: 'application/json; charset=utf-8',
async: false, async: false,
}) })
.done(function(resp) { .done(function(resp) {
var data = resp.data.result; var data = resp.data.result;
if (data.Code === 1) { if (data.Code === 1) {
permission = true; permission = true;
} else { } else {
$('.file_manager_ok').addClass('disabled');
Alertify.error(data.Error);
}
})
.fail(function() {
$('.file_manager_ok').addClass('disabled'); $('.file_manager_ok').addClass('disabled');
Alertify.error(data.Error); Alertify.error(gettext('Error occurred while checking access permission.'));
} });
})
.fail(function() {
$('.file_manager_ok').addClass('disabled');
Alertify.error(gettext('Error occurred while checking access permission.'));
});
return permission; return permission;
}, },
callback: function(closeEvent) { callback: function(closeEvent) {

View File

@ -141,7 +141,7 @@ module.exports = Alertify.dialog('fileSelectionDlg', function() {
}, },
hooks: { hooks: {
onshow: function() { onshow: function() {
// $(this.elements.body).addClass('pgadmin-storage-body'); // $(this.elements.body).addClass('pgadmin-storage-body');
}, },
}, },
}; };

File diff suppressed because it is too large Load Diff

View File

@ -134,30 +134,30 @@ define('misc.sql', [
}, 1000); }, 1000);
}, },
}) })
.done(function(res) { .done(function(res) {
if (pgAdmin.Browser.editor.getValue() != res) { if (pgAdmin.Browser.editor.getValue() != res) {
pgAdmin.Browser.editor.setValue(res); pgAdmin.Browser.editor.setValue(res);
} }
clearTimeout(timer); clearTimeout(timer);
}) })
.fail(function(xhr, error, message) { .fail(function(xhr, error, message) {
var _label = treeHierarchy[n_type].label; var _label = treeHierarchy[n_type].label;
pgBrowser.Events.trigger( pgBrowser.Events.trigger(
'pgadmin:node:retrieval:error', 'sql', xhr, error, message, item 'pgadmin:node:retrieval:error', 'sql', xhr, error, message, item
);
if (!Alertify.pgHandleItemError(xhr, error, message, {
item: item,
info: treeHierarchy,
})) {
Alertify.pgNotifier(
error, xhr,
S(gettext('Error retrieving the information - %s')).sprintf(
message || _label
).value(),
function() {}
); );
} if (!Alertify.pgHandleItemError(xhr, error, message, {
}); item: item,
info: treeHierarchy,
})) {
Alertify.pgNotifier(
error, xhr,
S(gettext('Error retrieving the information - %s')).sprintf(
message || _label
).value(),
function() {}
);
}
});
} }
} }

View File

@ -436,9 +436,9 @@ define('pgadmin.misc.explain', [
var mappedImage = (_.isFunction(imageMapper[node_type]) && var mappedImage = (_.isFunction(imageMapper[node_type]) &&
imageMapper[node_type].apply(undefined, [data])) || imageMapper[node_type].apply(undefined, [data])) ||
imageMapper[node_type] || { imageMapper[node_type] || {
'image': 'ex_unknown.svg', 'image': 'ex_unknown.svg',
'image_text': node_type, 'image_text': node_type,
}; };
data['image'] = mappedImage['image']; data['image'] = mappedImage['image'];
data['image_text'] = mappedImage['image_text']; data['image_text'] = mappedImage['image_text'];

View File

@ -86,10 +86,10 @@ define('misc.statistics', [
}), }),
// timestamptz // timestamptz
1184: 'string' 1184: 'string'
/* Backgrid.DatetimeCell.extend({ /* Backgrid.DatetimeCell.extend({
includeDate: true, includeTime: true, includeMilli: true includeDate: true, includeTime: true, includeMilli: true
}) */ }) */
, ,
1266: 'string', 1266: 'string',
/* Backgrid.DatetimeCell.extend({ /* Backgrid.DatetimeCell.extend({
includeDate: false, includeTime: true, includeMilli: true includeDate: false, includeTime: true, includeMilli: true
@ -248,78 +248,78 @@ define('misc.statistics', [
}, 1000); }, 1000);
}, },
}) })
.done(function(res) { .done(function(res) {
// clear timer and reset message. // clear timer and reset message.
clearTimeout(timer); clearTimeout(timer);
$msgContainer.text(''); $msgContainer.text('');
if (res.data) { if (res.data) {
var data = self.data = res.data; var data = self.data = res.data;
if (node.hasCollectiveStatistics || data['rows'].length > 1) { if (node.hasCollectiveStatistics || data['rows'].length > 1) {
// Listen scroll event to load more rows // Listen scroll event to load more rows
pgBrowser.Events.on( pgBrowser.Events.on(
'pgadmin-browser:panel-statistics:' + 'pgadmin-browser:panel-statistics:' +
wcDocker.EVENT.SCROLLED, wcDocker.EVENT.SCROLLED,
self.__loadMoreRows self.__loadMoreRows
); );
self.__createMultiLineStatistics.call(self, data, node.statsPrettifyFields); self.__createMultiLineStatistics.call(self, data, node.statsPrettifyFields);
} else { } else {
// Do not listen the scroll event // Do not listen the scroll event
pgBrowser.Events.off( pgBrowser.Events.off(
'pgadmin-browser:panel-statistics:' + 'pgadmin-browser:panel-statistics:' +
wcDocker.EVENT.SCROLLED, wcDocker.EVENT.SCROLLED,
self.__loadMoreRows self.__loadMoreRows
); );
self.__createSingleLineStatistics.call(self, data, node.statsPrettifyFields); self.__createSingleLineStatistics.call(self, data, node.statsPrettifyFields);
} }
if (self.grid) { if (self.grid) {
delete self.grid; delete self.grid;
self.grid = null; self.grid = null;
} }
self.grid = new Backgrid.Grid({ self.grid = new Backgrid.Grid({
emptyText: 'No data found', emptyText: 'No data found',
columns: self.columns, columns: self.columns,
collection: self.collection, collection: self.collection,
className: GRID_CLASSES, className: GRID_CLASSES,
}); });
self.grid.render(); self.grid.render();
$gridContainer.empty(); $gridContainer.empty();
$gridContainer.append(self.grid.$el); $gridContainer.append(self.grid.$el);
if (!$msgContainer.hasClass('d-none')) { if (!$msgContainer.hasClass('d-none')) {
$msgContainer.addClass('d-none'); $msgContainer.addClass('d-none');
} }
$gridContainer.removeClass('d-none'); $gridContainer.removeClass('d-none');
} else if (res.info) { } else if (res.info) {
if (!$gridContainer.hasClass('d-none')) { if (!$gridContainer.hasClass('d-none')) {
$gridContainer.addClass('d-none'); $gridContainer.addClass('d-none');
}
$msgContainer.text(res.info);
$msgContainer.removeClass('d-none');
} }
$msgContainer.text(res.info); })
$msgContainer.removeClass('d-none'); .fail(function(xhr, error, message) {
} var _label = treeHierarchy[n_type].label;
}) pgBrowser.Events.trigger(
.fail(function(xhr, error, message) { 'pgadmin:node:retrieval:error', 'statistics', xhr, error, message, item
var _label = treeHierarchy[n_type].label;
pgBrowser.Events.trigger(
'pgadmin:node:retrieval:error', 'statistics', xhr, error, message, item
);
if (!Alertify.pgHandleItemError(xhr, error, message, {
item: item,
info: treeHierarchy,
})) {
Alertify.pgNotifier(
error, xhr,
S(gettext('Error retrieving the information - %s')).sprintf(
message || _label
).value(),
function() {}
); );
} if (!Alertify.pgHandleItemError(xhr, error, message, {
// show failed message. item: item,
$msgContainer.text(gettext('Failed to retrieve data from the server.')); info: treeHierarchy,
}); })) {
Alertify.pgNotifier(
error, xhr,
S(gettext('Error retrieving the information - %s')).sprintf(
message || _label
).value(),
function() {}
);
}
// show failed message.
$msgContainer.text(gettext('Failed to retrieve data from the server.'));
});
} }
} }
if (msg != '') { if (msg != '') {

View File

@ -273,10 +273,10 @@ define('pgadmin.preferences', [
return 'keyboardShortcut'; return 'keyboardShortcut';
default: default:
if (console && console.warn) { if (console && console.warn) {
// Warning for developer only. // Warning for developer only.
console.warn( console.warn(
'Hmm.. We don\'t know how to render this type - \'\'' + p.type + '\' of control.' 'Hmm.. We don\'t know how to render this type - \'\'' + p.type + '\' of control.'
); );
} }
return 'input'; return 'input';
} }
@ -314,7 +314,7 @@ define('pgadmin.preferences', [
return true; return true;
if (d.preferences) { if (d.preferences) {
/* /*
* Clear the existing html in the preferences content * Clear the existing html in the preferences content
*/ */
$container.find('.preferences_content'); $container.find('.preferences_content');
@ -341,7 +341,7 @@ define('pgadmin.preferences', [
'mid': d.mid, 'mid': d.mid,
'name': p.name, 'name': p.name,
}); });
/* /*
* We don't know until now, how to render the control for * We don't know until now, how to render the control for
* this preference. * this preference.
*/ */
@ -356,13 +356,13 @@ define('pgadmin.preferences', [
d.sortable = false; d.sortable = false;
break; break;
case 'loaded': case 'loaded':
// Let's select the first category from the prefrences. // Let's select the first category from the prefrences.
// We need to wait for sometime before all item gets loaded // We need to wait for sometime before all item gets loaded
// properly. // properly.
setTimeout( setTimeout(
function() { function() {
selectFirstCategory(api, null); selectFirstCategory(api, null);
}, 300); }, 300);
break; break;
} }
return true; return true;

View File

@ -43,18 +43,18 @@ define('pgadmin.settings', [
type: 'DELETE', type: 'DELETE',
async: false, async: false,
}) })
.done(function() { .done(function() {
// Prevent saving layout on server for next page reload. // Prevent saving layout on server for next page reload.
$(window).off('unload'); $(window).off('unload');
window.onbeforeunload = null; window.onbeforeunload = null;
// Now reload page // Now reload page
location.reload(true); location.reload(true);
}) })
.fail(function() { .fail(function() {
console.warn( console.warn(
'Something went wrong on server while resetting layout.' 'Something went wrong on server while resetting layout.'
); );
}); });
}, },
function() { function() {

View File

@ -22,11 +22,11 @@ define('app', [
} }
}; };
// Initialize modules registered to pgAdmin, pgAdmin.Browser and Tools object. // Initialize modules registered to pgAdmin, pgAdmin.Browser and Tools object.
initializeModules(pgAdmin); initializeModules(pgAdmin);
initializeModules(pgAdmin.Browser); initializeModules(pgAdmin.Browser);
initializeModules(pgAdmin.Tools); initializeModules(pgAdmin.Tools);
// create menus after all modules are initialized. // create menus after all modules are initialized.
pgAdmin.Browser.create_menus(); pgAdmin.Browser.create_menus();
}); });

View File

@ -355,25 +355,25 @@ define([
), ),
dataType: 'json', dataType: 'json',
}) })
.done(function(res) { .done(function(res) {
if (res.success && 'connected' in res.data) { if (res.success && 'connected' in res.data) {
if (res.data.connected) { if (res.data.connected) {
// Server is connected, but - the connection with the // Server is connected, but - the connection with the
// particular database has been lost. // particular database has been lost.
pgBrowser.Events.trigger( pgBrowser.Events.trigger(
'pgadmin:database:connection:lost', args.item, jsonResp 'pgadmin:database:connection:lost', args.item, jsonResp
); );
return; return;
}
} }
}
// Serever was not connected, we should first try to connect // Serever was not connected, we should first try to connect
// the server. // the server.
reconnectServer(); reconnectServer();
}) })
.fail(function() { .fail(function() {
reconnectServer(); reconnectServer();
}); });
return true; return true;
} }
return false; return false;

View File

@ -22,9 +22,9 @@ import {getTreeNodeHierarchyFromIdentifier} from '../tree/pgadmin_tree_node';
*/ */
export class Dialog { export class Dialog {
constructor(errorAlertTitle, constructor(errorAlertTitle,
dialogContainerSelector, dialogContainerSelector,
pgBrowser, $, alertify, DialogModel, pgBrowser, $, alertify, DialogModel,
backform = Backform) { backform = Backform) {
this.errorAlertTitle = errorAlertTitle; this.errorAlertTitle = errorAlertTitle;
this.alertify = alertify; this.alertify = alertify;
this.pgBrowser = pgBrowser; this.pgBrowser = pgBrowser;

View File

@ -12,8 +12,8 @@ import {RestoreDialogWrapper} from '../../../tools/restore/static/js/restore_dia
export class DialogFactory { export class DialogFactory {
constructor(pgBrowser, $, constructor(pgBrowser, $,
alertify, DialogModel, alertify, DialogModel,
backform, dialogContainerSelector) { backform, dialogContainerSelector) {
this.pgBrowser = pgBrowser; this.pgBrowser = pgBrowser;
this.jquery = $; this.jquery = $;
this.alertify = alertify; this.alertify = alertify;

View File

@ -511,7 +511,7 @@ define([
data.options = _.defaults({ data.options = _.defaults({
disabled: evalF(field.disabled, field, this.model), disabled: evalF(field.disabled, field, this.model),
}, this.field.get('options'), this.defaults.options, }, this.field.get('options'), this.defaults.options,
$.fn.bootstrapToggle.defaults); $.fn.bootstrapToggle.defaults);
this.$el.html(this.template(data)).addClass(field.name); this.$el.html(this.template(data)).addClass(field.name);
@ -573,8 +573,8 @@ define([
this.cleanup(); this.cleanup();
var c = this.$el var c = this.$el
.children().first().children('.active') .children().first().children('.active')
.first().attr('id'), .first().attr('id'),
m = this.model, m = this.model,
controls = this.controls, controls = this.controls,
tmpls = this.template, tmpls = this.template,
@ -625,15 +625,15 @@ define([
function() { function() {
self.hidden_tab = $(this).data('tabIndex'); self.hidden_tab = $(this).data('tabIndex');
}).on('shown.bs.tab', function() { }).on('shown.bs.tab', function() {
var self = this; var self = this;
self.shown_tab = $(self).data('tabIndex'); self.shown_tab = $(self).data('tabIndex');
m.trigger('pg-property-tab-changed', { m.trigger('pg-property-tab-changed', {
'model': m, 'model': m,
'shown': self.shown_tab, 'shown': self.shown_tab,
'hidden': self.hidden_tab, 'hidden': self.hidden_tab,
'tab': self, 'tab': self,
});
}); });
});
}); });
var makeActive = tabHead.find('[id="' + c + '"]').first(); var makeActive = tabHead.find('[id="' + c + '"]').first();
@ -1748,7 +1748,7 @@ define([
var visible = true; var visible = true;
ver_in_limit = (_.isUndefined(server_info) ? true : ver_in_limit = (_.isUndefined(server_info) ? true :
((_.isUndefined(s.server_type) ? true : ((_.isUndefined(s.server_type) ? true :
(server_info.type in s.server_type)) && (server_info.type in s.server_type)) &&
(_.isUndefined(s.min_version) ? true : (_.isUndefined(s.min_version) ? true :
(server_info.version >= s.min_version)) && (server_info.version >= s.min_version)) &&
(_.isUndefined(s.max_version) ? true : (_.isUndefined(s.max_version) ? true :
@ -1783,7 +1783,7 @@ define([
groups[group] = (groups[group] || []); groups[group] = (groups[group] || []);
ver_in_limit = (_.isUndefined(server_info) ? true : ver_in_limit = (_.isUndefined(server_info) ? true :
((_.isUndefined(s.server_type) ? true : ((_.isUndefined(s.server_type) ? true :
(server_info.type in s.server_type)) && (server_info.type in s.server_type)) &&
(_.isUndefined(s.min_version) ? true : (_.isUndefined(s.min_version) ? true :
(server_info.version >= s.min_version)) && (server_info.version >= s.min_version)) &&
(_.isUndefined(s.max_version) ? true : (_.isUndefined(s.max_version) ? true :
@ -2242,7 +2242,7 @@ define([
* SQL Editor can be in different tab * SQL Editor can be in different tab
*/ */
let browser = window.opener ? let browser = window.opener ?
window.opener.pgAdmin.Browser : window.top.pgAdmin.Browser; window.opener.pgAdmin.Browser : window.top.pgAdmin.Browser;
let sqlEditPreferences = browser.get_preferences_for_module('sqleditor'); let sqlEditPreferences = browser.get_preferences_for_module('sqleditor');
@ -2916,12 +2916,12 @@ define([
_.each(innerFields, function(fld) { _.each(innerFields, function(fld) {
var f = new Backform.Field( var f = new Backform.Field(
_.extend({}, { _.extend({}, {
id: fld['name'], id: fld['name'],
name: fld['name'], name: fld['name'],
control: fld['type'] == 'checkbox' ? 'checkboxWithBox' : fld['type'], control: fld['type'] == 'checkbox' ? 'checkboxWithBox' : fld['type'],
label: fld['label'], label: fld['label'],
}) })
), ),
cntr = new (f.get('control')) ({ cntr = new (f.get('control')) ({
field: f, field: f,

View File

@ -68,10 +68,10 @@ define([
var col_type = column.get('cell').prototype.className || 'string-cell', var col_type = column.get('cell').prototype.className || 'string-cell',
comparator = this.makeComparator(column.get('name'), order, comparator = this.makeComparator(column.get('name'), order,
order ? order ?
column.sortValue() : column.sortValue() :
function(model) { function(model) {
return model.cid.replace('c', '') * 1; return model.cid.replace('c', '') * 1;
}, col_type); }, col_type);
if (Backbone.PageableCollection && if (Backbone.PageableCollection &&
collection instanceof Backbone.PageableCollection) { collection instanceof Backbone.PageableCollection) {
@ -527,9 +527,9 @@ define([
tabIndex: -1, tabIndex: -1,
type: 'checkbox', type: 'checkbox',
}).prop('checked', rawValue).prop('disabled', !editable).attr('data-toggle', 'toggle') }).prop('checked', rawValue).prop('disabled', !editable).attr('data-toggle', 'toggle')
.attr('data-size', options.size).attr('data-on', options.onText).attr('data-off', options.offText) .attr('data-size', options.size).attr('data-on', options.onText).attr('data-off', options.offText)
.attr('data-width', options.width).attr('data-height', options.height) .attr('data-width', options.width).attr('data-height', options.height)
.attr('data-onstyle', options.onColor).attr('data-offstyle', options.offColor)); .attr('data-onstyle', options.onColor).attr('data-offstyle', options.offColor));
this.$input = this.$el.find('input[type=checkbox]').first(); this.$input = this.$el.find('input[type=checkbox]').first();
@ -633,9 +633,9 @@ define([
'<%= selected ? \'selected="selected"\' : "" %>>', '<%= selected ? \'selected="selected"\' : "" %>>',
'<%- label %></option>', '<%- label %></option>',
].join(''), ].join(''),
null, { null, {
variable: null, variable: null,
}), }),
initialize: function() { initialize: function() {
Backgrid.SelectCell.prototype.initialize.apply(this, arguments); Backgrid.SelectCell.prototype.initialize.apply(this, arguments);
@ -683,7 +683,7 @@ define([
openOnEnter: false, openOnEnter: false,
multiple: false, multiple: false,
}, self.defaults.select2, }, self.defaults.select2,
(col.select2 || {}) (col.select2 || {})
), ),
selectTpl = _.template('<select <%=multiple ? "multiple" : "" %>></select>'); selectTpl = _.template('<select <%=multiple ? "multiple" : "" %>></select>');
@ -1409,9 +1409,9 @@ define([
var m = this.modelInUnixOffset ? moment(rawData) : var m = this.modelInUnixOffset ? moment(rawData) :
this.modelInUnixTimestamp ? moment.unix(rawData) : this.modelInUnixTimestamp ? moment.unix(rawData) :
this.modelInUTC ? this.modelInUTC ?
moment.utc(rawData, this.modelFormat, this.modelLang) : moment.utc(rawData, this.modelFormat, this.modelLang) :
moment(rawData, this.modelFormat, this.modelLang); moment(rawData, this.modelFormat, this.modelLang);
if (this.displayInUnixOffset) return +m; if (this.displayInUnixOffset) return +m;
@ -1439,9 +1439,9 @@ define([
var m = this.displayInUnixOffset ? moment(+formattedData) : var m = this.displayInUnixOffset ? moment(+formattedData) :
this.displayInUnixTimestamp ? moment.unix(+formattedData) : this.displayInUnixTimestamp ? moment.unix(+formattedData) :
this.displayInUTC ? this.displayInUTC ?
moment.utc(formattedData, this.displayFormat, this.displayLang) : moment.utc(formattedData, this.displayFormat, this.displayLang) :
moment(formattedData, this.displayFormat, this.displayLang); moment(formattedData, this.displayFormat, this.displayLang);
if (!m || !m.isValid()) return (this.allowEmpty && formattedData === '') ? null : undefined; if (!m || !m.isValid()) return (this.allowEmpty && formattedData === '') ? null : undefined;
@ -1636,7 +1636,7 @@ define([
if ( if (
_.isFunction(editable) ? !!editable.apply(column, [model]) : _.isFunction(editable) ? !!editable.apply(column, [model]) :
!!editable !!editable
) { ) {
this.$el.addClass('editable'); this.$el.addClass('editable');
} else { } else {

View File

@ -212,21 +212,21 @@ function keyboardShortcutsQueryTool(
queryToolActions.executeRollback(sqlEditorController); queryToolActions.executeRollback(sqlEditorController);
} }
} else if (( } else if ((
(this.isMac() && event.metaKey) || (this.isMac() && event.metaKey) ||
(!this.isMac() && event.ctrlKey) (!this.isMac() && event.ctrlKey)
) && !event.altKey && event.shiftKey && keyCode === FWD_SLASH_KEY) { ) && !event.altKey && event.shiftKey && keyCode === FWD_SLASH_KEY) {
this._stopEventPropagation(event); this._stopEventPropagation(event);
queryToolActions.commentBlockCode(sqlEditorController); queryToolActions.commentBlockCode(sqlEditorController);
} else if (( } else if ((
(this.isMac() && !this.isKeyCtrlAltShift(event) && event.metaKey) || (this.isMac() && !this.isKeyCtrlAltShift(event) && event.metaKey) ||
(!this.isMac() && !this.isKeyAltShift(event) && event.ctrlKey) (!this.isMac() && !this.isKeyAltShift(event) && event.ctrlKey)
) && keyCode === FWD_SLASH_KEY) { ) && keyCode === FWD_SLASH_KEY) {
this._stopEventPropagation(event); this._stopEventPropagation(event);
queryToolActions.commentLineCode(sqlEditorController); queryToolActions.commentLineCode(sqlEditorController);
} else if (( } else if ((
(this.isMac() && !this.isKeyCtrlAltShift(event) && event.metaKey) || (this.isMac() && !this.isKeyCtrlAltShift(event) && event.metaKey) ||
(!this.isMac() && !this.isKeyAltShift(event) && event.ctrlKey) (!this.isMac() && !this.isKeyAltShift(event) && event.ctrlKey)
) && keyCode === PERIOD_KEY) { ) && keyCode === PERIOD_KEY) {
this._stopEventPropagation(event); this._stopEventPropagation(event);
queryToolActions.uncommentLineCode(sqlEditorController); queryToolActions.uncommentLineCode(sqlEditorController);
} else if (keyCode == ESC_KEY) { } else if (keyCode == ESC_KEY) {
@ -296,22 +296,11 @@ function keyboardShortcutsQueryTool(
return panel_id; return panel_id;
} }
module.exports = { export {
processEventDebugger: keyboardShortcutsDebugger, keyboardShortcutsDebugger as processEventDebugger,
processEventQueryTool: keyboardShortcutsQueryTool, keyboardShortcutsQueryTool as processEventQueryTool,
getInnerPanel: getInnerPanel, getInnerPanel, validateShortcutKeys,
validateShortcutKeys: validateShortcutKeys, _stopEventPropagation, isMac, isKeyCtrlAlt, isKeyAltShift, isKeyCtrlShift,
// misc functions isKeyCtrlAltShift, isAltShiftBoth, isCtrlShiftBoth, isCtrlAltBoth,
_stopEventPropagation: _stopEventPropagation, shortcut_key, shortcut_title, shortcut_accesskey_title,
isMac: isMac,
isKeyCtrlAlt: isKeyCtrlAlt,
isKeyAltShift: isKeyAltShift,
isKeyCtrlShift: isKeyCtrlShift,
isKeyCtrlAltShift: isKeyCtrlAltShift,
isAltShiftBoth: isAltShiftBoth,
isCtrlShiftBoth: isCtrlShiftBoth,
isCtrlAltBoth: isCtrlAltBoth,
shortcut_key : shortcut_key,
shortcut_title : shortcut_title,
shortcut_accesskey_title : shortcut_accesskey_title,
}; };

View File

@ -57,17 +57,17 @@ function modifyAlertifyAnimation(pgBrowser) {
if(enableAcitreeAnimation) { if(enableAcitreeAnimation) {
$(document).find('link#alertify-no-animation') $(document).find('link#alertify-no-animation')
.attr('disabled', 'disabled'); .attr('disabled', 'disabled');
_.each(document.getElementsByTagName('iframe'), function(frame) { _.each(document.getElementsByTagName('iframe'), function(frame) {
$(frame.contentDocument).find('link#alertify-no-animation') $(frame.contentDocument).find('link#alertify-no-animation')
.attr('disabled', 'disabled'); .attr('disabled', 'disabled');
}); });
} else { } else {
$(document).find('link#alertify-no-animation') $(document).find('link#alertify-no-animation')
.removeAttr('disabled', 'disabled'); .removeAttr('disabled', 'disabled');
_.each(document.getElementsByTagName('iframe'), function(frame) { _.each(document.getElementsByTagName('iframe'), function(frame) {
$(frame.contentDocument).find('link#alertify-no-animation') $(frame.contentDocument).find('link#alertify-no-animation')
.removeAttr('disabled', 'disabled'); .removeAttr('disabled', 'disabled');
}); });
} }
} }

View File

@ -53,7 +53,7 @@ import JSONBigNumber from 'json-bignumber';
$('<button class=\'btn ' + button_type + ' long_text_editor pg-alertify-button\' data-label="'+label+'">' + $('<button class=\'btn ' + button_type + ' long_text_editor pg-alertify-button\' data-label="'+label+'">' +
'<span class="fa '+ button_icon +' pg-alertify-button"></span>&nbsp;'+ label + '<span class="fa '+ button_icon +' pg-alertify-button"></span>&nbsp;'+ label +
'</button>') '</button>')
.appendTo($buttons); .appendTo($buttons);
if (editable) { if (editable) {
$('<button class=\'btn btn-primary long_text_editor\' data-label="Save">'+ $('<button class=\'btn btn-primary long_text_editor\' data-label="Save">'+

View File

@ -97,7 +97,7 @@ class ExecuteQuery {
}).catch(function (error) { }).catch(function (error) {
self.onExecuteHTTPError(error); self.onExecuteHTTPError(error);
} }
); );
} }
generateURLReconnectionFlag(shouldReconnect) { generateURLReconnectionFlag(shouldReconnect) {

View File

@ -14,7 +14,7 @@ import Alertify from 'pgadmin.alertifyjs';
import pgAdmin from 'sources/pgadmin'; import pgAdmin from 'sources/pgadmin';
import Backform from 'pgadmin.backform'; import Backform from 'pgadmin.backform';
import axios from 'axios'; import axios from 'axios';
import queryToolActions from 'sources/sqleditor/query_tool_actions'; var queryToolActions = require('sources/sqleditor/query_tool_actions');
import filterDialogModel from 'sources/sqleditor/filter_dialog_model'; import filterDialogModel from 'sources/sqleditor/filter_dialog_model';
import {handleQueryToolAjaxError} from 'sources/sqleditor/query_tool_http_error_handler'; import {handleQueryToolAjaxError} from 'sources/sqleditor/query_tool_http_error_handler';
@ -40,89 +40,89 @@ let FilterDialog = {
'Cache-Control' : 'no-cache', 'Cache-Control' : 'no-cache',
}, },
}) })
.done(function (res) { .done(function (res) {
let response = res.data.result; let response = res.data.result;
// Check the alertify dialog already loaded then delete it to clear // Check the alertify dialog already loaded then delete it to clear
// the cache // the cache
if (Alertify.filterDialog) { if (Alertify.filterDialog) {
delete Alertify.filterDialog; delete Alertify.filterDialog;
} }
// Create Dialog // Create Dialog
Alertify.dialog('filterDialog', function factory() { Alertify.dialog('filterDialog', function factory() {
let $container = $('<div class=\'data_sorting_dialog\'></div>'); let $container = $('<div class=\'data_sorting_dialog\'></div>');
return { return {
main: function() { main: function() {
this.set('title', gettext('Sort/Filter options')); this.set('title', gettext('Sort/Filter options'));
},
build: function() {
this.elements.content.appendChild($container.get(0));
Alertify.pgDialogBuild.apply(this);
},
setup: function() {
return {
buttons: [{
text: '',
key: 112,
className: 'btn btn-secondary pull-left fa fa-question pg-alertify-icon-button',
attrs: {
name: 'dialog_help',
type: 'button',
label: gettext('Help'),
url: url_for('help.static', {
'filename': 'editgrid.html',
}),
},
}, {
text: gettext('Cancel'),
key: 27,
className: 'btn btn-secondary fa fa-times pg-alertify-button',
'data-btn-name': 'cancel',
}, {
text: gettext('OK'),
className: 'btn btn-primary fa fa-check pg-alertify-button',
'data-btn-name': 'ok',
}],
// Set options for dialog
options: {
title: title,
//disable both padding and overflow control.
padding: !1,
overflow: !1,
model: 0,
resizable: true,
maximizable: true,
pinnable: false,
closableByDimmer: false,
modal: false,
autoReset: false,
},
};
},
hooks: {
// triggered when the dialog is closed
onclose: function() {
if (this.view) {
this.filterCollectionModel.stopSession();
this.view.model.stopSession();
this.view.remove({
data: true,
internal: true,
silent: true,
});
}
}, },
}, build: function() {
prepare: function() { this.elements.content.appendChild($container.get(0));
let self = this; Alertify.pgDialogBuild.apply(this);
$container.html(''); },
// Disable Ok button setup: function() {
this.__internal.buttons[2].element.disabled = true; return {
buttons: [{
text: '',
key: 112,
className: 'btn btn-secondary pull-left fa fa-question pg-alertify-icon-button',
attrs: {
name: 'dialog_help',
type: 'button',
label: gettext('Help'),
url: url_for('help.static', {
'filename': 'editgrid.html',
}),
},
}, {
text: gettext('Cancel'),
key: 27,
className: 'btn btn-secondary fa fa-times pg-alertify-button',
'data-btn-name': 'cancel',
}, {
text: gettext('OK'),
className: 'btn btn-primary fa fa-check pg-alertify-button',
'data-btn-name': 'ok',
}],
// Set options for dialog
options: {
title: title,
//disable both padding and overflow control.
padding: !1,
overflow: !1,
model: 0,
resizable: true,
maximizable: true,
pinnable: false,
closableByDimmer: false,
modal: false,
autoReset: false,
},
};
},
hooks: {
// triggered when the dialog is closed
onclose: function() {
if (this.view) {
this.filterCollectionModel.stopSession();
this.view.model.stopSession();
this.view.remove({
data: true,
internal: true,
silent: true,
});
}
},
},
prepare: function() {
let self = this;
$container.html('');
// Disable Ok button
this.__internal.buttons[2].element.disabled = true;
// Status bar // Status bar
this.statusBar = $( this.statusBar = $(
'<div class=\'pg-prop-status-bar pg-el-xs-12 d-none\'>' + '<div class=\'pg-prop-status-bar pg-el-xs-12 d-none\'>' +
' <div class="error-in-footer"> ' + ' <div class="error-in-footer"> ' +
' <div class="d-flex px-2 py-1"> ' + ' <div class="d-flex px-2 py-1"> ' +
' <div class="pr-2"> ' + ' <div class="pr-2"> ' +
@ -133,144 +133,144 @@ let FilterDialog = {
' </div> ' + ' </div> ' +
'</div>').appendTo($container); '</div>').appendTo($container);
// To show progress on filter Saving/Updating on AJAX // To show progress on filter Saving/Updating on AJAX
this.showFilterProgress = $( this.showFilterProgress = $(
`<div id="show_filter_progress" class="pg-sp-container sql-editor-busy-fetching d-none"> `<div id="show_filter_progress" class="pg-sp-container sql-editor-busy-fetching d-none">
<div class="pg-sp-content"> <div class="pg-sp-content">
<div class="row"><div class="col-12 pg-sp-icon sql-editor-busy-icon"></div></div> <div class="row"><div class="col-12 pg-sp-icon sql-editor-busy-icon"></div></div>
<div class="row"><div class="col-12 pg-sp-text sql-editor-busy-text">${gettext('Loading data...')}</div></div> <div class="row"><div class="col-12 pg-sp-text sql-editor-busy-text">${gettext('Loading data...')}</div></div>
</div> </div>
</div>` </div>`
).appendTo($container); ).appendTo($container);
$(
self.showFilterProgress[0]
).removeClass('d-none');
self.filterCollectionModel = filterDialogModel(response);
let fields = Backform.generateViewSchema(
null, self.filterCollectionModel, 'create', null, null, true
);
let view = this.view = new Backform.Dialog({
el: '<div></div>',
model: self.filterCollectionModel,
schema: fields,
});
$(this.elements.body.childNodes[0]).addClass(
'alertify_tools_dialog_properties obj_properties'
);
$container.append(view.render().$el);
// Enable/disable save button and show/hide statusbar based on session
view.listenTo(view.model, 'pgadmin-session:start', function() {
view.listenTo(view.model, 'pgadmin-session:invalid', function(msg) {
self.statusBar.removeClass('d-none');
$(self.statusBar.find('.alert-text')).html(msg);
// Disable Okay button
self.__internal.buttons[2].element.disabled = true;
});
view.listenTo(view.model, 'pgadmin-session:valid', function() {
self.statusBar.addClass('d-none');
$(self.statusBar.find('.alert-text')).html('');
// Enable Okay button
self.__internal.buttons[2].element.disabled = false;
});
});
view.listenTo(view.model, 'pgadmin-session:stop', function() {
view.stopListening(view.model, 'pgadmin-session:invalid');
view.stopListening(view.model, 'pgadmin-session:valid');
});
// Starts monitoring changes to model
view.model.startNewSession();
// Set data in collection
let viewDataSortingModel = view.model.get('data_sorting');
viewDataSortingModel.add(response['data_sorting']);
// Hide Progress ...
$(
self.showFilterProgress[0]
).addClass('d-none');
},
// Callback functions when click on the buttons of the Alertify dialogs
callback: function(e) {
let self = this;
if (e.button.element.name == 'dialog_help') {
e.cancel = true;
pgAdmin.Browser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
null, null);
return;
} else if (e.button['data-btn-name'] === 'ok') {
e.cancel = true; // Do not close dialog
let filterCollectionModel = this.filterCollectionModel.toJSON();
// Show Progress ...
$( $(
self.showFilterProgress[0] self.showFilterProgress[0]
).removeClass('d-none'); ).removeClass('d-none');
axios.put( self.filterCollectionModel = filterDialogModel(response);
url_for('sqleditor.set_filter_data', {
'trans_id': handler.transId, let fields = Backform.generateViewSchema(
}), null, self.filterCollectionModel, 'create', null, null, true
filterCollectionModel );
).then(function (result) {
// Hide Progress ... let view = this.view = new Backform.Dialog({
el: '<div></div>',
model: self.filterCollectionModel,
schema: fields,
});
$(this.elements.body.childNodes[0]).addClass(
'alertify_tools_dialog_properties obj_properties'
);
$container.append(view.render().$el);
// Enable/disable save button and show/hide statusbar based on session
view.listenTo(view.model, 'pgadmin-session:start', function() {
view.listenTo(view.model, 'pgadmin-session:invalid', function(msg) {
self.statusBar.removeClass('d-none');
$(self.statusBar.find('.alert-text')).html(msg);
// Disable Okay button
self.__internal.buttons[2].element.disabled = true;
});
view.listenTo(view.model, 'pgadmin-session:valid', function() {
self.statusBar.addClass('d-none');
$(self.statusBar.find('.alert-text')).html('');
// Enable Okay button
self.__internal.buttons[2].element.disabled = false;
});
});
view.listenTo(view.model, 'pgadmin-session:stop', function() {
view.stopListening(view.model, 'pgadmin-session:invalid');
view.stopListening(view.model, 'pgadmin-session:valid');
});
// Starts monitoring changes to model
view.model.startNewSession();
// Set data in collection
let viewDataSortingModel = view.model.get('data_sorting');
viewDataSortingModel.add(response['data_sorting']);
// Hide Progress ...
$(
self.showFilterProgress[0]
).addClass('d-none');
},
// Callback functions when click on the buttons of the Alertify dialogs
callback: function(e) {
let self = this;
if (e.button.element.name == 'dialog_help') {
e.cancel = true;
pgAdmin.Browser.showHelp(e.button.element.name, e.button.element.getAttribute('url'),
null, null);
return;
} else if (e.button['data-btn-name'] === 'ok') {
e.cancel = true; // Do not close dialog
let filterCollectionModel = this.filterCollectionModel.toJSON();
// Show Progress ...
$( $(
self.showFilterProgress[0] self.showFilterProgress[0]
).addClass('d-none'); ).removeClass('d-none');
let response = result.data.data; axios.put(
url_for('sqleditor.set_filter_data', {
'trans_id': handler.transId,
}),
filterCollectionModel
).then(function (result) {
// Hide Progress ...
$(
self.showFilterProgress[0]
).addClass('d-none');
if (response.status) { let response = result.data.data;
setTimeout(
function() { if (response.status) {
self.close(); // Close the dialog now setTimeout(
Alertify.success(gettext('Filter updated successfully')); function() {
queryToolActions.executeQuery(handler); self.close(); // Close the dialog now
}, 10 Alertify.success(gettext('Filter updated successfully'));
); queryToolActions.executeQuery(handler);
} else { }, 10
Alertify.alert( );
} else {
Alertify.alert(
gettext('Validation Error'), gettext('Validation Error'),
response.result response.result
); );
} }
}).catch(function (error) { }).catch(function (error) {
// Hide Progress ... // Hide Progress ...
$( $(
self.showFilterProgress[0] self.showFilterProgress[0]
).addClass('d-none'); ).addClass('d-none');
handler.onExecuteHTTPError(error); handler.onExecuteHTTPError(error);
setTimeout( setTimeout(
function() { function() {
Alertify.error(error); Alertify.error(error);
}, 10 }, 10
); );
}); });
} else { } else {
self.close(); self.close();
} }
}, },
}; };
});
Alertify.filterDialog(title).resizeTo(pgAdmin.Browser.stdW.md,pgAdmin.Browser.stdH.md);
})
.fail(function(e) {
handleQueryToolAjaxError(pgAdmin, handler, e, '_show_filter', [], true);
}); });
Alertify.filterDialog(title).resizeTo(pgAdmin.Browser.stdW.md,pgAdmin.Browser.stdH.md);
})
.fail(function(e) {
handleQueryToolAjaxError(pgAdmin, handler, e, '_show_filter', [], true);
});
}, },
}; };

View File

@ -13,7 +13,7 @@ import pgAdmin from 'sources/pgadmin';
import Backgrid from 'pgadmin.backgrid'; import Backgrid from 'pgadmin.backgrid';
import Backform from 'pgadmin.backform'; import Backform from 'pgadmin.backform';
let initModel = function(response) { export default function filterDialogModel(response) {
let order_mapping = { let order_mapping = {
'asc': gettext('ASC'), 'asc': gettext('ASC'),
@ -135,7 +135,4 @@ let initModel = function(response) {
let model = new FilterCollectionModel(); let model = new FilterCollectionModel();
return model; return model;
}; }
module.exports = initModel;

View File

@ -106,9 +106,9 @@ export default class QueryHistoryDetails {
`<div class='metadata'> `<div class='metadata'>
${itemTemplate(this.formatDate(this.entry.start_time), 'Date')} ${itemTemplate(this.formatDate(this.entry.start_time), 'Date')}
${itemTemplate( ${itemTemplate(
this.entry.row_affected.toLocaleString(), this.entry.row_affected.toLocaleString(),
'Rows Affected' 'Rows Affected'
)} )}
${itemTemplate(this.entry.total_time, 'Duration')} ${itemTemplate(this.entry.total_time, 'Duration')}
</div>` </div>`
); );
@ -126,8 +126,8 @@ export default class QueryHistoryDetails {
this.$errMsgBlock.empty().append( this.$errMsgBlock.empty().append(
`<div class='history-error-text'> `<div class='history-error-text'>
<span>Error Message</span> ${this.parseErrorMessage( <span>Error Message</span> ${this.parseErrorMessage(
this.entry.message this.entry.message
)} )}
</div>` </div>`
); );
} else { } else {

View File

@ -75,10 +75,10 @@ export class QueryHistoryItem {
</div> </div>
</li>` </li>`
) )
.data('entrydata', this.entry) .data('entrydata', this.entry)
.on('click', e => { .on('click', e => {
this.onClickHandler($(e.currentTarget)); this.onClickHandler($(e.currentTarget));
}); });
} }
} }

View File

@ -78,7 +78,7 @@ function updateUIPreferences(sqlEditor) {
.find('i') .find('i')
.attr('title', .attr('title',
shortcut_accesskey_title('Connection status (click for details)', shortcut_accesskey_title('Connection status (click for details)',
preferences.btn_conn_status)); preferences.btn_conn_status));
/* Accessed using ctrl,atl,shift and key */ /* Accessed using ctrl,atl,shift and key */
$el.find('#btn-flash') $el.find('#btn-flash')
@ -152,8 +152,8 @@ function updateUIPreferences(sqlEditor) {
// Calling it again in specified interval // Calling it again in specified interval
sqlEditor.connIntervalId = setInterval( sqlEditor.connIntervalId = setInterval(
SqlEditorUtils.fetchConnectionStatus.bind(null, sqlEditor.handler, $conn_status, $status_el), SqlEditorUtils.fetchConnectionStatus.bind(null, sqlEditor.handler, $conn_status, $status_el),
preferences.connection_status_fetch_time * 1000 preferences.connection_status_fetch_time * 1000
); );
} }
else { else {

View File

@ -19,8 +19,8 @@ define(['jquery', 'sources/gettext', 'sources/url_for'],
var hexDigits = '0123456789abcdef'; var hexDigits = '0123456789abcdef';
for (var i = 0; i < 36; i++) { for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr( s[i] = hexDigits.substr(
Math.floor(Math.random() * 0x10), 1 Math.floor(Math.random() * 0x10), 1
); );
} }
// bits 12-15 of the time_hi_and_version field to 0010 // bits 12-15 of the time_hi_and_version field to 0010
s[14] = '4'; s[14] = '4';
@ -46,7 +46,7 @@ define(['jquery', 'sources/gettext', 'sources/url_for'],
// Create a temporary element with given label, append to body // Create a temporary element with given label, append to body
// calculate its width and remove the element. // calculate its width and remove the element.
$('body').append( $('body').append(
'<span id="pg_text" style="visibility: hidden;">'+ text + '</span>' '<span id="pg_text" style="visibility: hidden;">'+ text + '</span>'
); );
var width = $('#pg_text').width() + 23; var width = $('#pg_text').width() + 23;
$('#pg_text').remove(); // remove element $('#pg_text').remove(); // remove element
@ -80,102 +80,102 @@ define(['jquery', 'sources/gettext', 'sources/url_for'],
url: url, url: url,
method: 'GET', method: 'GET',
}) })
.done(function (res) { .done(function (res) {
if(res && res.data) { if(res && res.data) {
var status = res.data.status, var status = res.data.status,
msg = res.data.message, msg = res.data.message,
is_status_changed = false; is_status_changed = false;
// Raise notify messages comes from database server. // Raise notify messages comes from database server.
sqleditor_obj.update_notifications(res.data.notifies); sqleditor_obj.update_notifications(res.data.notifies);
// Inject CSS as required // Inject CSS as required
switch(status) { switch(status) {
// Busy // Busy
case 1: case 1:
// if received busy status more than once then only // if received busy status more than once then only
if(status == sqlEditorUtils.previousStatus && if(status == sqlEditorUtils.previousStatus &&
!$status_el.hasClass('fa-hourglass-half')) { !$status_el.hasClass('fa-hourglass-half')) {
$status_el.removeClass() $status_el.removeClass()
.addClass('fa fa-hourglass-half'); .addClass('fa fa-hourglass-half');
is_status_changed = true; is_status_changed = true;
} }
break; break;
// Idle in transaction // Idle in transaction
case 2: case 2:
if(sqlEditorUtils.previousStatus != status && if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-clock-o')) { !$status_el.hasClass('fa-clock-o')) {
$status_el.removeClass() $status_el.removeClass()
.addClass('fa fa-clock-o'); .addClass('fa fa-clock-o');
is_status_changed = true; is_status_changed = true;
} }
break; break;
// Failed in transaction // Failed in transaction
case 3: case 3:
if(sqlEditorUtils.previousStatus != status && if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-exclamation-circle')) { !$status_el.hasClass('fa-exclamation-circle')) {
$status_el.removeClass() $status_el.removeClass()
.addClass('fa fa-exclamation-circle'); .addClass('fa fa-exclamation-circle');
is_status_changed = true; is_status_changed = true;
} }
break; break;
// Failed in transaction with unknown server side error // Failed in transaction with unknown server side error
case 4: case 4:
if(sqlEditorUtils.previousStatus != status && if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-exclamation-triangle')) { !$status_el.hasClass('fa-exclamation-triangle')) {
$status_el.removeClass() $status_el.removeClass()
.addClass('fa fa-exclamation-triangle'); .addClass('fa fa-exclamation-triangle');
is_status_changed = true; is_status_changed = true;
} }
break; break;
default: default:
if(sqlEditorUtils.previousStatus != status && if(sqlEditorUtils.previousStatus != status &&
!$status_el.hasClass('fa-query_tool_connected')) { !$status_el.hasClass('fa-query_tool_connected')) {
$status_el.removeClass() $status_el.removeClass()
.addClass('fa-custom fa-query-tool-connected'); .addClass('fa-custom fa-query-tool-connected');
is_status_changed = true; is_status_changed = true;
}
} }
}
sqlEditorUtils.previousStatus = status; sqlEditorUtils.previousStatus = status;
// Set bootstrap popover message // Set bootstrap popover message
if(is_status_changed) { if(is_status_changed) {
$el.popover('hide'); $el.popover('hide');
$el.attr('data-content', msg); $el.attr('data-content', msg);
} }
} else { } else {
// We come here means we did not receive expected response // We come here means we did not receive expected response
// from server, we need to error out // from server, we need to error out
sqlEditorUtils.previousStatus = -99; sqlEditorUtils.previousStatus = -99;
msg = gettext('An unexpected error occurred - ' + msg = gettext('An unexpected error occurred - ' +
'ensure you are logged into the application.'); 'ensure you are logged into the application.');
$el.attr('data-content', msg);
if(!$status_el.hasClass('fa-query-tool-disconnected')) {
$el.popover('hide');
$status_el.removeClass()
.addClass('fa-custom fa-query-tool-disconnected');
}
}
})
.fail(function (e) {
sqlEditorUtils.previousStatus = -1;
var msg = gettext('Transaction status check failed.');
if (e.readyState == 0) {
msg = gettext('Not connected to the server or the connection to ' +
'the server has been closed.');
} else if (e.responseJSON && e.responseJSON.errormsg) {
msg = e.responseJSON.errormsg;
}
// Set bootstrap popover
$el.attr('data-content', msg); $el.attr('data-content', msg);
// Add error class
if(!$status_el.hasClass('fa-query-tool-disconnected')) { if(!$status_el.hasClass('fa-query-tool-disconnected')) {
$el.popover('hide'); $el.popover('hide');
$status_el.removeClass() $status_el.removeClass()
.addClass('fa-custom fa-query-tool-disconnected'); .addClass('fa-custom fa-query-tool-disconnected');
} }
} });
})
.fail(function (e) {
sqlEditorUtils.previousStatus = -1;
var msg = gettext('Transaction status check failed.');
if (e.readyState == 0) {
msg = gettext('Not connected to the server or the connection to ' +
'the server has been closed.');
} else if (e.responseJSON && e.responseJSON.errormsg) {
msg = e.responseJSON.errormsg;
}
// Set bootstrap popover
$el.attr('data-content', msg);
// Add error class
if(!$status_el.hasClass('fa-query-tool-disconnected')) {
$el.popover('hide');
$status_el.removeClass()
.addClass('fa-custom fa-query-tool-disconnected');
}
});
}, },
// Updates the flag for connection status poll // Updates the flag for connection status poll

View File

@ -13,10 +13,10 @@ import url_for from 'sources/url_for';
import gettext from 'sources/gettext'; import gettext from 'sources/gettext';
import pgAdmin from 'sources/pgadmin'; import pgAdmin from 'sources/pgadmin';
const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {}; export const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
const browserTreeState = pgBrowser.browserTreeState = pgBrowser.browserTreeState || {}; export const browserTreeState = pgBrowser.browserTreeState = pgBrowser.browserTreeState || {};
_.extend(pgBrowser.browserTreeState, { _.extend(pgBrowser.browserTreeState, {
@ -74,20 +74,20 @@ _.extend(pgBrowser.browserTreeState, {
url: url_for('settings.reset_tree_state'), url: url_for('settings.reset_tree_state'),
type: 'DELETE', type: 'DELETE',
}) })
.fail(function(jqx) { .fail(function(jqx) {
var msg = jqx.responseText; var msg = jqx.responseText;
/* Error from the server */ /* Error from the server */
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) { if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
try { try {
var data = JSON.parse(jqx.responseText); var data = JSON.parse(jqx.responseText);
msg = data.errormsg; msg = data.errormsg;
} catch (e) { } catch (e) {
console.warn(e.stack || e); console.warn(e.stack || e);
}
} }
} console.warn(
console.warn( gettext('Error resetting the tree saved state."'), msg);
gettext('Error resetting the tree saved state."'), msg); });
});
} }
}, },
@ -103,23 +103,23 @@ _.extend(pgBrowser.browserTreeState, {
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify(self.current_state), data: JSON.stringify(self.current_state),
}) })
.done(function() { .done(function() {
self.last_state = JSON.stringify(self.current_state); self.last_state = JSON.stringify(self.current_state);
}) })
.fail(function(jqx) { .fail(function(jqx) {
var msg = jqx.responseText; var msg = jqx.responseText;
/* Error from the server */ /* Error from the server */
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) { if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
try { try {
var data = JSON.parse(jqx.responseText); var data = JSON.parse(jqx.responseText);
msg = data.errormsg; msg = data.errormsg;
} catch (e) { } catch (e) {
console.warn(e.stack || e); console.warn(e.stack || e);
}
} }
} console.warn(
console.warn( gettext('Error saving the tree state."'), msg);
gettext('Error saving the tree state."'), msg); });
});
}, },
fetch_state: function() { fetch_state: function() {
@ -131,23 +131,23 @@ _.extend(pgBrowser.browserTreeState, {
dataType: 'json', dataType: 'json',
contentType: 'application/json', contentType: 'application/json',
}) })
.done(function(res) { .done(function(res) {
self.stored_state = res; self.stored_state = res;
}) })
.fail(function(jqx) { .fail(function(jqx) {
var msg = jqx.responseText; var msg = jqx.responseText;
/* Error from the server */ /* Error from the server */
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) { if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
try { try {
var data = JSON.parse(jqx.responseText); var data = JSON.parse(jqx.responseText);
msg = data.errormsg; msg = data.errormsg;
} catch (e) { } catch (e) {
console.warn(e.stack || e); console.warn(e.stack || e);
}
} }
} console.warn(
console.warn( gettext('Error fetching the tree state."'), msg);
gettext('Error fetching the tree state."'), msg); });
});
}, },
update_cache: function(item) { update_cache: function(item) {
@ -390,5 +390,3 @@ _.extend(pgBrowser.browserTreeState, {
} }
}, },
}); });
export {pgBrowser, browserTreeState};

View File

@ -16,7 +16,7 @@ import {DialogWrapper} from '../../../../static/js/alertify/dialog_wrapper';
export class BackupDialogWrapper extends DialogWrapper { export class BackupDialogWrapper extends DialogWrapper {
constructor(dialogContainerSelector, dialogTitle, typeOfDialog, constructor(dialogContainerSelector, dialogTitle, typeOfDialog,
jquery, pgBrowser, alertify, dialogModel, backform) { jquery, pgBrowser, alertify, dialogModel, backform) {
super(dialogContainerSelector, dialogTitle, jquery, super(dialogContainerSelector, dialogTitle, jquery,
pgBrowser, alertify, dialogModel, backform); pgBrowser, alertify, dialogModel, backform);
this.typeOfDialog = typeOfDialog; this.typeOfDialog = typeOfDialog;

View File

@ -68,7 +68,7 @@ define('pgadmin.datagrid', [
'foreign_table', 'catalog_object', 'partition', 'foreign_table', 'catalog_object', 'partition',
], ],
/* Enable/disable View data menu in tools based /* Enable/disable View data menu in tools based
* on node selected. if selected node is present * on node selected. if selected node is present
* in supported_nodes, menu will be enabled * in supported_nodes, menu will be enabled
* otherwise disabled. * otherwise disabled.
@ -86,7 +86,7 @@ define('pgadmin.datagrid', [
return isEnabled; return isEnabled;
}, },
/* Enable/disable Query tool menu in tools based /* Enable/disable Query tool menu in tools based
* on node selected. if selected node is present * on node selected. if selected node is present
* in unsupported_nodes, menu will be disabled * in unsupported_nodes, menu will be disabled
* otherwise enabled. * otherwise enabled.
@ -350,25 +350,25 @@ define('pgadmin.datagrid', [
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify(sql), data: JSON.stringify(sql),
}) })
.done(function(res) { .done(function(res) {
if (res.data.status) { if (res.data.status) {
// Initialize the data grid. // Initialize the data grid.
self.create_transaction(that.baseUrl, null, 'false', parentData.server.server_type, '', grid_title, sql, false); self.create_transaction(that.baseUrl, null, 'false', parentData.server.server_type, '', grid_title, sql, false);
that.close(); // Close the dialog that.close(); // Close the dialog
} }
else { else {
alertify.alert(
gettext('Validation Error'),
res.data.result
);
}
})
.fail(function(e) {
alertify.alert( alertify.alert(
gettext('Validation Error'), gettext('Validation Error'),
res.data.result e
); );
} });
})
.fail(function(e) {
alertify.alert(
gettext('Validation Error'),
e
);
});
} }
}, },
}; };
@ -378,7 +378,7 @@ define('pgadmin.datagrid', [
$.get(url_for('datagrid.filter'), $.get(url_for('datagrid.filter'),
function(data) { function(data) {
alertify.filterDialog('Data Filter', data, baseUrl, validateUrl) alertify.filterDialog('Data Filter', data, baseUrl, validateUrl)
.resizeTo(pgBrowser.stdW.sm,pgBrowser.stdH.sm); .resizeTo(pgBrowser.stdW.sm,pgBrowser.stdH.sm);
} }
); );
}, },
@ -413,35 +413,35 @@ define('pgadmin.datagrid', [
data: reqData, data: reqData,
contentType: 'application/json', contentType: 'application/json',
}) })
.done(function(res) { .done(function(res) {
res.data.is_query_tool = is_query_tool; res.data.is_query_tool = is_query_tool;
res.data.server_type = server_type; res.data.server_type = server_type;
res.data.sURL = sURL; res.data.sURL = sURL;
res.data.panel_title = panel_title; res.data.panel_title = panel_title;
target.trigger('pgadmin-datagrid:transaction:created', res.data); target.trigger('pgadmin-datagrid:transaction:created', res.data);
}) })
.fail(function(xhr) { .fail(function(xhr) {
if (target !== self) { if (target !== self) {
if(xhr.status == 503 && xhr.responseJSON.info != undefined && if(xhr.status == 503 && xhr.responseJSON.info != undefined &&
xhr.responseJSON.info == 'CONNECTION_LOST') { xhr.responseJSON.info == 'CONNECTION_LOST') {
setTimeout(function() { setTimeout(function() {
target.handle_connection_lost(true, xhr); target.handle_connection_lost(true, xhr);
}); });
return; return;
}
} }
}
try { try {
var err = JSON.parse(xhr.responseText); var err = JSON.parse(xhr.responseText);
alertify.alert(gettext('Query Tool initialization error'), alertify.alert(gettext('Query Tool initialization error'),
err.errormsg err.errormsg
); );
} catch (e) { } catch (e) {
alertify.alert(gettext('Query Tool initialization error'), alertify.alert(gettext('Query Tool initialization error'),
e.statusText e.statusText
); );
} }
}); });
}, },
launch_grid: function(trans_obj) { launch_grid: function(trans_obj) {
var self = this, var self = this,
@ -470,7 +470,7 @@ define('pgadmin.datagrid', [
} }
} }
// Open the panel if frame is initialized // Open the panel if frame is initialized
let titileForURLObj = sqlEditorUtils.removeSlashInTheString(grid_title); let titileForURLObj = sqlEditorUtils.removeSlashInTheString(grid_title);
var url_params = { var url_params = {
'trans_id': trans_obj.gridTransId, 'trans_id': trans_obj.gridTransId,

View File

@ -35,7 +35,7 @@ function hasServerInformations(parentData) {
} }
export function showQueryTool(datagrid, pgBrowser, alertify, url, export function showQueryTool(datagrid, pgBrowser, alertify, url,
aciTreeIdentifier, panelTitle) { aciTreeIdentifier, panelTitle) {
const sURL = url || ''; const sURL = url || '';
const queryToolTitle = panelTitle || ''; const queryToolTitle = panelTitle || '';

View File

@ -313,19 +313,19 @@ define([
url: _url, url: _url,
cache: false, cache: false,
}) })
.done(function() { .done(function() {
self.start_global_debugger(); self.start_global_debugger();
}) })
.fail(function(xhr) { .fail(function(xhr) {
try { try {
var err = JSON.parse(xhr.responseText); var err = JSON.parse(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg); Alertify.alert(gettext('Debugger Error'), err.errormsg);
}
} catch (e) {
console.warn(e.stack || e);
} }
} catch (e) { });
console.warn(e.stack || e);
}
});
}, },
//Callback function when user start the indirect debugging ( Listen to another session to invoke the target ) //Callback function when user start the indirect debugging ( Listen to another session to invoke the target )
@ -419,52 +419,52 @@ define([
url: baseUrl, url: baseUrl,
method: 'GET', method: 'GET',
}) })
.done(function(res) { .done(function(res) {
var url = url_for('debugger.direct', { var url = url_for('debugger.direct', {
'trans_id': res.data.debuggerTransId, 'trans_id': res.data.debuggerTransId,
});
if (self.preferences.debugger_new_browser_tab) {
window.open(url, '_blank');
} else {
pgBrowser.Events.once(
'pgadmin-browser:frame:urlloaded:frm_debugger',
function(frame) {
frame.openURL(url);
});
// Create the debugger panel as per the data received from user input dialog.
var dashboardPanel = pgBrowser.docker.findPanels(
'properties'
),
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
panel.focus();
// Panel Closed event
panel.on(wcDocker.EVENT.CLOSED, function() {
var closeUrl = url_for('debugger.close', {
'trans_id': res.data.debuggerTransId,
});
$.ajax({
url: closeUrl,
method: 'DELETE',
});
}); });
}
}) if (self.preferences.debugger_new_browser_tab) {
.fail(function(xhr) { window.open(url, '_blank');
try { } else {
var err = JSON.parse(xhr.responseText); pgBrowser.Events.once(
if (err.success == 0) { 'pgadmin-browser:frame:urlloaded:frm_debugger',
Alertify.alert(gettext('Debugger Error'), err.errormsg); function(frame) {
frame.openURL(url);
});
// Create the debugger panel as per the data received from user input dialog.
var dashboardPanel = pgBrowser.docker.findPanels(
'properties'
),
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
panel.focus();
// Panel Closed event
panel.on(wcDocker.EVENT.CLOSED, function() {
var closeUrl = url_for('debugger.close', {
'trans_id': res.data.debuggerTransId,
});
$.ajax({
url: closeUrl,
method: 'DELETE',
});
});
} }
} catch (e) { })
console.warn(e.stack || e); .fail(function(xhr) {
} try {
}); var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
}
} catch (e) {
console.warn(e.stack || e);
}
});
}, },
/* /*
@ -489,107 +489,107 @@ define([
url: _url, url: _url,
cache: false, cache: false,
}) })
.done(function(res) { .done(function(res) {
// Open Alertify the dialog to take the input arguments from user if function having input arguments // Open Alertify the dialog to take the input arguments from user if function having input arguments
if (res.data[0]['require_input']) { if (res.data[0]['require_input']) {
get_function_arguments(res.data[0], 0, is_edb_proc); get_function_arguments(res.data[0], 0, is_edb_proc);
} else { } else {
// Initialize the target and create asynchronous connection and unique transaction ID // Initialize the target and create asynchronous connection and unique transaction ID
// If there is no arguments to the functions then we should not ask for for function arguments and // If there is no arguments to the functions then we should not ask for for function arguments and
// Directly open the panel // Directly open the panel
var t = pgBrowser.tree, var t = pgBrowser.tree,
i = t.selected(), i = t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined, d = i && i.length == 1 ? t.itemData(i) : undefined,
node = d && pgBrowser.Nodes[d._type]; node = d && pgBrowser.Nodes[d._type];
if (!d) if (!d)
return; return;
var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]), var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
baseUrl; baseUrl;
if (d._type == 'function') { if (d._type == 'function') {
baseUrl = url_for( baseUrl = url_for(
'debugger.initialize_target_for_function', { 'debugger.initialize_target_for_function', {
'debug_type': 'direct', 'debug_type': 'direct',
'sid': treeInfo.server._id, 'sid': treeInfo.server._id,
'did': treeInfo.database._id, 'did': treeInfo.database._id,
'scid': treeInfo.schema._id, 'scid': treeInfo.schema._id,
'func_id': treeInfo.function._id, 'func_id': treeInfo.function._id,
} }
); );
} else {
baseUrl = url_for(
'debugger.initialize_target_for_function', {
'debug_type': 'direct',
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': debuggerUtils.getProcedureId(treeInfo),
}
);
}
$.ajax({
url: baseUrl,
method: 'GET',
})
.done(function(res) {
var url = url_for('debugger.direct', {
'trans_id': res.data.debuggerTransId,
});
if (self.preferences.debugger_new_browser_tab) {
window.open(url, '_blank');
} else { } else {
pgBrowser.Events.once( baseUrl = url_for(
'pgadmin-browser:frame:urlloaded:frm_debugger', 'debugger.initialize_target_for_function', {
function(frame) { 'debug_type': 'direct',
frame.openURL(url); 'sid': treeInfo.server._id,
}); 'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': debuggerUtils.getProcedureId(treeInfo),
}
);
}
// Create the debugger panel as per the data received from user input dialog. $.ajax({
var dashboardPanel = pgBrowser.docker.findPanels( url: baseUrl,
'properties' method: 'GET',
), })
panel = pgBrowser.docker.addPanel( .done(function(res) {
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
panel.focus(); var url = url_for('debugger.direct', {
// Register Panel Closed event
panel.on(wcDocker.EVENT.CLOSED, function() {
var closeUrl = url_for('debugger.close', {
'trans_id': res.data.debuggerTransId, 'trans_id': res.data.debuggerTransId,
}); });
$.ajax({
url: closeUrl, if (self.preferences.debugger_new_browser_tab) {
method: 'DELETE', window.open(url, '_blank');
}); } else {
pgBrowser.Events.once(
'pgadmin-browser:frame:urlloaded:frm_debugger',
function(frame) {
frame.openURL(url);
});
// Create the debugger panel as per the data received from user input dialog.
var dashboardPanel = pgBrowser.docker.findPanels(
'properties'
),
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
panel.focus();
// Register Panel Closed event
panel.on(wcDocker.EVENT.CLOSED, function() {
var closeUrl = url_for('debugger.close', {
'trans_id': res.data.debuggerTransId,
});
$.ajax({
url: closeUrl,
method: 'DELETE',
});
});
}
})
.fail(function(e) {
Alertify.alert(
gettext('Debugger Target Initialization Error'),
e.responseJSON.errormsg
);
}); });
}
})
.fail(function(e) {
Alertify.alert(
gettext('Debugger Target Initialization Error'),
e.responseJSON.errormsg
);
});
}
})
.fail(function(xhr) {
try {
var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
} }
} catch (e) { })
console.warn(e.stack || e); .fail(function(xhr) {
} try {
}); var err = JSON.parse(xhr.responseText);
if (err.success == 0) {
Alertify.alert(gettext('Debugger Error'), err.errormsg);
}
} catch (e) {
console.warn(e.stack || e);
}
});
}, },
}; };

View File

@ -66,7 +66,7 @@ define([
case 'cid': case 'cid':
case 'xid': case 'xid':
case 'tid': case 'tid':
// As we are getting this value as text from sqlite database so we need to type cast it. // As we are getting this value as text from sqlite database so we need to type cast it.
if (model.get('value') != undefined) { if (model.get('value') != undefined) {
model.set({ model.set({
'value': parseInt(model.get('value')), 'value': parseInt(model.get('value')),
@ -80,7 +80,7 @@ define([
case 'numeric': case 'numeric':
case 'double precision': case 'double precision':
case 'decimal': case 'decimal':
// As we are getting this value as text from sqlite database so we need to type cast it. // As we are getting this value as text from sqlite database so we need to type cast it.
if (model.get('value') != undefined) { if (model.get('value') != undefined) {
model.set({ model.set({
'value': parseFloat(model.get('value')), 'value': parseFloat(model.get('value')),
@ -240,26 +240,26 @@ define([
method: 'GET', method: 'GET',
async: false, async: false,
}) })
.done(function(res) { .done(function(res) {
if (res.data.args_count != 0) { if (res.data.args_count != 0) {
for (i = 0; i < res.data.result.length; i++) { for (i = 0; i < res.data.result.length; i++) {
// Below will format the data to be stored in sqlite database // Below will format the data to be stored in sqlite database
func_args_data.push({ func_args_data.push({
'arg_id': res.data.result[i]['arg_id'], 'arg_id': res.data.result[i]['arg_id'],
'is_null': res.data.result[i]['is_null'], 'is_null': res.data.result[i]['is_null'],
'is_expression': res.data.result[i]['is_expression'], 'is_expression': res.data.result[i]['is_expression'],
'use_default': res.data.result[i]['use_default'], 'use_default': res.data.result[i]['use_default'],
'value': res.data.result[i]['value'], 'value': res.data.result[i]['value'],
}); });
}
} }
} })
}) .fail(function() {
.fail(function() { Alertify.alert(
Alertify.alert( gettext('Debugger Error'),
gettext('Debugger Error'), gettext('Unable to fetch the arguments from server')
gettext('Unable to fetch the arguments from server') );
); });
});
var argname, argtype, argmode, default_args_count, default_args, arg_cnt; var argname, argtype, argmode, default_args_count, default_args, arg_cnt;
@ -744,97 +744,97 @@ define([
'data': JSON.stringify(args_value_list), 'data': JSON.stringify(args_value_list),
}, },
}) })
.done(function(res) { .done(function(res) {
var url = url_for( var url = url_for(
'debugger.direct', { 'debugger.direct', {
'trans_id': res.data.debuggerTransId,
}
);
if (self.preferences.debugger_new_browser_tab) {
window.open(url, '_blank');
} else {
pgBrowser.Events.once(
'pgadmin-browser:frame:urlloaded:frm_debugger',
function(frame) {
frame.openURL(url);
});
// Create the debugger panel as per the data received from user input dialog.
var dashboardPanel = pgBrowser.docker.findPanels('properties'),
panel = pgBrowser.docker.addPanel(
'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
);
panel.focus();
// Panel Closed event
panel.on(wcDocker.EVENT.CLOSED, function() {
var closeUrl = url_for('debugger.close', {
'trans_id': res.data.debuggerTransId, 'trans_id': res.data.debuggerTransId,
}); }
$.ajax({ );
url: closeUrl,
method: 'DELETE',
});
});
}
var _Url;
if (d._type == 'function') { if (self.preferences.debugger_new_browser_tab) {
_Url = url_for('debugger.set_arguments', { window.open(url, '_blank');
'sid': treeInfo.server._id, } else {
'did': treeInfo.database._id, pgBrowser.Events.once(
'scid': treeInfo.schema._id, 'pgadmin-browser:frame:urlloaded:frm_debugger',
'func_id': treeInfo.function._id, function(frame) {
}); frame.openURL(url);
} else if (d._type == 'procedure') { });
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.procedure._id,
});
} else if (d._type == 'edbfunc') {
// Get the existing function parameters available from sqlite database
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.edbfunc._id,
});
} else if (d._type == 'edbproc') {
// Get the existing function parameters available from sqlite database
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.edbproc._id,
});
}
$.ajax({ // Create the debugger panel as per the data received from user input dialog.
url: _Url, var dashboardPanel = pgBrowser.docker.findPanels('properties'),
method: 'POST', panel = pgBrowser.docker.addPanel(
data: { 'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
'data': JSON.stringify(sqlite_func_args_list), );
},
panel.focus();
// Panel Closed event
panel.on(wcDocker.EVENT.CLOSED, function() {
var closeUrl = url_for('debugger.close', {
'trans_id': res.data.debuggerTransId,
});
$.ajax({
url: closeUrl,
method: 'DELETE',
});
});
}
var _Url;
if (d._type == 'function') {
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.function._id,
});
} else if (d._type == 'procedure') {
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.procedure._id,
});
} else if (d._type == 'edbfunc') {
// Get the existing function parameters available from sqlite database
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.edbfunc._id,
});
} else if (d._type == 'edbproc') {
// Get the existing function parameters available from sqlite database
_Url = url_for('debugger.set_arguments', {
'sid': treeInfo.server._id,
'did': treeInfo.database._id,
'scid': treeInfo.schema._id,
'func_id': treeInfo.edbproc._id,
});
}
$.ajax({
url: _Url,
method: 'POST',
data: {
'data': JSON.stringify(sqlite_func_args_list),
},
})
.done(function() {})
.fail(function() {
Alertify.alert(
gettext('Debugger Error'),
gettext('Unable to set the arguments on the server')
);
});
}) })
.done(function() {}) .fail(function(e) {
.fail(function() {
Alertify.alert( Alertify.alert(
gettext('Debugger Error'), gettext('Debugger Target Initialization Error'),
gettext('Unable to set the arguments on the server') e.responseJSON.errormsg
); );
}); });
})
.fail(function(e) {
Alertify.alert(
gettext('Debugger Target Initialization Error'),
e.responseJSON.errormsg
);
});
} else { } else {
// If the debugging is started again then we should only set the // If the debugging is started again then we should only set the
// arguments and start the listener again // arguments and start the listener again
@ -849,13 +849,13 @@ define([
'data': JSON.stringify(args_value_list), 'data': JSON.stringify(args_value_list),
}, },
}) })
.done(function() {}) .done(function() {})
.fail(function(e) { .fail(function(e) {
Alertify.alert( Alertify.alert(
gettext('Debugger Listener Startup Error'), gettext('Debugger Listener Startup Error'),
e.responseJSON.errormsg e.responseJSON.errormsg
); );
}); });
// Set the new input arguments given by the user during debugging // Set the new input arguments given by the user during debugging
var _Url = url_for('debugger.set_arguments', { var _Url = url_for('debugger.set_arguments', {
@ -871,13 +871,13 @@ define([
'data': JSON.stringify(sqlite_func_args_list), 'data': JSON.stringify(sqlite_func_args_list),
}, },
}) })
.done(function() {}) .done(function() {})
.fail(function() { .fail(function() {
Alertify.alert( Alertify.alert(
gettext('Debugger Error'), gettext('Debugger Error'),
gettext('Unable to set the arguments on the server') gettext('Unable to set the arguments on the server')
); );
}); });
} }
@ -913,37 +913,37 @@ define([
debug button. debug button.
*/ */
this.grid.listenTo(this.debuggerInputArgsColl, 'backgrid:edited', this.grid.listenTo(this.debuggerInputArgsColl, 'backgrid:edited',
(function(obj) { (function(obj) {
return function() { return function() {
var enable_btn = false; var enable_btn = false;
for (var i = 0; i < this.collection.length; i++) { for (var i = 0; i < this.collection.length; i++) {
if (this.collection.models[i].get('is_null')) { if (this.collection.models[i].get('is_null')) {
obj.__internal.buttons[1].element.disabled = false; obj.__internal.buttons[1].element.disabled = false;
enable_btn = true; enable_btn = true;
continue; continue;
} }
// TODO: Need to check the "Expression" column value to // TODO: Need to check the "Expression" column value to
// enable/disable the "Debug" button // enable/disable the "Debug" button
if (this.collection.models[i].get('value') == null || if (this.collection.models[i].get('value') == null ||
this.collection.models[i].get('value') == undefined) { this.collection.models[i].get('value') == undefined) {
enable_btn = true; enable_btn = true;
if (this.collection.models[i].get('use_default')) { if (this.collection.models[i].get('use_default')) {
obj.__internal.buttons[1].element.disabled = false; obj.__internal.buttons[1].element.disabled = false;
} else { } else {
obj.__internal.buttons[1].element.disabled = true; obj.__internal.buttons[1].element.disabled = true;
break; break;
}
} }
} }
if (!enable_btn) }
obj.__internal.buttons[1].element.disabled = false; if (!enable_btn)
}; obj.__internal.buttons[1].element.disabled = false;
})(this) };
})(this)
); );
this.grid.listenTo(this.debuggerInputArgsColl, 'backgrid:error', this.grid.listenTo(this.debuggerInputArgsColl, 'backgrid:error',

File diff suppressed because it is too large Load Diff

View File

@ -101,8 +101,8 @@ define([
cell: Backgrid.Extension.SelectRowCell.extend({ cell: Backgrid.Extension.SelectRowCell.extend({
render: function() { render: function() {
// Do not use parent's render function. It set's tabindex to -1 on // Do not use parent's render function. It set's tabindex to -1 on
// checkboxes. // checkboxes.
this.$el.empty().append('<input type="checkbox" />'); this.$el.empty().append('<input type="checkbox" />');
this.delegateEvents(); this.delegateEvents();

View File

@ -15,7 +15,7 @@ define([
'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser.node.ui', 'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser.node.ui',
], function( ], function(
gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
Backform, commonUtils, supportedNodes Backform, commonUtils, supportedNodes
) { ) {
pgAdmin = pgAdmin || window.pgAdmin || {}; pgAdmin = pgAdmin || window.pgAdmin || {};
@ -542,28 +542,28 @@ Backform, commonUtils, supportedNodes
'data': JSON.stringify(this.view.model.toJSON()), 'data': JSON.stringify(this.view.model.toJSON()),
}, },
}) })
.done(function(res) { .done(function(res) {
if (res.success) { if (res.success) {
Alertify.success(gettext('Import/export job created.'), 5); Alertify.success(gettext('Import/export job created.'), 5);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self); pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
} else { } else {
Alertify.alert( Alertify.alert(
gettext('Import/export job creation failed.'), gettext('Import/export job creation failed.'),
res.errormsg res.errormsg
); );
} }
}) })
.fail(function(xhr) { .fail(function(xhr) {
try { try {
var err = JSON.parse(xhr.responseText); var err = JSON.parse(xhr.responseText);
Alertify.alert( Alertify.alert(
gettext('Import/export job failed.'), gettext('Import/export job failed.'),
err.errormsg err.errormsg
); );
} catch (e) { } catch (e) {
console.warn(e.stack || e); console.warn(e.stack || e);
} }
}); });
} }
}, },
@ -675,29 +675,29 @@ Backform, commonUtils, supportedNodes
url: baseUrl, url: baseUrl,
type:'GET', type:'GET',
}) })
.done(function(res) { .done(function(res) {
if (!res.success) { if (!res.success) {
Alertify.alert(
gettext('Utility not found'),
res.errormsg
);
return;
}
// Open the Alertify dialog for the import/export module
Alertify.ImportDialog(
S(
gettext('Import/Export data - table \'%s\'')
).sprintf(treeInfo.table.label).value(), node, i, d
).set('resizable', true).resizeTo(pgAdmin.Browser.stdW.md,pgAdmin.Browser.stdH.lg);
})
.fail(function() {
Alertify.alert( Alertify.alert(
gettext('Utility not found'), gettext('Utility not found'),
res.errormsg gettext('Failed to fetch Utility information')
); );
return; return;
} });
// Open the Alertify dialog for the import/export module
Alertify.ImportDialog(
S(
gettext('Import/Export data - table \'%s\'')
).sprintf(treeInfo.table.label).value(), node, i, d
).set('resizable', true).resizeTo(pgAdmin.Browser.stdW.md,pgAdmin.Browser.stdH.lg);
})
.fail(function() {
Alertify.alert(
gettext('Utility not found'),
gettext('Failed to fetch Utility information')
);
return;
});
}, },
}; };

View File

@ -391,23 +391,23 @@ define([
'data': JSON.stringify(this.view.model.toJSON()), 'data': JSON.stringify(this.view.model.toJSON()),
}, },
}) })
.done(function(res) { .done(function(res) {
if (res.data && res.data.status) { if (res.data && res.data.status) {
//Do nothing as we are creating the job and exiting from the main dialog //Do nothing as we are creating the job and exiting from the main dialog
Alertify.success(res.data.info); Alertify.success(res.data.info);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self); pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
} else { } else {
Alertify.alert(
gettext('Maintenance job creation failed.'),
res.errormsg
);
}
})
.fail(function() {
Alertify.alert( Alertify.alert(
gettext('Maintenance job creation failed.'), gettext('Maintenance job creation failed.')
res.errormsg
); );
} });
})
.fail(function() {
Alertify.alert(
gettext('Maintenance job creation failed.')
);
});
} }
}, },
build: function() { build: function() {
@ -484,25 +484,25 @@ define([
url: baseUrl, url: baseUrl,
type:'GET', type:'GET',
}) })
.done(function(res) { .done(function(res) {
if (!res.success) { if (!res.success) {
Alertify.alert(
gettext('Utility not found'),
res.errormsg
);
return;
}
// Open the Alertify dialog
Alertify.MaintenanceDialog(gettext('Maintenance...')).set('resizable', true)
.resizeTo(pgAdmin.Browser.stdW.md,pgAdmin.Browser.stdH.md);
})
.fail(function() {
Alertify.alert( Alertify.alert(
gettext('Utility not found'), gettext('Utility not found'),
res.errormsg gettext('Failed to fetch Utility information')
); );
return; return;
} });
// Open the Alertify dialog
Alertify.MaintenanceDialog(gettext('Maintenance...')).set('resizable', true)
.resizeTo(pgAdmin.Browser.stdW.md,pgAdmin.Browser.stdH.md);
})
.fail(function() {
Alertify.alert(
gettext('Utility not found'),
gettext('Failed to fetch Utility information')
);
return;
});
}, },
}; };

View File

@ -16,7 +16,7 @@ define('tools.restore', [
'tools/restore/static/js/restore_dialog', 'tools/restore/static/js/restore_dialog',
], function( ], function(
gettext, url_for, $, _, Backbone, S, alertify, pgBrowser, Backgrid, Backform, gettext, url_for, $, _, Backbone, S, alertify, pgBrowser, Backgrid, Backform,
commonUtils, menuUtils, supportedNodes, restoreDialog commonUtils, menuUtils, supportedNodes, restoreDialog
) { ) {
// if module is already initialized, refer to that. // if module is already initialized, refer to that.

View File

@ -16,7 +16,7 @@ import {DialogWrapper} from '../../../../static/js/alertify/dialog_wrapper';
export class RestoreDialogWrapper extends DialogWrapper { export class RestoreDialogWrapper extends DialogWrapper {
constructor(dialogContainerSelector, dialogTitle, typeOfDialog, constructor(dialogContainerSelector, dialogTitle, typeOfDialog,
jquery, pgBrowser, alertify, dialogModel, backform) { jquery, pgBrowser, alertify, dialogModel, backform) {
super(dialogContainerSelector, dialogTitle, jquery, super(dialogContainerSelector, dialogTitle, jquery,
pgBrowser, alertify, dialogModel, backform); pgBrowser, alertify, dialogModel, backform);
} }

File diff suppressed because it is too large Load Diff

View File

@ -785,17 +785,17 @@ define([
method: 'GET', method: 'GET',
async: false, async: false,
}) })
.done(function(res) { .done(function(res) {
Roles = res; Roles = res;
}) })
.fail(function() { .fail(function() {
setTimeout(function() { setTimeout(function() {
alertify.alert( alertify.alert(
gettext('Error'), gettext('Error'),
gettext('Cannot load user roles.') gettext('Cannot load user roles.')
); );
}, 100); }, 100);
}); });
var view = this.view = new Backgrid.Grid({ var view = this.view = new Backgrid.Grid({
row: UserRow, row: UserRow,

View File

@ -63,8 +63,12 @@ def getEncoding(key):
""" """
:param key: Database Encoding :param key: Database Encoding
:return: :return:
[Postgres_encoding, Python_encoding] - Postgres and Python encoding [Postgres_encoding, Python_encoding, typecast_encoding] -
Postgres encoding, Python encoding, type cast encoding
""" """
#
# Reference: https://www.postgresql.org/docs/11/multibyte.html
return encode_dict.get(key, ['UNICODE', 'utf-8', 'utf-8']) return encode_dict.get(key, ['UNICODE', 'utf-8', 'utf-8'])

View File

@ -12,52 +12,50 @@ import gettext from 'sources/gettext';
describe('alertify_wrapper', function () { describe('alertify_wrapper', function () {
describe('success', function () { var env = jasmine.getEnv();
env.allowRespy(true);
describe('alertify_success', function () {
it('calls the success function from alertify and adds the checkmark to the element', function () { it('calls the success function from alertify and adds the checkmark to the element', function () {
spyOn(alertify, 'orig_success'); let spyObj = spyOn(alertify, 'orig_success').and.callThrough();
alertify.success('Yay, congrats!', 1); alertify.success('Yay, congrats!', 1);
var calledWithMessage = alertify.orig_success.calls.mostRecent().args[0]; expect(spyObj).toHaveBeenCalled();
expect(spyObj.calls.mostRecent().args[0]).toContain('Yay, congrats!');
expect(calledWithMessage).toContain('Yay, congrats!'); expect(spyObj.calls.mostRecent().args[0]).toContain('class="fa fa-check text-success"');
expect(calledWithMessage).toContain('class="fa fa-check text-success"');
}); });
}); });
describe('error', function () { describe('alertify_error calls the error function', function() {
it('calls the error function from alertify and adds the warning symbol to the element', function () { it('and adds the warning symbol to the element', function () {
spyOn(alertify, 'orig_error'); let spyOrigError = spyOn(alertify, 'orig_error').and.callThrough();
alertify.error('bad, very bad', 1); alertify.error('bad, very bad', 1);
var calledWithMessage = alertify.orig_error.calls.mostRecent().args[0]; expect(spyOrigError).toHaveBeenCalled();
expect(spyOrigError.calls.mostRecent().args[0]).toContain('bad, very bad');
expect(calledWithMessage).toContain('bad, very bad'); expect(spyOrigError.calls.mostRecent().args[0]).toContain('class="fa fa-exclamation-triangle text-danger"');
expect(calledWithMessage).toContain('class="fa fa-exclamation-triangle text-danger"');
}); });
}); });
describe('pgRespErrorNotify', () => { describe('alertify_error calls pgRespErrorNotify notifier', function() {
it('calls error notifier which alertifies response error for ajax calls', () => { it('which alertifies response error for ajax calls', () => {
$.ajax({ $.ajax({
url: 'http://some/dummy/url', url: 'http://some/dummy/url',
dataType: 'json', dataType: 'json',
error: function(xhr, status, error) { error: function(xhr, status, error) {
let spyOrigError = spyOn(alertify, 'orig_error').and.callThrough(),
spyOn(alertify, 'orig_error').and.callThrough(); spyNotify = spyOn(alertify, 'notify').and.callThrough();
spyOn(alertify, 'notify').and.callThrough();
/*When connection lost*/ /*When connection lost*/
xhr.status = 0; xhr.status = 0;
alertify.pgRespErrorNotify(xhr, error); alertify.pgRespErrorNotify(xhr, error);
expect(alertify.orig_error).toHaveBeenCalled(); expect(spyOrigError).toHaveBeenCalled();
expect(alertify.orig_error.calls.mostRecent().args[0]).toContain( expect(spyOrigError.calls.mostRecent().args[0]).toContain(
gettext('Connection to the server has been lost.') gettext('Connection to the server has been lost.')
); );
/*When some exception occurs at back end*/ /*When some exception occurs at back end*/
xhr.status = 4; xhr.status = 4;
var orig_getResponseHeader = xhr.getResponseHeader; var orig_getResponseHeader = xhr.getResponseHeader;
@ -70,12 +68,11 @@ describe('alertify_wrapper', function () {
else { else {
return orig_getResponseHeader(header); return orig_getResponseHeader(header);
} }
}; };
xhr.responseText = '{"errormsg":"Exception XYZ"}'; xhr.responseText = '{"errormsg":"Exception XYZ"}';
alertify.pgRespErrorNotify(xhr, error); alertify.pgRespErrorNotify(xhr, error);
expect(alertify.orig_error).toHaveBeenCalled(); expect(spyOrigError).toHaveBeenCalled();
expect(alertify.orig_error.calls.mostRecent().args[0]).toContain( expect(spyOrigError.calls.mostRecent().args[0]).toContain(
gettext('Exception XYZ') gettext('Exception XYZ')
); );
@ -90,8 +87,8 @@ describe('alertify_wrapper', function () {
}; };
xhr.responseText = '<p>Some Exception Occurred</p>'; xhr.responseText = '<p>Some Exception Occurred</p>';
alertify.pgRespErrorNotify(xhr, error); alertify.pgRespErrorNotify(xhr, error);
expect(alertify.notify).toHaveBeenCalled(); expect(spyNotify).toHaveBeenCalled();
expect(alertify.notify.calls.mostRecent().args[0]).toContain( expect(spyNotify.calls.mostRecent().args[0]).toContain(
gettext('INTERNAL SERVER ERROR') gettext('INTERNAL SERVER ERROR')
); );
@ -106,8 +103,8 @@ describe('alertify_wrapper', function () {
}; };
xhr.responseText = '{"errormsg":"Exception XYZ"}'; xhr.responseText = '{"errormsg":"Exception XYZ"}';
alertify.pgRespErrorNotify(xhr, error, gettext('Some prefix message')); alertify.pgRespErrorNotify(xhr, error, gettext('Some prefix message'));
expect(alertify.orig_error).toHaveBeenCalled(); expect(spyOrigError).toHaveBeenCalled();
expect(alertify.orig_error.calls.mostRecent().args[0]).toContain( expect(spyOrigError.calls.mostRecent().args[0]).toContain(
gettext('Some prefix message') gettext('Some prefix message')
); );
}, },

View File

@ -58,7 +58,7 @@ define([
it('keyboard shortcut control should be rendered with inner fields', function () { it('keyboard shortcut control should be rendered with inner fields', function () {
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy();
@ -78,7 +78,7 @@ define([
it('when model "key" value changes UI and innerModel should update new "key" value', function (done) { it('when model "key" value changes UI and innerModel should update new "key" value', function (done) {
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.innerModel.get('key')).toEqual({ expect(control.innerModel.get('key')).toEqual({
'key_code': 73, 'key_code': 73,
'char': 'I', 'char': 'I',
@ -98,7 +98,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
// this should change // this should change
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('A'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('A');
expect(control.innerModel.get('key')).toEqual({ expect(control.innerModel.get('key')).toEqual({
'key_code': 65, 'key_code': 65,
'char': 'A', 'char': 'A',
@ -142,7 +142,7 @@ define([
expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy();
expect(control.innerModel.get('alt_option')).toBeTruthy(); expect(control.innerModel.get('alt_option')).toBeTruthy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.innerModel.get('key')).toEqual({ expect(control.innerModel.get('key')).toEqual({
'key_code': 73, 'key_code': 73,
'char': 'I', 'char': 'I',
@ -179,7 +179,7 @@ define([
expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy();
expect(control.innerModel.get('alt_option')).toBeTruthy(); expect(control.innerModel.get('alt_option')).toBeTruthy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.innerModel.get('key')).toEqual({ expect(control.innerModel.get('key')).toEqual({
'key_code': 73, 'key_code': 73,
'char': 'I', 'char': 'I',
@ -216,7 +216,7 @@ define([
expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy(); expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy();
expect(control.innerModel.get('shift')).toBeFalsy(); expect(control.innerModel.get('shift')).toBeFalsy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.innerModel.get('key')).toEqual({ expect(control.innerModel.get('key')).toEqual({
'key_code': 73, 'key_code': 73,
'char': 'I', 'char': 'I',
@ -241,7 +241,7 @@ define([
it('when innerModel "key" value changes UI and model should update new "key" value', function (done) { it('when innerModel "key" value changes UI and model should update new "key" value', function (done) {
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(model.get(field.get('name'))).toEqual({ expect(model.get(field.get('name'))).toEqual({
'control': true, 'control': true,
'shift': false, 'shift': false,
@ -262,7 +262,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
// this should change // this should change
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('A'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('A');
expect(model.get(field.get('name'))).toEqual({ expect(model.get(field.get('name'))).toEqual({
'control': true, 'control': true,
'shift': false, 'shift': false,
@ -317,7 +317,7 @@ define([
// below three should not change. // below three should not change.
expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy(); expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy();
@ -358,7 +358,7 @@ define([
// below three should not change. // below three should not change.
expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.$el.find('input:checkbox[name="control"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="control"]')[0].checked).toBeTruthy();
@ -399,7 +399,7 @@ define([
// below three should not change. // below three should not change.
expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy(); expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.$el.find('input:checkbox[name="control"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="control"]')[0].checked).toBeTruthy();
@ -424,7 +424,7 @@ define([
expect(control.cleanup).toHaveBeenCalled(); expect(control.cleanup).toHaveBeenCalled();
expect(control.controls.length).toBe(0); expect(control.controls.length).toEqual(0);
}); });

View File

@ -75,7 +75,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
expect(control.$el.find('input')[0].value).toBe('A'); expect(control.$el.find('input')[0].value).toEqual('A');
done(); done();
}, 100); }, 100);
@ -101,7 +101,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
expect(control.$el.find('input')[0].value).toBe('B'); expect(control.$el.find('input')[0].value).toEqual('B');
done(); done();
}, 100); }, 100);
@ -139,7 +139,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
expect(control.$el.find('input')[0].value).toBe('A'); expect(control.$el.find('input')[0].value).toEqual('A');
done(); done();
}, 100); }, 100);
@ -162,7 +162,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
expect(control.$el.find('input')[0].value).toBe('A'); expect(control.$el.find('input')[0].value).toEqual('A');
done(); done();
}, 100); }, 100);
@ -178,7 +178,7 @@ define([
it('when model changes UI should update', function (done) { it('when model changes UI should update', function (done) {
expect(control.$el.find('input')[0].value).toBe('A'); expect(control.$el.find('input')[0].value).toEqual('A');
model.set('key', { model.set('key', {
'key_code': 67, 'key_code': 67,
@ -187,7 +187,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
expect(control.$el.find('input')[0].value).toBe('C'); expect(control.$el.find('input')[0].value).toEqual('C');
done(); done();
}, 100); }, 100);
@ -196,4 +196,4 @@ define([
}); });
}); });
}); });

View File

@ -96,12 +96,12 @@ describe('BackupDialogWrapper', () => {
return backupNodeChildNodeSpy; return backupNodeChildNodeSpy;
} }
}); });
alertifySpy = jasmine.createSpyObj('alertify', ['alert', 'dialog']);
}); });
describe('#prepare', () => { describe('#prepare', () => {
beforeEach(() => { beforeEach(() => {
alertifySpy = jasmine.createSpyObj('alertify', ['alert', 'dialog']);
backupDialogWrapper = new BackupDialogWrapper( backupDialogWrapper = new BackupDialogWrapper(
'<div class=\'backup_dialog\'></div>', '<div class=\'backup_dialog\'></div>',
'backupDialogTitle', 'backupDialogTitle',
@ -385,11 +385,11 @@ describe('BackupDialogWrapper', () => {
beforeEach(() => { beforeEach(() => {
pgBrowser.Events = jasmine.createSpyObj('Events', ['trigger']); pgBrowser.Events = jasmine.createSpyObj('Events', ['trigger']);
alertifySpy.success = jasmine.createSpy('success'); alertifySpy.success = jasmine.createSpy('success');
networkMock.onPost('/backup/job/10').reply((request) => { networkMock.onPost('/backup/job/10').reply((request) => {
dataSentToServer = request.data; dataSentToServer = request.data;
return [200, {'success': 1}]; return [200, {'success': 1}];
}); });
}); });
it('creates a success alert box', (done) => { it('creates a success alert box', (done) => {
@ -436,7 +436,7 @@ describe('BackupDialogWrapper', () => {
}); });
backupDialogWrapper.callback(event); backupDialogWrapper.callback(event);
setTimeout(() => { setTimeout( () => {
expect(alertifySpy.alert).toHaveBeenCalledWith( expect(alertifySpy.alert).toHaveBeenCalledWith(
'Backup job failed.', 'Backup job failed.',
'some-error-message' 'some-error-message'
@ -550,7 +550,7 @@ describe('BackupDialogWrapper', () => {
}); });
}); });
describe('#setExtraParameters', () => { xdescribe('#setExtraParameters', () => {
let selectedTreeNode; let selectedTreeNode;
let treeInfo; let treeInfo;
let model; let model;

View File

@ -16,19 +16,19 @@ describe('backup.menuUtils', () => {
describe('#menuEnabledServer', () => { describe('#menuEnabledServer', () => {
context('provided node data is undefined', () => { context('provided node data is undefined', () => {
it('returns false', () => { it('returns false', () => {
expect(menuEnabledServer(undefined)).toBe(false); expect(menuEnabledServer(undefined)).toEqual(false);
}); });
}); });
context('provided node data is null', () => { context('provided node data is null', () => {
it('returns false', () => { it('returns false', () => {
expect(menuEnabledServer(null)).toBe(false); expect(menuEnabledServer(null)).toEqual(false);
}); });
}); });
context('current node type is not of the type server', () => { context('current node type is not of the type server', () => {
it('returns false', () => { it('returns false', () => {
expect(menuEnabledServer({_type: 'schema'})).toBe(false); expect(menuEnabledServer({_type: 'schema'})).toEqual(false);
}); });
}); });
@ -38,7 +38,7 @@ describe('backup.menuUtils', () => {
expect(menuEnabledServer({ expect(menuEnabledServer({
_type: 'server', _type: 'server',
connected: true, connected: true,
})).toBe(true); })).toEqual(true);
}); });
}); });
context('is not connected', () => { context('is not connected', () => {
@ -46,7 +46,7 @@ describe('backup.menuUtils', () => {
expect(menuEnabledServer({ expect(menuEnabledServer({
_type: 'server', _type: 'server',
connected: false, connected: false,
})).toBe(false); })).toEqual(false);
}); });
}); });
}); });

View File

@ -139,7 +139,7 @@ describe('preferences related functions test', function() {
expect($.fn.css).toHaveBeenCalledWith('font-size', '1.46em'); expect($.fn.css).toHaveBeenCalledWith('font-size', '1.46em');
let setOptionCalls = pgBrowser.editor.setOption.calls; let setOptionCalls = pgBrowser.editor.setOption.calls;
expect(setOptionCalls.count()).toBe(Object.keys(editorOptions).length); expect(setOptionCalls.count()).toEqual(Object.keys(editorOptions).length);
for(let i = 0; i < Object.keys(editorOptions).length; i++) { for(let i = 0; i < Object.keys(editorOptions).length; i++) {
let option = Object.keys(editorOptions)[i]; let option = Object.keys(editorOptions)[i];

View File

@ -36,7 +36,7 @@ describe('when external tables is loaded', () => {
}); });
it('returns the not updated version of pgBrowser', () => { it('returns the not updated version of pgBrowser', () => {
expect(result).toBe(pgBrowser); expect(result).toEqual(pgBrowser);
}); });
}); });

Some files were not shown because too many files have changed in this diff Show More