mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 01:23:57 +00:00
delete conn on cloud, save file to cloud WIP
This commit is contained in:
@@ -190,4 +190,21 @@ module.exports = {
|
|||||||
const respPut = await putCloudContent(folid, undefined, JSON.stringify(conn2), conn2.displayName, 'connection');
|
const respPut = await putCloudContent(folid, undefined, JSON.stringify(conn2), conn2.displayName, 'connection');
|
||||||
return respPut;
|
return respPut;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
deleteConnection_meta: true,
|
||||||
|
async deleteConnection({ conid }) {
|
||||||
|
const m = conid.match(/^cloud\:\/\/(.+)\/(.+)$/);
|
||||||
|
if (!m) {
|
||||||
|
throw new Error('Invalid cloud connection ID format');
|
||||||
|
}
|
||||||
|
const folid = m[1];
|
||||||
|
const cntid = m[2];
|
||||||
|
const resp = await callCloudApiPost(`content/delete/${folid}/${cntid}`);
|
||||||
|
socket.emitChanged('cloud-content-changed');
|
||||||
|
socket.emit('cloud-content-updated');
|
||||||
|
return resp;
|
||||||
|
},
|
||||||
|
|
||||||
|
// saveFile_meta: true,
|
||||||
|
// async saveFile({folid, file, data, folder, format})
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,9 +11,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { filterName } from 'dbgate-tools';
|
import { filterName, getConnectionLabel } from 'dbgate-tools';
|
||||||
import ConnectionAppObject, { openConnection } from './ConnectionAppObject.svelte';
|
import ConnectionAppObject, { openConnection } from './ConnectionAppObject.svelte';
|
||||||
import { _t } from '../translations';
|
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 data;
|
||||||
export let passProps;
|
export let passProps;
|
||||||
@@ -28,15 +31,44 @@
|
|||||||
isBold: true,
|
isBold: true,
|
||||||
});
|
});
|
||||||
res.push({ divider: 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({
|
res.push({
|
||||||
text: _t('connection.duplicate', { defaultMessage: 'Duplicate' }),
|
text: _t('connection.duplicate', { defaultMessage: 'Duplicate' }),
|
||||||
onClick: handleDuplicateConnection,
|
onClick: handleDuplicateConnection,
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
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() {
|
async function handleDuplicateConnection() {
|
||||||
await apiCall('cloud/duplicate-connection', { conid: data.conid });
|
await apiCall('cloud/duplicate-connection', { conid: data.conid });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
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 FormSubmit from '../forms/FormSubmit.svelte';
|
||||||
import FormTextField from '../forms/FormTextField.svelte';
|
import FormTextField from '../forms/FormTextField.svelte';
|
||||||
|
import { cloudSigninTokenHolder } from '../stores';
|
||||||
import { _t } from '../translations';
|
import { _t } from '../translations';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
import getElectron from '../utility/getElectron';
|
import getElectron from '../utility/getElectron';
|
||||||
|
import ChooseCloudFolderModal from './ChooseCloudFolderModal.svelte';
|
||||||
import ModalBase from './ModalBase.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 data;
|
||||||
export let name;
|
export let name;
|
||||||
@@ -19,6 +23,8 @@
|
|||||||
export let filePath;
|
export let filePath;
|
||||||
export let onSave = undefined;
|
export let onSave = undefined;
|
||||||
|
|
||||||
|
const values = writable({ name });
|
||||||
|
|
||||||
const electron = getElectron();
|
const electron = getElectron();
|
||||||
|
|
||||||
const handleSubmit = async e => {
|
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>
|
</script>
|
||||||
|
|
||||||
<FormProvider initialValues={{ name }}>
|
<FormProviderCore {values}>
|
||||||
<ModalBase {...$$restProps}>
|
<ModalBase {...$$restProps}>
|
||||||
<svelte:fragment slot="header">Save file</svelte:fragment>
|
<svelte:fragment slot="header">Save file</svelte:fragment>
|
||||||
<FormTextField label="File name" name="name" focused />
|
<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">
|
<svelte:fragment slot="footer">
|
||||||
<FormSubmit value={_t('common.save', { defaultMessage: 'Save' })} on:click={handleSubmit} />
|
<FormSubmit value={_t('common.save', { defaultMessage: 'Save' })} on:click={handleSubmit} />
|
||||||
{#if electron}
|
{#if electron}
|
||||||
@@ -79,4 +116,4 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</ModalBase>
|
</ModalBase>
|
||||||
</FormProvider>
|
</FormProviderCore>
|
||||||
|
|||||||
Reference in New Issue
Block a user