export model WIP

This commit is contained in:
Jan Prochazka
2021-09-20 16:31:21 +02:00
parent 760f5c9616
commit 3e1f947922
3 changed files with 26 additions and 0 deletions

View File

@@ -95,4 +95,13 @@ module.exports = {
});
});
},
async getNewArchiveFolder({ database }) {
if (!(await fs.exists(path.join(archivedir(), database)))) return database;
let index = 2;
while (await fs.exists(path.join(archivedir(), `${database}${index}`))) {
index += 1;
}
return `${database}${index}`;
},
};

View File

@@ -1,5 +1,6 @@
const uuidv1 = require('uuid/v1');
const connections = require('./connections');
const archive = require('./archive');
const socket = require('../utility/socket');
const { fork } = require('child_process');
const { DatabaseAnalyser } = require('dbgate-tools');
@@ -238,6 +239,12 @@ module.exports = {
return res;
},
exportModel_meta: 'post',
async exportModel({ conid, database }) {
const archiveFolder = await archive.getNewArchiveFolder({ database });
return { archiveFolder };
},
// runCommand_meta: 'post',
// async runCommand({ conid, database, sql }) {
// console.log(`Running SQL command , conid=${conid}, database=${database}, sql=${sql}`);

View File

@@ -53,11 +53,20 @@
currentDatabase.set(null);
};
const handleExportModel = async () => {
const resp = await axiosInstance.post('database-connections/export-model', {
conid: connection._id,
database: name,
});
showSnackbarSuccess(`Saved to archive ${resp.data.archiveFolder}`);
};
return [
{ onClick: handleNewQuery, text: 'New query', isNewQuery: true },
{ onClick: handleImport, text: 'Import' },
{ onClick: handleExport, text: 'Export' },
{ onClick: handleSqlGenerator, text: 'SQL Generator' },
{ onClick: handleExportModel, text: 'Export DB model' },
_.get($currentDatabase, 'connection._id') == _.get(connection, '_id') &&
_.get($currentDatabase, 'name') == name && { onClick: handleDisconnect, text: 'Disconnect' },
@@ -78,6 +87,7 @@
import getElectron from '../utility/getElectron';
import openNewTab from '../utility/openNewTab';
import AppObjectCore from './AppObjectCore.svelte';
import { showSnackbarSuccess } from '../utility/snackbar';
export let data;
function createMenu() {