mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 22:16:00 +00:00
show cloud content
This commit is contained in:
52
packages/web/src/appobj/PublicCloudFileAppObject.svelte
Normal file
52
packages/web/src/appobj/PublicCloudFileAppObject.svelte
Normal file
@@ -0,0 +1,52 @@
|
||||
<script lang="ts" context="module">
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
|
||||
export const extractKey = data => data.path;
|
||||
export const createMatcher =
|
||||
filter =>
|
||||
({ title, description }) =>
|
||||
filterName(filter, title, description);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { apiCall } from '../utility/api';
|
||||
import newQuery from '../query/newQuery';
|
||||
import { filterName } from 'dbgate-tools';
|
||||
|
||||
export let data;
|
||||
|
||||
async function handleOpenSqlFile() {
|
||||
const fileData = await apiCall('cloud/public-file-data', { path: data.path });
|
||||
newQuery({
|
||||
initialData: fileData.text,
|
||||
});
|
||||
}
|
||||
|
||||
function createMenu() {
|
||||
return [{ text: 'Open', onClick: handleOpenSqlFile }];
|
||||
}
|
||||
</script>
|
||||
|
||||
<AppObjectCore
|
||||
{...$$restProps}
|
||||
{data}
|
||||
icon={'img sql-file'}
|
||||
title={data.title}
|
||||
menu={createMenu}
|
||||
on:click={handleOpenSqlFile}
|
||||
>
|
||||
{#if data.description}
|
||||
<div class="info">
|
||||
{data.description}
|
||||
</div>
|
||||
{/if}
|
||||
</AppObjectCore>
|
||||
|
||||
<style>
|
||||
.info {
|
||||
margin-left: 30px;
|
||||
margin-right: 5px;
|
||||
color: var(--theme-font-3);
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user