mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-09 23:15:58 -06:00
Add missing new files from the previous commit. Ooops.
This commit is contained in:
parent
4a91bcde30
commit
6396b8ce18
@ -0,0 +1,539 @@
|
||||
define('pgadmin.node.primary_key', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'pgadmin',
|
||||
'pgadmin.browser', 'alertify', 'pgadmin.browser.collection'
|
||||
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
|
||||
// Extend the browser's node class for index constraint node
|
||||
if (!pgBrowser.Nodes['primary_key']) {
|
||||
pgAdmin.Browser.Nodes['primary_key'] = pgBrowser.Node.extend({
|
||||
type: 'primary_key',
|
||||
label: gettext('Primary key'),
|
||||
collection_type: 'coll-constraints',
|
||||
sqlAlterHelp: 'ddl-alter.html',
|
||||
sqlCreateHelp: 'ddl-constraints.html',
|
||||
dialogHelp: url_for('help.static', {filename: 'primary_key_dialog.html'}),
|
||||
hasSQL: true,
|
||||
hasDepends: true,
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Index size'],
|
||||
parent_type: 'table',
|
||||
canDrop: true,
|
||||
canDropCascade: true,
|
||||
Init: function() {
|
||||
/* Avoid multiple registration of menus */
|
||||
if (this.initialized)
|
||||
return;
|
||||
|
||||
this.initialized = true;
|
||||
|
||||
pgBrowser.add_menus([{
|
||||
name: 'create_primary_key_on_coll', node: 'coll-constraints', module: this,
|
||||
applies: ['object', 'context'], callback: 'show_obj_properties',
|
||||
category: 'create', priority: 4, label: gettext('Primary key'),
|
||||
icon: 'wcTabIcon icon-primary_key', data: {action: 'create', check: true},
|
||||
enable: 'canCreate'
|
||||
|
||||
}
|
||||
]);
|
||||
},
|
||||
canCreate: function(itemData, item, data) {
|
||||
// If check is false then , we will allow create menu
|
||||
if (data && data.check == false)
|
||||
return true;
|
||||
|
||||
var t = pgBrowser.tree, i = item, d = itemData, parents = [];
|
||||
// To iterate over tree to check parent node
|
||||
while (i) {
|
||||
// If it is schema then allow user to c reate table
|
||||
if (_.indexOf(['schema'], d._type) > -1) {
|
||||
// There should be only one primary key per table.
|
||||
var children = t.children(arguments[1], false),
|
||||
primary_key_found = false;
|
||||
|
||||
_.each(children, function(child){
|
||||
data = pgBrowser.tree.itemData($(child));
|
||||
if (!primary_key_found && data._type == "primary_key") {
|
||||
primary_key_found = true;
|
||||
}
|
||||
});
|
||||
return !primary_key_found;
|
||||
}
|
||||
parents.push(d._type);
|
||||
i = t.hasParent(i) ? t.parent(i) : null;
|
||||
d = i ? t.itemData(i) : null;
|
||||
}
|
||||
// If node is under catalog then do not allow 'create' menu
|
||||
if (_.indexOf(parents, 'catalog') > -1) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
// Define the model for index constraint node
|
||||
model: pgAdmin.Browser.Node.Model.extend({
|
||||
idAttribute: 'oid',
|
||||
|
||||
defaults: {
|
||||
name: undefined,
|
||||
oid: undefined,
|
||||
comment: undefined,
|
||||
spcname: undefined,
|
||||
index: undefined,
|
||||
fillfactor: undefined,
|
||||
condeferrable: undefined,
|
||||
condeferred: undefined,
|
||||
columns: []
|
||||
},
|
||||
|
||||
// Define the schema for the index constraint node
|
||||
schema: [{
|
||||
id: 'name', label: gettext('Name'), type: 'text',
|
||||
mode: ['properties', 'create', 'edit'], editable:true,
|
||||
cellHeaderClasses:'width_percent_40',
|
||||
},{
|
||||
id: 'oid', label: gettext('OID'), cell: 'string',
|
||||
type: 'text' , mode: ['properties'], editable: false,
|
||||
cellHeaderClasses:'width_percent_20',
|
||||
},{
|
||||
id: 'comment', label: gettext('Comment'), cell: 'string',
|
||||
type: 'multiline', mode: ['properties', 'create', 'edit'],
|
||||
deps:['name'], disabled:function(m) {
|
||||
var name = m.get('name');
|
||||
if (!(name && name != '')) {
|
||||
setTimeout(function(){
|
||||
if(m.get('comment') && m.get('comment') !== '') {
|
||||
m.set('comment', null);
|
||||
}
|
||||
},10);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'columns', label: gettext('Columns'),
|
||||
type: 'collection', group: gettext('Definition'),
|
||||
editable: false,
|
||||
cell: Backgrid.StringCell.extend({
|
||||
initialize: function() {
|
||||
Backgrid.StringCell.prototype.initialize.apply(this, arguments);
|
||||
|
||||
var self = this,
|
||||
collection = this.model.get('columns');
|
||||
|
||||
// Do not listen for any event(s) for existing constraint.
|
||||
if (_.isUndefined(self.model.get('oid'))) {
|
||||
var tableCols = self.model.top.get('columns');
|
||||
self.listenTo(tableCols, 'remove' , self.removeColumn);
|
||||
self.listenTo(tableCols, 'change:name', self.resetColOptions);
|
||||
}
|
||||
|
||||
collection.on('pgadmin:multicolumn:updated', function() {
|
||||
self.render.apply(self);
|
||||
});
|
||||
self.listenTo(collection, "add", self.render);
|
||||
self.listenTo(collection, "remove", self.render);
|
||||
},
|
||||
removeColumn: function(m) {
|
||||
var self = this,
|
||||
removedCols = self.model.get('columns').where(
|
||||
{column: m.get('name')}
|
||||
);
|
||||
|
||||
self.model.get('columns').remove(removedCols);
|
||||
setTimeout(function () {
|
||||
self.render();
|
||||
}, 10);
|
||||
|
||||
var key = 'primary_key'
|
||||
setTimeout(function () {
|
||||
constraints = self.model.top.get(key);
|
||||
var removed = [];
|
||||
constraints.each(function(constraint) {
|
||||
if (constraint.get("columns").length == 0) {
|
||||
removed.push(constraint);
|
||||
}
|
||||
});
|
||||
constraints.remove(removed);
|
||||
},100);
|
||||
|
||||
},
|
||||
resetColOptions : function(m) {
|
||||
var self = this,
|
||||
updatedCols = self.model.get('columns').where(
|
||||
{column: m.previous('name')}
|
||||
);
|
||||
if (updatedCols.length > 0) {
|
||||
/*
|
||||
* Table column name has changed so update
|
||||
* column name in primary key as well.
|
||||
*/
|
||||
updatedCols[0].set(
|
||||
{"column": m.get('name')},
|
||||
{silent: true});
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
self.render();
|
||||
}, 10);
|
||||
},
|
||||
formatter: {
|
||||
fromRaw: function (rawValue, model) {
|
||||
return rawValue.pluck("column").toString();
|
||||
},
|
||||
toRaw: function (val, model) {
|
||||
return val;
|
||||
}
|
||||
},
|
||||
render: function() {
|
||||
return Backgrid.StringCell.prototype.render.apply(this, arguments);
|
||||
},
|
||||
remove: function() {
|
||||
var tableCols = this.model.top.get('columns'),
|
||||
primary_key_col = this.model.get('columns');
|
||||
|
||||
if (primary_key_col) {
|
||||
primary_key_col.off('pgadmin:multicolumn:updated');
|
||||
}
|
||||
|
||||
this.stopListening(tableCols, 'remove' , self.removeColumn);
|
||||
this.stopListening(tableCols, 'change:name' , self.resetColOptions);
|
||||
|
||||
Backgrid.StringCell.prototype.remove.apply(this, arguments);
|
||||
}
|
||||
}),
|
||||
canDelete: true, canAdd: true,
|
||||
control: Backform.MultiSelectAjaxControl.extend({
|
||||
defaults: _.extend(
|
||||
{},
|
||||
Backform.NodeListByNameControl.prototype.defaults,
|
||||
{
|
||||
select2: {
|
||||
multiple: true,
|
||||
allowClear: true,
|
||||
width: 'style',
|
||||
placeholder: gettext('Select the column(s)'),
|
||||
}
|
||||
}
|
||||
),
|
||||
keyPathAccessor: function(obj, path) {
|
||||
var res = obj;
|
||||
if(_.isArray(res)) {
|
||||
return _.map(res, function(o) { return o['column']
|
||||
});
|
||||
}
|
||||
path = path.split('.');
|
||||
for (var i = 0; i < path.length; i++) {
|
||||
if (_.isNull(res)) return null;
|
||||
if (_.isEmpty(path[i])) continue;
|
||||
if (!_.isUndefined(res[path[i]])) res = res[path[i]];
|
||||
}
|
||||
return _.isObject(res) && !_.isArray(res) ? null : res;
|
||||
},
|
||||
initialize: function() {
|
||||
// Here we will decide if we need to call URL
|
||||
// Or fetch the data from parent columns collection
|
||||
var self = this;
|
||||
if(this.model.handler) {
|
||||
Backform.Select2Control.prototype.initialize.apply(this, arguments);
|
||||
// Do not listen for any event(s) for existing constraint.
|
||||
if (_.isUndefined(self.model.get('oid'))) {
|
||||
var tableCols = self.model.top.get('columns');
|
||||
self.listenTo(tableCols, 'remove' , self.resetColOptions);
|
||||
self.listenTo(tableCols, 'change:name', self.resetColOptions);
|
||||
}
|
||||
|
||||
self.custom_options();
|
||||
} else {
|
||||
Backform.MultiSelectAjaxControl.prototype.initialize.apply(this, arguments);
|
||||
}
|
||||
self.model.get('columns').on('pgadmin:multicolumn:updated', function() {
|
||||
self.render.apply(self);
|
||||
});
|
||||
},
|
||||
resetColOptions: function(m) {
|
||||
var self = this;
|
||||
|
||||
setTimeout(function () {
|
||||
self.custom_options();
|
||||
self.render.apply(self);
|
||||
}, 50);
|
||||
|
||||
},
|
||||
custom_options: function() {
|
||||
// We will add all the columns entered by user in table model
|
||||
var columns = this.model.top.get('columns'),
|
||||
added_columns_from_tables = [];
|
||||
|
||||
if (columns.length > 0) {
|
||||
_.each(columns.models, function(m) {
|
||||
var col = m.get('name');
|
||||
if(!_.isUndefined(col) && !_.isNull(col)) {
|
||||
added_columns_from_tables.push(
|
||||
{label: col, value: col, image:'icon-column'}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Set the values in to options so that user can select
|
||||
this.field.set('options', added_columns_from_tables);
|
||||
},
|
||||
onChange: function(e) {
|
||||
var self = this,
|
||||
model = this.model,
|
||||
$el = $(e.target),
|
||||
attrArr = this.field.get("name").split('.'),
|
||||
name = attrArr.shift(),
|
||||
path = attrArr.join('.'),
|
||||
vals = this.getValueFromDOM(),
|
||||
collection = model.get(name),
|
||||
removed = [];
|
||||
|
||||
this.stopListening(this.model, "change:" + name, this.render);
|
||||
|
||||
/*
|
||||
* Iterate through all the values, and find out how many are already
|
||||
* present in the collection.
|
||||
*/
|
||||
collection.each(function(m) {
|
||||
var column = m.get('column'),
|
||||
idx = _.indexOf(vals, column);
|
||||
|
||||
if (idx > -1) {
|
||||
vals.splice(idx, 1);
|
||||
} else {
|
||||
removed.push(column);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Adding new values
|
||||
*/
|
||||
|
||||
_.each(vals, function(v) {
|
||||
var m = new (self.field.get('model'))(
|
||||
{column: v}, { silent: true,
|
||||
top: self.model.top,
|
||||
collection: collection,
|
||||
handler: collection
|
||||
});
|
||||
|
||||
collection.add(m);
|
||||
});
|
||||
|
||||
/*
|
||||
* Removing unwanted!
|
||||
*/
|
||||
_.each(removed, function(v) {
|
||||
collection.remove(collection.where({column: v}));
|
||||
});
|
||||
|
||||
this.listenTo(this.model, "change:" + name, this.render);
|
||||
},
|
||||
remove: function() {
|
||||
if(this.model.handler) {
|
||||
var self = this,
|
||||
tableCols = self.model.top.get('columns');
|
||||
self.stopListening(tableCols, 'remove' , self.resetColOptions);
|
||||
self.stopListening(tableCols, 'change:name' , self.resetColOptions);
|
||||
self.model.get('columns').off('pgadmin:multicolumn:updated');
|
||||
|
||||
Backform.Select2Control.prototype.remove.apply(this, arguments);
|
||||
|
||||
} else {
|
||||
Backform.MultiSelectAjaxControl.prototype.remove.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
}),
|
||||
deps: ['index'], node: 'column',
|
||||
model: pgBrowser.Node.Model.extend({
|
||||
defaults: {
|
||||
column: undefined
|
||||
},
|
||||
validate: function() {
|
||||
return null;
|
||||
}
|
||||
}),
|
||||
transform : function(data){
|
||||
var res = [];
|
||||
if (data && _.isArray(data)) {
|
||||
_.each(data, function(d) {
|
||||
res.push({label: d.label, value: d.label, image:'icon-column'});
|
||||
})
|
||||
}
|
||||
return res;
|
||||
},
|
||||
select2:{allowClear:false},
|
||||
disabled: function(m) {
|
||||
// If we are in table edit mode then
|
||||
if (_.has(m, 'top') && !_.isUndefined(m.top)
|
||||
&& !m.top.isNew()) {
|
||||
// If OID is undefined then user is trying to add
|
||||
// new constraint which should be allowed for Unique
|
||||
return !_.isUndefined(m.get('oid'));
|
||||
}
|
||||
|
||||
// We can't update columns of existing index constraint.
|
||||
if (!m.isNew()) {
|
||||
return true;
|
||||
}
|
||||
// Disable if index is selected.
|
||||
var index = m.get('index');
|
||||
if(_.isUndefined(index) || index == '') {
|
||||
return false;
|
||||
} else {
|
||||
var col = m.get('columns');
|
||||
col.reset();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'spcname', label: gettext('Tablespace'),
|
||||
type: 'text', group: gettext('Definition'),
|
||||
control: 'node-list-by-name', node: 'tablespace',
|
||||
deps: ['index'],
|
||||
select2:{allowClear:false},
|
||||
filter: function(m) {
|
||||
// Don't show pg_global tablespace in selection.
|
||||
if (m.label == "pg_global") return false;
|
||||
else return true;
|
||||
},
|
||||
disabled: function(m) {
|
||||
// Disable if index is selected.
|
||||
m = m.top || m;
|
||||
var index = m.get('index');
|
||||
if(_.isUndefined(index) || index == '') {
|
||||
return false;
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
m.set('spcname', '');
|
||||
},10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'index', label: gettext('Index'),
|
||||
type: 'text', group: gettext('Definition'),
|
||||
control: Backform.NodeListByNameControl.extend({
|
||||
initialize:function() {
|
||||
if (_.isUndefined(this.model.top)) {
|
||||
Backform.NodeListByNameControl.prototype.initialize.apply(this,arguments);
|
||||
} else {
|
||||
Backform.Control.prototype.initialize.apply(this,arguments);
|
||||
}
|
||||
}
|
||||
}),
|
||||
select2:{allowClear:true}, node: 'index',
|
||||
disabled: function(m) {
|
||||
// If we are in table edit mode then disable it
|
||||
if (_.has(m, 'top') && !_.isUndefined(m.top)
|
||||
&& !m.top.isNew()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We can't update index of existing index constraint.
|
||||
return !m.isNew();
|
||||
},
|
||||
// We will not show this field in Create Table mode
|
||||
visible: function(m) {
|
||||
return !_.isUndefined(m.top.node_info['table']);
|
||||
}
|
||||
},{
|
||||
id: 'fillfactor', label: gettext('Fill factor'), deps: ['index'],
|
||||
type: 'int', group: gettext('Definition'), allowNull: true,
|
||||
disabled: function(m) {
|
||||
// Disable if index is selected.
|
||||
var index = m.get('index');
|
||||
if(_.isUndefined(index) || index == '') {
|
||||
return false;
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
m.set('fillfactor', null);
|
||||
},10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'condeferrable', label: gettext('Deferrable?'),
|
||||
type: 'switch', group: gettext('Definition'), deps: ['index'],
|
||||
disabled: function(m) {
|
||||
// If we are in table edit mode then
|
||||
if (_.has(m, 'top') && !_.isUndefined(m.top)
|
||||
&& !m.top.isNew()) {
|
||||
// If OID is undefined then user is trying to add
|
||||
// new constraint which should allowed for Unique
|
||||
return !_.isUndefined(m.get('oid'));
|
||||
}
|
||||
|
||||
// We can't update condeferrable of existing index constraint.
|
||||
if (!m.isNew()) {
|
||||
return true;
|
||||
}
|
||||
// Disable if index is selected.
|
||||
var index = m.get('index');
|
||||
if(_.isUndefined(index) || index == '') {
|
||||
return false;
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
if(m.get('condeferrable'))
|
||||
m.set('condeferrable', false);
|
||||
},10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'condeferred', label: gettext('Deferred?'),
|
||||
type: 'switch', group: gettext('Definition'),
|
||||
deps: ['condeferrable'],
|
||||
disabled: function(m) {
|
||||
// If we are in table edit mode then
|
||||
if (_.has(m, 'top') && !_.isUndefined(m.top)
|
||||
&& !m.top.isNew()) {
|
||||
// If OID is undefined then user is trying to add
|
||||
// new constraint which should allowed for Unique
|
||||
return !_.isUndefined(m.get('oid'));
|
||||
}
|
||||
|
||||
// We can't update condeferred of existing index constraint.
|
||||
if (!m.isNew()) {
|
||||
return true;
|
||||
}
|
||||
// Disable if condeferred is false or unselected.
|
||||
if(m.get('condeferrable') == true) {
|
||||
return false;
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
if(m.get('condeferred'))
|
||||
m.set('condeferred', false);
|
||||
},10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
validate: function() {
|
||||
this.errorModel.clear();
|
||||
// Clear parent's error as well
|
||||
if (_.has(this, 'top')) {
|
||||
this.top.errorModel.clear();
|
||||
}
|
||||
|
||||
var columns = this.get('columns'),
|
||||
index = this.get('index');
|
||||
|
||||
if ((_.isUndefined(index) || String(index).replace(/^\s+|\s+$/g, '') == '') &&
|
||||
(_.isUndefined(columns) || _.isNull(columns) || columns.length < 1)) {
|
||||
var msg = gettext('Please specify columns for %(node)s', {node: gettext('Primary key')});
|
||||
this.errorModel.set('columns', msg);
|
||||
return msg;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
return pgBrowser.Nodes['primary_key'];
|
||||
});
|
@ -0,0 +1,529 @@
|
||||
define('pgadmin.node.unique_constraint', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery', 'underscore', 'underscore.string', 'pgadmin',
|
||||
'pgadmin.browser', 'alertify', 'pgadmin.browser.collection'
|
||||
], function(gettext, url_for, $, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
|
||||
// Extend the browser's node class for index constraint node
|
||||
if (!pgBrowser.Nodes['unique_constraint']) {
|
||||
pgAdmin.Browser.Nodes['unique_constraint'] = pgBrowser.Node.extend({
|
||||
type: 'unique_constraint',
|
||||
label: gettext('Unique constraint'),
|
||||
collection_type: 'coll-constraints',
|
||||
sqlAlterHelp: 'ddl-alter.html',
|
||||
sqlCreateHelp: 'ddl-constraints.html',
|
||||
dialogHelp: url_for('help.static', {filename: 'unique_constraint_dialog.html'}),
|
||||
hasSQL: true,
|
||||
hasDepends: true,
|
||||
hasStatistics: true,
|
||||
statsPrettifyFields: ['Index size'],
|
||||
parent_type: 'table',
|
||||
canDrop: true,
|
||||
canDropCascade: true,
|
||||
Init: function() {
|
||||
/* Avoid multiple registration of menus */
|
||||
if (this.initialized)
|
||||
return;
|
||||
|
||||
this.initialized = true;
|
||||
|
||||
pgBrowser.add_menus([{
|
||||
name: 'create_unique_constraint_on_coll', node: 'coll-constraints', module: this,
|
||||
applies: ['object', 'context'], callback: 'show_obj_properties',
|
||||
category: 'create', priority: 4, label: gettext('Unique constraint'),
|
||||
icon: 'wcTabIcon icon-unique_constraint', data: {action: 'create', check: true},
|
||||
enable: 'canCreate'
|
||||
|
||||
}
|
||||
]);
|
||||
},
|
||||
canCreate: function(itemData, item, data) {
|
||||
// If check is false then , we will allow create menu
|
||||
if (data && data.check == false)
|
||||
return true;
|
||||
|
||||
var t = pgBrowser.tree, i = item, d = itemData, parents = [];
|
||||
// To iterate over tree to check parent node
|
||||
while (i) {
|
||||
// If it is schema then allow user to c reate table
|
||||
if (_.indexOf(['schema'], d._type) > -1) {
|
||||
return true;
|
||||
}
|
||||
parents.push(d._type);
|
||||
i = t.hasParent(i) ? t.parent(i) : null;
|
||||
d = i ? t.itemData(i) : null;
|
||||
}
|
||||
// If node is under catalog then do not allow 'create' menu
|
||||
if (_.indexOf(parents, 'catalog') > -1) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
// Define the model for index constraint node
|
||||
model: pgAdmin.Browser.Node.Model.extend({
|
||||
idAttribute: 'oid',
|
||||
|
||||
defaults: {
|
||||
name: undefined,
|
||||
oid: undefined,
|
||||
comment: undefined,
|
||||
spcname: undefined,
|
||||
index: undefined,
|
||||
fillfactor: undefined,
|
||||
condeferrable: undefined,
|
||||
condeferred: undefined,
|
||||
columns: []
|
||||
},
|
||||
|
||||
// Define the schema for the index constraint node
|
||||
schema: [{
|
||||
id: 'name', label: gettext('Name'), type: 'text',
|
||||
mode: ['properties', 'create', 'edit'], editable:true,
|
||||
cellHeaderClasses:'width_percent_40',
|
||||
},{
|
||||
id: 'oid', label: gettext('OID'), cell: 'string',
|
||||
type: 'text' , mode: ['properties'], editable: false,
|
||||
cellHeaderClasses:'width_percent_20',
|
||||
},{
|
||||
id: 'comment', label: gettext('Comment'), cell: 'string',
|
||||
type: 'multiline', mode: ['properties', 'create', 'edit'],
|
||||
deps:['name'], disabled:function(m) {
|
||||
var name = m.get('name');
|
||||
if (!(name && name != '')) {
|
||||
setTimeout(function(){
|
||||
if(m.get('comment') && m.get('comment') !== '') {
|
||||
m.set('comment', null);
|
||||
}
|
||||
},10);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'columns', label: gettext('Columns'),
|
||||
type: 'collection', group: gettext('Definition'),
|
||||
editable: false,
|
||||
cell: Backgrid.StringCell.extend({
|
||||
initialize: function() {
|
||||
Backgrid.StringCell.prototype.initialize.apply(this, arguments);
|
||||
|
||||
var self = this,
|
||||
collection = this.model.get('columns');
|
||||
|
||||
// Do not listen for any event(s) for existing constraint.
|
||||
if (_.isUndefined(self.model.get('oid'))) {
|
||||
var tableCols = self.model.top.get('columns');
|
||||
self.listenTo(tableCols, 'remove' , self.removeColumn);
|
||||
self.listenTo(tableCols, 'change:name', self.resetColOptions);
|
||||
}
|
||||
|
||||
collection.on('pgadmin:multicolumn:updated', function() {
|
||||
self.render.apply(self);
|
||||
});
|
||||
self.listenTo(collection, "add", self.render);
|
||||
self.listenTo(collection, "remove", self.render);
|
||||
},
|
||||
removeColumn: function(m) {
|
||||
var self = this,
|
||||
removedCols = self.model.get('columns').where(
|
||||
{column: m.get('name')}
|
||||
);
|
||||
|
||||
self.model.get('columns').remove(removedCols);
|
||||
setTimeout(function () {
|
||||
self.render();
|
||||
}, 10);
|
||||
|
||||
var key = 'unique_constraint'
|
||||
setTimeout(function () {
|
||||
constraints = self.model.top.get(key);
|
||||
var removed = [];
|
||||
constraints.each(function(constraint) {
|
||||
if (constraint.get("columns").length == 0) {
|
||||
removed.push(constraint);
|
||||
}
|
||||
});
|
||||
constraints.remove(removed);
|
||||
},100);
|
||||
|
||||
},
|
||||
resetColOptions : function(m) {
|
||||
var self = this,
|
||||
updatedCols = self.model.get('columns').where(
|
||||
{column: m.previous('name')}
|
||||
);
|
||||
if (updatedCols.length > 0) {
|
||||
/*
|
||||
* Table column name has changed so update
|
||||
* column name in primary key as well.
|
||||
*/
|
||||
updatedCols[0].set(
|
||||
{"column": m.get('name')},
|
||||
{silent: true});
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
self.render();
|
||||
}, 10);
|
||||
},
|
||||
formatter: {
|
||||
fromRaw: function (rawValue, model) {
|
||||
return rawValue.pluck("column").toString();
|
||||
},
|
||||
toRaw: function (val, model) {
|
||||
return val;
|
||||
}
|
||||
},
|
||||
render: function() {
|
||||
return Backgrid.StringCell.prototype.render.apply(this, arguments);
|
||||
},
|
||||
remove: function() {
|
||||
var tableCols = this.model.top.get('columns'),
|
||||
primary_key_col = this.model.get('columns');
|
||||
|
||||
if (primary_key_col) {
|
||||
primary_key_col.off('pgadmin:multicolumn:updated');
|
||||
}
|
||||
|
||||
this.stopListening(tableCols, 'remove' , self.removeColumn);
|
||||
this.stopListening(tableCols, 'change:name' , self.resetColOptions);
|
||||
|
||||
Backgrid.StringCell.prototype.remove.apply(this, arguments);
|
||||
}
|
||||
}),
|
||||
canDelete: true, canAdd: true,
|
||||
control: Backform.MultiSelectAjaxControl.extend({
|
||||
defaults: _.extend(
|
||||
{},
|
||||
Backform.NodeListByNameControl.prototype.defaults,
|
||||
{
|
||||
select2: {
|
||||
multiple: true,
|
||||
allowClear: true,
|
||||
width: 'style',
|
||||
placeholder: gettext('Select the column(s)'),
|
||||
}
|
||||
}
|
||||
),
|
||||
keyPathAccessor: function(obj, path) {
|
||||
var res = obj;
|
||||
if(_.isArray(res)) {
|
||||
return _.map(res, function(o) { return o['column']
|
||||
});
|
||||
}
|
||||
path = path.split('.');
|
||||
for (var i = 0; i < path.length; i++) {
|
||||
if (_.isNull(res)) return null;
|
||||
if (_.isEmpty(path[i])) continue;
|
||||
if (!_.isUndefined(res[path[i]])) res = res[path[i]];
|
||||
}
|
||||
return _.isObject(res) && !_.isArray(res) ? null : res;
|
||||
},
|
||||
initialize: function() {
|
||||
// Here we will decide if we need to call URL
|
||||
// Or fetch the data from parent columns collection
|
||||
var self = this;
|
||||
if(this.model.handler) {
|
||||
Backform.Select2Control.prototype.initialize.apply(this, arguments);
|
||||
// Do not listen for any event(s) for existing constraint.
|
||||
if (_.isUndefined(self.model.get('oid'))) {
|
||||
var tableCols = self.model.top.get('columns');
|
||||
self.listenTo(tableCols, 'remove' , self.resetColOptions);
|
||||
self.listenTo(tableCols, 'change:name', self.resetColOptions);
|
||||
}
|
||||
|
||||
self.custom_options();
|
||||
} else {
|
||||
Backform.MultiSelectAjaxControl.prototype.initialize.apply(this, arguments);
|
||||
}
|
||||
self.model.get('columns').on('pgadmin:multicolumn:updated', function() {
|
||||
self.render.apply(self);
|
||||
});
|
||||
},
|
||||
resetColOptions: function(m) {
|
||||
var self = this;
|
||||
|
||||
setTimeout(function () {
|
||||
self.custom_options();
|
||||
self.render.apply(self);
|
||||
}, 50);
|
||||
|
||||
},
|
||||
custom_options: function() {
|
||||
// We will add all the columns entered by user in table model
|
||||
var columns = this.model.top.get('columns'),
|
||||
added_columns_from_tables = [];
|
||||
|
||||
if (columns.length > 0) {
|
||||
_.each(columns.models, function(m) {
|
||||
var col = m.get('name');
|
||||
if(!_.isUndefined(col) && !_.isNull(col)) {
|
||||
added_columns_from_tables.push(
|
||||
{label: col, value: col, image:'icon-column'}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Set the values in to options so that user can select
|
||||
this.field.set('options', added_columns_from_tables);
|
||||
},
|
||||
onChange: function(e) {
|
||||
var self = this,
|
||||
model = this.model,
|
||||
$el = $(e.target),
|
||||
attrArr = this.field.get("name").split('.'),
|
||||
name = attrArr.shift(),
|
||||
path = attrArr.join('.'),
|
||||
vals = this.getValueFromDOM(),
|
||||
collection = model.get(name),
|
||||
removed = [];
|
||||
|
||||
this.stopListening(this.model, "change:" + name, this.render);
|
||||
|
||||
/*
|
||||
* Iterate through all the values, and find out how many are already
|
||||
* present in the collection.
|
||||
*/
|
||||
collection.each(function(m) {
|
||||
var column = m.get('column'),
|
||||
idx = _.indexOf(vals, column);
|
||||
|
||||
if (idx > -1) {
|
||||
vals.splice(idx, 1);
|
||||
} else {
|
||||
removed.push(column);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Adding new values
|
||||
*/
|
||||
|
||||
_.each(vals, function(v) {
|
||||
var m = new (self.field.get('model'))(
|
||||
{column: v}, { silent: true,
|
||||
top: self.model.top,
|
||||
collection: collection,
|
||||
handler: collection
|
||||
});
|
||||
|
||||
collection.add(m);
|
||||
});
|
||||
|
||||
/*
|
||||
* Removing unwanted!
|
||||
*/
|
||||
_.each(removed, function(v) {
|
||||
collection.remove(collection.where({column: v}));
|
||||
});
|
||||
|
||||
this.listenTo(this.model, "change:" + name, this.render);
|
||||
},
|
||||
remove: function() {
|
||||
if(this.model.handler) {
|
||||
var self = this,
|
||||
tableCols = self.model.top.get('columns');
|
||||
self.stopListening(tableCols, 'remove' , self.resetColOptions);
|
||||
self.stopListening(tableCols, 'change:name' , self.resetColOptions);
|
||||
self.model.get('columns').off('pgadmin:multicolumn:updated');
|
||||
|
||||
Backform.Select2Control.prototype.remove.apply(this, arguments);
|
||||
|
||||
} else {
|
||||
Backform.MultiSelectAjaxControl.prototype.remove.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
}),
|
||||
deps: ['index'], node: 'column',
|
||||
model: pgBrowser.Node.Model.extend({
|
||||
defaults: {
|
||||
column: undefined
|
||||
},
|
||||
validate: function() {
|
||||
return null;
|
||||
}
|
||||
}),
|
||||
transform : function(data){
|
||||
var res = [];
|
||||
if (data && _.isArray(data)) {
|
||||
_.each(data, function(d) {
|
||||
res.push({label: d.label, value: d.label, image:'icon-column'});
|
||||
})
|
||||
}
|
||||
return res;
|
||||
},
|
||||
select2:{allowClear:false},
|
||||
disabled: function(m) {
|
||||
// If we are in table edit mode then
|
||||
if (_.has(m, 'top') && !_.isUndefined(m.top)
|
||||
&& !m.top.isNew()) {
|
||||
// If OID is undefined then user is trying to add
|
||||
// new constraint which should be allowed for Unique
|
||||
return !_.isUndefined(m.get('oid'));
|
||||
}
|
||||
|
||||
// We can't update columns of existing index constraint.
|
||||
if (!m.isNew()) {
|
||||
return true;
|
||||
}
|
||||
// Disable if index is selected.
|
||||
var index = m.get('index');
|
||||
if(_.isUndefined(index) || index == '') {
|
||||
return false;
|
||||
} else {
|
||||
var col = m.get('columns');
|
||||
col.reset();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'spcname', label: gettext('Tablespace'),
|
||||
type: 'text', group: gettext('Definition'),
|
||||
control: 'node-list-by-name', node: 'tablespace',
|
||||
deps: ['index'],
|
||||
select2:{allowClear:false},
|
||||
filter: function(m) {
|
||||
// Don't show pg_global tablespace in selection.
|
||||
if (m.label == "pg_global") return false;
|
||||
else return true;
|
||||
},
|
||||
disabled: function(m) {
|
||||
// Disable if index is selected.
|
||||
m = m.top || m;
|
||||
var index = m.get('index');
|
||||
if(_.isUndefined(index) || index == '') {
|
||||
return false;
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
m.set('spcname', '');
|
||||
},10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'index', label: gettext('Index'),
|
||||
type: 'text', group: gettext('Definition'),
|
||||
control: Backform.NodeListByNameControl.extend({
|
||||
initialize:function() {
|
||||
if (_.isUndefined(this.model.top)) {
|
||||
Backform.NodeListByNameControl.prototype.initialize.apply(this,arguments);
|
||||
} else {
|
||||
Backform.Control.prototype.initialize.apply(this,arguments);
|
||||
}
|
||||
}
|
||||
}),
|
||||
select2:{allowClear:true}, node: 'index',
|
||||
disabled: function(m) {
|
||||
// If we are in table edit mode then disable it
|
||||
if (_.has(m, 'top') && !_.isUndefined(m.top)
|
||||
&& !m.top.isNew()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We can't update index of existing index constraint.
|
||||
return !m.isNew();
|
||||
},
|
||||
// We will not show this field in Create Table mode
|
||||
visible: function(m) {
|
||||
return !_.isUndefined(m.top.node_info['table']);
|
||||
}
|
||||
},{
|
||||
id: 'fillfactor', label: gettext('Fill factor'), deps: ['index'],
|
||||
type: 'int', group: gettext('Definition'), allowNull: true,
|
||||
disabled: function(m) {
|
||||
// Disable if index is selected.
|
||||
var index = m.get('index');
|
||||
if(_.isUndefined(index) || index == '') {
|
||||
return false;
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
m.set('fillfactor', null);
|
||||
},10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'condeferrable', label: gettext('Deferrable?'),
|
||||
type: 'switch', group: gettext('Definition'), deps: ['index'],
|
||||
disabled: function(m) {
|
||||
// If we are in table edit mode then
|
||||
if (_.has(m, 'top') && !_.isUndefined(m.top)
|
||||
&& !m.top.isNew()) {
|
||||
// If OID is undefined then user is trying to add
|
||||
// new constraint which should allowed for Unique
|
||||
return !_.isUndefined(m.get('oid'));
|
||||
}
|
||||
|
||||
// We can't update condeferrable of existing index constraint.
|
||||
if (!m.isNew()) {
|
||||
return true;
|
||||
}
|
||||
// Disable if index is selected.
|
||||
var index = m.get('index');
|
||||
if(_.isUndefined(index) || index == '') {
|
||||
return false;
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
if(m.get('condeferrable'))
|
||||
m.set('condeferrable', false);
|
||||
},10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'condeferred', label: gettext('Deferred?'),
|
||||
type: 'switch', group: gettext('Definition'),
|
||||
deps: ['condeferrable'],
|
||||
disabled: function(m) {
|
||||
// If we are in table edit mode then
|
||||
if (_.has(m, 'top') && !_.isUndefined(m.top)
|
||||
&& !m.top.isNew()) {
|
||||
// If OID is undefined then user is trying to add
|
||||
// new constraint which should allowed for Unique
|
||||
return !_.isUndefined(m.get('oid'));
|
||||
}
|
||||
|
||||
// We can't update condeferred of existing index constraint.
|
||||
if (!m.isNew()) {
|
||||
return true;
|
||||
}
|
||||
// Disable if condeferred is false or unselected.
|
||||
if(m.get('condeferrable') == true) {
|
||||
return false;
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
if(m.get('condeferred'))
|
||||
m.set('condeferred', false);
|
||||
},10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
validate: function() {
|
||||
this.errorModel.clear();
|
||||
// Clear parent's error as well
|
||||
if (_.has(this, 'top')) {
|
||||
this.top.errorModel.clear();
|
||||
}
|
||||
|
||||
var columns = this.get('columns'),
|
||||
index = this.get('index');
|
||||
|
||||
if ((_.isUndefined(index) || String(index).replace(/^\s+|\s+$/g, '') == '') &&
|
||||
(_.isUndefined(columns) || _.isNull(columns) || columns.length < 1)) {
|
||||
var msg = gettext('Please specify columns for %(node)s', {node: gettext('Unique constraint')});
|
||||
this.errorModel.set('columns', msg);
|
||||
return msg;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
return pgBrowser.Nodes['unique_constraint'];
|
||||
});
|
88
web/pgadmin/browser/templates/browser/js/utils.js
Normal file
88
web/pgadmin/browser/templates/browser/js/utils.js
Normal file
@ -0,0 +1,88 @@
|
||||
define('pgadmin.browser.utils',
|
||||
['pgadmin'], function(pgAdmin) {
|
||||
|
||||
var pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
|
||||
/* Add hooked-in panels by extensions */
|
||||
pgBrowser['panels_items'] = '{{ current_app.panels|tojson }}';
|
||||
|
||||
|
||||
// Define list of nodes on which Query tool option doesn't appears
|
||||
var unsupported_nodes = pgAdmin.unsupported_nodes = [
|
||||
'server-group', 'server', 'coll-tablespace', 'tablespace',
|
||||
'coll-role', 'role', 'coll-resource_group', 'resource_group',
|
||||
'coll-database'
|
||||
];
|
||||
|
||||
pgBrowser.utils = {
|
||||
layout: '{{ layout }}',
|
||||
pg_help_path: '{{ pg_help_path }}',
|
||||
edbas_help_path: '{{ edbas_help_path }}',
|
||||
tabSize: '{{ editor_tab_size }}',
|
||||
wrapCode: '{{ editor_wrap_code }}' == 'True',
|
||||
useSpaces: '{{ editor_use_spaces }}',
|
||||
insertPairBrackets: '{{ editor_insert_pair_brackets }}' == 'True',
|
||||
braceMatching: '{{ editor_brace_matching }}' == 'True',
|
||||
app_name: '{{ app_name }}',
|
||||
|
||||
counter: {total: 0, loaded: 0},
|
||||
registerScripts: function (ctx) {
|
||||
// There are some scripts which needed to be loaded immediately,
|
||||
// but - not all. We will will need to generate all the menus only
|
||||
// after they all were loaded completely.
|
||||
},
|
||||
|
||||
addMenus: function (obj) {
|
||||
// Generate the menu items only when all the initial scripts
|
||||
// were loaded completely.
|
||||
//
|
||||
// First - register the menus from the other
|
||||
// modules/extensions.
|
||||
var self = this;
|
||||
if (this.counter.total == this.counter.loaded) {
|
||||
{% for key in ('File', 'Edit', 'Object' 'Tools', 'Management', 'Help') %}
|
||||
obj.add_menus([{% for item in current_app.menu_items['%s_items' % key.lower()] %}{% if loop.index != 1 %}, {% endif %}{
|
||||
name: "{{ item.name }}",
|
||||
{% if item.module %}module: {{ item.module }},
|
||||
{% endif %}{% if item.url %}url: "{{ item.url }}",
|
||||
{% endif %}{% if item.target %}target: "{{ item.target }}",
|
||||
{% endif %}{% if item.callback %}callback: "{{ item.callback }}",
|
||||
{% endif %}{% if item.category %}category: "{{ item.category }}",
|
||||
{% endif %}{% if item.icon %}icon: '{{ item.icon }}',
|
||||
{% endif %}{% if item.data %}data: {{ item.data }},
|
||||
{% endif %}label: '{{ item.label }}', applies: ['{{ key.lower() }}'],
|
||||
priority: {{ item.priority }},
|
||||
enable: '{{ item.enable }}'
|
||||
}{% set hasMenus = True %}{% endfor %}]);
|
||||
{% endfor %}
|
||||
obj.create_menus();
|
||||
} else {
|
||||
//recall after some time
|
||||
setTimeout(function(){ self.addMenus(obj); }, 3000);
|
||||
}
|
||||
},
|
||||
|
||||
// load the module right now
|
||||
load_module: function(name, path, c) {
|
||||
var 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;
|
||||
});
|
23
web/pgadmin/static/bundle/app.js
Normal file
23
web/pgadmin/static/bundle/app.js
Normal file
@ -0,0 +1,23 @@
|
||||
define('app', [
|
||||
'babel-polyfill','pgadmin', 'browser_node', 'tools.datagrid'
|
||||
], function() {
|
||||
var initializeModules = function(Object) {
|
||||
for (var key in Object) {
|
||||
var module = Object[key];
|
||||
if (module.init && typeof module.init == 'function') {
|
||||
module.init();
|
||||
}
|
||||
else if (module.Init && typeof module.Init == 'function') {
|
||||
module.Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize modules registered to pgAdmin, pgAdmin.Browser and Tools object.
|
||||
initializeModules(pgAdmin);
|
||||
initializeModules(pgAdmin.Browser);
|
||||
initializeModules(pgAdmin.Tools);
|
||||
|
||||
// create menus after all modules are initialized.
|
||||
pgAdmin.Browser.create_menus();
|
||||
});
|
5
web/pgadmin/static/bundle/browser.js
Normal file
5
web/pgadmin/static/bundle/browser.js
Normal file
@ -0,0 +1,5 @@
|
||||
define('browser_node',[
|
||||
'pgadmin.browser'
|
||||
], function(pgBrowser) {
|
||||
pgBrowser.init();
|
||||
});
|
18
web/pgadmin/static/bundle/codemirror.js
Normal file
18
web/pgadmin/static/bundle/codemirror.js
Normal file
@ -0,0 +1,18 @@
|
||||
import CodeMirror from 'codemirror/lib/codemirror';
|
||||
import 'codemirror/mode/sql/sql';
|
||||
import 'codemirror/addon/selection/mark-selection';
|
||||
import 'codemirror/addon/selection/active-line';
|
||||
import 'codemirror/addon/fold/foldcode';
|
||||
import 'codemirror/addon/fold/foldgutter';
|
||||
import 'codemirror/addon/hint/show-hint';
|
||||
import 'codemirror/addon/hint/sql-hint';
|
||||
import 'codemirror/addon/scroll/simplescrollbars';
|
||||
import 'codemirror/addon/dialog/dialog';
|
||||
import 'codemirror/addon/search/search';
|
||||
import 'codemirror/addon/search/searchcursor';
|
||||
import 'codemirror/addon/search/jump-to-line';
|
||||
import 'codemirror/addon/edit/matchbrackets';
|
||||
import 'codemirror/addon/edit/closebrackets';
|
||||
import 'pgadmin.sqlfoldcode';
|
||||
|
||||
export default CodeMirror;
|
37
web/pgadmin/static/css/lib.css
Normal file
37
web/pgadmin/static/css/lib.css
Normal file
@ -0,0 +1,37 @@
|
||||
@import '~bootstrap/dist/css/bootstrap.css';
|
||||
@import '~alertifyjs/build/css/alertify.css';
|
||||
@import '~alertifyjs/build/css/themes/bootstrap.css';
|
||||
@import '~bootstrap/dist/css/bootstrap-theme.css';
|
||||
@import '~font-awesome/css/font-awesome.css';
|
||||
@import '~font-mfizz/font/font-mfizz.css';
|
||||
@import '~bootstrap-datepicker/dist/css/bootstrap-datepicker3.css';
|
||||
@import '~bootstrap-datetime-picker/css/bootstrap-datetimepicker.css';
|
||||
@import '~bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.css';
|
||||
@import '~backgrid-select-all/backgrid-select-all.css';
|
||||
@import '~backgrid-filter/backgrid-filter.css';
|
||||
@import '~backgrid-sizeable-columns/backgrid-sizeable-columns.css';
|
||||
@import '~slickgrid/css/select2.css';
|
||||
@import '~jquery-contextmenu/dist/jquery.contextMenu.css';
|
||||
@import '~webcabin-docker/Build/wcDocker.css';
|
||||
@import '~acitree/css/aciTree.css';
|
||||
|
||||
@import '~codemirror/lib/codemirror.css';
|
||||
@import '~codemirror/addon/dialog/dialog.css';
|
||||
@import '~codemirror/addon/scroll/simplescrollbars.css';
|
||||
|
||||
@import '~slickgrid/slick.grid.css';
|
||||
@import '~slickgrid/slick-default-theme.css';
|
||||
@import '~slickgrid/css/smoothness/jquery-ui-1.11.3.custom.css';
|
||||
|
||||
@import '../../preferences/static/css/preferences.css';
|
||||
@import '../../browser/static/css/browser.css';
|
||||
@import '../../dashboard/static/css/dashboard.css';
|
||||
@import '../../browser/static/css/wizard.css';
|
||||
@import '../../tools/debugger/static/css/debugger.css';
|
||||
|
||||
@import '../../tools/grant_wizard/static/css/grant_wizard.css';
|
||||
@import '../../tools/maintenance/static/css/maintenance.css';
|
||||
@import '../../tools/sqleditor/static/css/sqleditor.css';
|
||||
@import '../../misc/static/explain/css/explain.css';
|
||||
@import '../../misc/bgprocess/static/css/bgprocess.css';
|
||||
@import '../../misc/static/explain/css/explain.css';
|
282
web/webpack.shim.js
Normal file
282
web/webpack.shim.js
Normal file
@ -0,0 +1,282 @@
|
||||
/* eslint-env node */
|
||||
//Configuration file contains requireJS like shim and paths used by webpack shim-loader
|
||||
const path = require('path');
|
||||
|
||||
var webpackShimConfig = {
|
||||
shim: {
|
||||
'moment': {
|
||||
exports: 'moment',
|
||||
},
|
||||
'underscore': {
|
||||
exports: '_',
|
||||
},
|
||||
'jquery': {
|
||||
'exports': '$',
|
||||
},
|
||||
'bootstrap': {
|
||||
'deps': ['jquery'],
|
||||
},
|
||||
'select2': {
|
||||
'deps': ['jquery'],
|
||||
'exports': '$.fn.select2',
|
||||
},
|
||||
'bootstrap.datepicker': {
|
||||
'deps': ['jquery', 'bootstrap'],
|
||||
'exports': 'jQuery.fn.datepicker',
|
||||
},
|
||||
'bootstrap.datetimepicker': {
|
||||
'exports': 'jQuery.fn.datetimepicker',
|
||||
},
|
||||
'bootstrap.switch': {
|
||||
deps: ['jquery', 'bootstrap'],
|
||||
'exports': '$.fn.bootstrapSwitch',
|
||||
},
|
||||
'backbone': {
|
||||
exports: 'Backbone', // Once loaded, use the global 'Backbone' as the module value.
|
||||
deps: [
|
||||
'underscore', // just make sure that underscore is loaded before (uses it's global value)
|
||||
'jquery:$', // Provide jquery as dependency with name $
|
||||
],
|
||||
},
|
||||
'backgrid': {
|
||||
'deps': ['backform'],
|
||||
'exports': 'Backgrid',
|
||||
},
|
||||
'pgadmin.backform': {
|
||||
'deps': ['backform', 'pgadmin.backgrid', 'select2'],
|
||||
},
|
||||
'pgadmin.backgrid': {
|
||||
'deps': ['backgrid', 'bootstrap.datetimepicker', 'bootstrap.switch'],
|
||||
},
|
||||
|
||||
'backgrid.select.all': {
|
||||
'deps': ['backgrid'],
|
||||
},
|
||||
'backgrid.paginator': {
|
||||
'deps': ['backgrid', 'backbone.paginator'],
|
||||
},
|
||||
'backgrid.filter': {
|
||||
'deps': ['backgrid'],
|
||||
},
|
||||
'backgrid.sizeable.columns': {
|
||||
'deps': ['backgrid'],
|
||||
},
|
||||
'jquery.event.drag': {
|
||||
'deps': ['jquery'], 'exports': 'jQuery.fn.drag',
|
||||
},
|
||||
'jquery.ui': {'deps': ['jquery']},
|
||||
'slick.pgadmin.formatters': {
|
||||
'deps': ['slickgrid'],
|
||||
},
|
||||
'slick.pgadmin.editors': {
|
||||
'deps': ['slickgrid'],
|
||||
},
|
||||
'slickgrid': {
|
||||
'deps': ['jquery', 'jquery.ui', 'jquery.event.drag'],
|
||||
'exports': 'Slick',
|
||||
},
|
||||
'flotr2': {
|
||||
deps: ['bean'],
|
||||
},
|
||||
'alertify': {
|
||||
'exports': 'alertify',
|
||||
},
|
||||
'jqueryui.position': {
|
||||
'deps': ['jquery'],
|
||||
'exports': 'jQuery.ui.position',
|
||||
},
|
||||
'jquery.contextmenu': {
|
||||
'deps': ['jquery', 'jqueryui.position'],
|
||||
'exports': 'jQuery.contextMenu',
|
||||
},
|
||||
'jquery.aciplugin': {
|
||||
'deps': ['jquery'],
|
||||
'exports': 'aciPluginClass',
|
||||
},
|
||||
'jquery.acitree': {
|
||||
'deps': ['jquery', 'jquery.aciplugin'],
|
||||
'exports': 'aciPluginClass.plugins.aciTree',
|
||||
},
|
||||
'jquery.acisortable': {
|
||||
'deps': ['jquery', 'jquery.aciplugin'],
|
||||
'exports': 'aciPluginClass.plugins.aciSortable',
|
||||
},
|
||||
'jquery.acifragment': {
|
||||
'deps': ['jquery', 'jquery.aciplugin'],
|
||||
'exports': 'aciPluginClass.plugins.aciFragment',
|
||||
},
|
||||
'wcdocker': {
|
||||
'deps': ['jquery.contextmenu'],
|
||||
},
|
||||
'pgadmin.browser.messages': {
|
||||
'deps': ['pgadmin.browser.datamodel'],
|
||||
},
|
||||
},
|
||||
|
||||
resolveAlias: {
|
||||
'baseurl': path.join(__dirname, './pgadmin'),
|
||||
'misc': path.join(__dirname, './pgadmin/static/bundle/misc'),
|
||||
'browser_node': path.join(__dirname, './pgadmin/static/bundle/browser'),
|
||||
'sources': path.join(__dirname, './pgadmin/static/js'),
|
||||
'pgadmin': path.join(__dirname, './pgadmin/static/js/pgadmin'),
|
||||
'tools.translations': path.join(__dirname, './pgadmin/tools/templates/js/translations'),
|
||||
'sources/gettext': path.join(__dirname, './pgadmin/static/js/gettext'),
|
||||
'babel-polyfill': path.join(__dirname, './node_modules/babel-polyfill/dist/polyfill'),
|
||||
|
||||
// Vendor JS
|
||||
'jquery': path.join(__dirname, './node_modules/jquery/dist/jquery'),
|
||||
'wcdocker': path.join(__dirname, './node_modules/webcabin-docker/Build/wcDocker'),
|
||||
'alertify': path.join(__dirname, './node_modules/alertifyjs/build/alertify'),
|
||||
'moment': path.join(__dirname, './node_modules/moment/moment'),
|
||||
'jquery.event.drag': path.join(__dirname, './node_modules/slickgrid/lib/jquery.event.drag-2.2'),
|
||||
'jquery.ui': path.join(__dirname, './node_modules/slickgrid/lib/jquery-ui-1.11.3'),
|
||||
'flotr2': path.join(__dirname, './node_modules/flotr2/flotr2.amd'),
|
||||
'bean': path.join(__dirname, './node_modules/flotr2/lib/bean'),
|
||||
'jqueryui.position': path.join(__dirname, './node_modules/jquery-contextmenu/dist/jquery.ui.position'),
|
||||
'jquery.contextmenu': path.join(__dirname, './node_modules/jquery-contextmenu/dist/jquery.contextmenu'),
|
||||
'dropzone': path.join(__dirname, './node_modules/dropzone/dist/dropzone'),
|
||||
'bignumber': path.join(__dirname, './node_modules/bignumber.js/bignumber'),
|
||||
|
||||
// AciTree
|
||||
'jquery.acitree': path.join(__dirname, './node_modules/acitree/js/jquery.aciTree.min'),
|
||||
'jquery.aciplugin': path.join(__dirname, './node_modules/acitree/js/jquery.aciPlugin.min'),
|
||||
'jquery.acisortable': path.join(__dirname, './node_modules/acitree/js/jquery.aciSortable.min'),
|
||||
'jquery.acifragment': path.join(__dirname, './node_modules/acitree/js/jquery.aciFragment.min'),
|
||||
|
||||
// Backbone and Backgrid
|
||||
'backbone': path.join(__dirname, './node_modules/backbone/backbone'),
|
||||
'backbone.undo': path.join(__dirname, './node_modules/backbone-undo/Backbone.Undo'),
|
||||
'backform': path.join(__dirname, './node_modules/backform/src/backform'),
|
||||
'backgrid': path.join(__dirname, './node_modules/backgrid/lib/backgrid'),
|
||||
'bootstrap.datetimepicker': path.join(__dirname, './node_modules/bootstrap-datetime-picker/js/bootstrap-datetimepicker'),
|
||||
'bootstrap.switch': path.join(__dirname, './node_modules/bootstrap-switch/dist/js/bootstrap-switch'),
|
||||
'select2': path.join(__dirname, './node_modules/select2/dist/js/select2.full'),
|
||||
'backgrid.filter': path.join(__dirname, './node_modules/backgrid-filter/backgrid-filter'),
|
||||
'backgrid.sizeable.columns': path.join(__dirname, './node_modules/backgrid-sizeable-columns/backgrid-sizeable-columns'),
|
||||
'backgrid.select.all': path.join(__dirname, './node_modules/backgrid-select-all/backgrid-select-all'),
|
||||
|
||||
'pgadmin.alertifyjs': path.join(__dirname, './pgadmin/static/js/alertify.pgadmin.defaults'),
|
||||
'pgadmin.backform': path.join(__dirname, './pgadmin/static/js/backform.pgadmin'),
|
||||
'pgadmin.backgrid': path.join(__dirname, './pgadmin/static/js/backgrid.pgadmin'),
|
||||
'pgadmin.misc.explain': path.join(__dirname, './pgadmin/misc/templates/explain/js/explain'),
|
||||
'pgadmin.settings': path.join(__dirname, './pgadmin/settings/templates/settings/settings'),
|
||||
'pgadmin.preferences': path.join(__dirname, './pgadmin/preferences/templates/preferences/preferences'),
|
||||
'pgadmin.dashboard': path.join(__dirname, './pgadmin/dashboard/templates/dashboard/js/dashboard'),
|
||||
'bundled_codemirror': path.join(__dirname, './pgadmin/static/bundle/codemirror'),
|
||||
'pgadmin.sqlfoldcode': path.join(__dirname, './pgadmin/static/js/codemirror/addon/fold/pgadmin-sqlfoldcode'),
|
||||
'pgadmin.about': path.join(__dirname, './pgadmin/about/templates/about/about'),
|
||||
|
||||
//tools JS
|
||||
'tools.backup': path.join(__dirname, './pgadmin/tools/backup/templates/backup/js/backup'),
|
||||
'tools.restore': path.join(__dirname, './pgadmin/tools/restore/templates/restore/js/restore'),
|
||||
'pgadmin.browser.wizard': path.join(__dirname, './pgadmin/browser/static/js/wizard'),
|
||||
'tools.grant_wizard': path.join(__dirname, './pgadmin/tools/grant_wizard/templates/grant_wizard/js/grant_wizard'),
|
||||
'tools.datagrid': path.join(__dirname, './pgadmin/tools/datagrid/templates/datagrid/js/datagrid'),
|
||||
'tools.querytool': path.join(__dirname, './pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor'),
|
||||
'tools.maintenance': path.join(__dirname, './pgadmin/tools/maintenance/templates/maintenance/js/maintenance'),
|
||||
'tools.import_export': path.join(__dirname, './pgadmin/tools/import_export/templates/import_export/js/import_export'),
|
||||
'tools.debugger.ui': path.join(__dirname, './pgadmin/tools/debugger/templates/debugger/js/debugger_ui'),
|
||||
'tools.debugger': path.join(__dirname, './pgadmin/tools/debugger/templates/debugger/js/debugger'),
|
||||
'tools.direct': path.join(__dirname, './pgadmin/tools/debugger/templates/debugger/js/direct'),
|
||||
|
||||
// Misc JS
|
||||
'misc.bgprocess': path.join(__dirname, './pgadmin/misc/bgprocess/static/js/bgprocess'),
|
||||
'misc.file_manager': path.join(__dirname, './pgadmin/misc/file_manager/templates/file_manager/js/file_manager'),
|
||||
'misc.file_utility': path.join(__dirname, './pgadmin/misc/file_manager/templates/file_manager/js/utility'),
|
||||
'misc.statistics': path.join(__dirname, './pgadmin/misc/statistics/static/js/statistics'),
|
||||
'misc.depends': path.join(__dirname, './pgadmin/misc/depends/static/js/depends'),
|
||||
'misc.sql': path.join(__dirname, './pgadmin/misc/sql/static/js/sql'),
|
||||
|
||||
// Browser Plugins JS
|
||||
'pgadmin.browser': path.join(__dirname, './pgadmin/browser/templates/browser/js/browser'),
|
||||
'pgadmin.browser.error': path.join(__dirname, './pgadmin/browser/templates/browser/js/error'),
|
||||
'pgadmin.browser.utils': path.join(__dirname, './pgadmin/browser/templates/browser/js/utils'),
|
||||
'pgadmin.browser.server.privilege': path.join(__dirname, './pgadmin/browser/server_groups/servers/static/js/privilege'),
|
||||
'pgadmin.browser.server.variable': path.join(__dirname, './pgadmin/browser/server_groups/servers/static/js/variable'),
|
||||
'pgadmin.browser.collection': path.join(__dirname, './pgadmin/browser/templates/browser/js/collection'),
|
||||
'pgadmin.browser.node': path.join(__dirname, './pgadmin/browser/templates/browser/js/node'),
|
||||
'pgadmin.browser.node.ui': path.join(__dirname, './pgadmin/browser/static/js/node.ui'),
|
||||
'pgadmin.browser.datamodel': path.join(__dirname, './pgadmin/browser/static/js/datamodel'),
|
||||
'pgadmin.browser.menu': path.join(__dirname, './pgadmin/browser/static/js/menu'),
|
||||
'pgadmin.browser.panel': path.join(__dirname, './pgadmin/browser/static/js/panel'),
|
||||
'pgadmin.browser.frame': path.join(__dirname, './pgadmin/browser/static/js/frame'),
|
||||
'pgadmin.tools.user_management': path.join(__dirname, './pgadmin/tools/user_management/templates/user_management/js/user_management'),
|
||||
'slick.pgadmin.editors': path.join(__dirname, './pgadmin/static/js/slickgrid/slick.pgadmin.editors'),
|
||||
'slick.pgadmin.formatters': path.join(__dirname, './pgadmin/static/js/slickgrid/slick.pgadmin.formatters'),
|
||||
|
||||
// Browser Nodes JS
|
||||
'pgadmin.node.server_group': path.join(__dirname, './pgadmin/browser/server_groups/static/js/server-group'),
|
||||
'pgadmin.node.server': path.join(__dirname, './pgadmin/browser/server_groups/servers/static/js/server'),
|
||||
'pgadmin.node.database': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/static/js/database'),
|
||||
'pgadmin.node.role': path.join(__dirname, './pgadmin/browser/server_groups/servers/roles/templates/role/js/role'),
|
||||
'pgadmin.node.tablespace': path.join(__dirname, './pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/js/tablespaces'),
|
||||
'pgadmin.node.resource_group': path.join(__dirname, './pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups'),
|
||||
'pgadmin.node.cast': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/casts/static/js/cast'),
|
||||
'pgadmin.node.event_trigger': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/event_triggers/static/js/event_trigger'),
|
||||
'pgadmin.node.extension': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension'),
|
||||
'pgadmin.node.foreign_data_wrapper': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/static/js/foreign_data_wrapper'),
|
||||
'pgadmin.node.language': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/languages/static/js/language'),
|
||||
'pgadmin.node.schema': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema'),
|
||||
'pgadmin.node.catalog': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog'),
|
||||
'pgadmin.node.catalog_object': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/static/js/catalog_object'),
|
||||
'pgadmin.node.collation': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation'),
|
||||
'pgadmin.node.domain': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain'),
|
||||
'pgadmin.node.domain_constraints': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints'),
|
||||
'pgadmin.node.foreign_table': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign-table'),
|
||||
'pgadmin.node.fts_configuration': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration'),
|
||||
'pgadmin.node.fts_dictionary': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary'),
|
||||
'pgadmin.node.fts_parser': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/static/js/fts_parser'),
|
||||
'pgadmin.node.fts_template': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/static/js/fts_template'),
|
||||
|
||||
'pgadmin.node.function': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function'),
|
||||
'pgadmin.node.procedure': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/procedure'),
|
||||
'pgadmin.node.trigger_function': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function'),
|
||||
'pgadmin.node.package': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package'),
|
||||
'pgadmin.node.sequence': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence'),
|
||||
'pgadmin.node.synonym': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym'),
|
||||
|
||||
'pgadmin.node.table': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table'),
|
||||
'pgadmin.browser.table.partition.utils': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils'),
|
||||
'pgadmin.node.type': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type'),
|
||||
'pgadmin.node.view': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view'),
|
||||
'pgadmin.node.mview': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview'),
|
||||
'pgadmin.node.rule': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/templates/rules/js/rules'),
|
||||
'pgadmin.node.index': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/templates/index/js/index'),
|
||||
'pgadmin.node.trigger': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/templates/trigger/js/trigger'),
|
||||
'pgadmin.node.column': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column'),
|
||||
'pgadmin.node.constraints': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/templates/constraints/js/constraints'),
|
||||
'pgadmin.node.check_constraints': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/templates/check_constraint/js/check_constraint'),
|
||||
'pgadmin.node.exclusion_constraint': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint'),
|
||||
'pgadmin.node.foreign_key': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key'),
|
||||
'pgadmin.node.primary_key': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key'),
|
||||
'pgadmin.node.unique_constraint': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint'),
|
||||
'pgadmin.node.catalog_object_column': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/templates/catalog_object_column/js/catalog_object_column'),
|
||||
'pgadmin.node.edbfunc': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbfunc/js/edbfunc'),
|
||||
'pgadmin.node.edbproc': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/templates/edbproc/js/edbproc'),
|
||||
'pgadmin.node.edbvar': path.join(__dirname, './pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/templates/edbvar/js/edbvar'),
|
||||
|
||||
// pgAgent jobs JS
|
||||
'pgadmin.node.pga_job': path.join(__dirname, './pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job'),
|
||||
'pgadmin.node.pga_schedule': path.join(__dirname, './pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule'),
|
||||
'pgadmin.node.pga_jobstep': path.join(__dirname, './pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep'),
|
||||
},
|
||||
pgLibs: [
|
||||
'pgadmin.browser.wizard', 'pgadmin.browser.error', 'pgadmin.browser.server.privilege',
|
||||
'pgadmin.browser.server.variable', 'pgadmin.browser.collection', 'pgadmin.browser.node.ui',
|
||||
'pgadmin.browser.datamodel', 'pgadmin.browser.menu', 'pgadmin.browser.panel', 'pgadmin',
|
||||
'pgadmin.browser.frame', 'slick.pgadmin.editors', 'slick.pgadmin.formatters',
|
||||
'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser', 'misc.file_manager',
|
||||
'misc.file_utility', 'sources/alerts/alertify_wrapper', 'pgadmin.browser.node',
|
||||
'pgadmin.alertifyjs', 'pgadmin.settings', 'pgadmin.preferences', 'pgadmin.sqlfoldcode',
|
||||
],
|
||||
isExternal: function(module) {
|
||||
var context = module.context;
|
||||
if (typeof context !== 'string') { return false; }
|
||||
return context.indexOf('node_modules') !== -1;
|
||||
},
|
||||
isPgAdminLib: function (module) {
|
||||
if (module.rawRequest === undefined) { return false; }
|
||||
return this.pgLibs.indexOf(module.rawRequest) !== -1;
|
||||
},
|
||||
};
|
||||
module.exports = webpackShimConfig;
|
Loading…
Reference in New Issue
Block a user