mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 02:36:00 +00:00
cloud content fixes
This commit is contained in:
@@ -5,6 +5,7 @@ const {
|
|||||||
callCloudApiGet,
|
callCloudApiGet,
|
||||||
callCloudApiPost,
|
callCloudApiPost,
|
||||||
getCloudFolderEncryptor,
|
getCloudFolderEncryptor,
|
||||||
|
getCloudContent,
|
||||||
} = require('../utility/cloudIntf');
|
} = require('../utility/cloudIntf');
|
||||||
const connections = require('./connections');
|
const connections = require('./connections');
|
||||||
const socket = require('../utility/socket');
|
const socket = require('../utility/socket');
|
||||||
@@ -48,8 +49,8 @@ module.exports = {
|
|||||||
|
|
||||||
getContent_meta: true,
|
getContent_meta: true,
|
||||||
async getContent({ folid, cntid }) {
|
async getContent({ folid, cntid }) {
|
||||||
const { content, name, type } = await callCloudApiGet(`content/${folid}/${cntid}`);
|
const resp = await getCloudContent(folid, cntid);
|
||||||
return { content, name, type };
|
return resp;
|
||||||
},
|
},
|
||||||
|
|
||||||
putContent_meta: true,
|
putContent_meta: true,
|
||||||
|
|||||||
@@ -425,12 +425,9 @@ module.exports = {
|
|||||||
|
|
||||||
const cloudMatch = conid.match(/^cloud\:\/\/(.+)\/(.+)$/);
|
const cloudMatch = conid.match(/^cloud\:\/\/(.+)\/(.+)$/);
|
||||||
if (cloudMatch) {
|
if (cloudMatch) {
|
||||||
const cloud = require('./cloud');
|
const { loadCachedCloudConnection } = require('../utility/cloudIntf');
|
||||||
const { content } = await cloud.getContent({ folid: cloudMatch[1], cntid: cloudMatch[2] });
|
const conn = await loadCachedCloudConnection(cloudMatch[1], cloudMatch[2]);
|
||||||
return {
|
return conn;
|
||||||
...JSON.parse(content),
|
|
||||||
_id: conid,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const storage = require('./storage');
|
const storage = require('./storage');
|
||||||
|
|||||||
@@ -248,6 +248,24 @@ async function getCloudFolderEncryptor(folid) {
|
|||||||
return simpleEncryptor.createEncryptor(encryptionKey);
|
return simpleEncryptor.createEncryptor(encryptionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getCloudContent(folid, cntid) {
|
||||||
|
const { content, name, type } = await callCloudApiGet(`content/${folid}/${cntid}`);
|
||||||
|
return { content, name, type };
|
||||||
|
}
|
||||||
|
|
||||||
|
const cloudConnectionCache = {};
|
||||||
|
async function loadCachedCloudConnection(folid, cntid) {
|
||||||
|
const cacheKey = `${folid}|${cntid}`;
|
||||||
|
if (!cloudConnectionCache[cacheKey]) {
|
||||||
|
const { content } = await getCloudContent(folid, cntid);
|
||||||
|
cloudConnectionCache[cacheKey] = {
|
||||||
|
...JSON.parse(content),
|
||||||
|
_id: `cloud://${folid}/${cntid}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return cloudConnectionCache[cacheKey];
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
createDbGateIdentitySession,
|
createDbGateIdentitySession,
|
||||||
startCloudTokenChecking,
|
startCloudTokenChecking,
|
||||||
@@ -258,4 +276,6 @@ module.exports = {
|
|||||||
callCloudApiGet,
|
callCloudApiGet,
|
||||||
callCloudApiPost,
|
callCloudApiPost,
|
||||||
getCloudFolderEncryptor,
|
getCloudFolderEncryptor,
|
||||||
|
getCloudContent,
|
||||||
|
loadCachedCloudConnection,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { findEngineDriver } from 'dbgate-tools';
|
import { findEngineDriver } from 'dbgate-tools';
|
||||||
import { currentDatabase, extensions, pinnedDatabases, pinnedTables } from '../stores';
|
import { currentDatabase, extensions, pinnedDatabases, pinnedTables } from '../stores';
|
||||||
import { useCloudContentList, useConfig, useConnectionInfo } from '../utility/metadataLoaders';
|
import { useConnectionInfo } from '../utility/metadataLoaders';
|
||||||
|
|
||||||
import PinnedObjectsList from './PinnedObjectsList.svelte';
|
import PinnedObjectsList from './PinnedObjectsList.svelte';
|
||||||
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
});
|
});
|
||||||
$: contentGroupTitleMap = _.fromPairs(($cloudContentList || []).map(x => [x.folid, x.name]));
|
$: contentGroupTitleMap = _.fromPairs(($cloudContentList || []).map(x => [x.folid, x.name]));
|
||||||
|
|
||||||
$: console.log('cloudContentFlat', cloudContentFlat);
|
// $: console.log('cloudContentFlat', cloudContentFlat);
|
||||||
|
|
||||||
async function handleRefreshContent() {
|
async function handleRefreshContent() {
|
||||||
await apiCall('cloud/refresh-content');
|
await apiCall('cloud/refresh-content');
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
>
|
>
|
||||||
<WidgetsInnerContainer>
|
<WidgetsInnerContainer>
|
||||||
<SearchBoxWrapper>
|
<SearchBoxWrapper>
|
||||||
<SearchInput placeholder="Search cloud items" bind:value={cloudFilter} />
|
<SearchInput placeholder="Search cloud connections and files" bind:value={cloudFilter} />
|
||||||
<CloseSearchButton bind:filter={cloudFilter} />
|
<CloseSearchButton bind:filter={cloudFilter} />
|
||||||
<InlineButton
|
<InlineButton
|
||||||
on:click={handleRefreshContent}
|
on:click={handleRefreshContent}
|
||||||
|
|||||||
@@ -163,6 +163,8 @@
|
|||||||
($focusedConnectionOrDatabase.conid != conid ||
|
($focusedConnectionOrDatabase.conid != conid ||
|
||||||
($focusedConnectionOrDatabase?.database &&
|
($focusedConnectionOrDatabase?.database &&
|
||||||
$focusedConnectionOrDatabase?.database != extractDbNameFromComposite(database)));
|
$focusedConnectionOrDatabase?.database != extractDbNameFromComposite(database)));
|
||||||
|
|
||||||
|
// $: console.log('STATUS', $status);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $status && $status.name == 'error'}
|
{#if $status && $status.name == 'error'}
|
||||||
|
|||||||
Reference in New Issue
Block a user