mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 04:00:59 +00:00
mdoel transform
This commit is contained in:
parent
1f9f997748
commit
4927c13e55
@ -9,9 +9,9 @@ module.exports = ({ editMenu }) => [
|
||||
{ command: 'new.queryDesign', hideDisabled: true },
|
||||
{ command: 'new.diagram', hideDisabled: true },
|
||||
{ command: 'new.perspective', hideDisabled: true },
|
||||
{ command: 'new.freetable', hideDisabled: true },
|
||||
{ command: 'new.shell', hideDisabled: true },
|
||||
{ command: 'new.jsonl', hideDisabled: true },
|
||||
{ command: 'new.modelTransform', hideDisabled: true },
|
||||
{ divider: true },
|
||||
{ command: 'file.open', hideDisabled: true },
|
||||
{ command: 'file.openArchive', hideDisabled: true },
|
||||
|
@ -81,6 +81,14 @@
|
||||
currentConnection: true,
|
||||
};
|
||||
|
||||
const modtrans: FileTypeHandler = {
|
||||
icon: 'img transform',
|
||||
format: 'text',
|
||||
tabComponent: 'ModelTransformTab',
|
||||
folder: 'modtrans',
|
||||
currentConnection: false,
|
||||
};
|
||||
|
||||
export const SAVED_FILE_HANDLERS = {
|
||||
sql,
|
||||
shell,
|
||||
@ -91,6 +99,7 @@
|
||||
diagrams,
|
||||
perspectives,
|
||||
jobs,
|
||||
modtrans,
|
||||
};
|
||||
|
||||
export const extractKey = data => data.file;
|
||||
|
@ -185,6 +185,50 @@ registerCommand({
|
||||
findEngineDriver(getCurrentDatabase()?.connection, getExtensions())?.databaseEngineTypes?.includes('sql'),
|
||||
});
|
||||
|
||||
if (isProApp()) {
|
||||
registerCommand({
|
||||
id: 'new.modelTransform',
|
||||
category: 'New',
|
||||
icon: 'img transform',
|
||||
name: 'Model transform',
|
||||
menuName: 'New model transform',
|
||||
onClick: () => {
|
||||
openNewTab(
|
||||
{
|
||||
title: 'Model transform #',
|
||||
icon: 'img transform',
|
||||
tabComponent: 'ModelTransformTab',
|
||||
},
|
||||
{
|
||||
editor: JSON.stringify(
|
||||
[
|
||||
{
|
||||
transform: 'dataTypeMapperTransform',
|
||||
arguments: ['json', 'nvarchar(max)'],
|
||||
},
|
||||
{
|
||||
transform: 'sqlTextReplacementTransform',
|
||||
arguments: [
|
||||
{
|
||||
oldval1: 'newval1',
|
||||
oldval2: 'newval2',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
transform: 'autoIndexForeignKeysTransform',
|
||||
arguments: [],
|
||||
},
|
||||
],
|
||||
null,
|
||||
2
|
||||
),
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
registerCommand({
|
||||
id: 'new.perspective',
|
||||
category: 'New',
|
||||
|
@ -283,6 +283,7 @@
|
||||
'img duplicator': 'mdi mdi-content-duplicate color-icon-green',
|
||||
'img import': 'mdi mdi-database-import color-icon-green',
|
||||
'img export': 'mdi mdi-database-export color-icon-green',
|
||||
'img transform': 'mdi mdi-rotate-orbit color-icon-blue',
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
const diagramFiles = useFiles({ folder: 'diagrams' });
|
||||
const jobFiles = useFiles({ folder: 'jobs' });
|
||||
const perspectiveFiles = useFiles({ folder: 'perspectives' });
|
||||
const modelTransformFiles = useFiles({ folder: 'modtrans' });
|
||||
|
||||
$: files = [
|
||||
...($sqlFiles || []),
|
||||
@ -33,13 +34,30 @@
|
||||
...($diagramFiles || []),
|
||||
...($perspectiveFiles || []),
|
||||
...($jobFiles || []),
|
||||
...($modelTransformFiles || []),
|
||||
];
|
||||
|
||||
function handleRefreshFiles() {
|
||||
apiCall('files/refresh', {
|
||||
folders: ['sql', 'shell', 'markdown', 'charts', 'query', 'sqlite', 'diagrams', 'perspectives', 'jobs'],
|
||||
folders: [
|
||||
'sql',
|
||||
'shell',
|
||||
'markdown',
|
||||
'charts',
|
||||
'query',
|
||||
'sqlite',
|
||||
'diagrams',
|
||||
'perspectives',
|
||||
'jobs',
|
||||
'modtrans',
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
function dataFolderTitle(folder) {
|
||||
if (folder == 'modtrans') return 'Model transforms';
|
||||
return _.startCase(folder);
|
||||
}
|
||||
</script>
|
||||
|
||||
<WidgetsInnerContainer>
|
||||
@ -51,5 +69,5 @@
|
||||
</InlineButton>
|
||||
</SearchBoxWrapper>
|
||||
|
||||
<AppObjectList list={files} module={savedFileAppObject} groupFunc={data => _.startCase(data.folder)} {filter} />
|
||||
<AppObjectList list={files} module={savedFileAppObject} groupFunc={data => dataFolderTitle(data.folder)} {filter} />
|
||||
</WidgetsInnerContainer>
|
||||
|
Loading…
Reference in New Issue
Block a user