mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 16:36:00 +00:00
show cloud content
This commit is contained in:
30
packages/web/src/appobj/CloudContentAppObject.svelte
Normal file
30
packages/web/src/appobj/CloudContentAppObject.svelte
Normal file
@@ -0,0 +1,30 @@
|
||||
<script lang="ts" context="module">
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
|
||||
export const extractKey = data => data.cntid;
|
||||
export const createMatcher =
|
||||
filter =>
|
||||
({ name }) =>
|
||||
filterName(filter, name);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { filterName } from 'dbgate-tools';
|
||||
|
||||
export let data;
|
||||
|
||||
function createMenu() {
|
||||
return [];
|
||||
}
|
||||
</script>
|
||||
|
||||
<AppObjectCore {...$$restProps} {data} icon={'img connection'} title={data.name} menu={createMenu}></AppObjectCore>
|
||||
|
||||
<style>
|
||||
.info {
|
||||
margin-left: 30px;
|
||||
margin-right: 5px;
|
||||
color: var(--theme-font-3);
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
@@ -108,6 +108,7 @@
|
||||
import _ from 'lodash';
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import {
|
||||
cloudSigninToken,
|
||||
currentDatabase,
|
||||
DEFAULT_CONNECTION_SEARCH_SETTINGS,
|
||||
expandedConnections,
|
||||
@@ -332,6 +333,17 @@
|
||||
text: _t('connection.duplicate', { defaultMessage: 'Duplicate' }),
|
||||
onClick: handleDuplicate,
|
||||
},
|
||||
!$openedConnections.includes(data._id) &&
|
||||
$cloudSigninToken &&
|
||||
passProps?.cloudContentList?.length > 0 && {
|
||||
text: _t('connection.moveToCloudFolder', { defaultMessage: 'Move to cloud folder' }),
|
||||
submenu: passProps?.cloudContentList?.map(fld => ({
|
||||
text: fld.name,
|
||||
onClick: () => {
|
||||
apiCall('cloud/move-connection-cloud', { conid: data._id, folid: fld.folid });
|
||||
},
|
||||
})),
|
||||
},
|
||||
],
|
||||
{ divider: true },
|
||||
!data.singleDatabase && [
|
||||
|
||||
@@ -183,7 +183,6 @@ export const focusedConnectionOrDatabase = writable<{ conid: string; database?:
|
||||
export const focusedTreeDbKey = writable<{ key: string; root: string; type: string; text: string }>(null);
|
||||
|
||||
export const cloudSigninToken = writableSettingsValue(null, 'cloudSigninToken');
|
||||
export const cloudEncryptKeysByFolder = writableSettingsValue({}, 'cloudEncryptKeysByFolder');
|
||||
|
||||
// export const cloudSigninToken = getElectron()
|
||||
// ? writableSettingsValue(null, 'cloudSigninToken')
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
import WidgetColumnBarItem from './WidgetColumnBarItem.svelte';
|
||||
|
||||
import AppObjectList from '../appobj/AppObjectList.svelte';
|
||||
import * as cloudFileAppObject from '../appobj/CloudFileAppObject.svelte';
|
||||
import * as publicCloudFileAppObject from '../appobj/PublicCloudFileAppObject.svelte';
|
||||
import * as cloudContentAppObject from '../appobj/CloudContentAppObject.svelte';
|
||||
import { useCloudContentList, usePublicCloudFiles } from '../utility/metadataLoaders';
|
||||
import { _t } from '../translations';
|
||||
|
||||
@@ -26,7 +27,7 @@
|
||||
$: cloudContentList = useCloudContentList();
|
||||
|
||||
$: emptyCloudContent = ($cloudContentList || []).filter(x => !x.items?.length).map(x => x.folid);
|
||||
$: cloudContentFlat = ($cloudContentList || []).flatMap(fld => fld.items ?? []).map(x => x.folid);
|
||||
$: cloudContentFlat = ($cloudContentList || []).flatMap(fld => fld.items ?? []);
|
||||
$: contentGroupTitleMap = _.fromPairs(($cloudContentList || []).map(x => [x.folid, x.name]));
|
||||
|
||||
async function handleRefreshPublic() {
|
||||
@@ -61,7 +62,7 @@
|
||||
|
||||
<AppObjectList
|
||||
list={cloudContentFlat || []}
|
||||
module={cloudFileAppObject}
|
||||
module={cloudContentAppObject}
|
||||
emptyGroupNames={emptyCloudContent}
|
||||
groupFunc={data => data.folid}
|
||||
mapGroupTitle={folid => contentGroupTitleMap[folid]}
|
||||
@@ -86,7 +87,7 @@
|
||||
|
||||
<AppObjectList
|
||||
list={$publicFiles || []}
|
||||
module={cloudFileAppObject}
|
||||
module={publicCloudFileAppObject}
|
||||
groupFunc={data => data.folder || undefined}
|
||||
filter={publicFilter}
|
||||
/>
|
||||
|
||||
@@ -351,6 +351,7 @@
|
||||
isExpandable={data => $openedConnections.includes(data._id) && !data.singleDatabase}
|
||||
{filter}
|
||||
passProps={{
|
||||
...passProps,
|
||||
connectionColorFactory: $connectionColorFactory,
|
||||
showPinnedInsteadOfUnpin: true,
|
||||
searchSettings: $connectionAppObjectSearchSettings,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { findEngineDriver } from 'dbgate-tools';
|
||||
import { currentDatabase, extensions, pinnedDatabases, pinnedTables } from '../stores';
|
||||
import { useConfig, useConnectionInfo } from '../utility/metadataLoaders';
|
||||
import { useCloudContentList, useConfig, useConnectionInfo } from '../utility/metadataLoaders';
|
||||
|
||||
import ConnectionList from './ConnectionList.svelte';
|
||||
import PinnedObjectsList from './PinnedObjectsList.svelte';
|
||||
@@ -26,6 +26,7 @@
|
||||
$: config = useConfig();
|
||||
$: singleDatabase = $currentDatabase?.connection?.singleDatabase;
|
||||
$: database = $currentDatabase?.name;
|
||||
$: cloudContentList = useCloudContentList();
|
||||
</script>
|
||||
|
||||
<WidgetColumnBar {hidden}>
|
||||
@@ -45,7 +46,12 @@
|
||||
height="35%"
|
||||
storageName="connectionsWidget"
|
||||
>
|
||||
<ConnectionList passProps={{ onFocusSqlObjectList: () => domSqlObjectList.focus() }} />
|
||||
<ConnectionList
|
||||
passProps={{
|
||||
onFocusSqlObjectList: () => domSqlObjectList.focus(),
|
||||
cloudContentList: $cloudContentList,
|
||||
}}
|
||||
/>
|
||||
</WidgetColumnBarItem>
|
||||
{/if}
|
||||
<WidgetColumnBarItem
|
||||
|
||||
Reference in New Issue
Block a user