mdoel transform

This commit is contained in:
SPRINX0\prochazka 2024-11-01 15:58:52 +01:00
parent 1f9f997748
commit 4927c13e55
5 changed files with 75 additions and 3 deletions

View File

@ -9,9 +9,9 @@ module.exports = ({ editMenu }) => [
{ command: 'new.queryDesign', hideDisabled: true }, { command: 'new.queryDesign', hideDisabled: true },
{ command: 'new.diagram', hideDisabled: true }, { command: 'new.diagram', hideDisabled: true },
{ command: 'new.perspective', hideDisabled: true }, { command: 'new.perspective', hideDisabled: true },
{ command: 'new.freetable', hideDisabled: true },
{ command: 'new.shell', hideDisabled: true }, { command: 'new.shell', hideDisabled: true },
{ command: 'new.jsonl', hideDisabled: true }, { command: 'new.jsonl', hideDisabled: true },
{ command: 'new.modelTransform', hideDisabled: true },
{ divider: true }, { divider: true },
{ command: 'file.open', hideDisabled: true }, { command: 'file.open', hideDisabled: true },
{ command: 'file.openArchive', hideDisabled: true }, { command: 'file.openArchive', hideDisabled: true },

View File

@ -81,6 +81,14 @@
currentConnection: true, currentConnection: true,
}; };
const modtrans: FileTypeHandler = {
icon: 'img transform',
format: 'text',
tabComponent: 'ModelTransformTab',
folder: 'modtrans',
currentConnection: false,
};
export const SAVED_FILE_HANDLERS = { export const SAVED_FILE_HANDLERS = {
sql, sql,
shell, shell,
@ -91,6 +99,7 @@
diagrams, diagrams,
perspectives, perspectives,
jobs, jobs,
modtrans,
}; };
export const extractKey = data => data.file; export const extractKey = data => data.file;

View File

@ -185,6 +185,50 @@ registerCommand({
findEngineDriver(getCurrentDatabase()?.connection, getExtensions())?.databaseEngineTypes?.includes('sql'), 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({ registerCommand({
id: 'new.perspective', id: 'new.perspective',
category: 'New', category: 'New',

View File

@ -283,6 +283,7 @@
'img duplicator': 'mdi mdi-content-duplicate color-icon-green', 'img duplicator': 'mdi mdi-content-duplicate color-icon-green',
'img import': 'mdi mdi-database-import color-icon-green', 'img import': 'mdi mdi-database-import color-icon-green',
'img export': 'mdi mdi-database-export color-icon-green', 'img export': 'mdi mdi-database-export color-icon-green',
'img transform': 'mdi mdi-rotate-orbit color-icon-blue',
}; };
</script> </script>

View File

@ -22,6 +22,7 @@
const diagramFiles = useFiles({ folder: 'diagrams' }); const diagramFiles = useFiles({ folder: 'diagrams' });
const jobFiles = useFiles({ folder: 'jobs' }); const jobFiles = useFiles({ folder: 'jobs' });
const perspectiveFiles = useFiles({ folder: 'perspectives' }); const perspectiveFiles = useFiles({ folder: 'perspectives' });
const modelTransformFiles = useFiles({ folder: 'modtrans' });
$: files = [ $: files = [
...($sqlFiles || []), ...($sqlFiles || []),
@ -33,13 +34,30 @@
...($diagramFiles || []), ...($diagramFiles || []),
...($perspectiveFiles || []), ...($perspectiveFiles || []),
...($jobFiles || []), ...($jobFiles || []),
...($modelTransformFiles || []),
]; ];
function handleRefreshFiles() { function handleRefreshFiles() {
apiCall('files/refresh', { 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> </script>
<WidgetsInnerContainer> <WidgetsInnerContainer>
@ -51,5 +69,5 @@
</InlineButton> </InlineButton>
</SearchBoxWrapper> </SearchBoxWrapper>
<AppObjectList list={files} module={savedFileAppObject} groupFunc={data => _.startCase(data.folder)} {filter} /> <AppObjectList list={files} module={savedFileAppObject} groupFunc={data => dataFolderTitle(data.folder)} {filter} />
</WidgetsInnerContainer> </WidgetsInnerContainer>