mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
better archive tools
This commit is contained in:
parent
240af66809
commit
f1190400a5
@ -79,17 +79,26 @@ module.exports = {
|
||||
},
|
||||
|
||||
deleteFile_meta: 'post',
|
||||
async deleteFile({ folder, file }) {
|
||||
await fs.unlink(path.join(resolveArchiveFolder(folder), `${file}.jsonl`));
|
||||
async deleteFile({ folder, file, fileType }) {
|
||||
await fs.unlink(path.join(resolveArchiveFolder(folder), `${file}.${fileType}`));
|
||||
socket.emitChanged(`archive-files-changed-${folder}`);
|
||||
},
|
||||
|
||||
renameFile_meta: 'post',
|
||||
async renameFile({ folder, file, newFile }) {
|
||||
await fs.rename(path.join(resolveArchiveFolder(folder), `${file}.jsonl`), path.join(resolveArchiveFolder(folder), `${newFile}.jsonl`));
|
||||
async renameFile({ folder, file, newFile, fileType }) {
|
||||
await fs.rename(
|
||||
path.join(resolveArchiveFolder(folder), `${file}.${fileType}`),
|
||||
path.join(resolveArchiveFolder(folder), `${newFile}.${fileType}`)
|
||||
);
|
||||
socket.emitChanged(`archive-files-changed-${folder}`);
|
||||
},
|
||||
|
||||
renameFolder_meta: 'post',
|
||||
async renameFolder({ folder, newFolder }) {
|
||||
await fs.rename(path.join(resolveArchiveFolder(folder)), path.join(resolveArchiveFolder(newFolder)));
|
||||
socket.emitChanged(`archive-folders-changed`);
|
||||
},
|
||||
|
||||
deleteFolder_meta: 'post',
|
||||
async deleteFolder({ folder }) {
|
||||
if (!folder) throw new Error('Missing folder parameter');
|
||||
|
@ -68,22 +68,37 @@
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
||||
|
||||
export let data;
|
||||
|
||||
const handleRename = () => {
|
||||
showModal(InputTextModal, {
|
||||
value: data.file,
|
||||
value: data.fileName,
|
||||
label: 'New file name',
|
||||
header: 'Rename file',
|
||||
onConfirm: newFile => {
|
||||
axiosInstance.post('archive/rename-file', { file: data.fileName, folder: data.folderName, newFile });
|
||||
axiosInstance.post('archive/rename-file', {
|
||||
file: data.fileName,
|
||||
folder: data.folderName,
|
||||
fileType: data.fileType,
|
||||
newFile,
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleDelete = () => {
|
||||
axiosInstance.post('archive/delete-file', { file: data.fileName, folder: data.folderName });
|
||||
showModal(ConfirmModal, {
|
||||
message: `Really delete file ${data.fileName}?`,
|
||||
onConfirm: () => {
|
||||
axiosInstance.post('archive/delete-file', {
|
||||
file: data.fileName,
|
||||
folder: data.folderName,
|
||||
fileType: data.fileType,
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
const handleOpenRead = () => {
|
||||
openArchive(data.fileName, data.folderName);
|
||||
|
@ -13,11 +13,36 @@
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import newQuery from '../query/newQuery';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||
|
||||
export let data;
|
||||
|
||||
const handleDelete = () => {
|
||||
axiosInstance.post('archive/delete-folder', { folder: data.name });
|
||||
showModal(ConfirmModal, {
|
||||
message: `Really delete folder ${data.name}?`,
|
||||
onConfirm: () => {
|
||||
axiosInstance.post('archive/delete-folder', { folder: data.name });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleRename = () => {
|
||||
showModal(InputTextModal, {
|
||||
value: data.name,
|
||||
label: 'New folder name',
|
||||
header: 'Rename folder',
|
||||
onConfirm: async newFolder => {
|
||||
await axiosInstance.post('archive/rename-folder', {
|
||||
folder: data.name,
|
||||
newFolder,
|
||||
});
|
||||
if ($currentArchive == data.name) {
|
||||
$currentArchive = newFolder;
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleGenerateDeployScript = () => {
|
||||
@ -58,6 +83,7 @@ await dbgateApi.deployDb(${JSON.stringify(
|
||||
function createMenu() {
|
||||
return [
|
||||
data.name != 'default' && { text: 'Delete', onClick: handleDelete },
|
||||
data.name != 'default' && { text: 'Rename', onClick: handleRename },
|
||||
data.name != 'default' &&
|
||||
$currentDatabase && [
|
||||
{ text: 'Generate deploy DB SQL', onClick: handleGenerateDeploySql },
|
||||
|
@ -58,6 +58,8 @@
|
||||
conid: connection._id,
|
||||
database: name,
|
||||
});
|
||||
currentArchive.set(resp.data.archiveFolder);
|
||||
selectedWidget.set('archive');
|
||||
showSnackbarSuccess(`Saved to archive ${resp.data.archiveFolder}`);
|
||||
};
|
||||
|
||||
@ -107,7 +109,7 @@
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import SqlGeneratorModal from '../modals/SqlGeneratorModal.svelte';
|
||||
import { getDefaultFileFormat } from '../plugins/fileformats';
|
||||
import { currentDatabase, extensions } from '../stores';
|
||||
import { currentArchive, currentDatabase, extensions, selectedWidget } from '../stores';
|
||||
import axiosInstance from '../utility/axiosInstance';
|
||||
import getElectron from '../utility/getElectron';
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
|
Loading…
Reference in New Issue
Block a user