Improved alertify notification logic. Remove AlertifyWrapper class and extend notification methods in alertify itself.

This commit is contained in:
Akshay Joshi
2017-07-31 18:59:44 +05:30
parent a7f58e2b92
commit e506fa1dbe
29 changed files with 220 additions and 352 deletions

View File

@@ -1,10 +1,7 @@
define('pgadmin.node.cast', [ define('pgadmin.node.cast', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'pgadmin', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'pgadmin',
'pgadmin.browser', 'alertify', 'pgadmin.browser', 'pgadmin.alertifyjs', 'pgadmin.browser.collection'
'sources/alerts/alertify_wrapper', ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
'pgadmin.browser.collection'
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, AlertifyWrapper) {
// Extend the collection class for cast // Extend the collection class for cast
if (!pgBrowser.Nodes['coll-cast']) { if (!pgBrowser.Nodes['coll-cast']) {
var casts = pgAdmin.Browser.Nodes['coll-cast'] = var casts = pgAdmin.Browser.Nodes['coll-cast'] =
@@ -215,8 +212,7 @@ define('pgadmin.node.cast', [
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
} }

View File

@@ -1,10 +1,8 @@
define('pgadmin.node.synonym', [ define('pgadmin.node.synonym', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify', 'underscore.string', 'pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
'sources/alerts/alertify_wrapper',
'pgadmin.browser.collection' 'pgadmin.browser.collection'
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, AlertifyWrapper) { ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
if (!pgBrowser.Nodes['coll-synonym']) { if (!pgBrowser.Nodes['coll-synonym']) {
var databases = pgAdmin.Browser.Nodes['coll-synonym'] = var databases = pgAdmin.Browser.Nodes['coll-synonym'] =
@@ -169,8 +167,7 @@ define('pgadmin.node.synonym', [
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
} }

View File

@@ -1,11 +1,9 @@
// Check Constraint Module: Node // Check Constraint Module: Node
define('pgadmin.node.check_constraint', [ define('pgadmin.node.check_constraint', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify', 'underscore.string', 'pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
'sources/alerts/alertify_wrapper',
'pgadmin.browser.collection' 'pgadmin.browser.collection'
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, AlertifyWrapper) { ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
// Check Constraint Node // Check Constraint Node
if (!pgBrowser.Nodes['check_constraints']) { if (!pgBrowser.Nodes['check_constraints']) {
@@ -66,8 +64,7 @@ define('pgadmin.node.check_constraint', [
type:'GET', type:'GET',
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.success(res.info);
t.removeIcon(i); t.removeIcon(i);
data.valid = true; data.valid = true;
data.icon = 'icon-check_constraints'; data.icon = 'icon-check_constraints';
@@ -80,8 +77,7 @@ define('pgadmin.node.check_constraint', [
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);

View File

@@ -1,10 +1,8 @@
define('pgadmin.node.foreign_key', [ define('pgadmin.node.foreign_key', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify', 'underscore.string', 'pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
'sources/alerts/alertify_wrapper',
'pgadmin.browser.collection' 'pgadmin.browser.collection'
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, AlertifyWrapper) { ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
var formatNode = function(opt) { var formatNode = function(opt) {
if (!opt.id) { if (!opt.id) {
@@ -655,8 +653,7 @@ define('pgadmin.node.foreign_key', [
type:'GET', type:'GET',
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.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';
@@ -669,8 +666,7 @@ define('pgadmin.node.foreign_key', [
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);

View File

@@ -1,10 +1,9 @@
define([ define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'pgadmin.browser', 'backform', 'alertify', 'underscore.string', 'pgadmin', 'pgadmin.browser', 'backform', 'pgadmin.alertifyjs',
'sources/alerts/alertify_wrapper',
'pgadmin.browser.collection', 'pgadmin.browser.table.partition.utils' 'pgadmin.browser.collection', 'pgadmin.browser.table.partition.utils'
], ],
function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, AlertifyWrapper) { function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
if (!pgBrowser.Nodes['coll-partition']) { if (!pgBrowser.Nodes['coll-partition']) {
var databases = pgAdmin.Browser.Nodes['coll-partition'] = var databases = pgAdmin.Browser.Nodes['coll-partition'] =
@@ -164,8 +163,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.success(res.info);
t.unload(i); t.unload(i);
t.setInode(i); t.setInode(i);
t.deselect(i); t.deselect(i);
@@ -178,8 +176,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -219,8 +216,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.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});
@@ -237,8 +233,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -269,8 +264,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
type:'DELETE', type:'DELETE',
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.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});
@@ -287,8 +281,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -320,8 +313,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
type:'PUT', type:'PUT',
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.success(res.info);
var n = t.next(i); var n = t.next(i);
if (!n || !n.length) { if (!n || !n.length) {
n = t.prev(i); n = t.prev(i);
@@ -340,8 +332,7 @@ function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, Aler
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
} }

View File

@@ -1,12 +1,10 @@
define('pgadmin.node.table', [ define('pgadmin.node.table', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify', 'underscore.string', 'pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
'sources/alerts/alertify_wrapper',
'pgadmin.browser.collection', 'pgadmin.node.column', 'pgadmin.browser.collection', 'pgadmin.node.column',
'pgadmin.node.constraints', 'pgadmin.browser.table.partition.utils' 'pgadmin.node.constraints', 'pgadmin.browser.table.partition.utils'
], function( ], function(
gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, AlertifyWrapper gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
) {
if (!pgBrowser.Nodes['coll-table']) { if (!pgBrowser.Nodes['coll-table']) {
var databases = pgBrowser.Nodes['coll-table'] = var databases = pgBrowser.Nodes['coll-table'] =
@@ -129,8 +127,7 @@ define('pgadmin.node.table', [
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.success(res.info);
t.unload(i); t.unload(i);
t.setInode(i); t.setInode(i);
t.deselect(i); t.deselect(i);
@@ -143,8 +140,7 @@ define('pgadmin.node.table', [
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -184,8 +180,7 @@ define('pgadmin.node.table', [
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.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});
@@ -202,8 +197,7 @@ define('pgadmin.node.table', [
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -234,8 +228,7 @@ define('pgadmin.node.table', [
type:'DELETE', type:'DELETE',
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.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});
@@ -252,8 +245,7 @@ define('pgadmin.node.table', [
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);

View File

@@ -1,9 +1,8 @@
define('pgadmin.node.trigger', [ define('pgadmin.node.trigger', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'pgadmin.browser', 'backform', 'alertify', 'underscore.string', 'pgadmin', 'pgadmin.browser', 'backform', 'pgadmin.alertifyjs',
'sources/alerts/alertify_wrapper',
'pgadmin.browser.collection' 'pgadmin.browser.collection'
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify, AlertifyWrapper) { ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Backform, alertify) {
var CustomSwitchControl = Backform.CustomSwitchControl = Backform.SwitchControl.extend({ var CustomSwitchControl = Backform.CustomSwitchControl = Backform.SwitchControl.extend({
template: _.template([ template: _.template([
@@ -118,8 +117,7 @@ define('pgadmin.node.trigger', [
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.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});
@@ -136,8 +134,7 @@ define('pgadmin.node.trigger', [
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -163,8 +160,7 @@ define('pgadmin.node.trigger', [
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.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});
@@ -181,8 +177,7 @@ define('pgadmin.node.trigger', [
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);

View File

@@ -1,10 +1,8 @@
define('pgadmin.node.mview', [ define('pgadmin.node.mview', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'alertify', 'pgadmin.browser', 'codemirror', 'underscore.string', 'pgadmin', 'pgadmin.alertifyjs', 'pgadmin.browser', 'codemirror',
'sources/alerts/alertify_wrapper',
'pgadmin.browser.server.privilege' 'pgadmin.browser.server.privilege'
], function(gettext, url_for, $, _, S, pgAdmin, alertify, pgBrowser, CodeMirror, AlertifyWrapper) { ], function(gettext, url_for, $, _, S, pgAdmin, alertify, pgBrowser, CodeMirror) {
/** /**
Create and add a view collection into nodes Create and add a view collection into nodes
@@ -294,8 +292,7 @@ define('pgadmin.node.mview', [
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success('View refreshed successfully');
alertifyWrapper.success('View refreshed successfully');
} }
else { else {
alertify.alert( alertify.alert(

View File

@@ -1,11 +1,9 @@
define('pgadmin.node.database', [ define('pgadmin.node.database', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'pgadmin.browser.utils', 'alertify', 'underscore.string', 'pgadmin', 'pgadmin.browser.utils', 'pgadmin.alertifyjs',
'sources/alerts/alertify_wrapper',
'pgadmin.browser.collection', 'pgadmin.browser.server.privilege', 'pgadmin.browser.collection', 'pgadmin.browser.server.privilege',
'pgadmin.browser.server.variable', 'pgadmin.browser.server.variable'
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, AlertifyWrapper) { ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify) {
if (!pgBrowser.Nodes['coll-database']) { if (!pgBrowser.Nodes['coll-database']) {
var databases = pgBrowser.Nodes['coll-database'] = var databases = pgBrowser.Nodes['coll-database'] =
@@ -192,9 +190,8 @@ define('pgadmin.node.database', [
type:'DELETE', type:'DELETE',
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var prv_i = t.parent(i), var prv_i = t.parent(i);
alertifyWrapper = new AlertifyWrapper(); Alertify.success(res.info);
alertifyWrapper.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';
@@ -208,8 +205,7 @@ define('pgadmin.node.database', [
} }
else { else {
try { try {
var alertifyWrapper = new AlertifyWrapper(); Alertify.error(res.errormsg);
alertifyWrapper.error(res.errormsg);
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
} }
@@ -218,8 +214,7 @@ define('pgadmin.node.database', [
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); Alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -516,8 +511,7 @@ define('pgadmin.node.database', [
tree.addIcon(item, {icon: data.icon}); tree.addIcon(item, {icon: data.icon});
} }
var alertifyWrapper = new AlertifyWrapper(); Alertify.success(res.info);
alertifyWrapper.success(res.info);
obj.trigger('connected', obj, item, data); obj.trigger('connected', obj, item, data);
pgBrowser.Events.trigger( pgBrowser.Events.trigger(
'pgadmin:database:connected', item, data 'pgadmin:database:connected', item, data

View File

@@ -1,10 +1,8 @@
define('pgadmin.node.pga_job', [ define('pgadmin.node.pga_job', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify', 'underscore.string', 'pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
'sources/alerts/alertify_wrapper',
'pgadmin.node.pga_jobstep', 'pgadmin.node.pga_schedule' 'pgadmin.node.pga_jobstep', 'pgadmin.node.pga_schedule'
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, Alertify, AlertifyWrapper) { ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
if (!pgBrowser.Nodes['coll-pga_job']) { if (!pgBrowser.Nodes['coll-pga_job']) {
var pga_jobs = pgBrowser.Nodes['coll-pga_job'] = var pga_jobs = pgBrowser.Nodes['coll-pga_job'] =
@@ -181,18 +179,17 @@ define('pgadmin.node.pga_job', [
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
var error_msg = "Unable to run pgagent job."; var error_msg = "Unable to run pgagent job.";
var alertifyWrapper = new AlertifyWrapper();
if (xhr.readyState == 0) { if (xhr.readyState == 0) {
alertifyWrapper.error(gettext('Not connected to the server or the connection to the server has been closed.')); alertify.error(gettext('Not connected to the server or the connection to the server has been closed.'));
} }
else { else {
if (_.isUndefined(xhr.responseText)) { if (_.isUndefined(xhr.responseText)) {
alertifyWrapper.error(error_msg); alertify.error(error_msg);
} }
else { else {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
alertifyWrapper.error(err.errormsg); alertify.error(err.errormsg);
} }
} }
} }

View File

@@ -1,12 +1,12 @@
define('pgadmin.node.server', [ define('pgadmin.node.server', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify', 'underscore.string', 'pgadmin', 'pgadmin.browser',
'pgadmin.server.supported_servers', 'pgadmin.server.supported_servers',
'pgadmin.user_management.current_user', 'pgadmin.user_management.current_user',
'sources/alerts/alertify_wrapper', 'pgadmin.browser.server.privilege' 'pgadmin.alertifyjs', 'pgadmin.browser.server.privilege'
], function( ], function(
gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, gettext, url_for, $, _, S, pgAdmin, pgBrowser,
supported_servers, current_user, AlertifyWrapper supported_servers, current_user, alertify
) { ) {
if (!pgBrowser.Nodes['server']) { if (!pgBrowser.Nodes['server']) {
@@ -189,8 +189,7 @@ define('pgadmin.node.server', [
type:'DELETE', type:'DELETE',
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.success(res.info);
d = t.itemData(i); d = t.itemData(i);
t.removeIcon(i); t.removeIcon(i);
d.connected = false; d.connected = false;
@@ -209,8 +208,7 @@ define('pgadmin.node.server', [
} }
else { else {
try { try {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(res.errormsg);
alertifyWrapper.error(res.errormsg);
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
} }
@@ -219,8 +217,7 @@ define('pgadmin.node.server', [
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -288,20 +285,17 @@ define('pgadmin.node.server', [
method:'GET', method:'GET',
success: function(res) { success: function(res) {
if (res.data.status) { if (res.data.status) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.data.result);
alertifyWrapper.success(res.data.result);
} }
else { else {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(res.data.result);
alertifyWrapper.error(res.data.result);
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -336,15 +330,13 @@ define('pgadmin.node.server', [
method:'POST', method:'POST',
data:{ 'value': JSON.stringify(value) }, data:{ 'value': JSON.stringify(value) },
success: function(res) { success: function(res) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.data.result, 10);
alertifyWrapper.success(res.data.result, 10);
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg, 10);
alertifyWrapper.error(err.errormsg, 10);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -352,8 +344,7 @@ define('pgadmin.node.server', [
}); });
} else { } else {
evt.cancel = true; evt.cancel = true;
var alertifyWrapper = new AlertifyWrapper(); alertify.error( gettext('Please enter a valid name.'), 10);
alertifyWrapper.error( gettext('Please enter a valid name.'), 10);
} }
}, },
// We will execute this function when user clicks on the Cancel button // We will execute this function when user clicks on the Cancel button
@@ -494,20 +485,18 @@ define('pgadmin.node.server', [
method:'POST', method:'POST',
data:{'data': JSON.stringify(args) }, data:{'data': JSON.stringify(args) },
success: function(res) { success: function(res) {
var alertifyWrapper = new AlertifyWrapper();
if (res.success) { if (res.success) {
alertifyWrapper.success(res.info); alertify.success(res.info);
self.close(); self.close();
} else { } else {
alertifyWrapper.error(res.errormsg); alertify.error(res.errormsg);
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
} }
@@ -540,8 +529,7 @@ define('pgadmin.node.server', [
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.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.unload(i);
t.setInode(i); t.setInode(i);
@@ -557,8 +545,7 @@ define('pgadmin.node.server', [
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
msg = S(err.errormsg).value(); msg = S(err.errormsg).value();
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -584,8 +571,7 @@ define('pgadmin.node.server', [
dataType: "json", dataType: "json",
success: function(res) { success: function(res) {
if (res.success == 1) { if (res.success == 1) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.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.unload(i);
t.setInode(i); t.setInode(i);
@@ -601,8 +587,7 @@ define('pgadmin.node.server', [
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
msg = S(err.errormsg).value(); msg = S(err.errormsg).value();
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
t.unload(i); t.unload(i);
@@ -908,8 +893,7 @@ define('pgadmin.node.server', [
pgBrowser.serverInfo || {}; pgBrowser.serverInfo || {};
serverInfo[data._id] = _.extend({}, data); serverInfo[data._id] = _.extend({}, data);
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.success(res.info);
obj.trigger('connected', obj, item, data); obj.trigger('connected', obj, item, data);
// Generate the event that server is connected // Generate the event that server is connected

View File

@@ -1,11 +1,9 @@
define('pgadmin.node.tablespace', [ define('pgadmin.node.tablespace', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify', 'underscore.string', 'pgadmin', 'pgadmin.browser', 'pgadmin.alertifyjs',
'sources/alerts/alertify_wrapper',
'pgadmin.browser.collection', 'pgadmin.browser.node.ui', 'pgadmin.browser.collection', 'pgadmin.browser.node.ui',
'pgadmin.browser.server.privilege' 'pgadmin.browser.server.privilege'
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify, AlertifyWrapper) { ], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
if (!pgBrowser.Nodes['coll-tablespace']) { if (!pgBrowser.Nodes['coll-tablespace']) {
var databases = pgBrowser.Nodes['coll-tablespace'] = var databases = pgBrowser.Nodes['coll-tablespace'] =
@@ -280,20 +278,17 @@ define('pgadmin.node.tablespace', [
data:{'data': JSON.stringify(args) }, data:{'data': JSON.stringify(args) },
success: function(res) { success: function(res) {
if (res.success) { if (res.success) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(res.info);
alertifyWrapper.success(res.info);
self.close(); self.close();
} else { } else {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(res.errormsg);
alertifyWrapper.error(res.errormsg);
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
} }

View File

@@ -1,10 +1,10 @@
define( define(
'pgadmin.browser', [ 'pgadmin.browser', [
'sources/gettext', 'sources/url_for', 'require', 'jquery', 'underscore', 'underscore.string', 'sources/gettext', 'sources/url_for', 'require', 'jquery', 'underscore', 'underscore.string',
'bootstrap', 'pgadmin', 'alertify', 'bundled_codemirror', 'bootstrap', 'pgadmin', 'pgadmin.alertifyjs', 'bundled_codemirror',
'sources/check_node_visibility', 'pgadmin.browser.utils', 'wcdocker', 'sources/check_node_visibility', 'pgadmin.browser.utils', 'wcdocker',
'jquery.contextmenu', 'jquery.aciplugin', 'jquery.acitree', 'jquery.contextmenu', 'jquery.aciplugin', 'jquery.acitree',
'pgadmin.alertifyjs', 'pgadmin.browser.messages', 'pgadmin.browser.messages',
'pgadmin.browser.menu', 'pgadmin.browser.panel', 'pgadmin.browser.menu', 'pgadmin.browser.panel',
'pgadmin.browser.error', 'pgadmin.browser.frame', 'pgadmin.browser.error', 'pgadmin.browser.frame',
'pgadmin.browser.node', 'pgadmin.browser.collection' 'pgadmin.browser.node', 'pgadmin.browser.collection'
@@ -1846,8 +1846,7 @@ define(
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); Alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
fetchNodeInfo(_callback); fetchNodeInfo(_callback);

View File

@@ -1,8 +1,8 @@
define( define(
'pgadmin.browser.node', [ 'pgadmin.browser.node', [
'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'pgadmin', 'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'pgadmin',
'pgadmin.browser.menu', 'backbone', 'alertify', 'pgadmin.browser.datamodel', 'pgadmin.browser.menu', 'backbone', 'pgadmin.alertifyjs', 'pgadmin.browser.datamodel',
'backform', 'pgadmin.browser.utils', 'pgadmin.backform', 'pgadmin.alertifyjs' 'backform', 'pgadmin.browser.utils', 'pgadmin.backform'
], function(gettext, $, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) { ], function(gettext, $, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
var wcDocker = window.wcDocker, var wcDocker = window.wcDocker,
@@ -626,8 +626,7 @@ define(
if (!(_.isFunction(obj.canDropCascade) ? if (!(_.isFunction(obj.canDropCascade) ?
obj.canDropCascade.apply(obj, [d, i]) : obj.canDropCascade)) { obj.canDropCascade.apply(obj, [d, i]) : obj.canDropCascade)) {
var alertifyWrapper = new AlertifyWrapper(); Alertify.error(
alertifyWrapper.error(
S('The %s "%s" cannot be dropped!') S('The %s "%s" cannot be dropped!')
.sprintf(obj.label, d.label).value(), .sprintf(obj.label, d.label).value(),
10 10
@@ -641,8 +640,7 @@ define(
if (!(_.isFunction(obj.canDrop) ? if (!(_.isFunction(obj.canDrop) ?
obj.canDrop.apply(obj, [d, i]) : obj.canDrop)) { obj.canDrop.apply(obj, [d, i]) : obj.canDrop)) {
var alertifyWrapper = new AlertifyWrapper(); Alertify.error(
alertifyWrapper.error(
S('The %s "%s" cannot be dropped!') S('The %s "%s" cannot be dropped!')
.sprintf(obj.label, d.label).value(), .sprintf(obj.label, d.label).value(),
10 10

View File

@@ -1,11 +1,11 @@
define('pgadmin.dashboard', [ define('pgadmin.dashboard', [
'sources/url_for', 'sources/gettext', 'require', 'jquery', 'underscore', 'sources/url_for', 'sources/gettext', 'require', 'jquery', 'underscore',
'pgadmin', 'backbone', 'backgrid', 'flotr2', 'alertify', 'pgadmin', 'backbone', 'backgrid', 'flotr2',
'sources/alerts/alertify_wrapper', 'backgrid.filter', 'pgadmin.alertifyjs', 'backgrid.filter',
'pgadmin.browser', 'bootstrap', 'wcdocker' 'pgadmin.browser', 'bootstrap', 'wcdocker'
], ],
function(url_for, gettext, r, $, _, pgAdmin, Backbone, Backgrid, Flotr, function(url_for, gettext, r, $, _, pgAdmin, Backbone, Backgrid, Flotr,
alertify, AlertifyWrapper) { alertify) {
var wcDocker = window.wcDocker, var wcDocker = window.wcDocker,
pgBrowser = pgAdmin.Browser; pgBrowser = pgAdmin.Browser;
@@ -64,20 +64,18 @@ function(url_for, gettext, r, $, _, pgAdmin, Backbone, Backgrid, Flotr,
url: cancel_query_url + self.model.get('pid'), url: cancel_query_url + self.model.get('pid'),
type:'DELETE', type:'DELETE',
success: function(res) { success: function(res) {
var alertifyWrapper = new AlertifyWrapper();
if (res == gettext('Success')) { if (res == gettext('Success')) {
alertifyWrapper.success(gettext('Active query cancelled successfully.')); alertify.success(gettext('Active query cancelled successfully.'));
refresh_grid(); refresh_grid();
} else { } else {
alertifyWrapper.error(gettext('An error occurred whilst cancelling the active query.')); alertify.error(gettext('An error occurred whilst cancelling the active query.'));
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
try { try {
var err = $.parseJSON(xhr.responseText); var err = $.parseJSON(xhr.responseText);
if (err.success == 0) { if (err.success == 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err.errormsg);
alertifyWrapper.error(err.errormsg);
} }
} catch (e) {} } catch (e) {}
} }
@@ -1073,7 +1071,6 @@ function(url_for, gettext, r, $, _, pgAdmin, Backbone, Backgrid, Flotr,
// If there is only one active session means it probably our main // If there is only one active session means it probably our main
// connection session // connection session
var active_sessions = m.collection.where({'state': 'active'}), var active_sessions = m.collection.where({'state': 'active'}),
alertifyWrapper = new AlertifyWrapper(),
pg_version = this.get('postgres_version') || null; pg_version = this.get('postgres_version') || null;
// With PG10, We have background process showing on dashboard // With PG10, We have background process showing on dashboard
@@ -1082,20 +1079,20 @@ function(url_for, gettext, r, $, _, pgAdmin, Backbone, Backgrid, Flotr,
// Background processes do not have database field populated // Background processes do not have database field populated
if (pg_version && pg_version >= 100000 && !m.get('datname')) { if (pg_version && pg_version >= 100000 && !m.get('datname')) {
alertifyWrapper.info( alertify.info(
gettext('You cannot cancel background worker processes.') gettext('You cannot cancel background worker processes.')
); );
return false; return false;
// If it is the last active connection on maintenance db then error out // If it is the last active connection on maintenance db then error out
} else if (maintenance_database == m.get('datname') && } else if (maintenance_database == m.get('datname') &&
m.get('state') == 'active' && active_sessions.length == 1) { m.get('state') == 'active' && active_sessions.length == 1) {
alertifyWrapper.error( alertify.error(
gettext('You are not allowed to cancel the main active session.') gettext('You are not allowed to cancel the main active session.')
); );
return false; return false;
} else if(m.get('state') == 'idle') { } else if(m.get('state') == 'idle') {
// If this session is already idle then do nothing // If this session is already idle then do nothing
alertifyWrapper.info( alertify.info(
gettext('The session is already in idle state.') gettext('The session is already in idle state.')
); );
return false; return false;
@@ -1107,8 +1104,7 @@ function(url_for, gettext, r, $, _, pgAdmin, Backbone, Backgrid, Flotr,
return true; return true;
} else { } else {
// Do not allow to cancel someone else session to non-super user // Do not allow to cancel someone else session to non-super user
var alertifyWrapper = new AlertifyWrapper(); alertify.error(
alertifyWrapper.error(
gettext('Superuser privileges are required to cancel another users query.') gettext('Superuser privileges are required to cancel another users query.')
); );
return false; return false;

View File

@@ -1,7 +1,7 @@
define('misc.file_manager', [ define('misc.file_manager', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'alertify', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'sources/alerts/alertify_wrapper' 'pgadmin.alertifyjs'
], function(gettext, url_for, $, _, alertify, AlertifyWrapper) { ], function(gettext, url_for, $, _, alertify) {
pgAdmin = pgAdmin || window.pgAdmin || {}; pgAdmin = pgAdmin || window.pgAdmin || {};
/* /*
@@ -595,14 +595,12 @@ define('misc.file_manager', [
permission = true; permission = true;
} else { } else {
$('.file_manager_ok').addClass('disabled'); $('.file_manager_ok').addClass('disabled');
var alertifyWrapper = new AlertifyWrapper(); alertify.error(data.Error);
alertifyWrapper.error(data.Error);
} }
}, },
error: function() { error: function() {
$('.file_manager_ok').addClass('disabled'); $('.file_manager_ok').addClass('disabled');
var alertifyWrapper = new AlertifyWrapper(); alertify.error( gettext('Error occurred while checking access permission.'));
alertifyWrapper.error( gettext('Error occurred while checking access permission.'));
} }
}); });
return permission; return permission;

View File

@@ -11,10 +11,10 @@
import loading_icon from 'acitree/image/load-root.gif'; import loading_icon from 'acitree/image/load-root.gif';
define(['jquery', 'underscore', 'underscore.string', define(['jquery', 'underscore', 'underscore.string',
'sources/alerts/alertify_wrapper', 'sources/gettext', 'pgadmin.alertifyjs', 'sources/gettext',
'sources/url_for', 'dropzone' 'sources/url_for', 'dropzone'
], ],
function($, _, S, AlertifyWrapper, gettext, url_for, Dropzone) { function($, _, S, alertify, gettext, url_for, Dropzone) {
/*--------------------------------------------------------- /*---------------------------------------------------------
Define functions used for various operations Define functions used for various operations
@@ -311,11 +311,9 @@ var renameItem = function(data) {
// UnBind toolbar functions. // UnBind toolbar functions.
$('.fileinfo').find('button.rename, button.delete, button.download').unbind(); $('.fileinfo').find('button.rename, button.delete, button.download').unbind();
var alertifyWrapper = new AlertifyWrapper(); alertify.success(lg.successful_rename);
alertifyWrapper.success(lg.successful_rename);
} else { } else {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(result.Error);
alertifyWrapper.error(result.Error);
} }
finalName = result['New Name']; finalName = result['New Name'];
@@ -356,16 +354,14 @@ var deleteItem = function(data) {
if (result.Code === 1) { if (result.Code === 1) {
isDeleted = true; isDeleted = true;
if (isDeleted) { if (isDeleted) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(lg.successful_delete);
alertifyWrapper.success(lg.successful_delete);
var rootpath = result.Path.substring(0, result.Path.length-1); // removing the last slash var rootpath = result.Path.substring(0, result.Path.length-1); // removing the last slash
rootpath = rootpath.substr(0, rootpath.lastIndexOf('/') + 1); rootpath = rootpath.substr(0, rootpath.lastIndexOf('/') + 1);
getFolderInfo(rootpath); getFolderInfo(rootpath);
} }
} else { } else {
isDeleted = false; isDeleted = false;
var alertifyWrapper = new AlertifyWrapper(); alertify.error(result.Error);
alertifyWrapper.error(result.Error);
} }
} }
}); });
@@ -438,8 +434,7 @@ var getFileInfo = function(file) {
} }
} else { } else {
$('.file_manager_ok').addClass('disabled'); $('.file_manager_ok').addClass('disabled');
var alertifyWrapper = new AlertifyWrapper(); alertify.error(data.Error);
alertifyWrapper.error(data.Error);
} }
} }
}); });
@@ -466,14 +461,12 @@ var checkPermission = function(path) {
permission = true; permission = true;
} else { } else {
$('.file_manager_ok').addClass('disabled'); $('.file_manager_ok').addClass('disabled');
var alertifyWrapper = new AlertifyWrapper(); alertify.error(data.Error);
alertifyWrapper.error(data.Error);
} }
}, },
error: function() { error: function() {
$('.file_manager_ok').addClass('disabled'); $('.file_manager_ok').addClass('disabled');
var alertifyWrapper = new AlertifyWrapper(); alertify.error( gettext('Error occurred while checking access permission.'));
alertifyWrapper.error( gettext('Error occurred while checking access permission.'));
} }
}); });
return permission; return permission;
@@ -549,8 +542,7 @@ var getFolderInfo = function(path, file_type) {
// hide activity indicator // hide activity indicator
$('.fileinfo').find('span.activity').hide(); $('.fileinfo').find('span.activity').hide();
if (data.Code === 0) { if (data.Code === 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(data.Error);
alertifyWrapper.error(data.Error);
return; return;
} }
// generate HTML for files/folder and render into container // generate HTML for files/folder and render into container
@@ -1452,21 +1444,18 @@ pgAdmin.FileUtils = {
$this.find(".dz-upload").addClass("success"); $this.find(".dz-upload").addClass("success");
}, 1000); }, 1000);
$this.find(".dz-upload").css('width', "100%").html("100%"); $this.find(".dz-upload").css('width', "100%").html("100%");
var alertifyWrapper = new AlertifyWrapper(); alertify.success(lg.upload_success);
alertifyWrapper.success(lg.upload_success);
} else { } else {
$this.find(".dz-upload").addClass("error"); $this.find(".dz-upload").addClass("error");
$this.find(".dz-upload").css('width', "0%").html("0%"); $this.find(".dz-upload").css('width', "0%").html("0%");
var alertifyWrapper = new AlertifyWrapper(); alertify.error(data.Error);
alertifyWrapper.error(data.Error);
} }
getFolderInfo(path); getFolderInfo(path);
}, },
totaluploadprogress: function(progress) {}, totaluploadprogress: function(progress) {},
complete: function(file) { complete: function(file) {
if (file.status == "error") { if (file.status == "error") {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(lg.upload_error);
alertifyWrapper.error(lg.upload_error);
} }
$('.upload_file .dz_cross_btn').removeAttr('disabled'); $('.upload_file .dz_cross_btn').removeAttr('disabled');
getFolderInfo(path); getFolderInfo(path);

View File

@@ -1,11 +1,10 @@
require( define(
['sources/gettext', 'alertify', 'underscore.string'], ['sources/gettext', 'alertify', 'underscore.string'],
function(gettext, alertify, S) { function(gettext, alertify, S) {
alertify.defaults.transition = "zoom"; alertify.defaults.transition = "zoom";
alertify.defaults.theme.ok = "btn btn-primary"; alertify.defaults.theme.ok = "btn btn-primary";
alertify.defaults.theme.cancel = "btn btn-danger"; alertify.defaults.theme.cancel = "btn btn-danger";
alertify.defaults.theme.input = "form-control"; alertify.defaults.theme.input = "form-control";
alertify.pgIframeDialog || alertify.dialog('pgIframeDialog', function() { alertify.pgIframeDialog || alertify.dialog('pgIframeDialog', function() {
var iframe; var iframe;
return { return {
@@ -84,7 +83,6 @@ function(gettext, alertify, S) {
} }
}; };
}); });
alertify.pgNotifier = function(type, xhr, promptmsg, onJSONResult) { alertify.pgNotifier = function(type, xhr, promptmsg, onJSONResult) {
var msg = xhr.responseText, var msg = xhr.responseText,
contentType = xhr.getResponseHeader('Content-Type'); contentType = xhr.getResponseHeader('Content-Type');
@@ -309,4 +307,56 @@ function(gettext, alertify, S) {
return false; return false;
}; };
var alertifySuccess = alertify.success,
alertifyError = alertify.error;
/*
For adding the jasmine test cases, we needed to refer the original success,
and error functions, as orig_success and orig_error respectively.
*/
_.extend(alertify, {
orig_success: alertifySuccess, orig_error: alertifyError
});
_.extend(alertify, {
success: function (message, timeout, callback) {
var alertMessage = '\
<div class="media font-green-3 text-14">\
<div class="media-body media-middle">\
<div class="alert-icon success-icon">\
<i class="fa fa-check" aria-hidden="true"></i>\
</div>\
<div class="alert-text">' + message + '</div>\
</div>\
</div>';
return alertify.orig_success(alertMessage, timeout, callback);
},
error: function(message, timeout, callback) {
var alertMessage = '\
<div class="media font-red-3 text-14">\
<div class="media-body media-middle">\
<div class="alert-icon error-icon">\
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>\
</div>\
<div class="alert-text">' + message + '</div>\
</div>\
</div>';
return alertify.orig_error(alertMessage, timeout, callback);
},
info: function(message, timeout) {
var alertMessage = '\
<div class="media alert-info font-blue text-14">\
<div class="media-body media-middle">\
<div class="alert-icon info-icon">\
<i class="fa fa-info" aria-hidden="true"></i>\
</div>\
<div class="alert-text">' + message + '</div>\
</div>\
</div>';
var alert = alertify.notify(alertMessage, timeout);
return alert;
}
});
return alertify;
}); });

View File

@@ -1,55 +0,0 @@
define([
'jquery',
'alertify',
], function ($, alertify) {
var AlertifyWrapper = function () {
var success = function (message, timeout) {
var alertMessage = '\
<div class="media font-green-3 text-14">\
<div class="media-body media-middle">\
<div class="alert-icon success-icon">\
<i class="fa fa-check" aria-hidden="true"></i>\
</div>\
<div class="alert-text">' + message + '</div>\
</div>\
</div>';
var alert = alertify.success(alertMessage, timeout);
return alert;
};
var error = function(message, timeout) {
var alertMessage = '\
<div class="media font-red-3 text-14">\
<div class="media-body media-middle">\
<div class="alert-icon error-icon">\
<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>\
</div>\
<div class="alert-text">' + message + '</div>\
</div>\
</div>';
var alert = alertify.error(alertMessage, timeout);
return alert;
};
var info = function(message, timeout) {
var alertMessage = '\
<div class="media alert-info font-blue text-14">\
<div class="media-body media-middle">\
<div class="alert-icon info-icon">\
<i class="fa fa-info" aria-hidden="true"></i>\
</div>\
<div class="alert-text">' + message + '</div>\
</div>\
</div>';
var alert = alertify.notify(alertMessage, timeout);
return alert;
};
$.extend(this, {
'success': success,
'error': error,
'info': info,
});
};
return AlertifyWrapper;
});

View File

@@ -1,9 +1,8 @@
// Backup dialog // Backup dialog
define([ define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'alertify', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
'pgadmin.browser', 'backbone', 'backgrid', 'backform', 'pgadmin.browser.node', 'pgadmin.browser', 'backbone', 'backgrid', 'backform', 'pgadmin.browser.node'
'sources/alerts/alertify_wrapper' ], function(gettext, url_for, $, _, S, alertify, pgBrowser, Backbone, Backgrid, Backform, pgNode) {
], function(gettext, url_for, $, _, S, alertify, pgBrowser, Backbone, Backgrid, Backform, pgNode, AlertifyWrapper) {
// if module is already initialized, refer to that. // if module is already initialized, refer to that.
if (pgBrowser.Backup) { if (pgBrowser.Backup) {
@@ -556,8 +555,7 @@ TODO LIST FOR BACKUP:
data:{ 'data': JSON.stringify(args) }, data:{ 'data': JSON.stringify(args) },
success: function(res) { success: function(res) {
if (res.success) { if (res.success) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(gettext('Backup job created.'), 5);
alertifyWrapper.success(gettext('Backup job created.'), 5);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self); pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
} else { } else {
console.log(res); console.log(res);
@@ -785,8 +783,7 @@ TODO LIST FOR BACKUP:
data:{ 'data': JSON.stringify(args) }, data:{ 'data': JSON.stringify(args) },
success: function(res) { success: function(res) {
if (res.success) { if (res.success) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(gettext('Backup job created.'), 5);
alertifyWrapper.success(gettext('Backup job created.'), 5);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self); pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
} }
}, },

View File

@@ -1,15 +1,12 @@
define([ define([
'sources/gettext', 'sources/url_for' ,'jquery', 'underscore', 'underscore.string', 'alertify', 'sources/gettext', 'sources/url_for' ,'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
'pgadmin','pgadmin.browser', 'backbone', 'backgrid', 'sources/../bundle/codemirror', 'backform', 'pgadmin','pgadmin.browser', 'backbone', 'backgrid', 'sources/../bundle/codemirror', 'backform',
'pgadmin.tools.debugger.ui', 'pgadmin.tools.debugger.ui',
'sources/alerts/alertify_wrapper',
'wcdocker', 'pgadmin.backform', 'wcdocker', 'pgadmin.backform',
'pgadmin.backgrid' 'pgadmin.backgrid'
], function( ], function(
gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
codemirror, Backform, debug_function_again, AlertifyWrapper codemirror, Backform, debug_function_again
) { ) {
var CodeMirror = codemirror.default; var CodeMirror = codemirror.default;
@@ -481,8 +478,7 @@ define([
pgTools.DirectDebug.polling_timeout_idle = true; pgTools.DirectDebug.polling_timeout_idle = true;
//Set the alertify message to inform the user that execution is completed. //Set the alertify message to inform the user that execution is completed.
var alertifyWrapper = new AlertifyWrapper(); Alertify.success(res.info, 3);
alertifyWrapper.success(res.info, 3);
// Update the message tab of the debugger // Update the message tab of the debugger
if (res.data.status_message) { if (res.data.status_message) {
@@ -513,8 +509,7 @@ define([
pgTools.DirectDebug.polling_timeout_idle = true; pgTools.DirectDebug.polling_timeout_idle = true;
//Set the alertify message to inform the user that execution is completed. //Set the alertify message to inform the user that execution is completed.
var alertifyWrapper = new AlertifyWrapper(); Alertify.success(res.info, 3);
alertifyWrapper.success(res.info, 3);
// Update the message tab of the debugger // Update the message tab of the debugger
if (res.data.status_message) { if (res.data.status_message) {
@@ -556,11 +551,9 @@ define([
pgTools.DirectDebug.direct_execution_completed = true; pgTools.DirectDebug.direct_execution_completed = true;
pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background'); pgTools.DirectDebug.editor.removeLineClass(self.active_line_no, 'wrap', 'CodeMirror-activeline-background');
//Set the alertify message to inform the user that execution is completed with error. //Set the Alertify message to inform the user that execution is completed with error.
var alertifyWrapper = new AlertifyWrapper();
if(!pgTools.DirectDebug.is_user_aborted_debugging) { if(!pgTools.DirectDebug.is_user_aborted_debugging) {
alertifyWrapper.error(res.info, 3); Alertify.error(res.info, 3);
} }
// Update the message tab of the debugger // Update the message tab of the debugger
@@ -825,10 +818,9 @@ define([
// We will give same behaviour as pgAdmin3 and disable all buttons // We will give same behaviour as pgAdmin3 and disable all buttons
self.enable('continue', false); self.enable('continue', false);
// Set the alertify message to inform the user that execution // Set the Alertify message to inform the user that execution
// is completed. // is completed.
var alertifyWrapper = new AlertifyWrapper(); Alertify.success(res.info, 3);
alertifyWrapper.success(res.info, 3);
} }
else if (res.data.status === 'NotConnected') { else if (res.data.status === 'NotConnected') {
Alertify.alert( Alertify.alert(
@@ -1221,11 +1213,10 @@ define([
// Get the updated variables value // Get the updated variables value
self.GetLocalVariables(pgTools.DirectDebug.trans_id); self.GetLocalVariables(pgTools.DirectDebug.trans_id);
// Show the message to the user that deposit value is success or failure // Show the message to the user that deposit value is success or failure
var alertifyWrapper = new AlertifyWrapper();
if (res.data.result) { if (res.data.result) {
alertifyWrapper.success(res.data.info, 3); Alertify.success(res.data.info, 3);
} else { } else {
alertifyWrapper.error(res.data.info, 3); Alertify.error(res.data.info, 3);
} }
} }
}, },

View File

@@ -1,11 +1,9 @@
define([ define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'alertify', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
'pgadmin', 'pgadmin.browser', 'backbone', 'backgrid', 'backform', 'pgadmin', 'pgadmin.browser', 'backbone', 'backgrid', 'backform',
'sources/alerts/alertify_wrapper',
'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, Backform, AlertifyWrapper gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, Backform
) { ) {
pgAdmin = pgAdmin || window.pgAdmin || {}; pgAdmin = pgAdmin || window.pgAdmin || {};
@@ -420,8 +418,7 @@ define([
data:{ 'data': JSON.stringify(this.view.model.toJSON()) }, data:{ 'data': JSON.stringify(this.view.model.toJSON()) },
success: function(res) { success: function(res) {
if (res.success) { if (res.success) {
var alertifyWrapper = new AlertifyWrapper(); Alertify.success(gettext('Import/export job created.'), 5);
alertifyWrapper.success(gettext('Import/export job created.'), 5);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self); pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
} }
}, },

View File

@@ -1,14 +1,12 @@
define([ define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'alertify', 'pgadmin', 'pgadmin.browser', 'backbone', 'underscore.string', 'pgadmin.alertifyjs', 'pgadmin', 'pgadmin.browser', 'backbone',
'backgrid', 'backform', 'backgrid', 'backform',
'sources/alerts/alertify_wrapper',
'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.backform', 'pgadmin.backgrid',
'pgadmin.browser.node.ui' '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, AlertifyWrapper Backform
) { ) {
pgAdmin = pgAdmin || window.pgAdmin || {}; pgAdmin = pgAdmin || window.pgAdmin || {};
@@ -353,13 +351,11 @@ define([
success: function(res) { success: 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
var alertifyWrapper = new AlertifyWrapper(); Alertify.success(res.data.info);
alertifyWrapper.success(res.data.info);
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self); pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
} }
else { else {
var alertifyWrapper = new AlertifyWrapper(); Alertify.error(res.data.errmsg);
alertifyWrapper.error(res.data.errmsg);
} }
}, },
error: function(e) { error: function(e) {

View File

@@ -1,12 +1,11 @@
// Restore dialog // Restore dialog
define('tools.restore', [ define('tools.restore', [
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore',
'underscore.string', 'alertify', 'pgadmin.browser', 'backbone', 'backgrid', 'underscore.string', 'pgadmin.alertifyjs', 'pgadmin.browser', 'backbone', 'backgrid',
'backform', 'pgadmin.browser.node', 'backform', 'pgadmin.browser.node'
'sources/alerts/alertify_wrapper',
], function( ], function(
gettext, url_for, $, _, S, alertify, pgBrowser, Backbone, Backgrid, Backform, gettext, url_for, $, _, S, alertify, pgBrowser, Backbone, Backgrid, Backform,
pgNode, AlertifyWrapper pgNode
) { ) {
// if module is already initialized, refer to that. // if module is already initialized, refer to that.
@@ -531,8 +530,7 @@ define('tools.restore', [
data:{ 'data': JSON.stringify(args) }, data:{ 'data': JSON.stringify(args) },
success: function(res) { success: function(res) {
if (res.success) { if (res.success) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(
alertifyWrapper.success(
gettext('Restore job created.'), 5 gettext('Restore job created.'), 5
); );
pgBrowser.Events.trigger('pgadmin-bgprocess:created', self); pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);

View File

@@ -1,6 +1,6 @@
define('tools.querytool', [ define('tools.querytool', [
'babel-polyfill', 'sources/gettext','sources/url_for', 'jquery', 'babel-polyfill', 'sources/gettext','sources/url_for', 'jquery',
'underscore', 'underscore.string', 'alertify', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
'pgadmin', 'backbone', 'sources/../bundle/codemirror', 'pgadmin', 'backbone', 'sources/../bundle/codemirror',
'pgadmin.misc.explain', 'pgadmin.misc.explain',
'sources/selection/grid_selector', 'sources/selection/grid_selector',
@@ -15,7 +15,6 @@ define('tools.querytool', [
'sources/history/index.js', 'sources/history/index.js',
'sources/../jsx/history/query_history', 'sources/../jsx/history/query_history',
'react', 'react-dom', 'react', 'react-dom',
'sources/alerts/alertify_wrapper',
'sources/sqleditor/keyboard_shortcuts', 'sources/sqleditor/keyboard_shortcuts',
'sources/../bundle/slickgrid', 'sources/../bundle/slickgrid',
'pgadmin.file_manager', 'pgadmin.file_manager',
@@ -26,7 +25,7 @@ define('tools.querytool', [
], function( ], function(
babelPollyfill, gettext, url_for, $, _, S, alertify, pgAdmin, Backbone, codemirror, babelPollyfill, gettext, url_for, $, _, S, alertify, pgAdmin, Backbone, codemirror,
pgExplain, GridSelector, ActiveCellCapture, clipboard, copyData, RangeSelectionHelper, handleQueryOutputKeyboardEvent, pgExplain, GridSelector, ActiveCellCapture, clipboard, copyData, RangeSelectionHelper, handleQueryOutputKeyboardEvent,
XCellSelectionModel, setStagedRows, SqlEditorUtils, HistoryBundle, queryHistory, React, ReactDOM, AlertifyWrapper, XCellSelectionModel, setStagedRows, SqlEditorUtils, HistoryBundle, queryHistory, React, ReactDOM,
keyboardShortcuts keyboardShortcuts
) { ) {
/* Return back, this has been called more than once */ /* Return back, this has been called more than once */
@@ -1734,8 +1733,7 @@ define('tools.querytool', [
self.update_msg_history(true, res.result, false); self.update_msg_history(true, res.result, false);
// Display the notifier if the timeout is set to >= 0 // Display the notifier if the timeout is set to >= 0
if (self.info_notifier_timeout >= 0) { if (self.info_notifier_timeout >= 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(msg, self.info_notifier_timeout);
alertifyWrapper.success(msg, self.info_notifier_timeout);
} }
} }
@@ -1886,8 +1884,7 @@ define('tools.querytool', [
// Display the notifier if the timeout is set to >= 0 // Display the notifier if the timeout is set to >= 0
if (self.info_notifier_timeout >= 0) { if (self.info_notifier_timeout >= 0) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(msg1 + ' ' + msg2, self.info_notifier_timeout);
alertifyWrapper.success(msg1 + ' ' + msg2, self.info_notifier_timeout);
} }
var _msg = msg1 + '\n' + msg2; var _msg = msg1 + '\n' + msg2;
@@ -2205,8 +2202,7 @@ define('tools.querytool', [
} else { } else {
$("#btn-save").prop('disabled', true); $("#btn-save").prop('disabled', true);
} }
var alertifyWrapper = new AlertifyWrapper(); alertify.success(gettext("Row(s) deleted"));
alertifyWrapper.success(gettext("Row(s) deleted"));
} else { } else {
// There are other data to needs to be updated on server // There are other data to needs to be updated on server
if(is_updated) { if(is_updated) {
@@ -2357,8 +2353,7 @@ define('tools.querytool', [
$("#btn-flash").prop('disabled', false); $("#btn-flash").prop('disabled', false);
$('.sql-editor-message').text(res.data.result); $('.sql-editor-message').text(res.data.result);
var err_msg = S(gettext("%s.")).sprintf(res.data.result).value(); var err_msg = S(gettext("%s.")).sprintf(res.data.result).value();
var alertifyWrapper = new AlertifyWrapper(); alertify.error(err_msg, 20);
alertifyWrapper.error(err_msg, 20);
grid.setSelectedRows([]); grid.setSelectedRows([]);
// To highlight the row at fault // To highlight the row at fault
if(_.has(res.data, '_rowid') && if(_.has(res.data, '_rowid') &&
@@ -2393,8 +2388,7 @@ define('tools.querytool', [
self.trigger('pgadmin-sqleditor:loading-icon:hide'); self.trigger('pgadmin-sqleditor:loading-icon:hide');
grid.invalidate(); grid.invalidate();
var alertifyWrapper = new AlertifyWrapper(); alertify.success(gettext("Data saved successfully."));
alertifyWrapper.success(gettext("Data saved successfully."));
if (self.close_on_save) { if (self.close_on_save) {
self.close(); self.close();
} }
@@ -2549,8 +2543,7 @@ define('tools.querytool', [
}, },
error: function(e) { error: function(e) {
var errmsg = $.parseJSON(e.responseText).errormsg; var errmsg = $.parseJSON(e.responseText).errormsg;
var alertifyWrapper = new AlertifyWrapper(); alertify.error(errmsg);
alertifyWrapper.error(errmsg);
self.trigger('pgadmin-sqleditor:loading-icon:hide'); self.trigger('pgadmin-sqleditor:loading-icon:hide');
// hide cursor // hide cursor
$busy_icon_div.removeClass('show_progress'); $busy_icon_div.removeClass('show_progress');
@@ -2578,8 +2571,7 @@ define('tools.querytool', [
data: JSON.stringify(data), data: JSON.stringify(data),
success: function(res) { success: function(res) {
if (res.data.status) { if (res.data.status) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(gettext("File saved successfully."));
alertifyWrapper.success(gettext("File saved successfully."));
self.gridView.current_file = e; self.gridView.current_file = e;
self.setTitle(self.gridView.current_file.replace(/^.*[\\\/]/g, '')); self.setTitle(self.gridView.current_file.replace(/^.*[\\\/]/g, ''));
// disable save button on file save // disable save button on file save
@@ -2600,8 +2592,7 @@ define('tools.querytool', [
var errmsg = $.parseJSON(e.responseText).errormsg; var errmsg = $.parseJSON(e.responseText).errormsg;
setTimeout( setTimeout(
function() { function() {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(errmsg);
alertifyWrapper.error(errmsg);
}, 10 }, 10
); );
}, },

View File

@@ -1,11 +1,11 @@
define([ define([
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'alertify', 'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'pgadmin.alertifyjs',
'pgadmin.browser', 'backbone', 'backgrid', 'backform', 'pgadmin.browser.node', 'pgadmin.browser', 'backbone', 'backgrid', 'backform', 'pgadmin.browser.node',
'sources/alerts/alertify_wrapper', 'pgadmin.user_management.current_user', 'pgadmin.user_management.current_user',
'backgrid.select.all', 'backgrid.filter' 'backgrid.select.all', 'backgrid.filter'
], function( ], function(
gettext, url_for, $, _, S, alertify, pgBrowser, Backbone, Backgrid, Backform, gettext, url_for, $, _, S, alertify, pgBrowser, Backbone, Backgrid, Backform,
pgNode, AlertifyWrapper, userInfo pgNode, userInfo
) { ) {
// if module is already initialized, refer to that. // if module is already initialized, refer to that.
@@ -310,12 +310,10 @@ define([
self.model.destroy({ self.model.destroy({
wait: true, wait: true,
success: function(res) { success: function(res) {
var alertifyWrapper = new AlertifyWrapper(); alertify.success(gettext('User deleted.'));
alertifyWrapper.success(gettext('User deleted.'));
}, },
error: function(m, jqxhr) { error: function(m, jqxhr) {
var alertifyWrapper = new AlertifyWrapper(); alertify.error(gettext('Error during deleting user.'));
alertifyWrapper.error(gettext('Error during deleting user.'));
} }
}); });
}, },
@@ -492,15 +490,13 @@ define([
'confirmPassword':undefined}); 'confirmPassword':undefined});
m.startNewSession(); m.startNewSession();
var alertifyWrapper = new AlertifyWrapper(); alertify.success(S(gettext("User '%s' saved.")).sprintf(
alertifyWrapper.success(S(gettext("User '%s' saved.")).sprintf(
m.get('email') m.get('email')
).value()); ).value());
}, },
error: function(res, jqxhr) { error: function(res, jqxhr) {
m.startNewSession(); m.startNewSession();
var alertifyWrapper = new AlertifyWrapper(); alertify.error(
alertifyWrapper.error(
S(gettext("Error saving user: '%s'")).sprintf( S(gettext("Error saving user: '%s'")).sprintf(
jqxhr.responseJSON.errormsg jqxhr.responseJSON.errormsg
).value() ).value()

View File

@@ -6,19 +6,16 @@
// This software is released under the PostgreSQL Licence // This software is released under the PostgreSQL Licence
// //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
import alertify from 'pgadmin.alertifyjs';
import alertify from 'alertify';
import AlertifyWrapper from 'sources/alerts/alertify_wrapper';
describe('alertify_wrapper', function () { describe('alertify_wrapper', function () {
describe('success', function () { describe('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, 'success'); spyOn(alertify, 'orig_success');
var alertifyWrapper = new AlertifyWrapper();
alertifyWrapper.success('Yay, congrats!', 1); alertify.success('Yay, congrats!', 1);
var calledWithMessage = alertify.success.calls.mostRecent().args[0]; var calledWithMessage = alertify.orig_success.calls.mostRecent().args[0];
expect(calledWithMessage).toContain('Yay, congrats!'); expect(calledWithMessage).toContain('Yay, congrats!');
expect(calledWithMessage).toContain('class="fa fa-check"'); expect(calledWithMessage).toContain('class="fa fa-check"');
@@ -27,12 +24,11 @@ describe('alertify_wrapper', function () {
describe('error', function () { describe('error', function () {
it('calls the error function from alertify and adds the warning symbol to the element', function () { it('calls the error function from alertify and adds the warning symbol to the element', function () {
spyOn(alertify, 'error'); spyOn(alertify, 'orig_error');
var alertifyWrapper = new AlertifyWrapper();
alertifyWrapper.error('bad, very bad', 1); alertify.error('bad, very bad', 1);
var calledWithMessage = alertify.error.calls.mostRecent().args[0]; var calledWithMessage = alertify.orig_error.calls.mostRecent().args[0];
expect(calledWithMessage).toContain('bad, very bad'); expect(calledWithMessage).toContain('bad, very bad');
expect(calledWithMessage).toContain('class="fa fa-exclamation-triangle"'); expect(calledWithMessage).toContain('class="fa fa-exclamation-triangle"');

View File

@@ -271,7 +271,7 @@ var webpackShimConfig = {
'pgadmin.browser.datamodel', 'pgadmin.browser.menu', 'pgadmin.browser.panel', 'pgadmin', 'pgadmin.browser.datamodel', 'pgadmin.browser.menu', 'pgadmin.browser.panel', 'pgadmin',
'pgadmin.browser.frame', 'slick.pgadmin.editors', 'slick.pgadmin.formatters', 'pgadmin.browser.frame', 'slick.pgadmin.editors', 'slick.pgadmin.formatters',
'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser', 'pgadmin.file_manager', 'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser', 'pgadmin.file_manager',
'pgadmin.file_utility', 'sources/alerts/alertify_wrapper', 'pgadmin.browser.node', 'pgadmin.file_utility', 'pgadmin.browser.node',
'pgadmin.alertifyjs', 'pgadmin.settings', 'pgadmin.preferences', 'pgadmin.sqlfoldcode', 'pgadmin.alertifyjs', 'pgadmin.settings', 'pgadmin.preferences', 'pgadmin.sqlfoldcode',
], ],
// Checks whether JS module is npm module or not // Checks whether JS module is npm module or not

View File

@@ -69,6 +69,7 @@ module.exports = {
'browser': path.resolve(__dirname, 'pgadmin/browser/static/js'), 'browser': path.resolve(__dirname, 'pgadmin/browser/static/js'),
'pgadmin': sourcesDir + '/js/pgadmin', 'pgadmin': sourcesDir + '/js/pgadmin',
'pgadmin.sqlfoldcode': sourcesDir + '/js/codemirror/addon/fold/pgadmin-sqlfoldcode', 'pgadmin.sqlfoldcode': sourcesDir + '/js/codemirror/addon/fold/pgadmin-sqlfoldcode',
'pgadmin.alertifyjs': sourcesDir + '/js/alertify.pgadmin.defaults',
}, },
}, },
externals: { externals: {