mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
copy saved file
This commit is contained in:
parent
45501c82eb
commit
7fe5c354f1
@ -58,6 +58,14 @@ module.exports = {
|
|||||||
socket.emitChanged(`all-files-changed`);
|
socket.emitChanged(`all-files-changed`);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
copy_meta: 'post',
|
||||||
|
async copy({ folder, file, newFile }) {
|
||||||
|
if (!hasPermission(`files/${folder}/write`)) return;
|
||||||
|
await fs.copyFile(path.join(filesdir(), folder, file), path.join(filesdir(), folder, newFile));
|
||||||
|
socket.emitChanged(`files-changed-${folder}`);
|
||||||
|
socket.emitChanged(`all-files-changed`);
|
||||||
|
},
|
||||||
|
|
||||||
load_meta: 'post',
|
load_meta: 'post',
|
||||||
async load({ folder, file, format }) {
|
async load({ folder, file, format }) {
|
||||||
if (folder.startsWith('archive:')) {
|
if (folder.startsWith('archive:')) {
|
||||||
|
@ -104,6 +104,7 @@
|
|||||||
return [
|
return [
|
||||||
handler?.tabComponent && { text: 'Open', onClick: openTab },
|
handler?.tabComponent && { text: 'Open', onClick: openTab },
|
||||||
hasPermission(`files/${data.folder}/write`) && { text: 'Rename', onClick: handleRename },
|
hasPermission(`files/${data.folder}/write`) && { text: 'Rename', onClick: handleRename },
|
||||||
|
hasPermission(`files/${data.folder}/write`) && { text: 'Create copy', onClick: handleCopy },
|
||||||
hasPermission(`files/${data.folder}/write`) && { text: 'Delete', onClick: handleDelete },
|
hasPermission(`files/${data.folder}/write`) && { text: 'Delete', onClick: handleDelete },
|
||||||
folder == 'markdown' && { text: 'Show page', onClick: showMarkdownPage },
|
folder == 'markdown' && { text: 'Show page', onClick: showMarkdownPage },
|
||||||
];
|
];
|
||||||
@ -129,6 +130,17 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCopy = () => {
|
||||||
|
showModal(InputTextModal, {
|
||||||
|
value: data.file,
|
||||||
|
label: 'New file name',
|
||||||
|
header: 'Rename file',
|
||||||
|
onConfirm: newFile => {
|
||||||
|
axiosInstance.post('files/copy', { ...data, newFile });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
async function openTab() {
|
async function openTab() {
|
||||||
const resp = await axiosInstance.post('files/load', { folder, file: data.file, format: handler.format });
|
const resp = await axiosInstance.post('files/load', { folder, file: data.file, format: handler.format });
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
import { loadChartData, loadChartStructure } from './chartDataLoader';
|
import { loadChartData, loadChartStructure } from './chartDataLoader';
|
||||||
import DataChart from './DataChart.svelte';
|
import DataChart from './DataChart.svelte';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let configStore;
|
export let configStore;
|
||||||
@ -47,6 +48,7 @@
|
|||||||
const columns = await loadChartStructure(driver, conid, database, sql);
|
const columns = await loadChartStructure(driver, conid, database, sql);
|
||||||
availableColumnNames = columns;
|
availableColumnNames = columns;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
error = err.message;
|
error = err.message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -151,7 +153,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<svelte:fragment slot="2">
|
<svelte:fragment slot="2">
|
||||||
<DataChart data={data || loadedData} />
|
{#if error}
|
||||||
|
<ErrorInfo message={error} alignTop />
|
||||||
|
{:else}
|
||||||
|
<DataChart data={data || loadedData} />
|
||||||
|
{/if}
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</HorizontalSplitter>
|
</HorizontalSplitter>
|
||||||
</FormProviderCore>
|
</FormProviderCore>
|
||||||
|
Loading…
Reference in New Issue
Block a user