mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 09:44:00 +00:00
apps improvements
This commit is contained in:
@@ -265,4 +265,16 @@ module.exports = {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
createConfigFile_meta: true,
|
||||||
|
async createConfigFile({ appFolder, fileName, content }) {
|
||||||
|
const file = path.join(appdir(), appFolder, fileName);
|
||||||
|
if (!(await fs.exists(file))) {
|
||||||
|
await fs.writeFile(file, JSON.stringify(content, undefined, 2));
|
||||||
|
socket.emitChanged(`app-files-changed-${appFolder}`);
|
||||||
|
socket.emitChanged('used-apps-changed');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ module.exports = {
|
|||||||
const app = folder.substring('app:'.length);
|
const app = folder.substring('app:'.length);
|
||||||
await fs.writeFile(path.join(appdir(), app, file), serialize(format, data));
|
await fs.writeFile(path.join(appdir(), app, file), serialize(format, data));
|
||||||
socket.emitChanged(`app-files-changed-${app}`);
|
socket.emitChanged(`app-files-changed-${app}`);
|
||||||
|
socket.emitChanged('used-apps-changed');
|
||||||
apps.emitChangedDbApp(folder);
|
apps.emitChangedDbApp(folder);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
import useEditorData from '../query/useEditorData';
|
import useEditorData from '../query/useEditorData';
|
||||||
import invalidateCommands from '../commands/invalidateCommands';
|
import invalidateCommands from '../commands/invalidateCommands';
|
||||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||||
|
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||||
|
import ToolStripSaveButton from '../buttons/ToolStripSaveButton.svelte';
|
||||||
|
|
||||||
export let tabid;
|
export let tabid;
|
||||||
|
|
||||||
@@ -70,14 +72,20 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<AceEditor
|
<ToolStripContainer>
|
||||||
value={$editorState.value || ''}
|
<AceEditor
|
||||||
menu={createMenu()}
|
value={$editorState.value || ''}
|
||||||
on:input={e => setEditorData(e.detail)}
|
menu={createMenu()}
|
||||||
on:focus={() => {
|
on:input={e => setEditorData(e.detail)}
|
||||||
activator.activate();
|
on:focus={() => {
|
||||||
invalidateCommands();
|
activator.activate();
|
||||||
}}
|
invalidateCommands();
|
||||||
bind:this={domEditor}
|
}}
|
||||||
mode="json"
|
bind:this={domEditor}
|
||||||
/>
|
mode="json"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<svelte:fragment slot="toolstrip">
|
||||||
|
<ToolStripSaveButton idPrefix="json" />
|
||||||
|
</svelte:fragment>
|
||||||
|
</ToolStripContainer>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
import { useAppFiles, useArchiveFolders } from '../utility/metadataLoaders';
|
import { useAppFiles, useArchiveFolders } from '../utility/metadataLoaders';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
||||||
|
import { showSnackbarError } from '../utility/snackbar';
|
||||||
|
|
||||||
let filter = '';
|
let filter = '';
|
||||||
|
|
||||||
@@ -66,12 +67,27 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleNewConfigFile(fileName, content) {
|
||||||
|
if (!(await apiCall('apps/create-config-file', { fileName, content, appFolder: $currentApplication }))) {
|
||||||
|
showSnackbarError('File not created, probably already exists');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createAddMenu() {
|
function createAddMenu() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
text: 'New SQL command',
|
text: 'New SQL command',
|
||||||
onClick: () => handleNewSqlFile('command.sql', 'Create new SQL command', COMMAND_TEMPLATE),
|
onClick: () => handleNewSqlFile('command.sql', 'Create new SQL command', COMMAND_TEMPLATE),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: 'New virtual references file',
|
||||||
|
onClick: () => handleNewConfigFile('virtual-references.config.json', []),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'New disctionary descriptions file',
|
||||||
|
onClick: () => handleNewConfigFile('dictionary-descriptions.config.json', []),
|
||||||
|
},
|
||||||
|
|
||||||
// { text: 'New query view', onClick: () => handleNewSqlFile('query.sql', 'Create new SQL query', QUERY_TEMPLATE) },
|
// { text: 'New query view', onClick: () => handleNewSqlFile('query.sql', 'Create new SQL query', QUERY_TEMPLATE) },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user