mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed code smell 'Update this function so that its implementation is not identical' reported by SonarQube.
This commit is contained in:
@@ -29,6 +29,16 @@ export default class CastSchema extends BaseUISchema {
|
||||
return 'oid';
|
||||
}
|
||||
|
||||
getCastName(state) {
|
||||
var srctype = state.srctyp;
|
||||
var trgtype = state.trgtyp;
|
||||
if(srctype != undefined && srctype != '' &&
|
||||
trgtype != undefined && trgtype != '')
|
||||
return state.name = srctype+'->'+trgtype;
|
||||
else
|
||||
return state.name = '';
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
let obj = this;
|
||||
return [{
|
||||
@@ -53,13 +63,7 @@ export default class CastSchema extends BaseUISchema {
|
||||
* target type are set, if yes then fetch values from both
|
||||
* controls and generate cast name
|
||||
*/
|
||||
var srctype = state.srctyp;
|
||||
var trgtype = state.trgtyp;
|
||||
if(srctype != undefined && srctype != '' &&
|
||||
trgtype != undefined && trgtype != '')
|
||||
return state.name = srctype+'->'+trgtype;
|
||||
else
|
||||
return state.name = '';
|
||||
return obj.getCastName(state);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -83,13 +87,7 @@ export default class CastSchema extends BaseUISchema {
|
||||
* target type are set, if yes then fetch values from both
|
||||
* controls and generate cast name
|
||||
*/
|
||||
var srctype = state.srctyp;
|
||||
var trgtype = state.trgtyp;
|
||||
if(srctype != undefined && srctype != '' &&
|
||||
trgtype != undefined && trgtype != '')
|
||||
return state.name = srctype+'->'+trgtype;
|
||||
else
|
||||
return state.name = '';
|
||||
return obj.getCastName(state);
|
||||
},
|
||||
},
|
||||
/*
|
||||
|
||||
@@ -66,18 +66,7 @@ export default class FTSParserSchema extends BaseUISchema {
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
options.forEach((option) => {
|
||||
if(option && option.label == '') {
|
||||
return;
|
||||
}
|
||||
res.push({ label: option.label, value: option.value });
|
||||
});
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.getFilterOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -93,18 +82,7 @@ export default class FTSParserSchema extends BaseUISchema {
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
options.forEach((option) => {
|
||||
if(option && option.label == '') {
|
||||
return;
|
||||
}
|
||||
res.push({ label: option.label, value: option.value });
|
||||
});
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.getFilterOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -120,18 +98,7 @@ export default class FTSParserSchema extends BaseUISchema {
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
options.forEach((option) => {
|
||||
if(option && option.label == '') {
|
||||
return;
|
||||
}
|
||||
res.push({ label: option.label, value: option.value });
|
||||
});
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.getFilterOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -147,18 +114,7 @@ export default class FTSParserSchema extends BaseUISchema {
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
options.forEach((option) => {
|
||||
if(option && option.label == '') {
|
||||
return;
|
||||
}
|
||||
res.push({ label: option.label, value: option.value });
|
||||
});
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.getFilterOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -174,18 +130,7 @@ export default class FTSParserSchema extends BaseUISchema {
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
options.forEach((option) => {
|
||||
if(option && option.label == '') {
|
||||
return;
|
||||
}
|
||||
res.push({ label: option.label, value: option.value });
|
||||
});
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.getFilterOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -66,18 +66,7 @@ export default class FTSTemplateSchema extends BaseUISchema {
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
options.forEach((option) => {
|
||||
if(option && option.label == '') {
|
||||
return;
|
||||
}
|
||||
res.push({ label: option.label, value: option.value });
|
||||
});
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.getFilterOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -96,18 +85,7 @@ export default class FTSTemplateSchema extends BaseUISchema {
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
options.forEach((option) => {
|
||||
if(option && option.label == '') {
|
||||
return;
|
||||
}
|
||||
res.push({ label: option.label, value: option.value });
|
||||
});
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.getFilterOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -147,6 +147,10 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
return null;
|
||||
}
|
||||
|
||||
attCell(state) {
|
||||
return { cell: this.attlenRange(state) ? 'int' : '' };
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
let obj = this;
|
||||
|
||||
@@ -281,9 +285,7 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
id: 'attlen', label: gettext('Length/Precision'),
|
||||
deps: ['cltype'], type: 'int', group: gettext('Definition'), width: 120, disableResizing: true,
|
||||
cell: (state)=>{
|
||||
return {
|
||||
cell: obj.attlenRange(state) ? 'int' : '',
|
||||
};
|
||||
return obj.attCell(state);
|
||||
},
|
||||
depChange: (state)=>{
|
||||
let range = this.attlenRange(state);
|
||||
@@ -311,9 +313,7 @@ export default class ColumnSchema extends BaseUISchema {
|
||||
id: 'attprecision', label: gettext('Scale'), width: 60, disableResizing: true,
|
||||
deps: ['cltype'], type: 'int', group: gettext('Definition'),
|
||||
cell: (state)=>{
|
||||
return {
|
||||
cell: obj.attlenRange(state) ? 'int' : '',
|
||||
};
|
||||
return obj.attCell(state);
|
||||
},
|
||||
depChange: (state)=>{
|
||||
let range = this.attprecisionRange(state);
|
||||
|
||||
@@ -8,6 +8,16 @@ import { getNodeAjaxOptions, getNodeListByName } from '../../../../../../../../.
|
||||
import TableSchema from '../../../../static/js/table.ui';
|
||||
import Notify from '../../../../../../../../../../static/js/helpers/Notifier';
|
||||
|
||||
function getData(data) {
|
||||
let res = [];
|
||||
if (data && _.isArray(data)) {
|
||||
_.each(data, function(d) {
|
||||
res.push({label: d[0], value: d[1]});
|
||||
});
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
export function getNodeExclusionConstraintSchema(treeNodeInfo, itemNodeData, pgBrowser, noColumns=false) {
|
||||
let tableNode = pgBrowser.Nodes['table'];
|
||||
return new ExclusionConstraintSchema({
|
||||
@@ -17,22 +27,10 @@ export function getNodeExclusionConstraintSchema(treeNodeInfo, itemNodeData, pgB
|
||||
return (m.label != 'pg_global');
|
||||
}),
|
||||
getOperClass: (urlParams)=>getNodeAjaxOptions('get_oper_class', tableNode, treeNodeInfo, itemNodeData, {urlParams: urlParams, useCache:false}, (data)=>{
|
||||
let res = [];
|
||||
if (data && _.isArray(data)) {
|
||||
_.each(data, function(d) {
|
||||
res.push({label: d[0], value: d[1]});
|
||||
});
|
||||
}
|
||||
return res;
|
||||
return getData(data);
|
||||
}),
|
||||
getOperator: (urlParams)=>getNodeAjaxOptions('get_operator', tableNode, treeNodeInfo, itemNodeData, {urlParams: urlParams, useCache:false}, (data)=>{
|
||||
let res = [];
|
||||
if (data && _.isArray(data)) {
|
||||
_.each(data, function(d) {
|
||||
res.push({label: d[0], value: d[1]});
|
||||
});
|
||||
}
|
||||
return res;
|
||||
return getData(data);
|
||||
}),
|
||||
}, treeNodeInfo);
|
||||
}
|
||||
|
||||
@@ -126,6 +126,49 @@ define('pgadmin.node.primary_key', [
|
||||
include: [],
|
||||
},
|
||||
|
||||
genResetColOptions: function() {
|
||||
var self = this;
|
||||
|
||||
setTimeout(function () {
|
||||
self.custom_options();
|
||||
self.render.apply(self);
|
||||
}, 50);
|
||||
},
|
||||
|
||||
genCustomOptions: 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);
|
||||
},
|
||||
checkReadOnly(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;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
// Define the schema for the index constraint node
|
||||
schema: [{
|
||||
id: 'name', label: gettext('Name'), type: 'text',
|
||||
@@ -294,30 +337,10 @@ define('pgadmin.node.primary_key', [
|
||||
});
|
||||
},
|
||||
resetColOptions: function() {
|
||||
var self = this;
|
||||
|
||||
setTimeout(function () {
|
||||
self.custom_options();
|
||||
self.render.apply(self);
|
||||
}, 50);
|
||||
this.genResetColOptions();
|
||||
},
|
||||
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);
|
||||
this.genCustomOptions();
|
||||
},
|
||||
onChange: function() {
|
||||
var self = this,
|
||||
@@ -412,18 +435,7 @@ define('pgadmin.node.primary_key', [
|
||||
},
|
||||
select2:{allowClear:false},
|
||||
readonly: 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;
|
||||
}
|
||||
return this.checkReadOnly(m);
|
||||
},
|
||||
disabled: function(m) {
|
||||
// Disable if index is selected.
|
||||
@@ -477,46 +489,15 @@ define('pgadmin.node.primary_key', [
|
||||
}
|
||||
},
|
||||
resetColOptions: function() {
|
||||
var self = this;
|
||||
|
||||
setTimeout(function () {
|
||||
self.custom_options();
|
||||
self.render.apply(self);
|
||||
}, 50);
|
||||
this.genResetColOptions();
|
||||
},
|
||||
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);
|
||||
this.genCustomOptions();
|
||||
},
|
||||
}),
|
||||
deps: ['index'], node: 'column',
|
||||
readonly: 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;
|
||||
}
|
||||
return this.checkReadOnly(m);
|
||||
},
|
||||
disabled: function(m) {
|
||||
// Disable if index is selected.
|
||||
@@ -596,18 +577,7 @@ define('pgadmin.node.primary_key', [
|
||||
id: 'condeferrable', label: gettext('Deferrable?'),
|
||||
type: 'switch', group: gettext('Definition'), deps: ['index'],
|
||||
readonly: 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;
|
||||
}
|
||||
return this.checkReadOnly(m);
|
||||
},
|
||||
disabled: function(m) {
|
||||
// Disable if index is selected.
|
||||
@@ -627,18 +597,7 @@ define('pgadmin.node.primary_key', [
|
||||
type: 'switch', group: gettext('Definition'),
|
||||
deps: ['condeferrable'],
|
||||
readonly: 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;
|
||||
}
|
||||
return this.checkReadOnly(m);
|
||||
},
|
||||
disabled: function(m) {
|
||||
// Disable if condeferred is false or unselected.
|
||||
|
||||
@@ -158,9 +158,7 @@ export default class PrimaryKeySchema extends BaseUISchema {
|
||||
},
|
||||
deps: ['index'],
|
||||
readonly: function(state) {
|
||||
if(!obj.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
return obj.isReadOnly(state);
|
||||
},
|
||||
disabled: function(state) {
|
||||
// Disable if index is selected.
|
||||
@@ -225,10 +223,7 @@ export default class PrimaryKeySchema extends BaseUISchema {
|
||||
id: 'condeferrable', label: gettext('Deferrable?'),
|
||||
type: 'switch', group: gettext('Definition'), deps: ['index'],
|
||||
readonly: function(state) {
|
||||
if(!obj.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isReadOnly(state);
|
||||
},
|
||||
disabled: function(state) {
|
||||
// Disable if index is selected.
|
||||
@@ -246,10 +241,7 @@ export default class PrimaryKeySchema extends BaseUISchema {
|
||||
type: 'switch', group: gettext('Definition'),
|
||||
deps: ['condeferrable'],
|
||||
readonly: function(state) {
|
||||
if(!obj.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isReadOnly(state);
|
||||
},
|
||||
disabled: function(state) {
|
||||
// Disable if index is selected.
|
||||
|
||||
@@ -130,9 +130,7 @@ export default class UniqueConstraintSchema extends BaseUISchema {
|
||||
}), group: gettext('Definition'),
|
||||
editable: false,
|
||||
readonly: function(state) {
|
||||
if(!obj.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
return obj.isReadOnly(state);
|
||||
},
|
||||
disabled: function(state) {
|
||||
// Disable if index is selected.
|
||||
@@ -161,9 +159,7 @@ export default class UniqueConstraintSchema extends BaseUISchema {
|
||||
},
|
||||
deps: ['index'],
|
||||
readonly: function(state) {
|
||||
if(!obj.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
return obj.isReadOnly(state);
|
||||
},
|
||||
disabled: function(state) {
|
||||
// Disable if index is selected.
|
||||
@@ -228,10 +224,7 @@ export default class UniqueConstraintSchema extends BaseUISchema {
|
||||
id: 'condeferrable', label: gettext('Deferrable?'),
|
||||
type: 'switch', group: gettext('Definition'), deps: ['index'],
|
||||
readonly: function(state) {
|
||||
if(!obj.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isReadOnly(state);
|
||||
},
|
||||
disabled: function(state) {
|
||||
// Disable if index is selected.
|
||||
@@ -249,10 +242,7 @@ export default class UniqueConstraintSchema extends BaseUISchema {
|
||||
type: 'switch', group: gettext('Definition'),
|
||||
deps: ['condeferrable'],
|
||||
readonly: function(state) {
|
||||
if(!obj.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isReadOnly(state);
|
||||
},
|
||||
disabled: function(state) {
|
||||
// Disable if index is selected.
|
||||
|
||||
@@ -75,6 +75,19 @@ export class ColumnSchema extends BaseUISchema {
|
||||
this.op_class_types = options;
|
||||
}
|
||||
|
||||
isEditable(state) {
|
||||
let topObj = this._top;
|
||||
if(this.inSchemaWithModelCheck(state)) {
|
||||
return false;
|
||||
} else if (topObj._sessData && topObj._sessData.amname === 'btree') {
|
||||
state.is_sort_nulls_applicable = true;
|
||||
return true;
|
||||
} else {
|
||||
state.is_sort_nulls_applicable = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
let columnSchemaObj = this;
|
||||
return [
|
||||
@@ -161,31 +174,13 @@ export class ColumnSchema extends BaseUISchema {
|
||||
}
|
||||
},
|
||||
editable: function(state) {
|
||||
let topObj = columnSchemaObj._top;
|
||||
if(columnSchemaObj.inSchemaWithModelCheck(state)) {
|
||||
return false;
|
||||
} else if (topObj._sessData && topObj._sessData.amname === 'btree') {
|
||||
state.is_sort_nulls_applicable = true;
|
||||
return true;
|
||||
} else {
|
||||
state.is_sort_nulls_applicable = false;
|
||||
return false;
|
||||
}
|
||||
return columnSchemaObj.isEditable(state);
|
||||
},
|
||||
deps: ['amname'],
|
||||
},{
|
||||
id: 'nulls', label: gettext('NULLs'),
|
||||
editable: function(state) {
|
||||
let topObj = columnSchemaObj._top;
|
||||
if(columnSchemaObj.inSchemaWithModelCheck(state)) {
|
||||
return false;
|
||||
} else if (topObj._sessData && topObj._sessData.amname === 'btree') {
|
||||
state.is_sort_nulls_applicable = true;
|
||||
return true;
|
||||
} else {
|
||||
state.is_sort_nulls_applicable = false;
|
||||
return false;
|
||||
}
|
||||
return columnSchemaObj.isEditable(state);
|
||||
},
|
||||
deps: ['amname', 'sort_order'],
|
||||
type:'select', cell: 'select',
|
||||
@@ -237,6 +232,39 @@ export default class IndexSchema extends BaseUISchema {
|
||||
return 'oid';
|
||||
}
|
||||
|
||||
getColumns() {
|
||||
return {
|
||||
type: 'select',
|
||||
options: this.fieldOptions.columnList,
|
||||
optionsLoaded: (options) => { this.fieldOptions.columnList = options; },
|
||||
controlProps: {
|
||||
allowClear: false,
|
||||
multiple: true,
|
||||
placeholder: gettext('Select the column(s)'),
|
||||
width: 'style',
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (options && _.isArray(options)) {
|
||||
_.each(options, function(d) {
|
||||
if(d.label != '')
|
||||
res.push({label: d.label, value: d.value, image:'icon-column'});
|
||||
});
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
isVisible() {
|
||||
if(!_.isUndefined(this.node_info) && !_.isUndefined(this.node_info.server)
|
||||
&& !_.isUndefined(this.node_info.server.version) &&
|
||||
this.node_info.server.version >= 110000)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
let indexSchemaObj = this;
|
||||
return [
|
||||
@@ -324,35 +352,10 @@ export default class IndexSchema extends BaseUISchema {
|
||||
return !indexSchemaObj.isNew(state);
|
||||
},
|
||||
type: () => {
|
||||
return {
|
||||
type: 'select',
|
||||
options: indexSchemaObj.fieldOptions.columnList,
|
||||
optionsLoaded: (options) => { indexSchemaObj.fieldOptions.columnList = options; },
|
||||
controlProps: {
|
||||
allowClear: false,
|
||||
multiple: true,
|
||||
placeholder: gettext('Select the column(s)'),
|
||||
width: 'style',
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (options && _.isArray(options)) {
|
||||
_.each(options, function(d) {
|
||||
if(d.label != '')
|
||||
res.push({label: d.label, value: d.value, image:'icon-column'});
|
||||
});
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
};
|
||||
return indexSchemaObj.getColumns();
|
||||
},
|
||||
visible: function() {
|
||||
if(!_.isUndefined(this.node_info) && !_.isUndefined(this.node_info.server)
|
||||
&& !_.isUndefined(this.node_info.server.version) &&
|
||||
this.node_info.server.version >= 110000)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return indexSchemaObj.isVisible();
|
||||
},
|
||||
node:'column',
|
||||
},{
|
||||
@@ -416,27 +419,7 @@ export default class IndexSchema extends BaseUISchema {
|
||||
}, {
|
||||
id: 'include', label: gettext('Include columns'),
|
||||
type: () => {
|
||||
return {
|
||||
type: 'select',
|
||||
options: indexSchemaObj.fieldOptions.columnList,
|
||||
optionsLoaded: (options) => { indexSchemaObj.fieldOptions.columnList = options; },
|
||||
controlProps: {
|
||||
allowClear: false,
|
||||
multiple: true,
|
||||
placeholder: gettext('Select the column(s)'),
|
||||
width: 'style',
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (options && _.isArray(options)) {
|
||||
_.each(options, function(d) {
|
||||
if(d.label != '')
|
||||
res.push({label: d.label, value: d.value, image:'icon-column'});
|
||||
});
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
};
|
||||
return indexSchemaObj.getColumns();
|
||||
},
|
||||
group: gettext('Definition'),
|
||||
editable: false,
|
||||
@@ -446,12 +429,7 @@ export default class IndexSchema extends BaseUISchema {
|
||||
return !indexSchemaObj.isNew(state);
|
||||
},
|
||||
visible: function() {
|
||||
if(!_.isUndefined(this.node_info) && !_.isUndefined(this.node_info.server)
|
||||
&& !_.isUndefined(this.node_info.server.version) &&
|
||||
this.node_info.server.version >= 110000)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return indexSchemaObj.isVisible();
|
||||
},
|
||||
node:'column',
|
||||
},{
|
||||
|
||||
@@ -127,6 +127,21 @@ function(
|
||||
encodeURIComponent(info['partition']._id)
|
||||
);
|
||||
},
|
||||
on_done: function(res, data, t, i) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
data.icon = 'icon-partition';
|
||||
t.addIcon(i, {icon: data.icon});
|
||||
t.unload(i);
|
||||
t.setInode(i);
|
||||
t.deselect(i);
|
||||
// Fetch updated data from server
|
||||
setTimeout(function() {
|
||||
t.select(i);
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
|
||||
canDropCascade: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
|
||||
callbacks: {
|
||||
@@ -197,35 +212,22 @@ function(
|
||||
Notify.confirm(
|
||||
gettext('Truncate Table'),
|
||||
gettext('Are you sure you want to truncate table %s?', d.label),
|
||||
function (e) {
|
||||
if (e) {
|
||||
var data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'truncate' , d, true),
|
||||
type:'PUT',
|
||||
data: params,
|
||||
dataType: 'json',
|
||||
function () {
|
||||
var data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'truncate' , d, true),
|
||||
type:'PUT',
|
||||
data: params,
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
obj.on_done(res, data, t, i);
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
data.icon = 'icon-partition';
|
||||
t.addIcon(i, {icon: data.icon});
|
||||
t.unload(i);
|
||||
t.setInode(i);
|
||||
t.deselect(i);
|
||||
// Fetch updated data from server
|
||||
setTimeout(function() {
|
||||
t.select(i);
|
||||
}, 10);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
});
|
||||
}},
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
reset_table_stats: function(args) {
|
||||
@@ -241,33 +243,19 @@ function(
|
||||
Notify.confirm(
|
||||
gettext('Reset statistics'),
|
||||
gettext('Are you sure you want to reset the statistics for table "%s"?', d._label),
|
||||
function (e) {
|
||||
if (e) {
|
||||
var data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'reset' , d, true),
|
||||
type:'DELETE',
|
||||
function () {
|
||||
var data = d;
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'reset' , d, true),
|
||||
type:'DELETE',
|
||||
})
|
||||
.done(function(res) {
|
||||
obj.on_done(res, data, t, i);
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.removeIcon(i);
|
||||
data.icon = 'icon-partition';
|
||||
t.addIcon(i, {icon: data.icon});
|
||||
t.unload(i);
|
||||
t.setInode(i);
|
||||
t.deselect(i);
|
||||
// Fetch updated data from server
|
||||
setTimeout(function() {
|
||||
t.select(i);
|
||||
}, 10);
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
});
|
||||
}
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
t.unload(i);
|
||||
});
|
||||
},
|
||||
function() {/*This is intentional (SonarQube)*/}
|
||||
);
|
||||
@@ -285,32 +273,30 @@ function(
|
||||
Notify.confirm(
|
||||
gettext('Detach Partition'),
|
||||
gettext('Are you sure you want to detach the partition %s?', d._label),
|
||||
function (e) {
|
||||
if (e) {
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'detach' , d, true),
|
||||
type:'PUT',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
var n = t.next(i);
|
||||
function () {
|
||||
$.ajax({
|
||||
url: obj.generate_url(i, 'detach' , d, true),
|
||||
type:'PUT',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
var n = t.next(i);
|
||||
if (!n) {
|
||||
n = t.prev(i);
|
||||
if (!n) {
|
||||
n = t.prev(i);
|
||||
if (!n) {
|
||||
n = t.parent(i);
|
||||
}
|
||||
}
|
||||
t.remove(i);
|
||||
if (n) {
|
||||
t.select(n);
|
||||
n = t.parent(i);
|
||||
}
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
});
|
||||
}
|
||||
t.remove(i);
|
||||
if (n) {
|
||||
t.select(n);
|
||||
}
|
||||
}
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
});
|
||||
},
|
||||
function() {/*This is intentional (SonarQube)*/}
|
||||
);
|
||||
|
||||
@@ -18,6 +18,13 @@ export class PartitionKeysSchema extends BaseUISchema {
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
isEditable(state) {
|
||||
if(state.key_type == 'expression') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
let obj = this;
|
||||
return [{
|
||||
@@ -47,10 +54,7 @@ export class PartitionKeysSchema extends BaseUISchema {
|
||||
}
|
||||
}),
|
||||
editable: function(state) {
|
||||
if(state.key_type == 'expression') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return obj.isEditable(state);
|
||||
},
|
||||
},{
|
||||
id: 'expression', label: gettext('Expression'), type:'text',
|
||||
@@ -73,10 +77,7 @@ export class PartitionKeysSchema extends BaseUISchema {
|
||||
type: 'select', group: gettext('partition'), deps:['key_type'],
|
||||
options: obj.getCollations, mode: ['create', 'properties', 'edit'],
|
||||
editable: function(state) {
|
||||
if(state.key_type == 'expression') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return obj.isEditable(state);
|
||||
},
|
||||
disabled: ()=>{return !(obj.isNew()); },
|
||||
},
|
||||
@@ -84,10 +85,7 @@ export class PartitionKeysSchema extends BaseUISchema {
|
||||
id: 'op_class', label: gettext('Operator class'), cell: 'select',
|
||||
type: 'select', group: gettext('partition'), deps:['key_type'],
|
||||
editable: function(state) {
|
||||
if(state.key_type == 'expression') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return obj.isEditable(state);
|
||||
},
|
||||
disabled: ()=>{return !(obj.isNew()); },
|
||||
options: obj.getOperatorClass, mode: ['create', 'properties', 'edit'],
|
||||
@@ -137,6 +135,22 @@ export class PartitionsSchema extends BaseUISchema {
|
||||
this.subPartitionsObj.changeColumnOptions(columns);
|
||||
}
|
||||
|
||||
isEditable(state, type) {
|
||||
if(this.top && this.top.sessData.partition_type == type && this.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
isDisable(state, type) {
|
||||
if(this.top && this.top.sessData.partition_type == type && this.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
let obj = this;
|
||||
return [{
|
||||
@@ -223,68 +237,37 @@ export class PartitionsSchema extends BaseUISchema {
|
||||
id: 'values_from', label: gettext('From'), type:'text', cell: 'text',
|
||||
deps: ['is_default'],
|
||||
editable: function(state) {
|
||||
if(obj.top && obj.top.sessData.partition_type == 'range' && obj.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isEditable(state, 'range');
|
||||
},
|
||||
disabled: function(state) {
|
||||
if(obj.top && obj.top.sessData.partition_type == 'range' && obj.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
return obj.isDisable(state, 'range');
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'values_to', label: gettext('To'), type:'text', cell: 'text',
|
||||
deps: ['is_default'],
|
||||
editable: function(state) {
|
||||
if(obj.top && obj.top.sessData.partition_type == 'range' && obj.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isEditable(state, 'range');
|
||||
},
|
||||
disabled: function(state) {
|
||||
if(obj.top && obj.top.sessData.partition_type == 'range' && obj.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return obj.isDisable(state, 'range');
|
||||
},
|
||||
},{
|
||||
id: 'values_in', label: gettext('In'), type:'text', cell: 'text',
|
||||
deps: ['is_default'],
|
||||
editable: function(state) {
|
||||
if(obj.top && obj.top.sessData.partition_type == 'list' && obj.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isEditable(state, 'list');
|
||||
},
|
||||
readonly: function(state) {
|
||||
if(obj.top && obj.top.sessData.partition_type == 'list' && obj.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return obj.isDisable(state, 'list');
|
||||
},
|
||||
},{
|
||||
id: 'values_modulus', label: gettext('Modulus'), type:'int', cell: 'int',
|
||||
editable: function(state) {
|
||||
if(obj.top && obj.top.sessData.partition_type == 'hash' && obj.isNew(state)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isEditable(state, 'hash');
|
||||
},
|
||||
disabled: function(state) {
|
||||
if(obj.top && obj.top.sessData.partition_type == 'hash' && obj.isNew(state)
|
||||
&& state.is_default !== true) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return obj.isDisable(state, 'hash');
|
||||
},
|
||||
},{
|
||||
id: 'values_remainder', label: gettext('Remainder'), type:'int', cell: 'int',
|
||||
|
||||
@@ -97,6 +97,13 @@ export class ConstraintsSchema extends BaseUISchema {
|
||||
return _.some(_.map(state.columns, 'name'));
|
||||
}
|
||||
|
||||
canAdd(state) {
|
||||
if (state.is_partitioned && this.top.getServerVersion() < 110000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
let obj = this;
|
||||
return [{
|
||||
@@ -108,10 +115,7 @@ export class ConstraintsSchema extends BaseUISchema {
|
||||
columns : ['name', 'columns'],
|
||||
disabled: this.inCatalog,
|
||||
canAdd: function(state) {
|
||||
if (state.is_partitioned && obj.top.getServerVersion() < 110000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return obj.canAdd(state);
|
||||
},
|
||||
canAddRow: function(state) {
|
||||
return ((state.primary_key||[]).length < 1 && obj.anyColumnAdded(state));
|
||||
@@ -137,10 +141,7 @@ export class ConstraintsSchema extends BaseUISchema {
|
||||
group: gettext('Foreign Key'), mode: ['edit', 'create'],
|
||||
canEdit: true, canDelete: true, deps:['is_partitioned', 'columns'],
|
||||
canAdd: function(state) {
|
||||
if (state.is_partitioned && obj.top.getServerVersion() < 110000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return obj.canAdd(state);
|
||||
},
|
||||
columns : ['name', 'columns','references_table_name'],
|
||||
disabled: this.inCatalog,
|
||||
@@ -172,10 +173,7 @@ export class ConstraintsSchema extends BaseUISchema {
|
||||
columns : ['name', 'columns'],
|
||||
disabled: this.inCatalog,
|
||||
canAdd: function(state) {
|
||||
if (state.is_partitioned && obj.top.getServerVersion() < 110000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return obj.canAdd(state);
|
||||
},
|
||||
canAddRow: obj.anyColumnAdded,
|
||||
depChange: (state)=>{
|
||||
@@ -194,10 +192,7 @@ export class ConstraintsSchema extends BaseUISchema {
|
||||
columns : ['name', 'columns', 'constraint'],
|
||||
disabled: this.inCatalog,
|
||||
canAdd: function(state) {
|
||||
if (state.is_partitioned && obj.top.getServerVersion() < 110000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return obj.canAdd(state);
|
||||
},
|
||||
canAddRow: obj.anyColumnAdded,
|
||||
depChange: (state)=>{
|
||||
|
||||
@@ -188,6 +188,13 @@ export default class TriggerSchema extends BaseUISchema {
|
||||
return flag;
|
||||
}
|
||||
|
||||
isDisable(state) {
|
||||
if(!state.is_constraint_trigger) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
let obj = this;
|
||||
return [{
|
||||
@@ -301,10 +308,7 @@ export default class TriggerSchema extends BaseUISchema {
|
||||
}
|
||||
},
|
||||
disabled: (state) => {
|
||||
if(!state.is_constraint_trigger) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isDisable(state);
|
||||
}
|
||||
},{
|
||||
id: 'tginitdeferred', label: gettext('Deferred?'),
|
||||
@@ -331,10 +335,7 @@ export default class TriggerSchema extends BaseUISchema {
|
||||
}
|
||||
},
|
||||
disabled: (state) => {
|
||||
if(!state.is_constraint_trigger) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return obj.isDisable(state);
|
||||
}
|
||||
},{
|
||||
id: 'tfunction', label: gettext('Trigger function'),
|
||||
|
||||
@@ -145,6 +145,13 @@ function getDataTypeSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
||||
);
|
||||
}
|
||||
|
||||
function isVisible(state, type) {
|
||||
if(state.typtype === type) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class EnumerationSchema extends BaseUISchema {
|
||||
|
||||
constructor() {
|
||||
@@ -249,18 +256,7 @@ class RangeSchema extends BaseUISchema {
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state) {
|
||||
options.forEach((option) => {
|
||||
if(option && option.label == '') {
|
||||
return;
|
||||
}
|
||||
res.push({ label: option.label, value: option.value });
|
||||
});
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.getFilterOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -277,18 +273,7 @@ class RangeSchema extends BaseUISchema {
|
||||
placeholder: '',
|
||||
width: '100%',
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
options.forEach((option) => {
|
||||
if(option && option.label == '') {
|
||||
return;
|
||||
}
|
||||
res.push({ label: option.label, value: option.value });
|
||||
});
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.getFilterOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -336,18 +321,7 @@ class RangeSchema extends BaseUISchema {
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state) {
|
||||
options.forEach((option) => {
|
||||
if(option && option.label == '') {
|
||||
return;
|
||||
}
|
||||
res.push({ label: option.label, value: option.value });
|
||||
});
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.getFilterOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -377,18 +351,7 @@ class RangeSchema extends BaseUISchema {
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state) {
|
||||
options.forEach((option) => {
|
||||
if(option && option.label == '') {
|
||||
return;
|
||||
}
|
||||
res.push({ label: option.label, value: option.value });
|
||||
});
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.getFilterOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -479,6 +442,33 @@ class ExternalSchema extends BaseUISchema {
|
||||
return result;
|
||||
}
|
||||
|
||||
filterFunctionOptions(state, options) {
|
||||
let res = [];
|
||||
if (state && this.isNew(state)) {
|
||||
res = this.external_func_combo(options);
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
getFunctionType(state) {
|
||||
let obj = this;
|
||||
return {
|
||||
type: 'select',
|
||||
options: obj.fieldOptions.externalFunctionsList,
|
||||
optionsLoaded: (options) => { obj.fieldOptions.externalFunctionsList = options; },
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
placeholder: '',
|
||||
width: '100%',
|
||||
filter: (options) => {
|
||||
return obj.filterFunctionOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
var obj = this;
|
||||
return [{
|
||||
@@ -491,50 +481,14 @@ class ExternalSchema extends BaseUISchema {
|
||||
return !obj.isNew(state);
|
||||
},
|
||||
type: (state) => {
|
||||
return {
|
||||
type: 'select',
|
||||
options: obj.fieldOptions.externalFunctionsList,
|
||||
optionsLoaded: (options) => { obj.fieldOptions.externalFunctionsList = options; },
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
placeholder: '',
|
||||
width: '100%',
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
res = obj.external_func_combo(options);
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
};
|
||||
return obj.getFunctionType(state);
|
||||
},
|
||||
}, {
|
||||
id: 'typoutput', label: gettext('Output function'),
|
||||
mode: ['properties', 'create', 'edit'],
|
||||
group: gettext('Required'),
|
||||
type: (state) => {
|
||||
return {
|
||||
type: 'select',
|
||||
options: obj.fieldOptions.externalFunctionsList,
|
||||
optionsLoaded: (options) => { obj.fieldOptions.externalFunctionsList = options; },
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
placeholder: '',
|
||||
width: '100%',
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
res = obj.external_func_combo(options);
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
};
|
||||
return obj.getFunctionType(state);
|
||||
},
|
||||
readonly: function (state) {
|
||||
return !obj.isNew(state);
|
||||
@@ -586,13 +540,7 @@ class ExternalSchema extends BaseUISchema {
|
||||
placeholder: '',
|
||||
width: '100%',
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
res = obj.external_func_combo(options);
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
return obj.filterFunctionOptions(state, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -705,25 +653,7 @@ class ExternalSchema extends BaseUISchema {
|
||||
id: 'typanalyze', label: gettext('Analyze function'),
|
||||
group: gettext('Optional-1'),
|
||||
type: (state) => {
|
||||
return {
|
||||
type: 'select',
|
||||
options: obj.fieldOptions.externalFunctionsList,
|
||||
optionsLoaded: (options) => { obj.fieldOptions.externalFunctionsList = options; },
|
||||
controlProps: {
|
||||
allowClear: true,
|
||||
placeholder: '',
|
||||
width: '100%',
|
||||
filter: (options) => {
|
||||
let res = [];
|
||||
if (state && obj.isNew(state)) {
|
||||
res = obj.external_func_combo(options);
|
||||
} else {
|
||||
res = options;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
};
|
||||
return obj.getFunctionType(state);
|
||||
},
|
||||
mode: ['properties', 'create','edit'],
|
||||
disabled: () => obj.inCatalog(),
|
||||
@@ -908,6 +838,14 @@ class CompositeSchema extends BaseUISchema {
|
||||
return 'oid';
|
||||
}
|
||||
|
||||
onTypeChange(state, changeSource) {
|
||||
if(_.isArray(changeSource) && changeSource[2] == 'type') {
|
||||
return {...state
|
||||
, value: null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
var obj = this;
|
||||
return [{
|
||||
@@ -970,11 +908,7 @@ class CompositeSchema extends BaseUISchema {
|
||||
id: 'precision', label: gettext('Scale'), deps: ['type'],
|
||||
type: 'text', disabled: false, cell: 'int',
|
||||
depChange: (state, changeSource)=>{
|
||||
if(_.isArray(changeSource) && changeSource[2] == 'type') {
|
||||
return {...state
|
||||
, value: null
|
||||
};
|
||||
}
|
||||
return obj.onTypeChange(state, changeSource);
|
||||
},
|
||||
editable: (state) => {
|
||||
// We will store type from selected from combobox
|
||||
@@ -1003,11 +937,7 @@ class CompositeSchema extends BaseUISchema {
|
||||
}, {
|
||||
id: 'collation', label: gettext('Collation'), type: 'text',
|
||||
depChange: (state, changeSource)=>{
|
||||
if(_.isArray(changeSource) && changeSource[2] == 'type') {
|
||||
return {...state
|
||||
, value: null
|
||||
};
|
||||
}
|
||||
return obj.onTypeChange(state, changeSource);
|
||||
},
|
||||
cell: ()=>({
|
||||
cell: 'select', options: obj.fieldOptions.collations,
|
||||
@@ -1138,9 +1068,7 @@ class DataTypeSchema extends BaseUISchema {
|
||||
readonly: function (state) {
|
||||
return !dataTypeObj.isNew(state);
|
||||
},
|
||||
visible: function (state) {
|
||||
return state.typtype === 'V';
|
||||
}
|
||||
visible: (state) => isVisible(state, 'V'),
|
||||
},{
|
||||
// Note: There are ambiguities in the PG catalogs and docs between
|
||||
// precision and scale. In the UI, we try to follow the docs as
|
||||
@@ -1155,9 +1083,7 @@ class DataTypeSchema extends BaseUISchema {
|
||||
readonly: function (state) {
|
||||
return !dataTypeObj.isNew(state);
|
||||
},
|
||||
visible: function (state) {
|
||||
return state.typtype === 'N';
|
||||
},
|
||||
visible: (state) => isVisible(state, 'N'),
|
||||
disabled: function(state) {
|
||||
|
||||
var of_type = state.type,
|
||||
@@ -1217,9 +1143,7 @@ class DataTypeSchema extends BaseUISchema {
|
||||
return !dataTypeObj.isNew(state);
|
||||
},
|
||||
cell: 'int',
|
||||
visible: function (state) {
|
||||
return state.typtype === 'N';
|
||||
},
|
||||
visible: (state) => isVisible(state, 'N'),
|
||||
disabled: function(state) {
|
||||
var of_type = state.type,
|
||||
flag = true;
|
||||
@@ -1416,9 +1340,7 @@ export default class TypeSchema extends BaseUISchema {
|
||||
state.composite.splice(0, state.composite.length);
|
||||
}
|
||||
},
|
||||
visible: (state) => {
|
||||
return state.typtype === 'c';
|
||||
},
|
||||
visible: (state) => isVisible(state, 'c'),
|
||||
},
|
||||
{
|
||||
id: 'enum', label: gettext('Enumeration type'),
|
||||
@@ -1437,9 +1359,7 @@ export default class TypeSchema extends BaseUISchema {
|
||||
disabled: () => obj.inCatalog(),
|
||||
deps: ['typtype'],
|
||||
uniqueCol : ['label'],
|
||||
visible: function(state) {
|
||||
return state.typtype === 'e';
|
||||
},
|
||||
visible: (state) => isVisible(state, 'e'),
|
||||
}, {
|
||||
type: 'nested-fieldset',
|
||||
group: gettext('Definition'),
|
||||
@@ -1456,9 +1376,7 @@ export default class TypeSchema extends BaseUISchema {
|
||||
group: gettext('Definition'),
|
||||
label: '',
|
||||
mode: ['edit', 'create'],
|
||||
visible: (state) => {
|
||||
return state.typtype && state.typtype === 'r';
|
||||
},
|
||||
visible: (state) => isVisible(state, 'r'),
|
||||
deps: ['typtype'],
|
||||
schema: obj.getRangeSchema(),
|
||||
}, {
|
||||
@@ -1466,9 +1384,7 @@ export default class TypeSchema extends BaseUISchema {
|
||||
group: gettext('Definition'),
|
||||
label: gettext('External Type'), deps: ['typtype'],
|
||||
mode: ['create', 'edit'], tabPanelExtraClasses:'inline-tab-panel-padded',
|
||||
visible: function(state) {
|
||||
return state.typtype === 'b';
|
||||
},
|
||||
visible: (state) => isVisible(state, 'b'),
|
||||
schema: obj.getExternalSchema(),
|
||||
},
|
||||
{
|
||||
@@ -1480,99 +1396,54 @@ export default class TypeSchema extends BaseUISchema {
|
||||
id: 'member_list', label: gettext('Members'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'c') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
visible: (state) => isVisible(state, 'c'),
|
||||
},{
|
||||
id: 'enum_list', label: gettext('Labels'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'e') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
visible: (state) => isVisible(state, 'e'),
|
||||
},
|
||||
{
|
||||
id: 'typname', label: gettext('SubType'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'r') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
visible: (state) => isVisible(state, 'r'),
|
||||
},
|
||||
{
|
||||
id: 'opcname', label: gettext('Subtype operator class'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'r') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
visible: (state) => isVisible(state, 'r'),
|
||||
},
|
||||
{
|
||||
id: 'collname', label: gettext('Collation'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'r') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
visible: (state) => isVisible(state, 'r'),
|
||||
},
|
||||
{
|
||||
id: 'rngcanonical', label: gettext('Canonical function'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'r') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
visible: (state) => isVisible(state, 'r'),
|
||||
},
|
||||
{
|
||||
id: 'rngsubdiff', label: gettext('Subtype diff function'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'r') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
visible: (state) => isVisible(state, 'r'),
|
||||
},
|
||||
{
|
||||
id: 'typinput', label: gettext('Input function'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'b') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
visible: (state) => isVisible(state, 'b'),
|
||||
},
|
||||
{
|
||||
id: 'typoutput', label: gettext('Output function'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'b') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
visible: (state) => isVisible(state, 'b'),
|
||||
},
|
||||
{
|
||||
id: 'type', label: gettext('Data Type'), cell: 'string',
|
||||
@@ -1589,34 +1460,19 @@ export default class TypeSchema extends BaseUISchema {
|
||||
id: 'tlength', label: gettext('Length/Precision'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'N') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
visible: (state) => isVisible(state, 'N'),
|
||||
},
|
||||
{
|
||||
id: 'precision', label: gettext('Scale'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'N') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
visible: (state) => isVisible(state, 'N'),
|
||||
},
|
||||
{
|
||||
id: 'maxsize', label: gettext('Size'), cell: 'string',
|
||||
type: 'text', mode: ['properties'], group: gettext('Definition'),
|
||||
disabled: () => obj.inCatalog(),
|
||||
visible: function(state) {
|
||||
if(state.typtype === 'V') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
visible: (state) => isVisible(state, 'V'),
|
||||
},
|
||||
{
|
||||
id: 'type_acl', label: gettext('Privileges'), cell: 'string',
|
||||
|
||||
@@ -313,6 +313,10 @@ define('pgadmin.node.database', [
|
||||
},
|
||||
},
|
||||
getSchema: function(treeNodeInfo, itemNodeData) {
|
||||
let c_types = ()=>getNodeAjaxOptions('get_ctypes', this, treeNodeInfo, itemNodeData, {
|
||||
cacheLevel: 'server',
|
||||
});
|
||||
|
||||
return new DatabaseSchema(
|
||||
()=>getNodeVariableSchema(this, treeNodeInfo, itemNodeData, false, true),
|
||||
(privileges)=>getNodePrivilegeRoleSchema(this, treeNodeInfo, itemNodeData, privileges),
|
||||
@@ -339,14 +343,8 @@ define('pgadmin.node.database', [
|
||||
()=>getNodeListByName('tablespace', treeNodeInfo, itemNodeData, {}, (m)=>{
|
||||
return (m.label != 'pg_global');
|
||||
}),
|
||||
datcollate:
|
||||
()=>getNodeAjaxOptions('get_ctypes', this, treeNodeInfo, itemNodeData, {
|
||||
cacheLevel: 'server',
|
||||
}),
|
||||
datctype:
|
||||
()=>getNodeAjaxOptions('get_ctypes', this, treeNodeInfo, itemNodeData, {
|
||||
cacheLevel: 'server',
|
||||
}),
|
||||
datcollate: c_types,
|
||||
datctype: c_types,
|
||||
},
|
||||
{
|
||||
datowner: pgBrowser.serverInfo[treeNodeInfo.server._id].user.name,
|
||||
|
||||
@@ -584,6 +584,20 @@ define('pgadmin.node.server', [
|
||||
return false;
|
||||
},
|
||||
|
||||
on_done: function(res, t, i) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.itemData(i).wal_pause=res.data.wal_pause;
|
||||
t.unload(i);
|
||||
t.setInode(i);
|
||||
t.deselect(i);
|
||||
// Fetch updated data from server
|
||||
setTimeout(function() {
|
||||
t.select(i);
|
||||
}, 10);
|
||||
}
|
||||
},
|
||||
|
||||
/* Pause WAL Replay */
|
||||
pause_wal_replay: function(args) {
|
||||
var input = args || {},
|
||||
@@ -601,17 +615,7 @@ define('pgadmin.node.server', [
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.itemData(i).wal_pause=res.data.wal_pause;
|
||||
t.unload(i);
|
||||
t.setInode(i);
|
||||
t.deselect(i);
|
||||
// Fetch updated data from server
|
||||
setTimeout(function() {
|
||||
t.select(i);
|
||||
}, 10);
|
||||
}
|
||||
obj.on_done(res, t, i);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
@@ -636,17 +640,7 @@ define('pgadmin.node.server', [
|
||||
dataType: 'json',
|
||||
})
|
||||
.done(function(res) {
|
||||
if (res.success == 1) {
|
||||
Notify.success(res.info);
|
||||
t.itemData(i).wal_pause=res.data.wal_pause;
|
||||
t.unload(i);
|
||||
t.setInode(i);
|
||||
t.deselect(i);
|
||||
// Fetch updated data from server
|
||||
setTimeout(function() {
|
||||
t.select(i);
|
||||
}, 10);
|
||||
}
|
||||
obj.on_done(res, t, i);
|
||||
})
|
||||
.fail(function(xhr, status, error) {
|
||||
Notify.pgRespErrorNotify(xhr, error);
|
||||
|
||||
Reference in New Issue
Block a user