mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 06:26:00 +00:00
SYNC: Merge branch 'feature/backup-restore'
This commit is contained in:
@@ -182,26 +182,6 @@ export async function exportQuickExportFile(dataName, reader, format: QuickExpor
|
||||
}
|
||||
}
|
||||
|
||||
// export async function exportSqlDump(connection, databaseName) {
|
||||
// await saveExportedFile(
|
||||
// [{ name: 'SQL files', extensions: ['sql'] }],
|
||||
// `${databaseName}.sql`,
|
||||
// 'sql',
|
||||
// `${databaseName}-dump`,
|
||||
// filePath => {
|
||||
// const script = getCurrentConfig().allowShellScripting ? new ScriptWriter() : new ScriptWriterJson();
|
||||
|
||||
// script.dumpDatabase({
|
||||
// connection,
|
||||
// databaseName,
|
||||
// outputFile: filePath,
|
||||
// });
|
||||
|
||||
// return script.getScript();
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
|
||||
export async function saveFileToDisk(
|
||||
filePathFunc,
|
||||
options: any = { formatLabel: 'HTML page', formatExtension: 'html' }
|
||||
|
||||
25
packages/web/src/utility/openWebFile.ts
Normal file
25
packages/web/src/utility/openWebFile.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import newQuery from '../query/newQuery';
|
||||
import _ from 'lodash';
|
||||
|
||||
export function canOpenByWeb(file, extensions) {
|
||||
if (!file) return false;
|
||||
const nameLower = file.toLowerCase();
|
||||
if (nameLower.endsWith('.sql')) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function openWebFileCore(file, extensions) {
|
||||
const nameLower = file.path.toLowerCase();
|
||||
|
||||
if (nameLower.endsWith('.sql')) {
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = function (e) {
|
||||
newQuery({
|
||||
initialData: e.target.result,
|
||||
});
|
||||
};
|
||||
|
||||
reader.readAsText(file);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { showModal } from '../modals/modalTools';
|
||||
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
||||
import openNewTab from './openNewTab';
|
||||
import { openImportExportTab } from './importExportTools';
|
||||
import { canOpenByWeb, openWebFileCore } from './openWebFile';
|
||||
|
||||
let uploadListener;
|
||||
|
||||
@@ -28,6 +29,11 @@ export default function uploadFiles(files) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!electron && canOpenByWeb(file.path, ext)) {
|
||||
openWebFileCore(file, ext);
|
||||
return;
|
||||
}
|
||||
|
||||
const maxSize = 32 * 1024 * 1024;
|
||||
if (parseInt(file.size, 10) >= maxSize) {
|
||||
showModal(ErrorMessageModal, {
|
||||
|
||||
Reference in New Issue
Block a user