mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 14:56:00 +00:00
delete conn on cloud, save file to cloud WIP
This commit is contained in:
@@ -11,9 +11,12 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { filterName } from 'dbgate-tools';
|
||||
import { filterName, getConnectionLabel } from 'dbgate-tools';
|
||||
import ConnectionAppObject, { openConnection } from './ConnectionAppObject.svelte';
|
||||
import { _t } from '../translations';
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
||||
|
||||
export let data;
|
||||
export let passProps;
|
||||
@@ -28,15 +31,44 @@
|
||||
isBold: true,
|
||||
});
|
||||
res.push({ divider: true });
|
||||
res.push({
|
||||
text: _t('connection.edit', { defaultMessage: 'Edit' }),
|
||||
onClick: handleEditConnection,
|
||||
});
|
||||
res.push({
|
||||
text: _t('connection.delete', { defaultMessage: 'Delete' }),
|
||||
onClick: handleDeleteConnection,
|
||||
});
|
||||
res.push({
|
||||
text: _t('connection.duplicate', { defaultMessage: 'Duplicate' }),
|
||||
onClick: handleDuplicateConnection,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
function handleEditConnection() {
|
||||
openNewTab({
|
||||
title: data.name,
|
||||
icon: 'img cloud-connection',
|
||||
tabComponent: 'ConnectionTab',
|
||||
props: {
|
||||
conid: data.conid,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function handleDeleteConnection() {
|
||||
showModal(ConfirmModal, {
|
||||
message: `Really delete connection ${data.name}?`,
|
||||
onConfirm: () => {
|
||||
apiCall('cloud/delete-connection', { conid: data.conid });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function handleDuplicateConnection() {
|
||||
await apiCall('cloud/duplicate-connection', { conid: data.conid });
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
<script lang="ts">
|
||||
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
||||
|
||||
import FormProvider from '../forms/FormProvider.svelte';
|
||||
import FormProviderCore from '../forms/FormProviderCore.svelte';
|
||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
||||
import FormTextField from '../forms/FormTextField.svelte';
|
||||
import { cloudSigninTokenHolder } from '../stores';
|
||||
import { _t } from '../translations';
|
||||
import { apiCall } from '../utility/api';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
import getElectron from '../utility/getElectron';
|
||||
import ChooseCloudFolderModal from './ChooseCloudFolderModal.svelte';
|
||||
import ModalBase from './ModalBase.svelte';
|
||||
import { closeCurrentModal } from './modalTools';
|
||||
import { closeCurrentModal, showModal } from './modalTools';
|
||||
import FormCloudFolderSelect from '../forms/FormCloudFolderSelect.svelte';
|
||||
|
||||
export let data;
|
||||
export let name;
|
||||
@@ -19,6 +23,8 @@
|
||||
export let filePath;
|
||||
export let onSave = undefined;
|
||||
|
||||
const values = writable({ name });
|
||||
|
||||
const electron = getElectron();
|
||||
|
||||
const handleSubmit = async e => {
|
||||
@@ -50,12 +56,43 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleSaveToCloud = async folid => {
|
||||
const resp = await apiCall('cloud/save-file', {
|
||||
folid,
|
||||
fileName: $values.name,
|
||||
data,
|
||||
contentFolder: folder,
|
||||
format,
|
||||
});
|
||||
if (resp.cntid) {
|
||||
closeCurrentModal();
|
||||
if (onSave) {
|
||||
onSave(name, {
|
||||
savedFile: name,
|
||||
savedFolder: folder,
|
||||
savedFilePath: null,
|
||||
savedCloudFolderId: folid,
|
||||
savedCloudContentId: resp.cntid,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<FormProvider initialValues={{ name }}>
|
||||
<FormProviderCore {values}>
|
||||
<ModalBase {...$$restProps}>
|
||||
<svelte:fragment slot="header">Save file</svelte:fragment>
|
||||
<FormTextField label="File name" name="name" focused />
|
||||
{#if $cloudSigninTokenHolder}
|
||||
<FormCloudFolderSelect
|
||||
label="Choose local or cloud folder"
|
||||
name="cloudFolder"
|
||||
isNative
|
||||
requiredRoleVariants={['write', 'admin']}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<FormSubmit value={_t('common.save', { defaultMessage: 'Save' })} on:click={handleSubmit} />
|
||||
{#if electron}
|
||||
@@ -79,4 +116,4 @@
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</ModalBase>
|
||||
</FormProvider>
|
||||
</FormProviderCore>
|
||||
|
||||
Reference in New Issue
Block a user