mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Remove usage of jQuery in pgAdmin.
Remove usage of Bootstrap in React components. #5701
This commit is contained in:
@@ -66,7 +66,6 @@ except ImportError as e:
|
||||
|
||||
MODULE_NAME = 'browser'
|
||||
BROWSER_STATIC = 'browser.static'
|
||||
JQUERY_ACIPLUGIN = 'jquery.aciplugin'
|
||||
BROWSER_INDEX = 'browser.index'
|
||||
PGADMIN_BROWSER = 'pgAdmin.Browser'
|
||||
PASS_ERROR_MSG = gettext('Your password has not been changed.')
|
||||
|
||||
@@ -12,9 +12,9 @@ import { getNodePrivilegeRoleSchema } from '../../../../static/js/privilege.ui';
|
||||
import { getNodeListByName } from '../../../../../../static/js/node_ajax';
|
||||
|
||||
define('pgadmin.node.schema', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
'sources/gettext', 'sources/url_for',
|
||||
'pgadmin.browser', 'pgadmin.browser.collection',
|
||||
], function(gettext, url_for, $, pgBrowser) {
|
||||
], function(gettext, url_for, pgBrowser) {
|
||||
|
||||
// Extend the browser's collection class for schema collection
|
||||
if (!pgBrowser.Nodes['coll-schema']) {
|
||||
|
||||
@@ -10,14 +10,15 @@
|
||||
import { getNodeListByName } from '../../../../../../../../static/js/node_ajax';
|
||||
import CompoundTriggerSchema from './compound_trigger.ui';
|
||||
import Notify from '../../../../../../../../../static/js/helpers/Notifier';
|
||||
import getApiInstance from '../../../../../../../../../static/js/api_instance';
|
||||
|
||||
define('pgadmin.node.compound_trigger', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
'sources/gettext', 'sources/url_for',
|
||||
'sources/pgadmin', 'pgadmin.browser',
|
||||
'pgadmin.node.schema.dir/schema_child_tree_node',
|
||||
'pgadmin.browser.collection',
|
||||
], function(
|
||||
gettext, url_for, $, pgAdmin, pgBrowser, SchemaChildTreeNode
|
||||
gettext, url_for, pgAdmin, pgBrowser, SchemaChildTreeNode
|
||||
) {
|
||||
|
||||
if (!pgBrowser.Nodes['coll-compound_trigger']) {
|
||||
@@ -112,31 +113,27 @@ define('pgadmin.node.compound_trigger', [
|
||||
return false;
|
||||
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'enable' , d, true),
|
||||
type:'PUT',
|
||||
data: {'is_enable_trigger' : 'O'},
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
data.icon = 'icon-compound_trigger';
|
||||
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) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
getApiInstance().put(
|
||||
obj.generate_url(i, 'enable' , d, true),
|
||||
{'is_enable_trigger' : 'O'}
|
||||
).then(({data: res})=> {
|
||||
if(res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
data.icon = 'icon-compound_trigger';
|
||||
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);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
/* Disable compound trigger */
|
||||
disable_compound_trigger: function(args) {
|
||||
@@ -150,31 +147,27 @@ define('pgadmin.node.compound_trigger', [
|
||||
return false;
|
||||
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'enable' , d, true),
|
||||
type:'PUT',
|
||||
data: {'is_enable_trigger' : 'D'},
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
data.icon = 'icon-compound_trigger-bad';
|
||||
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) {
|
||||
Notify.pgRespErrorNotify(xhr, error, gettext('Disable compound trigger failed'));
|
||||
getApiInstance().put(
|
||||
obj.generate_url(i, 'enable' , d, true),
|
||||
{'is_enable_trigger' : 'D'}
|
||||
).then(({data: res})=> {
|
||||
if(res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
data.icon = 'icon-compound_trigger-bad';
|
||||
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);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
},
|
||||
canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
import CheckConstraintSchema from './check_constraint.ui';
|
||||
import Notify from '../../../../../../../../../../static/js/helpers/Notifier';
|
||||
import _ from 'lodash';
|
||||
import getApiInstance from '../../../../../../../../../../static/js/api_instance';
|
||||
|
||||
// Check Constraint Module: Node
|
||||
define('pgadmin.node.check_constraint', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
'sources/gettext', 'sources/url_for',
|
||||
'sources/pgadmin', 'pgadmin.browser',
|
||||
'pgadmin.node.schema.dir/schema_child_tree_node', 'pgadmin.browser.collection',
|
||||
], function(gettext, url_for, $, pgAdmin, pgBrowser, schemaChildTreeNode) {
|
||||
], function(gettext, url_for, pgAdmin, pgBrowser, schemaChildTreeNode) {
|
||||
|
||||
// Check Constraint Node
|
||||
if (!pgBrowser.Nodes['check_constraint']) {
|
||||
@@ -69,11 +70,8 @@ define('pgadmin.node.check_constraint', [
|
||||
|
||||
if (d) {
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'validate', d, true),
|
||||
type:'GET',
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().get(obj.generate_url(i, 'validate', d, true))
|
||||
.then(({data: res})=>{
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
@@ -84,8 +82,8 @@ define('pgadmin.node.check_constraint', [
|
||||
setTimeout(function() {t.select(i);}, 100);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
import { getNodeForeignKeySchema } from './foreign_key.ui';
|
||||
import Notify from '../../../../../../../../../../static/js/helpers/Notifier';
|
||||
import _ from 'lodash';
|
||||
import getApiInstance from '../../../../../../../../../../static/js/api_instance';
|
||||
|
||||
define('pgadmin.node.foreign_key', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
'sources/gettext', 'sources/url_for',
|
||||
'sources/pgadmin', 'pgadmin.browser', 'pgadmin.browser.collection',
|
||||
], function(
|
||||
gettext, url_for, $, pgAdmin, pgBrowser
|
||||
gettext, url_for, pgAdmin, pgBrowser
|
||||
) {
|
||||
// Extend the browser's node class for foreign key node
|
||||
if (!pgBrowser.Nodes['foreign_key']) {
|
||||
@@ -65,11 +66,8 @@ define('pgadmin.node.foreign_key', [
|
||||
|
||||
if (d) {
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'validate', d, true),
|
||||
type:'GET',
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().get(obj.generate_url(i, 'validate', d, true))
|
||||
.then(({data: res})=>{
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
@@ -80,8 +78,8 @@ define('pgadmin.node.foreign_key', [
|
||||
setTimeout(function() {t.select(i);}, 100);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import { getNodePartitionTableSchema } from './partition.ui';
|
||||
import Notify from '../../../../../../../../../static/js/helpers/Notifier';
|
||||
import _ from 'lodash';
|
||||
import getApiInstance from '../../../../../../../../../static/js/api_instance';
|
||||
|
||||
define([
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
@@ -166,13 +167,8 @@ function(
|
||||
if (!d)
|
||||
return false;
|
||||
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'set_trigger' , d, true),
|
||||
type:'PUT',
|
||||
data: params,
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().put(obj.generate_url(i, 'set_trigger' , d, true), params)
|
||||
.then(({data: res})=>{
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.unload(i);
|
||||
@@ -183,8 +179,8 @@ function(
|
||||
}, 10);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
@@ -213,17 +209,12 @@ function(
|
||||
gettext('Are you sure you want to truncate table %s?', d.label),
|
||||
function () {
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'truncate' , d, true),
|
||||
type:'PUT',
|
||||
data: params,
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().put(obj.generate_url(i, 'truncate' , d, true), params)
|
||||
.then(({data: res})=>{
|
||||
obj.on_done(res, data, t, i);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
@@ -244,15 +235,12 @@ function(
|
||||
gettext('Are you sure you want to reset the statistics for table "%s"?', d._label),
|
||||
function () {
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'reset' , d, true),
|
||||
type:'DELETE',
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().delete(obj.generate_url(i, 'reset' , d, true))
|
||||
.then(({data: res})=>{
|
||||
obj.on_done(res, data, t, i);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
@@ -273,11 +261,8 @@ function(
|
||||
gettext('Detach Partition'),
|
||||
gettext('Are you sure you want to detach the partition %s?', d._label),
|
||||
function () {
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'detach' , d, true),
|
||||
type:'PUT',
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().put(obj.generate_url(i, 'detach' , d, true))
|
||||
.then(({data: res})=>{
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
let n = t.next(i);
|
||||
@@ -293,8 +278,8 @@ function(
|
||||
}
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
});
|
||||
},
|
||||
function() {/*This is intentional (SonarQube)*/}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import RuleSchema from './rule.ui';
|
||||
import Notify from '../../../../../../../../../static/js/helpers/Notifier';
|
||||
import _ from 'lodash';
|
||||
import getApiInstance from '../../../../../../../../../static/js/api_instance';
|
||||
|
||||
define('pgadmin.node.rule', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
@@ -134,13 +135,8 @@ define('pgadmin.node.rule', [
|
||||
return false;
|
||||
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'obj' , d, true),
|
||||
type:'PUT',
|
||||
data: {'is_enable_rule' : 'O'},
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function() {
|
||||
getApiInstance().put(obj.generate_url(i, 'obj' , d, true), {'is_enable_rule' : 'O'})
|
||||
.then(()=>{
|
||||
Notify.success('Rule updated.');
|
||||
t.removeIcon(i);
|
||||
data.icon = 'icon-rule';
|
||||
@@ -153,9 +149,8 @@ define('pgadmin.node.rule', [
|
||||
t.select(i);
|
||||
}, 10);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
});
|
||||
},
|
||||
/* Disable rule */
|
||||
@@ -170,13 +165,8 @@ define('pgadmin.node.rule', [
|
||||
return false;
|
||||
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'obj' , d, true),
|
||||
type:'PUT',
|
||||
data: {'is_enable_rule' : 'D'},
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function() {
|
||||
getApiInstance().put(obj.generate_url(i, 'obj' , d, true), {'is_enable_rule' : 'D'})
|
||||
.then(()=>{
|
||||
Notify.success('Rule updated');
|
||||
t.removeIcon(i);
|
||||
data.icon = 'icon-rule-bad';
|
||||
@@ -189,9 +179,8 @@ define('pgadmin.node.rule', [
|
||||
t.select(i);
|
||||
}, 10);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error, gettext('Disable rule failed'));
|
||||
t.unload(i);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import { getNodeTableSchema } from './table.ui';
|
||||
import Notify from '../../../../../../../../static/js/helpers/Notifier';
|
||||
import _ from 'lodash';
|
||||
import getApiInstance from '../../../../../../../../static/js/api_instance';
|
||||
|
||||
define('pgadmin.node.table', [
|
||||
'pgadmin.tables.js/enable_disable_triggers',
|
||||
@@ -187,13 +188,8 @@ define('pgadmin.node.table', [
|
||||
gettext('Are you sure you want to truncate table %s?', d.label),
|
||||
function () {
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'truncate' , d, true),
|
||||
type:'PUT',
|
||||
data: params,
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().put(obj.generate_url(i, 'truncate' , d, true), params)
|
||||
.then(({data: res})=>{
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
@@ -211,8 +207,8 @@ define('pgadmin.node.table', [
|
||||
Notify.error(res.info);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
}, function() {/*This is intentional (SonarQube)*/}
|
||||
@@ -233,11 +229,8 @@ define('pgadmin.node.table', [
|
||||
gettext('Are you sure you want to reset the statistics for table "%s"?', d._label),
|
||||
function () {
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'reset' , d, true),
|
||||
type:'DELETE',
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().delete(obj.generate_url(i, 'reset' , d, true))
|
||||
.then(({data: res})=>{
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
@@ -252,8 +245,8 @@ define('pgadmin.node.table', [
|
||||
}, 10);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
@@ -274,11 +267,8 @@ define('pgadmin.node.table', [
|
||||
...d, _type: this.type,
|
||||
};
|
||||
// Fetch the total rows of a table
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'count_rows' , newD, true),
|
||||
type:'GET',
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().get(obj.generate_url(i, 'count_rows' , newD, true))
|
||||
.then(({data: res})=>{
|
||||
Notify.success(res.info, null);
|
||||
d.rows_cnt = res.data.total_rows;
|
||||
t.unload(i);
|
||||
@@ -288,8 +278,8 @@ define('pgadmin.node.table', [
|
||||
t.select(i);
|
||||
}, 10);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -10,6 +10,7 @@ import { getNodeListByName, getNodeAjaxOptions } from '../../../../../../../../s
|
||||
import TriggerSchema from './trigger.ui';
|
||||
import Notify from '../../../../../../../../../static/js/helpers/Notifier';
|
||||
import _ from 'lodash';
|
||||
import getApiInstance from '../../../../../../../../../static/js/api_instance';
|
||||
|
||||
define('pgadmin.node.trigger', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
@@ -108,13 +109,8 @@ define('pgadmin.node.trigger', [
|
||||
return false;
|
||||
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'enable' , d, true),
|
||||
type:'PUT',
|
||||
data: {'is_enable_trigger' : 'O'},
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().put(obj.generate_url(i, 'enable' , d, true), {'is_enable_trigger' : 'O'})
|
||||
.then(({data: res})=>{
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
@@ -130,8 +126,8 @@ define('pgadmin.node.trigger', [
|
||||
}, 10);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
@@ -147,13 +143,8 @@ define('pgadmin.node.trigger', [
|
||||
return false;
|
||||
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'enable' , d, true),
|
||||
type:'PUT',
|
||||
data: {'is_enable_trigger' : 'D'},
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().put(obj.generate_url(i, 'enable' , d, true), {'is_enable_trigger' : 'D'})
|
||||
.then(({data: res})=>{
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
@@ -169,8 +160,8 @@ define('pgadmin.node.trigger', [
|
||||
}, 10);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error, gettext('Disable trigger failed'));
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1965,8 +1965,8 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
|
||||
request.data, encoding='utf-8'
|
||||
)
|
||||
# Convert str 'true' to boolean type
|
||||
is_cascade = json.loads(data.get('cascade') or 'false')
|
||||
is_identity = json.loads(data.get('identity') or 'false')
|
||||
is_cascade = data.get('cascade') or False
|
||||
is_identity = data.get('identity') or False
|
||||
|
||||
data = res['rows'][0]
|
||||
|
||||
|
||||
@@ -2161,8 +2161,8 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
request.data, encoding='utf-8'
|
||||
)
|
||||
|
||||
is_concurrent = json.loads(data['concurrent'])
|
||||
with_data = json.loads(data['with_data'])
|
||||
is_concurrent = data['concurrent']
|
||||
with_data = data['with_data']
|
||||
data = dict()
|
||||
data['is_concurrent'] = is_concurrent
|
||||
data['is_with_data'] = with_data
|
||||
|
||||
@@ -13,6 +13,7 @@ import { getNodePrivilegeRoleSchema } from '../../../../../static/js/privilege.u
|
||||
import { getNodeVacuumSettingsSchema } from '../../../../../static/js/vacuum.ui';
|
||||
import Notify from '../../../../../../../../static/js/helpers/Notifier';
|
||||
import _ from 'lodash';
|
||||
import getApiInstance from '../../../../../../../../static/js/api_instance';
|
||||
|
||||
define('pgadmin.node.mview', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
@@ -86,39 +87,39 @@ define('pgadmin.node.mview', [
|
||||
pgBrowser.add_menus([{
|
||||
name: 'create_mview_on_coll', node: 'coll-mview', module: this,
|
||||
applies: ['object', 'context'], callback: 'show_obj_properties',
|
||||
category: 'create', priority: 1,
|
||||
category: 'create', priority: 1,
|
||||
data: {action: 'create', check: true}, enable: 'canCreate',
|
||||
label: gettext('Materialized View...'),
|
||||
},{
|
||||
name: 'create_mview', node: 'mview', module: this,
|
||||
applies: ['object', 'context'], callback: 'show_obj_properties',
|
||||
category: 'create', priority: 1,
|
||||
category: 'create', priority: 1,
|
||||
data: {action: 'create', check: true}, enable: 'canCreate',
|
||||
label: gettext('Materialized View...'),
|
||||
},{
|
||||
name: 'create_mview', node: 'schema', module: this,
|
||||
applies: ['object', 'context'], callback: 'show_obj_properties',
|
||||
category: 'create', priority: 18,
|
||||
category: 'create', priority: 18,
|
||||
data: {action: 'create', check: false}, enable: 'canCreate',
|
||||
label: gettext('Materialized View...'),
|
||||
},{
|
||||
name: 'refresh_mview_data', node: 'mview', module: this,
|
||||
priority: 1, callback: 'refresh_mview', category: 'refresh_mview',
|
||||
applies: ['object', 'context'], label: gettext('With data'),
|
||||
data: {concurrent: false, with_data: true},
|
||||
data: {concurrent: false, with_data: true},
|
||||
},{
|
||||
name: 'refresh_mview_nodata', node: 'mview',
|
||||
callback: 'refresh_mview', priority: 2, module: this,
|
||||
category: 'refresh_mview', applies: ['object', 'context'],
|
||||
label: gettext('With no data'), data: {
|
||||
concurrent: false, with_data: false,
|
||||
},
|
||||
},
|
||||
},{
|
||||
name: 'refresh_mview_concurrent', node: 'mview', module: this,
|
||||
category: 'refresh_mview', enable: 'is_version_supported',
|
||||
data: {concurrent: true, with_data: true}, priority: 3,
|
||||
applies: ['object', 'context'], callback: 'refresh_mview',
|
||||
label: gettext('With data (concurrently)'),
|
||||
label: gettext('With data (concurrently)'),
|
||||
},{
|
||||
name: 'refresh_mview_concurrent_nodata', node: 'mview', module: this,
|
||||
category: 'refresh_mview', enable: 'is_version_supported',
|
||||
@@ -181,47 +182,41 @@ define('pgadmin.node.mview', [
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'check_utility_exists' , d, true),
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
}).done(function(res) {
|
||||
if (!res.success) {
|
||||
const api = getApiInstance();
|
||||
api.get(obj.generate_url(i, 'check_utility_exists' , d, true))
|
||||
.then(({data: res})=>{
|
||||
if (!res.success) {
|
||||
Notify.alert(
|
||||
gettext('Utility not found'),
|
||||
res.errormsg
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
api.put(obj.generate_url(i, 'refresh_data' , d, true), {'concurrent': args.concurrent, 'with_data': args.with_data})
|
||||
.then(({data: refreshed_res})=>{
|
||||
if (refreshed_res.data && refreshed_res.data.status) {
|
||||
//Do nothing as we are creating the job and exiting from the main dialog
|
||||
pgBrowser.BgProcessManager.startProcess(refreshed_res.data.job_id, refreshed_res.data.desc);
|
||||
} else {
|
||||
Notify.alert(
|
||||
gettext('Failed to create materialized view refresh job.'),
|
||||
refreshed_res.errormsg
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((error)=>{
|
||||
Notify.pgRespErrorNotify(
|
||||
error, gettext('Failed to create materialized view refresh job.')
|
||||
);
|
||||
});
|
||||
})
|
||||
.catch(()=>{
|
||||
Notify.alert(
|
||||
gettext('Utility not found'),
|
||||
res.errormsg
|
||||
gettext('Failed to fetch Utility information')
|
||||
);
|
||||
return;
|
||||
}
|
||||
// Make ajax call to refresh mview data
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'refresh_data' , d, true),
|
||||
type: 'PUT',
|
||||
data: {'concurrent': args.concurrent, 'with_data': args.with_data},
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(refreshed_res) {
|
||||
if (refreshed_res.data && refreshed_res.data.status) {
|
||||
//Do nothing as we are creating the job and exiting from the main dialog
|
||||
pgBrowser.BgProcessManager.startProcess(refreshed_res.data.job_id, refreshed_res.data.desc);
|
||||
} else {
|
||||
Notify.alert(
|
||||
gettext('Failed to create materialized view refresh job.'),
|
||||
refreshed_res.errormsg
|
||||
);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(
|
||||
xhr, error, gettext('Failed to create materialized view refresh job.')
|
||||
);
|
||||
});
|
||||
}).fail(function() {
|
||||
Notify.alert(
|
||||
gettext('Utility not found'),
|
||||
gettext('Failed to fetch Utility information')
|
||||
);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
is_version_supported: function(data, item) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import DatabaseSchema from './database.ui';
|
||||
import Notify from '../../../../../../static/js/helpers/Notifier';
|
||||
import { showServerPassword } from '../../../../../../static/js/Dialogs/index';
|
||||
import _ from 'lodash';
|
||||
import getApiInstance, { parseApiError } from '../../../../../../static/js/api_instance';
|
||||
|
||||
define('pgadmin.node.database', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
@@ -228,41 +229,38 @@ define('pgadmin.node.database', [
|
||||
gettext('Are you sure you want to disconnect from database - %s?', d.label),
|
||||
function() {
|
||||
let data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'connect', d, true),
|
||||
type:'DELETE',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
let prv_i = t.parent(i);
|
||||
if(res.data.info_prefix) {
|
||||
res.info = `${_.escape(res.data.info_prefix)} - ${res.info}`;
|
||||
}
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
data.connected = false;
|
||||
data.icon = data.isTemplate ? 'icon-database-template-not-connected':'icon-database-not-connected';
|
||||
|
||||
t.addIcon(i, {icon: data.icon});
|
||||
t.unload(i);
|
||||
pgBrowser.Events.trigger('pgadmin:browser:tree:update-tree-state', i);
|
||||
setTimeout(function() {
|
||||
t.select(prv_i);
|
||||
}, 10);
|
||||
|
||||
} else {
|
||||
try {
|
||||
Notify.error(res.errormsg);
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
t.unload(i);
|
||||
getApiInstance().delete(
|
||||
obj.generate_url(i, 'connect', d, true),
|
||||
).then(({data: res})=> {
|
||||
if (res.success == 1) {
|
||||
let prv_i = t.parent(i);
|
||||
if(res.data.info_prefix) {
|
||||
res.info = `${_.escape(res.data.info_prefix)} - ${res.info}`;
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
data.connected = false;
|
||||
data.icon = data.isTemplate ? 'icon-database-template-not-connected':'icon-database-not-connected';
|
||||
|
||||
t.addIcon(i, {icon: data.icon});
|
||||
t.unload(i);
|
||||
});
|
||||
pgBrowser.Events.trigger('pgadmin:browser:tree:update-tree-state', i);
|
||||
setTimeout(function() {
|
||||
t.select(prv_i);
|
||||
}, 10);
|
||||
|
||||
} else {
|
||||
try {
|
||||
Notify.error(res.errormsg);
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
t.unload(i);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
function() { return true; }
|
||||
);
|
||||
@@ -372,16 +370,17 @@ define('pgadmin.node.database', [
|
||||
},
|
||||
};
|
||||
|
||||
let api = getApiInstance();
|
||||
let connect_to_database = function(obj, data, tree, item, _wasConnected) {
|
||||
connect(obj, data, tree, item, _wasConnected);
|
||||
},
|
||||
connect = function (obj, data, tree, item, _wasConnected) {
|
||||
let wasConnected = _wasConnected || data.connected,
|
||||
onFailure = function(
|
||||
xhr, status, error, _model, _data, _tree, _item, _status
|
||||
error, _model, _data, _tree, _item, _status
|
||||
) {
|
||||
data.is_connecting = false;
|
||||
if (xhr.status != 200 && xhr.responseText.search('Ticket expired') !== -1) {
|
||||
if (error.response?.status != 200 && error.response?.request?.responseText?.search('Ticket expired') !== -1) {
|
||||
tree.addIcon(_item, {icon: 'icon-server-connecting'});
|
||||
let fetchTicket = Kerberos.fetch_ticket();
|
||||
fetchTicket.then(
|
||||
@@ -392,7 +391,7 @@ define('pgadmin.node.database', [
|
||||
tree.setInode(_item);
|
||||
let dbIcon = data.isTemplate ? 'icon-database-template-not-connected':'icon-database-not-connected';
|
||||
tree.addIcon(_item, {icon: dbIcon});
|
||||
Notify.pgNotifier(fun_error, xhr, gettext('Connect to database.'));
|
||||
Notify.pgNotifier(fun_error, error, gettext('Connect to database.'));
|
||||
}
|
||||
);
|
||||
} else {
|
||||
@@ -402,7 +401,7 @@ define('pgadmin.node.database', [
|
||||
tree.addIcon(_item, {icon: dbIcon});
|
||||
}
|
||||
|
||||
Notify.pgNotifier('error', xhr, error, function(msg) {
|
||||
Notify.pgNotifier('error', error, 'Error', function(msg) {
|
||||
setTimeout(function() {
|
||||
if (msg == 'CRYPTKEY_SET') {
|
||||
connect_to_database(_model, _data, _tree, _item, _wasConnected);
|
||||
@@ -473,21 +472,21 @@ define('pgadmin.node.database', [
|
||||
_tree.select(server);
|
||||
};
|
||||
|
||||
$.post(
|
||||
obj.generate_url(item, 'connect', data, true)
|
||||
).done(function(res) {
|
||||
if (res.success == 1) {
|
||||
return onSuccess(res, obj, data, tree, item, wasConnected);
|
||||
}
|
||||
}).fail(function(xhr, status, error) {
|
||||
if (xhr.status === 410) {
|
||||
error = gettext('Error: Object not found - %s.', error);
|
||||
}
|
||||
api.post(obj.generate_url(item, 'connect', data, true))
|
||||
.then(({data: res})=>{
|
||||
if (res.success == 1) {
|
||||
return onSuccess(res, obj, data, tree, item, wasConnected);
|
||||
}
|
||||
})
|
||||
.catch((error)=>{
|
||||
if (error.response?.status === 410) {
|
||||
error = gettext('Error: Object not found - %s.', parseApiError(error));
|
||||
}
|
||||
|
||||
return onFailure(
|
||||
xhr, status, error, obj, data, tree, item, wasConnected
|
||||
);
|
||||
});
|
||||
return onFailure(
|
||||
error, obj, data, tree, item, wasConnected
|
||||
);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { getNodeAjaxOptions } from '../../../../../static/js/node_ajax';
|
||||
import PgaJobSchema from './pga_job.ui';
|
||||
import { getNodePgaJobStepSchema } from '../../steps/static/js/pga_jobstep.ui';
|
||||
import Notify from '../../../../../../static/js/helpers/Notifier';
|
||||
import getApiInstance from '../../../../../../static/js/api_instance';
|
||||
|
||||
define('pgadmin.node.pga_job', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery', 'pgadmin.browser',
|
||||
@@ -91,17 +92,15 @@ define('pgadmin.node.pga_job', [
|
||||
d = i ? t.itemData(i) : undefined;
|
||||
|
||||
if (d) {
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'run_now', d, true),
|
||||
method:'PUT',
|
||||
})
|
||||
// 'pgagent.pga_job' table updated with current time to run the job
|
||||
// now.
|
||||
.done(function() { t.unload(i); })
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
});
|
||||
getApiInstance().put(
|
||||
obj.generate_url(i, 'run_now', d, true),
|
||||
).then(({data: res})=> {
|
||||
Notify.success(res.info);
|
||||
t.unload(i);
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -68,7 +68,7 @@ export default class BinaryPathSchema extends BaseUISchema {
|
||||
Notify.alert(gettext('Validate binary path'), gettext(res.data.data));
|
||||
})
|
||||
.catch(function (error) {
|
||||
Notify.pgNotifier(error, gettext('Failed to validate binary path.'));
|
||||
Notify.pgNotifier('error', error, gettext('Failed to validate binary path.'));
|
||||
});
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -12,6 +12,7 @@ import ServerSchema from './server.ui';
|
||||
import Notify from '../../../../../static/js/helpers/Notifier';
|
||||
import { showServerPassword, showChangeServerPassword, showNamedRestorePoint } from '../../../../../static/js/Dialogs/index';
|
||||
import _ from 'lodash';
|
||||
import getApiInstance, { parseApiError } from '../../../../../static/js/api_instance';
|
||||
|
||||
define('pgadmin.node.server', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
@@ -196,45 +197,40 @@ define('pgadmin.node.server', [
|
||||
notify = notify || _.isUndefined(notify) || _.isNull(notify);
|
||||
|
||||
let disconnect = function() {
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'connect', d, true),
|
||||
type:'DELETE',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
d = t.itemData(i);
|
||||
t.removeIcon(i);
|
||||
d.connected = false;
|
||||
if (d.shared && pgAdmin.server_mode == 'True'){
|
||||
d.icon = 'icon-shared-server-not-connected';
|
||||
}else{
|
||||
d.icon = 'icon-server-not-connected';
|
||||
getApiInstance().delete(
|
||||
obj.generate_url(i, 'connect', d, true),
|
||||
).then(({data: res})=> {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
d = t.itemData(i);
|
||||
t.removeIcon(i);
|
||||
d.connected = false;
|
||||
if (d.shared && pgAdmin.server_mode == 'True'){
|
||||
d.icon = 'icon-shared-server-not-connected';
|
||||
}else{
|
||||
d.icon = 'icon-server-not-connected';
|
||||
}
|
||||
t.addIcon(i, {icon: d.icon});
|
||||
obj.callbacks.refresh.apply(obj, [null, i]);
|
||||
setTimeout(() => {
|
||||
t.close(i);
|
||||
}, 10);
|
||||
if (pgBrowser.serverInfo && d._id in pgBrowser.serverInfo) {
|
||||
delete pgBrowser.serverInfo[d._id];
|
||||
}
|
||||
else {
|
||||
try {
|
||||
Notify.error(res.errormsg);
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
t.addIcon(i, {icon: d.icon});
|
||||
obj.callbacks.refresh.apply(obj, [null, i]);
|
||||
setTimeout(() => {
|
||||
t.close(i);
|
||||
}, 10);
|
||||
if (pgBrowser.serverInfo && d._id in pgBrowser.serverInfo) {
|
||||
delete pgBrowser.serverInfo[d._id];
|
||||
}
|
||||
else {
|
||||
try {
|
||||
Notify.error(res.errormsg);
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
t.unload(i);
|
||||
}
|
||||
pgBrowser.Events.trigger(
|
||||
'pgadmin:server:disconnect', {item: i, data: d}, false
|
||||
);
|
||||
}})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
});
|
||||
t.unload(i);
|
||||
}
|
||||
}
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
};
|
||||
|
||||
if (notify) {
|
||||
@@ -295,22 +291,19 @@ define('pgadmin.node.server', [
|
||||
gettext('Reload server configuration'),
|
||||
gettext('Are you sure you want to reload the server configuration on %s?', d.label),
|
||||
function() {
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'reload', d, true),
|
||||
method:'GET',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.data.status) {
|
||||
Notify.success(res.data.result);
|
||||
}
|
||||
else {
|
||||
Notify.error(res.data.result);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
});
|
||||
getApiInstance().get(
|
||||
obj.generate_url(i, 'reload', d, true),
|
||||
).then(({data: res})=> {
|
||||
if (res.data.status) {
|
||||
Notify.success(res.data.result);
|
||||
}
|
||||
else {
|
||||
Notify.error(res.data.result);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
function() { return true; },
|
||||
);
|
||||
@@ -344,19 +337,16 @@ define('pgadmin.node.server', [
|
||||
|
||||
if (d) {
|
||||
// Call to check if server is using pgpass file or not
|
||||
$.ajax({
|
||||
url: check_pgpass_url,
|
||||
method:'GET',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success && res.data.is_pgpass) {
|
||||
is_pgpass_file_used = true;
|
||||
}
|
||||
showChangeServerPassword(gettext('Change Password'), d, obj, i, is_pgpass_file_used);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
});
|
||||
getApiInstance().get(
|
||||
check_pgpass_url
|
||||
).then(({data: res})=> {
|
||||
if (res.success && res.data.is_pgpass) {
|
||||
is_pgpass_file_used = true;
|
||||
}
|
||||
showChangeServerPassword(gettext('Change Password'), d, obj, i, is_pgpass_file_used);
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -387,18 +377,14 @@ define('pgadmin.node.server', [
|
||||
if (!d)
|
||||
return false;
|
||||
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'wal_replay' , d, true),
|
||||
type:'DELETE',
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
obj.on_done(res, t, i);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
});
|
||||
getApiInstance().delete(
|
||||
obj.generate_url(i, 'wal_replay' , d, true)
|
||||
).then(({data: res})=> {
|
||||
obj.on_done(res, t, i);
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
|
||||
/* Resume WAL Replay */
|
||||
@@ -412,18 +398,14 @@ define('pgadmin.node.server', [
|
||||
if (!d)
|
||||
return false;
|
||||
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'wal_replay' , d, true),
|
||||
type:'PUT',
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
obj.on_done(res, t, i);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
});
|
||||
getApiInstance().put(
|
||||
obj.generate_url(i, 'wal_replay' , d, true)
|
||||
).then(({data: res})=> {
|
||||
obj.on_done(res, t, i);
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
|
||||
/* Cleat saved database server password */
|
||||
@@ -439,22 +421,19 @@ define('pgadmin.node.server', [
|
||||
gettext('Clear saved password'),
|
||||
gettext('Are you sure you want to clear the saved password for server %s?', d.label),
|
||||
function() {
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'clear_saved_password', d, true),
|
||||
method:'PUT',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.itemData(i).is_password_saved=res.data.is_password_saved;
|
||||
}
|
||||
else {
|
||||
Notify.error(res.info);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
});
|
||||
getApiInstance().put(
|
||||
obj.generate_url(i, 'clear_saved_password' , d, true)
|
||||
).then(({data: res})=> {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.itemData(i).is_password_saved=res.data.is_password_saved;
|
||||
}
|
||||
else {
|
||||
Notify.error(res.info);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
});
|
||||
},
|
||||
function() { return true; }
|
||||
);
|
||||
@@ -476,22 +455,19 @@ define('pgadmin.node.server', [
|
||||
gettext('Clear SSH Tunnel password'),
|
||||
gettext('Are you sure you want to clear the saved password of SSH Tunnel for server %s?', d.label),
|
||||
function() {
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'clear_sshtunnel_password', d, true),
|
||||
method:'PUT',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.itemData(i).is_tunnel_password_saved=res.data.is_tunnel_password_saved;
|
||||
}
|
||||
else {
|
||||
Notify.error(res.info);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
});
|
||||
getApiInstance().put(
|
||||
obj.generate_url(i, 'clear_sshtunnel_password' , d, true)
|
||||
).then(({data: res})=> {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.itemData(i).is_tunnel_password_saved=res.data.is_tunnel_password_saved;
|
||||
}
|
||||
else {
|
||||
Notify.error(res.info);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
});
|
||||
},
|
||||
function() { return true; }
|
||||
);
|
||||
@@ -595,8 +571,8 @@ define('pgadmin.node.server', [
|
||||
// Open properties dialog in edit mode
|
||||
let server_url = obj.generate_url(item, 'obj', data, true);
|
||||
// Fetch the updated data
|
||||
$.get(server_url)
|
||||
.done(function(res) {
|
||||
getApiInstance().get(server_url)
|
||||
.then(({data: res})=>{
|
||||
if (res.shared && _.isNull(res.username) && data.user_id != current_user.id) {
|
||||
if (!res.service) {
|
||||
pgAdmin.Browser.Node.callbacks.show_obj_properties.call(
|
||||
@@ -617,13 +593,14 @@ define('pgadmin.node.server', [
|
||||
else if (res.cloud_status == -1) {
|
||||
pgAdmin.Browser.BgProcessManager.recheckCloudServer(data._id);
|
||||
}
|
||||
}).always(function(){
|
||||
})
|
||||
.then(()=>{
|
||||
data.is_connecting = false;
|
||||
});
|
||||
|
||||
let wasConnected = reconnect || data.connected,
|
||||
onFailure = function(
|
||||
xhr, status, error, _node, _data, _tree, _item, _wasConnected
|
||||
xhr, error, _node, _data, _tree, _item, _wasConnected
|
||||
) {
|
||||
data.connected = false;
|
||||
|
||||
@@ -647,7 +624,7 @@ define('pgadmin.node.server', [
|
||||
},
|
||||
function() {
|
||||
tree.addIcon(_item, {icon: 'icon-server-not-connected'});
|
||||
Notify.pgNotifier('Connection error', xhr, gettext('Connect to server.'));
|
||||
Notify.pgNotifier('error', 'Connection error', xhr, gettext('Connect to server.'));
|
||||
}
|
||||
);
|
||||
} else {
|
||||
@@ -750,20 +727,20 @@ define('pgadmin.node.server', [
|
||||
tree.removeIcon(item);
|
||||
tree.addIcon(item, {icon: 'icon-server-connecting'});
|
||||
let url = obj.generate_url(item, 'connect', data, true);
|
||||
$.post(url)
|
||||
.done(function(res) {
|
||||
getApiInstance().post(url)
|
||||
.then(({data: res})=>{
|
||||
if (res.success == 1) {
|
||||
return onSuccess(
|
||||
res, obj, data, tree, item, wasConnected
|
||||
);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
.catch((xhr)=>{
|
||||
return onFailure(
|
||||
xhr, status, error, obj, data, tree, item, wasConnected
|
||||
xhr.response?.request, parseApiError(xhr), obj, data, tree, item, wasConnected
|
||||
);
|
||||
})
|
||||
.always(function(){
|
||||
.then(()=>{
|
||||
data.is_connecting = false;
|
||||
});
|
||||
};
|
||||
@@ -773,8 +750,9 @@ define('pgadmin.node.server', [
|
||||
tree.setLeaf(item);
|
||||
tree.removeIcon(item);
|
||||
tree.addIcon(item, {icon: 'icon-server-connecting'});
|
||||
$.get(url)
|
||||
.done(function(res) {
|
||||
|
||||
getApiInstance().get(url)
|
||||
.then(({data: res})=>{
|
||||
tree.setInode(item);
|
||||
if (res && res.data) {
|
||||
if (typeof res.data.icon == 'string') {
|
||||
@@ -796,14 +774,14 @@ define('pgadmin.node.server', [
|
||||
);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
.catch((error)=>{
|
||||
tree.setInode(item);
|
||||
if (data.shared && pgAdmin.server_mode == 'True'){
|
||||
tree.addIcon(item, {icon: 'icon-shared-server-not-connected'});
|
||||
}else{
|
||||
tree.addIcon(item, {icon: 'icon-server-not-connected'});
|
||||
}
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
Notify.pgRespErrorNotify(error);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,23 +16,26 @@ import { checkMasterPassword } from '../../../static/js/Dialogs/index';
|
||||
import { pgHandleItemError } from '../../../static/js/utils';
|
||||
import { Search } from './quick_search/trigger_search';
|
||||
import { send_heartbeat, stop_heartbeat } from './heartbeat';
|
||||
import getApiInstance from '../../../static/js/api_instance';
|
||||
|
||||
define('pgadmin.browser', [
|
||||
'sources/gettext', 'sources/url_for', 'require', 'jquery',
|
||||
'bootstrap', 'sources/pgadmin', 'bundled_codemirror',
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
'sources/pgadmin', 'bundled_codemirror',
|
||||
'sources/check_node_visibility', './toolbar', 'pgadmin.help',
|
||||
'sources/csrf', 'sources/utils', 'sources/window', 'pgadmin.authenticate.kerberos',
|
||||
'sources/tree/tree_init',
|
||||
'pgadmin.browser.utils', 'wcdocker', 'jquery.contextmenu',
|
||||
'pgadmin.browser.utils',
|
||||
'pgadmin.browser.preferences', 'pgadmin.browser.messages',
|
||||
'pgadmin.browser.panel', 'pgadmin.browser.layout',
|
||||
'pgadmin.browser.error', 'pgadmin.browser.frame',
|
||||
'pgadmin.browser.frame',
|
||||
'pgadmin.browser.node', 'pgadmin.browser.collection', 'pgadmin.browser.activity',
|
||||
'sources/codemirror/addon/fold/pgadmin-sqlfoldcode',
|
||||
'pgadmin.browser.keyboard', 'sources/tree/pgadmin_tree_save_state'
|
||||
'pgadmin.browser.keyboard', 'sources/tree/pgadmin_tree_save_state',
|
||||
/* wcDocker dependencies */
|
||||
'bootstrap', 'jquery-contextmenu', 'wcdocker',
|
||||
], function(
|
||||
gettext, url_for, require, $,
|
||||
Bootstrap, pgAdmin, codemirror,
|
||||
gettext, url_for, $,
|
||||
pgAdmin, codemirror,
|
||||
checkNodeVisibility, toolBar, help, csrfToken, pgadminUtils, pgWindow,
|
||||
Kerberos, InitTree,
|
||||
) {
|
||||
@@ -201,9 +204,9 @@ define('pgadmin.browser', [
|
||||
icon: '',
|
||||
limit: 1,
|
||||
content: '<div id="tree" class="browser-tree"></div>',
|
||||
onCreate: function(panel, $container) {
|
||||
onCreate: function(panel, container) {
|
||||
toolBar.initializeToolbar(panel, wcDocker);
|
||||
$container.addClass('pg-no-overflow');
|
||||
container.classList.add('pg-no-overflow');
|
||||
},
|
||||
}),
|
||||
// Properties of the object node
|
||||
@@ -216,10 +219,10 @@ define('pgadmin.browser', [
|
||||
isPrivate: true,
|
||||
elContainer: true,
|
||||
limit: 1,
|
||||
content: '<div class="obj_properties container-fluid h-100"><div role="status" class="pg-panel-message">' + select_object_msg + '</div></div>',
|
||||
content: '<div class="obj_properties"><div role="status" class="pg-panel-message">' + select_object_msg + '</div></div>',
|
||||
events: panelEvents,
|
||||
onCreate: function(myPanel, $container) {
|
||||
$container.addClass('pg-no-overflow');
|
||||
onCreate: function(myPanel, container) {
|
||||
container.classList.add('pg-no-overflow');
|
||||
},
|
||||
}),
|
||||
// Statistics of the object
|
||||
@@ -232,7 +235,7 @@ define('pgadmin.browser', [
|
||||
isPrivate: false,
|
||||
limit : 1,
|
||||
canHide: true,
|
||||
content: '<div class="negative-space p-2"><div role="status" class="pg-panel-message pg-panel-statistics-message">' + select_object_msg + '</div><div class="pg-panel-statistics-container d-none"></div></div>',
|
||||
content: '<div></div>',
|
||||
events: panelEvents,
|
||||
}),
|
||||
// Reversed engineered SQL for the object
|
||||
@@ -244,7 +247,7 @@ define('pgadmin.browser', [
|
||||
isCloseable: false,
|
||||
isPrivate: true,
|
||||
limit: 1,
|
||||
content: '<label for="sql-textarea" class="sr-only">' + gettext('SQL Code') + '</label><div class="sql_textarea"><textarea id="sql-textarea" name="sql-textarea" title="' + gettext('SQL Code') + '"></textarea></div>',
|
||||
content: '<div></div>',
|
||||
}),
|
||||
// Dependencies of the object
|
||||
'dependencies': new pgAdmin.Browser.Panel({
|
||||
@@ -256,7 +259,7 @@ define('pgadmin.browser', [
|
||||
isPrivate: false,
|
||||
canHide: true,
|
||||
limit: 1,
|
||||
content: '<div class="negative-space p-2"><div role="status" class="pg-panel-message pg-panel-depends-message">' + select_object_msg + '</div><div class="pg-panel-dependencies-container d-none"></div></div>',
|
||||
content: '<div></div>',
|
||||
events: panelEvents,
|
||||
}),
|
||||
// Dependents of the object
|
||||
@@ -269,7 +272,7 @@ define('pgadmin.browser', [
|
||||
isPrivate: false,
|
||||
limit: 1,
|
||||
canHide: true,
|
||||
content: '<div class="negative-space p-2"><div role="status" class="pg-panel-message pg-panel-depends-message">' + select_object_msg + '</div><div class="pg-panel-dependents-container d-none"></div></div>',
|
||||
content: '<div></div>',
|
||||
events: panelEvents,
|
||||
}),
|
||||
// Background processes
|
||||
@@ -282,7 +285,7 @@ define('pgadmin.browser', [
|
||||
isPrivate: false,
|
||||
limit: 1,
|
||||
canHide: true,
|
||||
content: '<div class="negative-space p-2"><div class="pg-panel-processes-container d-none"></div></div>',
|
||||
content: '<div></div>',
|
||||
events: panelEvents,
|
||||
}),
|
||||
},
|
||||
@@ -526,17 +529,6 @@ define('pgadmin.browser', [
|
||||
initializeModalProvider();
|
||||
initializeNotifier();
|
||||
|
||||
// Syntax highlight the SQL Pane
|
||||
if(document.getElementById('sql-textarea')){
|
||||
obj.editor = CodeMirror.fromTextArea(
|
||||
document.getElementById('sql-textarea'), {
|
||||
lineNumbers: true,
|
||||
mode: 'text/x-pgsql',
|
||||
readOnly: true,
|
||||
extraKeys: pgAdmin.Browser.editor_shortcut_keys,
|
||||
screenReaderLabel: gettext('SQL'),
|
||||
});
|
||||
}
|
||||
/* Cache may take time to load for the first time
|
||||
* Reflect the changes once cache is available
|
||||
*/
|
||||
@@ -568,18 +560,15 @@ define('pgadmin.browser', [
|
||||
// Register scripts and add menus
|
||||
pgBrowser.utils.registerScripts(this);
|
||||
|
||||
let headers = {};
|
||||
headers[pgAdmin.csrf_token_header] = pgAdmin.csrf_token;
|
||||
|
||||
// Ping the server every 5 minutes
|
||||
setInterval(function() {
|
||||
$.ajax({
|
||||
url: url_for('misc.cleanup'),
|
||||
type:'POST',
|
||||
headers: headers,
|
||||
})
|
||||
.done(function() {/*This is intentional (SonarQube)*/})
|
||||
.fail(function() {/*This is intentional (SonarQube)*/});
|
||||
getApiInstance().post(
|
||||
url_for('misc.cleanup')
|
||||
).then(()=> {
|
||||
/*This is intentional (SonarQube)*/
|
||||
}).catch(function() {
|
||||
/*This is intentional (SonarQube)*/
|
||||
});
|
||||
}, 300000);
|
||||
|
||||
obj.Events.on(
|
||||
@@ -608,12 +597,9 @@ define('pgadmin.browser', [
|
||||
if (this.tree) this.tree.resizeTree();
|
||||
},
|
||||
check_corrupted_db_file: function() {
|
||||
$.ajax({
|
||||
url: url_for('browser.check_corrupted_db_file'),
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
}).done((res)=> {
|
||||
getApiInstance().get(
|
||||
url_for('browser.check_corrupted_db_file')
|
||||
).then(({data: res})=> {
|
||||
if(res.data.length > 0) {
|
||||
|
||||
Notify.alert(
|
||||
@@ -626,16 +612,14 @@ define('pgadmin.browser', [
|
||||
res.data.substring(0, res.data.length - 14),
|
||||
);
|
||||
}
|
||||
}).fail(function(xhr, status, error) {
|
||||
}).catch(function(error) {
|
||||
Notify.alert(error);
|
||||
});
|
||||
},
|
||||
check_master_password: function(on_resp_callback) {
|
||||
$.ajax({
|
||||
url: url_for('browser.check_master_password'),
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
}).done((res)=> {
|
||||
getApiInstance().get(
|
||||
url_for('browser.check_master_password')
|
||||
).then(({data: res})=> {
|
||||
if(on_resp_callback) {
|
||||
if(res.data) {
|
||||
on_resp_callback(true);
|
||||
@@ -643,23 +627,21 @@ define('pgadmin.browser', [
|
||||
on_resp_callback(false);
|
||||
}
|
||||
}
|
||||
}).fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
});
|
||||
},
|
||||
|
||||
reset_master_password: function() {
|
||||
let self = this;
|
||||
$.ajax({
|
||||
url: url_for('browser.set_master_password'),
|
||||
type: 'DELETE',
|
||||
contentType: 'application/json',
|
||||
}).done((res)=> {
|
||||
getApiInstance().delete(
|
||||
url_for('browser.set_master_password')
|
||||
).then(({data: res})=> {
|
||||
if(!res.data) {
|
||||
self.set_master_password('');
|
||||
}
|
||||
}).fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1687,59 +1669,51 @@ define('pgadmin.browser', [
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let api = getApiInstance();
|
||||
let fetchNodeInfo = function(__i, __d, __n) {
|
||||
let info = __n.getTreeNodeHierarchy(__i),
|
||||
url = __n.generate_url(__i, 'nodes', __d, true);
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'GET',
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
api.get(
|
||||
url
|
||||
).then(({data: res})=> {
|
||||
// Node information can come as result/data
|
||||
let newData = res.result || res.data;
|
||||
let newData = res.result || res.data;
|
||||
|
||||
newData._label = newData.label;
|
||||
newData.label = _.escape(newData.label);
|
||||
newData._label = newData.label;
|
||||
newData.label = _.escape(newData.label);
|
||||
|
||||
ctx.t.setLabel(ctx.i, {label: newData.label});
|
||||
ctx.t.addIcon(ctx.i, {icon: newData.icon});
|
||||
ctx.t.setId(ctx.i, {id: newData.id});
|
||||
if (newData.inode)
|
||||
ctx.t.setInode(ctx.i, {inode: true});
|
||||
ctx.t.setLabel(ctx.i, {label: newData.label});
|
||||
ctx.t.addIcon(ctx.i, {icon: newData.icon});
|
||||
ctx.t.setId(ctx.i, {id: newData.id});
|
||||
if (newData.inode)
|
||||
ctx.t.setInode(ctx.i, {inode: true});
|
||||
|
||||
// This will update the tree item data.
|
||||
let itemData = ctx.t.itemData(ctx.i);
|
||||
_.extend(itemData, newData);
|
||||
// This will update the tree item data.
|
||||
let itemData = ctx.t.itemData(ctx.i);
|
||||
_.extend(itemData, newData);
|
||||
|
||||
if (
|
||||
__n.can_expand && typeof(__n.can_expand) == 'function'
|
||||
) {
|
||||
if (!__n.can_expand(itemData)) {
|
||||
ctx.t.unload(ctx.i);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
__n.can_expand && typeof(__n.can_expand) == 'function'
|
||||
) {
|
||||
if (!__n.can_expand(itemData)) {
|
||||
ctx.t.unload(ctx.i);
|
||||
return;
|
||||
}
|
||||
ctx.b._refreshNode(ctx, ctx.branch);
|
||||
let success = (ctx.o && ctx.o.success) || ctx.success;
|
||||
if (success && typeof(success) == 'function') {
|
||||
success();
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, error) {
|
||||
if (!pgHandleItemError(
|
||||
xhr, {item: __i, info: info}
|
||||
)) {
|
||||
let contentType = xhr.getResponseHeader('Content-Type'),
|
||||
jsonResp = (
|
||||
contentType &&
|
||||
contentType.indexOf('application/json') == 0 &&
|
||||
JSON.parse(xhr.responseText)
|
||||
) || {};
|
||||
|
||||
if (xhr.status == 410 && jsonResp.success == 0) {
|
||||
}
|
||||
ctx.b._refreshNode(ctx, ctx.branch);
|
||||
let success = (ctx.o && ctx.o.success) || ctx.success;
|
||||
if (success && typeof(success) == 'function') {
|
||||
success();
|
||||
}
|
||||
}).catch(function(error) {
|
||||
if (!pgHandleItemError(
|
||||
error, {item: __i, info: info}
|
||||
)) {
|
||||
if(error.response.headers['content-type'] == 'application/json') {
|
||||
let jsonResp = error.response.data ?? {};
|
||||
if(error.response.status == 410 && jsonResp.success == 0) {
|
||||
let parent = ctx.t.parent(ctx.i);
|
||||
|
||||
ctx.t.remove(ctx.i, {
|
||||
@@ -1755,16 +1729,17 @@ define('pgadmin.browser', [
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Notify.pgNotifier(error, xhr, gettext('Error retrieving details for the node.'), function (msg) {
|
||||
if (msg == 'CRYPTKEY_SET') {
|
||||
fetchNodeInfo(__i, __d, __n);
|
||||
} else {
|
||||
console.warn(arguments);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Notify.pgNotifier('error', error, gettext('Error retrieving details for the node.'), function (msg) {
|
||||
if (msg == 'CRYPTKEY_SET') {
|
||||
fetchNodeInfo(__i, __d, __n);
|
||||
} else {
|
||||
console.warn(arguments);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}.bind(this);
|
||||
|
||||
if (n && n.collection_node) {
|
||||
@@ -1935,6 +1910,7 @@ define('pgadmin.browser', [
|
||||
},
|
||||
|
||||
addChildTreeNodes: function(_treeHierarchy, _node, _type, _arrayIds, _callback) {
|
||||
let api = getApiInstance();
|
||||
let module = _type in pgBrowser.Nodes && pgBrowser.Nodes[_type],
|
||||
childTreeInfo = _arrayIds.length && _.extend(
|
||||
{}, _.mapValues(_treeHierarchy, function(_val) {
|
||||
@@ -1961,20 +1937,17 @@ define('pgadmin.browser', [
|
||||
|
||||
_node = _node || arguments[1];
|
||||
|
||||
$.ajax({
|
||||
url: childNodeUrl,
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success) {
|
||||
arrayChildNodeData.push(res.data);
|
||||
}
|
||||
fetchNodeInfo(_callback);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
fetchNodeInfo(_callback);
|
||||
});
|
||||
api.get(
|
||||
childNodeUrl
|
||||
).then(({data: res})=> {
|
||||
if (res.success) {
|
||||
arrayChildNodeData.push(res.data);
|
||||
}
|
||||
fetchNodeInfo(_callback);
|
||||
}).catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
fetchNodeInfo(_callback);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2023, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import Notify from '../../../static/js/helpers/Notifier';
|
||||
import _ from 'lodash';
|
||||
|
||||
define(
|
||||
['sources/gettext', 'sources/pgadmin'],
|
||||
function(gettext, pgAdmin) {
|
||||
pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
|
||||
_.extend(pgAdmin.Browser, {
|
||||
report_error: function(title, message, info, callback) {
|
||||
title = _.escape(title);
|
||||
message = _.escape(message);
|
||||
info = _.escape(info);
|
||||
let text ='<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">'
|
||||
+ '<div class="panel panel-default">'
|
||||
+ '<div class="panel-heading" role="tab" id="headingOne">'
|
||||
+ '<h4 class="panel-title">'
|
||||
+ '<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">' + gettext('Error message') + '</a>'
|
||||
+ '</h4>'
|
||||
+ '</div>'
|
||||
+ '<div id="collapseOne" class="panel-collapse collapse show" role="tabpanel" aria-labelledby="headingOne">'
|
||||
+ '<div class="panel-body" style="overflow: auto;">' + message + '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>';
|
||||
|
||||
if (info != null && info != '') {
|
||||
text += '<div class="panel panel-default">'
|
||||
+ '<div class="panel-heading" role="tab" id="headingTwo">'
|
||||
+ '<h4 class="panel-title">'
|
||||
+ '<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">' + gettext('Additional info') + '</a>'
|
||||
+ '</h4>'
|
||||
+ '</div>'
|
||||
+ '<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">'
|
||||
+ '<div class="panel-body" style="overflow: auto;">' + info + '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>';
|
||||
}
|
||||
|
||||
text += '</div>';
|
||||
Notify.alert(
|
||||
_.unescape(title),
|
||||
text,
|
||||
function() {
|
||||
if(callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
return pgAdmin.Browser.report_error;
|
||||
});
|
||||
@@ -46,7 +46,6 @@ define([
|
||||
isPrivate: that.isPrivate,
|
||||
isLayoutMember: that.isLayoutMember,
|
||||
onCreate: function(myPanel) {
|
||||
$(myPanel).data('pgAdminName', that.name);
|
||||
myPanel.initSize(that.width, that.height);
|
||||
|
||||
if (!(myPanel.showTitle??true))
|
||||
@@ -61,13 +60,17 @@ define([
|
||||
myPanel.layout().addItem($frameArea);
|
||||
that.panel = myPanel;
|
||||
let frame = new wcIFrame($frameArea, myPanel);
|
||||
$(myPanel).data('frameInitialized', false);
|
||||
$(myPanel).data('embeddedFrame', frame);
|
||||
|
||||
myPanel.frameData = {
|
||||
pgAdminName: that.name,
|
||||
frameInitialized: false,
|
||||
embeddedFrame: frame,
|
||||
};
|
||||
|
||||
if (that.url != '' && that.url != 'about:blank') {
|
||||
setTimeout(function() {
|
||||
frame.openURL(that.url);
|
||||
$(myPanel).data('frameInitialized', true);
|
||||
myPanel.frameData.frameInitialized = true;
|
||||
pgBrowser.Events.trigger(
|
||||
'pgadmin-browser:frame:urlloaded:' + that.name, frame,
|
||||
that.url, self
|
||||
@@ -75,7 +78,7 @@ define([
|
||||
}, 50);
|
||||
} else {
|
||||
frame.openURL('about:blank');
|
||||
$(myPanel).data('frameInitialized', true);
|
||||
myPanel.frameData.frameInitialized = true;
|
||||
pgBrowser.Events.trigger(
|
||||
'pgadmin-browser:frame:urlloaded:' + that.name, frame,
|
||||
that.url, self
|
||||
@@ -112,7 +115,7 @@ define([
|
||||
}
|
||||
},
|
||||
eventFunc: function(eventName) {
|
||||
let name = $(this).data('pgAdminName');
|
||||
let name = this.frameData.pgAdminName;
|
||||
|
||||
try {
|
||||
pgBrowser.Events.trigger('pgadmin-browser:frame', eventName, this, arguments);
|
||||
|
||||
@@ -9,13 +9,10 @@
|
||||
|
||||
import _ from 'lodash';
|
||||
import pgAdmin from '../../../static/js/pgadmin';
|
||||
import $ from 'jquery';
|
||||
import Mousetrap from 'mousetrap';
|
||||
import * as commonUtils from '../../../static/js/utils';
|
||||
import dialogTabNavigator from '../../../static/js/dialog_tab_navigator';
|
||||
import * as keyboardFunc from 'sources/keyboard_shortcuts';
|
||||
import pgWindow from 'sources/window';
|
||||
import gettext from 'sources/gettext';
|
||||
import pgWindow from 'sources/window';
|
||||
|
||||
const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
|
||||
@@ -78,33 +75,6 @@ _.extend(pgBrowser.keyboardNavigation, {
|
||||
_.each(self.shortcutMethods, (keyCombo, callback) => {
|
||||
self._bindWithMousetrap(keyCombo.shortcuts, self[callback], keyCombo.bindElem);
|
||||
});
|
||||
|
||||
|
||||
/* Dropdown submenu was not working properly for up/down arrow keys.
|
||||
* So up/down/right/left events for dropdown were removed from Mousetrap and were
|
||||
* handled manually.
|
||||
*/
|
||||
const LEFT_KEY = 37,
|
||||
UP_KEY = 38,
|
||||
RIGHT_KEY = 39,
|
||||
DOWN_KEY = 40;
|
||||
|
||||
$('.pg-navbar').on('keydown', (event)=> {
|
||||
switch(event.keyCode) {
|
||||
case LEFT_KEY:
|
||||
self.bindMainMenuLeft(event);
|
||||
break;
|
||||
case UP_KEY:
|
||||
self.bindMainMenuUpDown(event, 'up');
|
||||
break;
|
||||
case RIGHT_KEY:
|
||||
self.bindMainMenuRight(event);
|
||||
break;
|
||||
case DOWN_KEY:
|
||||
self.bindMainMenuUpDown(event, 'down');
|
||||
break;
|
||||
}
|
||||
});
|
||||
},
|
||||
_bindWithMousetrap: function(shortcuts, callback, bindElem) {
|
||||
const self = this;
|
||||
@@ -179,89 +149,10 @@ _.extend(pgBrowser.keyboardNavigation, {
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
bindMainMenuLeft: function(event) {
|
||||
if ($(event.target).hasClass('nav-link')) { // Menu items
|
||||
let currNavMenu = $(event.target).closest('.nav-item');
|
||||
keyboardFunc._stopEventPropagation(event);
|
||||
|
||||
currNavMenu = currNavMenu.prev('.nav-item');
|
||||
// Skip hidden menus
|
||||
while(currNavMenu.hasClass('d-none')) {
|
||||
currNavMenu = currNavMenu.prev('.nav-item');
|
||||
}
|
||||
|
||||
currNavMenu.find('.dropdown-toggle').first().dropdown('toggle');
|
||||
|
||||
} else if($(event.target).closest('.dropdown-menu').length > 0) {
|
||||
let currLi = $(event.target).closest('li');
|
||||
keyboardFunc._stopEventPropagation(event);
|
||||
/*close submenu*/
|
||||
let currMenu = currLi.closest('.dropdown-menu');
|
||||
if(currMenu.closest('.dropdown-submenu').length > 0) {
|
||||
currMenu.removeClass('show');
|
||||
currMenu.closest('.dropdown-submenu').removeClass('dropdown-submenu-visible');
|
||||
currLi = currMenu.closest('.dropdown-submenu');
|
||||
currLi.find('.dropdown-item').trigger('focus');
|
||||
}
|
||||
}
|
||||
},
|
||||
bindMainMenuRight: function(event) {
|
||||
if ($(event.target).hasClass('nav-link')) { // Menu items
|
||||
let currNavMenu = $(event.target).closest('.nav-item');
|
||||
keyboardFunc._stopEventPropagation(event);
|
||||
|
||||
currNavMenu = currNavMenu.next('.nav-item');
|
||||
// Skip hidden menus
|
||||
while(currNavMenu.hasClass('d-none')) {
|
||||
currNavMenu = currNavMenu.next('.nav-item');
|
||||
}
|
||||
|
||||
currNavMenu.find('.dropdown-toggle').first().dropdown('toggle');
|
||||
} else if($(event.target).closest('.dropdown-menu').length > 0) {
|
||||
let currLi = $(event.target).closest('li');
|
||||
keyboardFunc._stopEventPropagation(event);
|
||||
|
||||
/*open submenu if any*/
|
||||
if(currLi.hasClass('dropdown-submenu')){
|
||||
currLi.addClass('dropdown-submenu-visible');
|
||||
currLi.find('.dropdown-menu').addClass('show');
|
||||
currLi.find('.dropdown-menu .dropdown-item').first().trigger('focus');
|
||||
}
|
||||
}
|
||||
},
|
||||
bindMainMenuUpDown: function(event, combo) {
|
||||
// Handle Sub-menus
|
||||
if($(event.target).closest('.dropdown-menu').length > 0) {
|
||||
keyboardFunc._stopEventPropagation(event);
|
||||
let currLi = $(event.target).closest('li');
|
||||
/*close all the submenus on movement*/
|
||||
let dropMenu = $(event.target).closest('.dropdown-menu');
|
||||
dropMenu.find('.show').removeClass('show');
|
||||
dropMenu.find('.dropdown-submenu').removeClass('dropdown-submenu-visible');
|
||||
if(combo === 'up') {
|
||||
currLi = currLi.prev();
|
||||
}
|
||||
else if(combo === 'down'){
|
||||
currLi = currLi.next();
|
||||
}
|
||||
|
||||
/*do not focus on divider and disabled */
|
||||
while(currLi.hasClass('dropdown-divider')
|
||||
|| currLi.find('.dropdown-item').first().hasClass('disabled')) {
|
||||
if(combo === 'up') {
|
||||
currLi = currLi.prev();
|
||||
}
|
||||
else if(combo === 'down'){
|
||||
currLi = currLi.next();
|
||||
}
|
||||
}
|
||||
currLi.find('.dropdown-item').trigger('focus');
|
||||
}
|
||||
},
|
||||
bindLeftTree: function() {
|
||||
const tree = this.getTreeDetails();
|
||||
|
||||
$('#tree').trigger('focus');
|
||||
document.querySelector('[id="tree"]').focus();
|
||||
tree.t.select(tree.i);
|
||||
},
|
||||
bindSubMenuQueryTool: function() {
|
||||
@@ -336,17 +227,6 @@ _.extend(pgBrowser.keyboardNavigation, {
|
||||
// Call refresh object callback
|
||||
pgAdmin.Browser.Node.callbacks.refresh.call(pgAdmin.Browser.Nodes[tree.t.itemData(tree.i)._type]);
|
||||
},
|
||||
bindContextMenu: function(event) {
|
||||
const tree = this.getTreeDetails();
|
||||
let _srcElement = event.srcElement || event.target;
|
||||
const left = $(_srcElement).find('.aciTreeEntry').position().left + 70;
|
||||
const top = $(_srcElement).find('.aciTreeEntry').position().top + 70;
|
||||
|
||||
tree.t.blur(tree.i);
|
||||
$('#tree').trigger('blur');
|
||||
// Call context menu and set position
|
||||
tree.i.children().contextMenu({x: left, y: top});
|
||||
},
|
||||
bindDirectDebugging: function() {
|
||||
const tree = this.getTreeDetails();
|
||||
const type = tree.t.itemData(tree.i)._type;
|
||||
@@ -359,24 +239,6 @@ _.extend(pgBrowser.keyboardNavigation, {
|
||||
pgAdmin.Tools.Debugger.get_function_information(pgAdmin.Browser.Nodes[type]);
|
||||
}
|
||||
},
|
||||
bindDropMultipleObjects: function() {
|
||||
let isPropertyPanelVisible = this.isPropertyPanelVisible();
|
||||
if (isPropertyPanelVisible === true && $('button.delete_multiple').length > 0) {
|
||||
$('button.delete_multiple').click();
|
||||
}
|
||||
},
|
||||
bindDropCascadeMultipleObjects: function() {
|
||||
let isPropertyPanelVisible = this.isPropertyPanelVisible();
|
||||
if (isPropertyPanelVisible === true && $('button.delete_multiple_cascade').length > 0) {
|
||||
$('button.delete_multiple_cascade').click();
|
||||
}
|
||||
},
|
||||
bindAddGridRow: function() {
|
||||
let subNode = $(document.activeElement).closest('.object.subnode');
|
||||
if ($(subNode).length) {
|
||||
$(subNode).find('.add').click();
|
||||
}
|
||||
},
|
||||
isPropertyPanelVisible: function() {
|
||||
let isPanelVisible = false;
|
||||
_.each(pgAdmin.Browser.docker.findPanels(), (panel) => {
|
||||
@@ -396,12 +258,6 @@ _.extend(pgBrowser.keyboardNavigation, {
|
||||
d: selectedTreeNodeData,
|
||||
};
|
||||
},
|
||||
getDialogTabNavigator: function(dialogContainer) {
|
||||
const backward_shortcut = pgWindow.pgAdmin.Browser.get_preference('browser', 'dialog_tab_backward').value;
|
||||
const forward_shortcut = pgWindow.pgAdmin.Browser.get_preference('browser', 'dialog_tab_forward').value;
|
||||
|
||||
return new dialogTabNavigator.dialogTabNavigator(dialogContainer, backward_shortcut, forward_shortcut);
|
||||
},
|
||||
bindOpenQuickSearch: function() {
|
||||
pgWindow.pgAdmin.Browser.all_menus_cache.help.mnu_quick_search_help.callback();
|
||||
},
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
import pgAdmin from 'sources/pgadmin';
|
||||
import url_for from 'sources/url_for';
|
||||
import $ from 'jquery';
|
||||
import gettext from 'sources/gettext';
|
||||
import 'wcdocker';
|
||||
import pgWindow from 'sources/window';
|
||||
import Notify from '../../../static/js/helpers/Notifier';
|
||||
import getApiInstance from '../../../static/js/api_instance';
|
||||
|
||||
const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
|
||||
@@ -50,11 +50,8 @@ _.extend(pgBrowser, {
|
||||
if(docker) {
|
||||
let layout = docker.save(),
|
||||
settings = { setting: layout_id, value: layout };
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: url_for('settings.store_bulk'),
|
||||
data: settings,
|
||||
});
|
||||
|
||||
getApiInstance().post(url_for('settings.store_bulk'), settings);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -143,17 +140,15 @@ _.extend(pgBrowser, {
|
||||
save_lock_layout: function(op) {
|
||||
let browser = pgWindow.pgAdmin.Browser;
|
||||
|
||||
$.ajax({
|
||||
url: url_for('browser.lock_layout'),
|
||||
method: 'PUT',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
getApiInstance().put(
|
||||
url_for('browser.lock_layout'),
|
||||
JSON.stringify({
|
||||
'value': op,
|
||||
}),
|
||||
}).done(function() {
|
||||
})
|
||||
).then(()=> {
|
||||
browser.cache_preferences('browser');
|
||||
}).fail(function(xhr, error) {
|
||||
Notify.pgNotifier(error, xhr, gettext('Failed to save the lock layout setting.'));
|
||||
}).catch(function(error) {
|
||||
Notify.pgNotifier('error', error, gettext('Failed to save the lock layout setting.'));
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
import {getNodeView, removeNodeView} from './node_view';
|
||||
import Notify from '../../../static/js/helpers/Notifier';
|
||||
import _ from 'lodash';
|
||||
import getApiInstance from '../../../static/js/api_instance';
|
||||
|
||||
define('pgadmin.browser.node', [
|
||||
'sources/gettext', 'jquery', 'sources/pgadmin',
|
||||
'sources/gettext', 'sources/pgadmin',
|
||||
'sources/browser/generate_url', 'sources/utils',
|
||||
'pgadmin.browser.utils', 'pgadmin.browser.events',
|
||||
], function(
|
||||
gettext, $, pgAdmin, generateUrl, commonUtils
|
||||
gettext, pgAdmin, generateUrl, commonUtils
|
||||
) {
|
||||
|
||||
let wcDocker = window.wcDocker;
|
||||
@@ -354,9 +355,9 @@ define('pgadmin.browser.node', [
|
||||
isLayoutMember: false,
|
||||
canMaximise: true,
|
||||
elContainer: true,
|
||||
content: '<div class="obj_properties container-fluid h-100"><div role="status" class="pg-panel-message">' + gettext('Please wait while we fetch information ...') + '</div></div>',
|
||||
onCreate: function(myPanel, $container) {
|
||||
$container.addClass('pg-no-overflow');
|
||||
content: '<div class="obj_properties"></div>',
|
||||
onCreate: function(myPanel, container) {
|
||||
container.classList.add('pg-no-overflow');
|
||||
},
|
||||
events: events,
|
||||
});
|
||||
@@ -379,9 +380,9 @@ define('pgadmin.browser.node', [
|
||||
isLayoutMember: false,
|
||||
canMaximise: true,
|
||||
elContainer: true,
|
||||
content: '<div class="obj_properties container-fluid h-100"><div role="status" class="pg-panel-message">' + gettext('Please wait while we fetch information about the node from the server...') + '</div></div>',
|
||||
onCreate: function(myPanel, $container) {
|
||||
$container.addClass('pg-no-overflow');
|
||||
content: '<div class="obj_properties"></div>',
|
||||
onCreate: function(myPanel, container) {
|
||||
container.classList.add('pg-no-overflow');
|
||||
},
|
||||
events: events,
|
||||
});
|
||||
@@ -688,45 +689,41 @@ define('pgadmin.browser.node', [
|
||||
}
|
||||
Notify.confirm(title, msg,
|
||||
function() {
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, input.url, d, true),
|
||||
type: 'DELETE',
|
||||
})
|
||||
.done(function(res) {
|
||||
if(res.success == 2){
|
||||
Notify.error(res.info, null);
|
||||
return;
|
||||
getApiInstance().delete(
|
||||
obj.generate_url(i, input.url, d, true),
|
||||
).then(({data: res})=> {
|
||||
if(res.success == 2){
|
||||
Notify.error(res.info, null);
|
||||
return;
|
||||
}
|
||||
if (res.success == 0) {
|
||||
Notify.alert(res.errormsg, res.info);
|
||||
} else {
|
||||
// Remove the node from tree and set collection node as selected.
|
||||
let selectNextNode = true;
|
||||
if(obj.selectParentNodeOnDelete) {
|
||||
let prv_i = t.parent(i);
|
||||
setTimeout(function() {
|
||||
t.select(prv_i);
|
||||
}, 10);
|
||||
selectNextNode = false;
|
||||
}
|
||||
if (res.success == 0) {
|
||||
pgBrowser.report_error(res.errormsg, res.info);
|
||||
} else {
|
||||
// Remove the node from tree and set collection node as selected.
|
||||
let selectNextNode = true;
|
||||
if(obj.selectParentNodeOnDelete) {
|
||||
let prv_i = t.parent(i);
|
||||
setTimeout(function() {
|
||||
t.select(prv_i);
|
||||
}, 10);
|
||||
selectNextNode = false;
|
||||
}
|
||||
pgBrowser.removeTreeNode(i, selectNextNode);
|
||||
pgBrowser.removeTreeNode(i, selectNextNode);
|
||||
}
|
||||
return true;
|
||||
}).catch(function(xhr) {
|
||||
let errmsg = xhr.responseText;
|
||||
/* Error from the server */
|
||||
if (xhr.status == 417 || xhr.status == 410 || xhr.status == 500) {
|
||||
try {
|
||||
let data = JSON.parse(xhr.responseText);
|
||||
errmsg = data.info || data.errormsg;
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.fail(function(jqx) {
|
||||
let errmsg = jqx.responseText;
|
||||
/* Error from the server */
|
||||
if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
|
||||
try {
|
||||
let data = JSON.parse(jqx.responseText);
|
||||
errmsg = data.info || data.errormsg;
|
||||
} catch (e) {
|
||||
console.warn(e.stack || e);
|
||||
}
|
||||
}
|
||||
pgBrowser.report_error(
|
||||
gettext('Error dropping/removing %s: "%s"', obj.label, objName), errmsg);
|
||||
});
|
||||
}
|
||||
Notify.alert(gettext('Error dropping/removing %s: "%s"', obj.label, objName), errmsg);
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
@@ -822,23 +819,27 @@ define('pgadmin.browser.node', [
|
||||
fgcolor = serverData.icon.split(' ')[2] || '';
|
||||
|
||||
if (bgcolor) {
|
||||
let dynamic_class = 'pga_server_' + serverData._id + '_bgcolor',
|
||||
style_tag;
|
||||
|
||||
let dynamic_class = 'pga_server_' + serverData._id + '_bgcolor';
|
||||
// Prepare dynamic style tag
|
||||
style_tag = '<style id=' + dynamic_class + ' type=\'text/css\'> \n';
|
||||
style_tag += '.' + dynamic_class + ' .file-label {';
|
||||
style_tag += ' border-radius: 3px; margin-bottom: 2px;';
|
||||
style_tag += ' background: ' + bgcolor + ' !important;} \n';
|
||||
if (fgcolor) {
|
||||
style_tag += '.' + dynamic_class + ' span.file-name {';
|
||||
style_tag += ' color: ' + fgcolor + ' !important;} \n';
|
||||
}
|
||||
style_tag += '</style>';
|
||||
const styleTag = document.createElement('style');
|
||||
styleTag.setAttribute('id', dynamic_class);
|
||||
styleTag.setAttribute('type', 'text/css');
|
||||
styleTag.innerText = `
|
||||
.${dynamic_class} .file-label {
|
||||
border-radius: 3px;
|
||||
margin-bottom: 2px;
|
||||
background: ${bgcolor} !important;
|
||||
}
|
||||
${fgcolor ? `
|
||||
.${dynamic_class} span.file-name {
|
||||
color: ${fgcolor} !important;
|
||||
}
|
||||
`:''}
|
||||
`;
|
||||
|
||||
// Prepare dynamic style tag using template
|
||||
$('#' + dynamic_class).remove();
|
||||
$(style_tag).appendTo('head');
|
||||
document.querySelector(`style[id="${dynamic_class}"]`).remove();
|
||||
document.head.appendChild(styleTag);
|
||||
// Add dynamic class to the tree node.
|
||||
pgBrowser.tree.addCssClass(item, dynamic_class);
|
||||
}
|
||||
@@ -895,7 +896,6 @@ define('pgadmin.browser.node', [
|
||||
t = pgBrowser.tree,
|
||||
data = _item && t.itemData(_item);
|
||||
|
||||
$(pgBrowser.panels['properties'].panel).removeData('node-prop');
|
||||
pgBrowser.Events.trigger(
|
||||
'pgadmin:browser:tree:refresh', _item || pgBrowser.tree.selected(), {
|
||||
success: function() {
|
||||
|
||||
@@ -63,25 +63,8 @@ export function getNodeView(nodeType, treeNodeInfo, actionType, itemNodeData, fo
|
||||
} else if(err.message){
|
||||
console.error('error msg', err.message);
|
||||
}
|
||||
|
||||
if (err?.response?.data?.info == 'CRYPTKEY_MISSING') {
|
||||
Notify.pgNotifier('error', err.request, 'The master password is not set', function(msg) {
|
||||
setTimeout(function() {
|
||||
if (msg == 'CRYPTKEY_SET') {
|
||||
resolve(initData());
|
||||
} else if (msg == 'CRYPTKEY_NOT_SET') {
|
||||
reject(err);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
} else if (err?.response?.data?.errormsg) {
|
||||
Notify.alert(
|
||||
gettext('Error'),
|
||||
gettext(err.response.data.errormsg)
|
||||
);
|
||||
|
||||
reject(err);
|
||||
}
|
||||
reject(err);
|
||||
Notify.pgRespErrorNotify(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -11,8 +11,8 @@ import { getPanelView } from './panel_view';
|
||||
import _ from 'lodash';
|
||||
|
||||
define(
|
||||
['sources/pgadmin', 'jquery', 'wcdocker'],
|
||||
function(pgAdmin, $) {
|
||||
['sources/pgadmin', 'wcdocker'],
|
||||
function(pgAdmin) {
|
||||
|
||||
let pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {},
|
||||
wcDocker = window.wcDocker;
|
||||
@@ -52,7 +52,9 @@ define(
|
||||
limit: that.limit,
|
||||
isLayoutMember: that.isLayoutMember,
|
||||
onCreate: function(myPanel) {
|
||||
$(myPanel).data('pgAdminName', that.name);
|
||||
myPanel.panelData = {
|
||||
pgAdminName: that.name,
|
||||
};
|
||||
myPanel.initSize(that.width, that.height);
|
||||
|
||||
if (!that.showTitle)
|
||||
@@ -64,18 +66,18 @@ define(
|
||||
myPanel.icon(that.icon);
|
||||
}
|
||||
|
||||
let $container = $('<div>', {
|
||||
'class': 'pg-panel-content',
|
||||
}).append($(that.content));
|
||||
let container = document.createElement('div');
|
||||
container.setAttribute('class', 'pg-panel-content');
|
||||
container.innerHTML = that.content;
|
||||
|
||||
// Add extra classes
|
||||
if (!_.isNull('extraClasses')) {
|
||||
$container.addClass(that.extraClasses);
|
||||
container.classList.add(that.extraClasses);
|
||||
}
|
||||
|
||||
myPanel.maximisable(!!that.canMaximise);
|
||||
myPanel.closeable(!!that.isCloseable);
|
||||
myPanel.layout().addItem($container);
|
||||
myPanel.layout().addItem(container);
|
||||
that.panel = myPanel;
|
||||
if (that.events && _.isObject(that.events)) {
|
||||
_.each(that.events, function(v, k) {
|
||||
@@ -99,21 +101,20 @@ define(
|
||||
});
|
||||
|
||||
if (that.onCreate && _.isFunction(that.onCreate)) {
|
||||
that.onCreate.apply(that, [myPanel, $container]);
|
||||
that.onCreate.apply(that, [myPanel, container]);
|
||||
}
|
||||
|
||||
// Prevent browser from opening the drag file.
|
||||
// Using addEventListener to avoid conflict with jquery.drag
|
||||
['dragover', 'drop'].forEach((eventName)=>{
|
||||
$container[0].addEventListener(eventName, function(event) {
|
||||
container.addEventListener(eventName, function(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
if (that.elContainer) {
|
||||
myPanel.pgElContainer = $container;
|
||||
$container.addClass('pg-el-container');
|
||||
myPanel.pgElContainer = container;
|
||||
_.each([
|
||||
wcDocker.EVENT.RESIZED, wcDocker.EVENT.ATTACHED,
|
||||
wcDocker.EVENT.DETACHED, wcDocker.EVENT.VISIBILITY_CHANGED,
|
||||
@@ -126,7 +127,7 @@ define(
|
||||
if (myPanel._type == 'dashboard' || myPanel._type == 'processes') {
|
||||
getPanelView(
|
||||
pgBrowser.tree,
|
||||
$container[0],
|
||||
container,
|
||||
pgBrowser,
|
||||
myPanel._type
|
||||
);
|
||||
@@ -136,7 +137,7 @@ define(
|
||||
pgBrowser.onPreferencesChange('dashboards', function() {
|
||||
getPanelView(
|
||||
pgBrowser.tree,
|
||||
$container[0],
|
||||
container,
|
||||
pgBrowser,
|
||||
myPanel._type
|
||||
);
|
||||
@@ -146,7 +147,7 @@ define(
|
||||
pgBrowser.onPreferencesChange('graphs', function() {
|
||||
getPanelView(
|
||||
pgBrowser.tree,
|
||||
$container[0],
|
||||
container,
|
||||
pgBrowser,
|
||||
myPanel._type
|
||||
);
|
||||
@@ -162,7 +163,7 @@ define(
|
||||
if(myPanel.isVisible() && myPanel._type !== 'properties') {
|
||||
getPanelView(
|
||||
pgBrowser.tree,
|
||||
$container[0],
|
||||
container,
|
||||
pgBrowser,
|
||||
myPanel._type
|
||||
);
|
||||
@@ -174,7 +175,7 @@ define(
|
||||
if(myPanel.isVisible() && myPanel._type !== 'properties') {
|
||||
getPanelView(
|
||||
pgBrowser.tree,
|
||||
$container[0],
|
||||
container,
|
||||
pgBrowser,
|
||||
myPanel._type
|
||||
);
|
||||
@@ -186,7 +187,7 @@ define(
|
||||
if(myPanel.isVisible() && myPanel._type !== 'properties') {
|
||||
getPanelView(
|
||||
pgBrowser.tree,
|
||||
$container[0],
|
||||
container,
|
||||
pgBrowser,
|
||||
myPanel._type
|
||||
);
|
||||
@@ -197,7 +198,7 @@ define(
|
||||
}
|
||||
},
|
||||
eventFunc: function(eventName) {
|
||||
let name = $(this).data('pgAdminName');
|
||||
let name = this.panelData.pgAdminName;
|
||||
try {
|
||||
pgBrowser.Events.trigger(
|
||||
'pgadmin-browser:panel', eventName, this, arguments
|
||||
@@ -248,18 +249,16 @@ define(
|
||||
elAttr = 'xl';
|
||||
}
|
||||
|
||||
p.pgElContainer.attr('el', elAttr);
|
||||
p.pgElContainer.setAttribute('el', elAttr);
|
||||
},
|
||||
100
|
||||
);
|
||||
}
|
||||
},
|
||||
handleVisibility: function(eventName) {
|
||||
if (_.isNull(pgBrowser.tree)) return;
|
||||
|
||||
let selectedPanel = pgBrowser.docker.findPanels(this._type)[0];
|
||||
let isPanelVisible = selectedPanel.isVisible();
|
||||
let $container = selectedPanel
|
||||
let container = selectedPanel
|
||||
.layout()
|
||||
.scene()
|
||||
.find('.pg-panel-content');
|
||||
@@ -268,7 +267,7 @@ define(
|
||||
if (eventName == 'panelVisibilityChanged') {
|
||||
getPanelView(
|
||||
pgBrowser.tree,
|
||||
$container[0],
|
||||
container[0],
|
||||
pgBrowser,
|
||||
this._type
|
||||
);
|
||||
@@ -277,7 +276,7 @@ define(
|
||||
if (eventName == 'panelClosed' && selectedPanel._type == 'dashboard') {
|
||||
getPanelView(
|
||||
pgBrowser.tree,
|
||||
$container[0],
|
||||
container[0],
|
||||
pgBrowser,
|
||||
this._type,
|
||||
false
|
||||
|
||||
@@ -9,12 +9,10 @@
|
||||
|
||||
import pgAdmin from 'sources/pgadmin';
|
||||
import url_for from 'sources/url_for';
|
||||
import $ from 'jquery';
|
||||
import pgWindow from 'sources/window';
|
||||
import Notify from '../../../static/js/helpers/Notifier';
|
||||
import { calcFontSize } from '../../../static/js/utils';
|
||||
import { shortcutToString } from '../../../static/js/components/ShortcutTitle';
|
||||
import gettext from 'sources/gettext';
|
||||
import getApiInstance from '../../../static/js/api_instance';
|
||||
|
||||
|
||||
const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
@@ -78,16 +76,11 @@ _.extend(pgBrowser, {
|
||||
|
||||
// Get and cache the preferences
|
||||
cache_preferences: function (modulesChanged) {
|
||||
let self = this,
|
||||
headers = {};
|
||||
headers[pgAdmin.csrf_token_header] = pgAdmin.csrf_token;
|
||||
let self = this;
|
||||
|
||||
setTimeout(function() {
|
||||
$.ajax({
|
||||
url: url_for('preferences.get_all'),
|
||||
headers: headers,
|
||||
})
|
||||
.done(function(res) {
|
||||
getApiInstance().get(url_for('preferences.get_all'))
|
||||
.then(({data: res})=>{
|
||||
self.preferences_cache = res;
|
||||
self.preference_version(self.generate_preference_version());
|
||||
|
||||
@@ -97,43 +90,30 @@ _.extend(pgBrowser, {
|
||||
pgBrowser.browserTreeState.init();
|
||||
|
||||
/* Once the cache is loaded after changing the preferences,
|
||||
* notify the modules of the change
|
||||
*/
|
||||
* notify the modules of the change
|
||||
*/
|
||||
if(modulesChanged) {
|
||||
if(typeof modulesChanged === 'string'){
|
||||
$.event.trigger('prefchange:'+modulesChanged);
|
||||
pgBrowser.Events.trigger('prefchange:'+modulesChanged);
|
||||
} else {
|
||||
_.each(modulesChanged, (val, key)=> {
|
||||
$.event.trigger('prefchange:'+key);
|
||||
pgBrowser.Events.trigger('prefchange:'+key);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
.catch(function(error) {
|
||||
Notify.pgRespErrorNotify(error);
|
||||
});
|
||||
}, 500);
|
||||
},
|
||||
|
||||
triggerPreferencesChange: function(moduleChanged) {
|
||||
$.event.trigger('prefchange:'+moduleChanged);
|
||||
pgBrowser.Events.trigger('prefchange:'+moduleChanged);
|
||||
},
|
||||
|
||||
reflectPreferences: function(module) {
|
||||
let obj = this;
|
||||
|
||||
if(module === 'sqleditor' || module === null || typeof module === 'undefined') {
|
||||
let sqlEditPreferences = obj.get_preferences_for_module('sqleditor');
|
||||
|
||||
$(obj?.editor?.getWrapperElement()).css(
|
||||
'font-size', calcFontSize(sqlEditPreferences.sql_font_size)
|
||||
);
|
||||
obj?.editor?.setOption('tabSize', sqlEditPreferences.tab_size);
|
||||
obj?.editor?.setOption('lineWrapping', sqlEditPreferences.wrap_code);
|
||||
obj?.editor?.setOption('autoCloseBrackets', sqlEditPreferences.insert_pair_brackets);
|
||||
obj?.editor?.setOption('matchBrackets', sqlEditPreferences.brace_matching);
|
||||
obj?.editor?.refresh();
|
||||
}
|
||||
//browser preference
|
||||
if(module === 'browser') {
|
||||
let browserPreferences = obj.get_preferences_for_module('browser');
|
||||
@@ -158,13 +138,7 @@ _.extend(pgBrowser, {
|
||||
},
|
||||
|
||||
onPreferencesChange: function(module, eventHandler) {
|
||||
let eventWindow = pgWindow;
|
||||
if (window.location === window.parent?.location ) {
|
||||
// The page is in a new tab
|
||||
eventWindow = window;
|
||||
}
|
||||
|
||||
$(eventWindow).on('prefchange:'+module, function(event) {
|
||||
pgBrowser.Events.on('prefchange:'+module, function(event) {
|
||||
eventHandler(event);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -52,6 +52,10 @@ samp,
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
font-size: 1.15em;
|
||||
|
||||
color: $color-fg !important;
|
||||
border-color: $border-color !important;
|
||||
background-color: $color-secondary;
|
||||
}
|
||||
|
||||
.pg-toolbar-psql {
|
||||
|
||||
@@ -168,28 +168,6 @@ define('pgadmin.browser.utils',
|
||||
],
|
||||
},
|
||||
{% endif %}
|
||||
|
||||
// load the module right now
|
||||
load_module: function(name, path, c) {
|
||||
let obj = this;
|
||||
require([name],function(m) {
|
||||
try {
|
||||
// initialize the module (if 'init' function present).
|
||||
if (m.init && typeof(m.init) == 'function')
|
||||
m.init();
|
||||
} catch (e) {
|
||||
// Log this exception on console to understand the issue properly.
|
||||
console.log(e);
|
||||
obj.report_error(gettext('Error loading script - ') + path);
|
||||
}
|
||||
if (c)
|
||||
c.loaded += 1;
|
||||
}, function() {
|
||||
// Log the arguments on console to understand the issue properly.
|
||||
console.log(arguments);
|
||||
obj.report_error(gettext('Error loading script - ') + path);
|
||||
});
|
||||
}
|
||||
};
|
||||
return pgBrowser;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user