mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
- Add VaccumSettings schema. - Allow collection to have fixed rows. - Changes in data change comparison and add state utils context. - Fixed jasmine test cases.
This commit is contained in:
committed by
Akshay Joshi
parent
eb48765a5a
commit
377fe80046
179
web/pgadmin/browser/server_groups/servers/static/js/vacuum.ui.js
Normal file
179
web/pgadmin/browser/server_groups/servers/static/js/vacuum.ui.js
Normal file
@@ -0,0 +1,179 @@
|
||||
import gettext from 'sources/gettext';
|
||||
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
|
||||
import { getNodeAjaxOptions } from '../../../../static/js/node_ajax';
|
||||
|
||||
export function getNodeVacuumSettingsSchema(nodeObj, treeNodeInfo, itemNodeData) {
|
||||
let tableVacuumRows = ()=>getNodeAjaxOptions('get_table_vacuum', nodeObj, treeNodeInfo, itemNodeData, {noCache: true});
|
||||
let toastTableVacuumRows = ()=>getNodeAjaxOptions('get_toast_table_vacuum', nodeObj, treeNodeInfo, itemNodeData, {noCache: true});
|
||||
return new VacuumSettingsSchema(tableVacuumRows, toastTableVacuumRows, treeNodeInfo);
|
||||
}
|
||||
export class VacuumTableSchema extends BaseUISchema {
|
||||
constructor(valueDep) {
|
||||
super();
|
||||
this.valueDep = valueDep;
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
let obj = this;
|
||||
|
||||
return [
|
||||
{
|
||||
id: 'label', name: 'label', label: gettext('Label'),
|
||||
},
|
||||
{
|
||||
id: 'value', name: 'value', label: gettext('Value'),
|
||||
type: 'text', deps: [[this.valueDep]],
|
||||
editable: function() {
|
||||
return obj.top.sessData[this.valueDep];
|
||||
},
|
||||
cell: (state)=>{
|
||||
switch(state.column_type) {
|
||||
case 'integer':
|
||||
return {cell: 'int'};
|
||||
case 'number':
|
||||
return {cell: 'numeric', controlProps: {decimals: 5}};
|
||||
case 'string':
|
||||
return {cell: 'text'};
|
||||
default:
|
||||
return {cell: ''};
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'setting', name: 'setting', label: gettext('Default'),
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
export default class VacuumSettingsSchema extends BaseUISchema {
|
||||
constructor(tableVars, toastTableVars, nodeInfo) {
|
||||
super({
|
||||
vacuum_table: [],
|
||||
vacuum_toast: [],
|
||||
});
|
||||
this.tableVars = tableVars;
|
||||
this.toastTableVars = toastTableVars;
|
||||
this.nodeInfo = nodeInfo;
|
||||
|
||||
this.vacuumTableObj = new VacuumTableSchema('autovacuum_custom');
|
||||
this.vacuumToastTableObj = new VacuumTableSchema('toast_autovacuum');
|
||||
}
|
||||
|
||||
inSchemaCheck() {
|
||||
if(this.nodeInfo && 'catalog' in this.nodeInfo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
var obj = this;
|
||||
return [{
|
||||
id: 'autovacuum_custom', label: gettext('Custom auto-vacuum?'),
|
||||
group: gettext('Table'), mode: ['edit', 'create'],
|
||||
type: 'switch', disabled: function(state) {
|
||||
if(state.is_partitioned) {
|
||||
return true;
|
||||
}
|
||||
// If table is partitioned table then disabled it.
|
||||
if(state.top && state.is_partitioned) {
|
||||
// We also need to unset rest of all
|
||||
state.autovacuum_custom = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(obj.inSchemaCheck)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
depChange(state) {
|
||||
if(state.is_partitioned) {
|
||||
return {autovacuum_custom: false};
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'autovacuum_enabled', label: gettext('Autovacuum Enabled?'),
|
||||
group: gettext('Table'), mode: ['edit', 'create'], type: 'toggle',
|
||||
options: [
|
||||
{'label': gettext('Not set'), 'value': 'x'},
|
||||
{'label': gettext('Yes'), 'value': 't'},
|
||||
{'label': gettext('No'), 'value': 'f'},
|
||||
],
|
||||
deps: ['autovacuum_custom'],
|
||||
disabled: function(state) {
|
||||
if(obj.inSchemaCheck && state.autovacuum_custom) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
depChange: function(state) {
|
||||
if(obj.inSchemaCheck && state.autovacuum_custom) {
|
||||
return;
|
||||
}
|
||||
return {autovacuum_enabled: 'x'};
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'vacuum_table', label: '', editable: false, type: 'collection',
|
||||
canEdit: false, canAdd: false, canDelete: false, group: gettext('Table'),
|
||||
fixedRows: this.tableVars,
|
||||
schema: this.vacuumTableObj,
|
||||
mode: ['edit', 'create'],
|
||||
},
|
||||
{
|
||||
id: 'toast_autovacuum', label: gettext('Custom auto-vacuum?'),
|
||||
group: gettext('TOAST table'), mode: ['edit', 'create'],
|
||||
type: 'switch',
|
||||
disabled: function(state) {
|
||||
// We need to check additional condition to toggle enable/disable
|
||||
// for table auto-vacuum
|
||||
if(obj.inSchemaCheck && (obj.isNew() || (state.toast_autovacuum_enabled || state.hastoasttable))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'toast_autovacuum_enabled', label: gettext('Autovacuum Enabled?'),
|
||||
group: gettext('TOAST table'), mode: ['edit', 'create'],
|
||||
type: 'toggle',
|
||||
options: [
|
||||
{'label': gettext('Not set'), 'value': 'x'},
|
||||
{'label': gettext('Yes'), 'value': 't'},
|
||||
{'label': gettext('No'), 'value': 'f'},
|
||||
],
|
||||
deps:['toast_autovacuum'],
|
||||
disabled: function(state) {
|
||||
if(obj.inSchemaCheck && state.toast_autovacuum) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
depChange: function(state) {
|
||||
if(obj.inSchemaCheck && state.toast_autovacuum) {
|
||||
return;
|
||||
}
|
||||
if(obj.isNew() || state.hastoasttable) {
|
||||
return {toast_autovacuum_enabled: 'x'};
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'vacuum_toast', label: '',
|
||||
type: 'collection',
|
||||
fixedRows: this.toastTableVars,
|
||||
editable: function(state) {
|
||||
return state.isNew();
|
||||
},
|
||||
canEdit: false, canAdd: false, canDelete: false, group: gettext('TOAST table'),
|
||||
schema: this.vacuumToastTableObj,
|
||||
mode: ['properties', 'edit', 'create'], deps: ['toast_autovacuum'],
|
||||
}];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user