mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 21:33:58 +00:00
cloud content refactor
This commit is contained in:
@@ -58,7 +58,7 @@ module.exports = {
|
|||||||
|
|
||||||
putContent_meta: true,
|
putContent_meta: true,
|
||||||
async putContent({ folid, cntid, content, name, type }) {
|
async putContent({ folid, cntid, content, name, type }) {
|
||||||
const resp = await putCloudContent(folid, cntid, content, name, type);
|
const resp = await putCloudContent(folid, cntid, content, name, type, {});
|
||||||
socket.emitChanged('cloud-content-changed');
|
socket.emitChanged('cloud-content-changed');
|
||||||
socket.emit('cloud-content-updated');
|
socket.emit('cloud-content-updated');
|
||||||
return resp;
|
return resp;
|
||||||
@@ -129,7 +129,11 @@ module.exports = {
|
|||||||
undefined,
|
undefined,
|
||||||
JSON.stringify(connToSend),
|
JSON.stringify(connToSend),
|
||||||
getConnectionLabel(conn),
|
getConnectionLabel(conn),
|
||||||
'connection'
|
'connection',
|
||||||
|
{
|
||||||
|
connectionColor: conn.connectionColor,
|
||||||
|
connectionEngine: conn.engine,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
return resp;
|
return resp;
|
||||||
},
|
},
|
||||||
@@ -157,7 +161,11 @@ module.exports = {
|
|||||||
cntid,
|
cntid,
|
||||||
JSON.stringify(recryptedConn),
|
JSON.stringify(recryptedConn),
|
||||||
getConnectionLabel(recryptedConn),
|
getConnectionLabel(recryptedConn),
|
||||||
'connection'
|
'connection',
|
||||||
|
{
|
||||||
|
connectionColor: connection.connectionColor,
|
||||||
|
connectionEngine: connection.engine,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (resp.apiErrorMessage) {
|
if (resp.apiErrorMessage) {
|
||||||
@@ -188,7 +196,10 @@ module.exports = {
|
|||||||
...conn,
|
...conn,
|
||||||
displayName: getConnectionLabel(conn) + ' - copy',
|
displayName: getConnectionLabel(conn) + ' - copy',
|
||||||
};
|
};
|
||||||
const respPut = await putCloudContent(folid, undefined, JSON.stringify(conn2), conn2.displayName, 'connection');
|
const respPut = await putCloudContent(folid, undefined, JSON.stringify(conn2), conn2.displayName, 'connection', {
|
||||||
|
connectionColor: conn.connectionColor,
|
||||||
|
connectionEngine: conn.engine,
|
||||||
|
});
|
||||||
return respPut;
|
return respPut;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -224,7 +235,7 @@ module.exports = {
|
|||||||
|
|
||||||
saveFile_meta: true,
|
saveFile_meta: true,
|
||||||
async saveFile({ folid, cntid, fileName, data, contentFolder, format }) {
|
async saveFile({ folid, cntid, fileName, data, contentFolder, format }) {
|
||||||
const resp = await putCloudContent(folid, cntid, data, fileName, 'file', contentFolder, format);
|
const resp = await putCloudContent(folid, cntid, data, fileName, 'file', { contentFolder, contentType: format });
|
||||||
socket.emitChanged('cloud-content-changed');
|
socket.emitChanged('cloud-content-changed');
|
||||||
socket.emit('cloud-content-updated');
|
socket.emit('cloud-content-updated');
|
||||||
return resp;
|
return resp;
|
||||||
|
|||||||
@@ -86,6 +86,16 @@ async function loadCloudFiles() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getCloudUsedEngines() {
|
||||||
|
try {
|
||||||
|
const resp = await callCloudApiGet('content-engines');
|
||||||
|
return resp || [];
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(extractErrorLogData(err), 'Error getting cloud content list');
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function collectCloudFilesSearchTags() {
|
async function collectCloudFilesSearchTags() {
|
||||||
const res = [];
|
const res = [];
|
||||||
if (platformInfo.isElectron) {
|
if (platformInfo.isElectron) {
|
||||||
@@ -120,11 +130,14 @@ async function collectCloudFilesSearchTags() {
|
|||||||
const engines = await connections.getUsedEngines();
|
const engines = await connections.getUsedEngines();
|
||||||
const engineTags = engines.map(engine => engine.split('@')[0]);
|
const engineTags = engines.map(engine => engine.split('@')[0]);
|
||||||
res.push(...engineTags);
|
res.push(...engineTags);
|
||||||
|
const cloudEngines = await getCloudUsedEngines();
|
||||||
|
const cloudEngineTags = cloudEngines.map(engine => engine.split('@')[0]);
|
||||||
|
res.push(...cloudEngineTags);
|
||||||
|
|
||||||
// team-premium and trials will return the same cloud files as premium - no need to check
|
// team-premium and trials will return the same cloud files as premium - no need to check
|
||||||
res.push(isProApp() ? 'premium' : 'community');
|
res.push(isProApp() ? 'premium' : 'community');
|
||||||
|
|
||||||
return res;
|
return _.uniq(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCloudSigninHolder() {
|
async function getCloudSigninHolder() {
|
||||||
@@ -293,7 +306,7 @@ async function getCloudContent(folid, cntid) {
|
|||||||
|
|
||||||
const encryptor = simpleEncryptor.createEncryptor(signinHolder.encryptionKey);
|
const encryptor = simpleEncryptor.createEncryptor(signinHolder.encryptionKey);
|
||||||
|
|
||||||
const { content, name, type, contentFolder, contentType, apiErrorMessage } = await callCloudApiGet(
|
const { content, name, type, contentAttributes, apiErrorMessage } = await callCloudApiGet(
|
||||||
`content/${folid}/${cntid}`,
|
`content/${folid}/${cntid}`,
|
||||||
signinHolder,
|
signinHolder,
|
||||||
{
|
{
|
||||||
@@ -309,8 +322,7 @@ async function getCloudContent(folid, cntid) {
|
|||||||
content: encryptor.decrypt(content),
|
content: encryptor.decrypt(content),
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
contentFolder,
|
contentAttributes,
|
||||||
contentType,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +330,7 @@ async function getCloudContent(folid, cntid) {
|
|||||||
*
|
*
|
||||||
* @returns Promise<{ cntid: string } | { apiErrorMessage: string }>
|
* @returns Promise<{ cntid: string } | { apiErrorMessage: string }>
|
||||||
*/
|
*/
|
||||||
async function putCloudContent(folid, cntid, content, name, type, contentFolder = null, contentType = null) {
|
async function putCloudContent(folid, cntid, content, name, type, contentAttributes) {
|
||||||
const signinHolder = await getCloudSigninHolder();
|
const signinHolder = await getCloudSigninHolder();
|
||||||
if (!signinHolder) {
|
if (!signinHolder) {
|
||||||
throw new Error('No signed in');
|
throw new Error('No signed in');
|
||||||
@@ -335,8 +347,7 @@ async function putCloudContent(folid, cntid, content, name, type, contentFolder
|
|||||||
type,
|
type,
|
||||||
kehid: signinHolder.kehid,
|
kehid: signinHolder.kehid,
|
||||||
content: encryptor.encrypt(content),
|
content: encryptor.encrypt(content),
|
||||||
contentFolder,
|
contentAttributes,
|
||||||
contentType,
|
|
||||||
},
|
},
|
||||||
signinHolder
|
signinHolder
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -92,7 +92,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if data.conid && $cloudConnectionsStore[data.conid]}
|
{#if data.conid && $cloudConnectionsStore[data.conid] && $cloudConnectionsStore[data.conid]?._id}
|
||||||
<ConnectionAppObject
|
<ConnectionAppObject
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
{passProps}
|
{passProps}
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
{passProps}
|
{passProps}
|
||||||
data={{
|
data={{
|
||||||
file: data.name,
|
file: data.name,
|
||||||
folder: data.contentFolder,
|
folder: data.contentAttributes?.contentFolder,
|
||||||
folid: data.folid,
|
folid: data.folid,
|
||||||
cntid: data.cntid,
|
cntid: data.cntid,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ registerCommand({
|
|||||||
category: 'New',
|
category: 'New',
|
||||||
toolbarOrder: 1,
|
toolbarOrder: 1,
|
||||||
name: 'Connection on Cloud',
|
name: 'Connection on Cloud',
|
||||||
testEnabled: () => !getCurrentConfig()?.runAsPortal && !getCurrentConfig()?.storageDatabase && isProApp(),
|
testEnabled: () => !getCurrentConfig()?.runAsPortal && !getCurrentConfig()?.storageDatabase,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openNewTab({
|
openNewTab({
|
||||||
title: 'New Connection on Cloud',
|
title: 'New Connection on Cloud',
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||||
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
||||||
import { showSnackbarInfo } from '../utility/snackbar';
|
import { showSnackbarInfo } from '../utility/snackbar';
|
||||||
|
import { isProApp } from '../utility/proTools';
|
||||||
|
|
||||||
let filter = '';
|
let filter = '';
|
||||||
let domSqlObjectList = null;
|
let domSqlObjectList = null;
|
||||||
@@ -100,7 +101,7 @@
|
|||||||
|
|
||||||
function createAddMenu() {
|
function createAddMenu() {
|
||||||
return [
|
return [
|
||||||
{
|
isProApp() && {
|
||||||
text: 'New shared folder',
|
text: 'New shared folder',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
showModal(InputTextModal, {
|
showModal(InputTextModal, {
|
||||||
@@ -114,7 +115,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
isProApp() && {
|
||||||
text: 'Add existing shared folder',
|
text: 'Add existing shared folder',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
showModal(InputTextModal, {
|
showModal(InputTextModal, {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
import { refreshPublicCloudFiles } from '../utility/api';
|
import { refreshPublicCloudFiles } from '../utility/api';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
||||||
|
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||||
let filter = '';
|
let filter = '';
|
||||||
|
|
||||||
const publicFiles = usePublicCloudFiles();
|
const publicFiles = usePublicCloudFiles();
|
||||||
@@ -45,6 +47,26 @@
|
|||||||
groupFunc={data => data.folder || 'Not defined'}
|
groupFunc={data => data.folder || 'Not defined'}
|
||||||
{filter}
|
{filter}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{#if !$publicFiles?.length}
|
||||||
|
<ErrorInfo message="No files found for your configuration" />
|
||||||
|
<div class="error-info">
|
||||||
|
<div class="m-1">
|
||||||
|
Only files relevant for your connections, platform and DbGate edition are listed. Please define connections at first.
|
||||||
|
</div>
|
||||||
|
<FormStyledButton value={`Refresh list`} skipWidth on:click={handleRefreshPublic} />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</WidgetsInnerContainer>
|
</WidgetsInnerContainer>
|
||||||
</WidgetColumnBarItem>
|
</WidgetColumnBarItem>
|
||||||
</WidgetColumnBar>
|
</WidgetColumnBar>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.error-info {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user