export model WIP

This commit is contained in:
SPRINX0\prochazka
2024-11-04 17:03:52 +01:00
parent 41162ee2c3
commit e31a52b659
3 changed files with 29 additions and 17 deletions

View File

@@ -170,14 +170,18 @@
}; };
const handleExportModel = async () => { const handleExportModel = async () => {
const resp = await apiCall('database-connections/export-model', { showModal(ExportDbModelModal, {
conid: connection._id, conid: connection._id,
database: name, database: name,
}); });
currentArchive.set(resp.archiveFolder); // const resp = await apiCall('database-connections/export-model', {
selectedWidget.set('archive'); // conid: connection._id,
visibleWidgetSideBar.set(true); // database: name,
showSnackbarSuccess(`Saved to archive ${resp.archiveFolder}`); // });
// currentArchive.set(resp.archiveFolder);
// selectedWidget.set('archive');
// visibleWidgetSideBar.set(true);
// showSnackbarSuccess(`Saved to archive ${resp.archiveFolder}`);
}; };
const handleCompareWithCurrentDb = () => { const handleCompareWithCurrentDb = () => {
@@ -198,13 +202,13 @@
); );
}; };
const handleOpenJsonModel = async () => { // const handleOpenJsonModel = async () => {
const db = await getDatabaseInfo({ // const db = await getDatabaseInfo({
conid: connection._id, // conid: connection._id,
database: name, // database: name,
}); // });
openJsonDocument(db, name); // openJsonDocument(db, name);
}; // };
const handleGenerateScript = async () => { const handleGenerateScript = async () => {
const data = await apiCall('database-connections/export-keys', { const data = await apiCall('database-connections/export-keys', {
@@ -325,11 +329,12 @@
hasPermission(`dbops/sql-generator`) && { onClick: handleSqlGenerator, text: 'SQL Generator' }, hasPermission(`dbops/sql-generator`) && { onClick: handleSqlGenerator, text: 'SQL Generator' },
driver?.supportsDatabaseProfiler && driver?.supportsDatabaseProfiler &&
hasPermission(`dbops/profiler`) && { onClick: handleDatabaseProfiler, text: 'Database profiler' }, hasPermission(`dbops/profiler`) && { onClick: handleDatabaseProfiler, text: 'Database profiler' },
// isSqlOrDoc &&
// isSqlOrDoc &&
// hasPermission(`dbops/model/view`) && { onClick: handleOpenJsonModel, text: 'Open model as JSON' },
isSqlOrDoc && isSqlOrDoc &&
isSqlOrDoc && isProApp() &&
hasPermission(`dbops/model/view`) && { onClick: handleOpenJsonModel, text: 'Open model as JSON' }, hasPermission(`dbops/model/view`) && { onClick: handleExportModel, text: 'Export DB model' },
isSqlOrDoc &&
hasPermission(`dbops/model/view`) && { onClick: handleExportModel, text: 'Export DB model - experimental' },
isSqlOrDoc && isSqlOrDoc &&
_.get($currentDatabase, 'connection._id') && _.get($currentDatabase, 'connection._id') &&
hasPermission('dbops/model/compare') && hasPermission('dbops/model/compare') &&
@@ -408,6 +413,7 @@
import newTable from '../tableeditor/newTable'; import newTable from '../tableeditor/newTable';
import { loadSchemaList, switchCurrentDatabase } from '../utility/common'; import { loadSchemaList, switchCurrentDatabase } from '../utility/common';
import { isProApp } from '../utility/proTools'; import { isProApp } from '../utility/proTools';
import ExportDbModelModal from '../modals/ExportDbModelModal.svelte';
export let data; export let data;
export let passProps; export let passProps;

View File

@@ -9,6 +9,7 @@
export let name; export let name;
export let disabled = false; export let disabled = false;
export let defaultFileName = ''; export let defaultFileName = '';
export let dialogProperties = ['showHiddenFiles', 'openFile'];
const { values, setFieldValue } = getFormContext(); const { values, setFieldValue } = getFormContext();
@@ -17,7 +18,7 @@
if (!electron) return; if (!electron) return;
const filePaths = await electron.showOpenDialog({ const filePaths = await electron.showOpenDialog({
defaultPath: values[name], defaultPath: values[name],
properties: ['showHiddenFiles', 'openFile'], properties: dialogProperties,
filters: [{ name: 'All Files', extensions: ['*'] }], filters: [{ name: 'All Files', extensions: ['*'] }],
}); });
const filePath = filePaths && filePaths[0]; const filePath = filePaths && filePaths[0];

View File

@@ -0,0 +1,5 @@
<script lang="ts">
import ModalBase from './ModalBase.svelte';
</script>
<ModalBase {...$$restProps}></ModalBase>