mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 05:16:00 +00:00
sql object list
This commit is contained in:
38
packages/web/src/widgets/ErrorInfo.svelte
Normal file
38
packages/web/src/widgets/ErrorInfo.svelte
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
|
|
||||||
|
export let message;
|
||||||
|
export let icon = 'img error';
|
||||||
|
export let isSmall = false;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if isSmall}
|
||||||
|
<div class="container-small">
|
||||||
|
<FontIcon {icon} />
|
||||||
|
{message}
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="container">
|
||||||
|
<div class="icon">
|
||||||
|
<FontIcon {icon} />
|
||||||
|
</div>
|
||||||
|
{message}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
.icon {
|
||||||
|
font-size: 20pt;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-small {
|
||||||
|
display: flex;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
export let square = false;
|
export let square = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="outer buttonLike" class:disabled class:square>
|
<div class="outer buttonLike" class:disabled class:square on:click>
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
@@ -33,11 +33,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.outer:hover:not(.disabled) {
|
.outer:hover:not(.disabled) {
|
||||||
border: 1px solid var(--bg-1);
|
border: 1px solid var(--theme-font-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.outer:active:not(.disabled) {
|
||||||
background: linear-gradient(to bottom, var(--bg-2) 5%, var(--bg-1) 100%);
|
background: linear-gradient(to bottom, var(--bg-2) 5%, var(--bg-1) 100%);
|
||||||
background-color: var(--bg-2);
|
background-color: var(--bg-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.inner {
|
.inner {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
54
packages/web/src/widgets/LoadingInfo.svelte
Normal file
54
packages/web/src/widgets/LoadingInfo.svelte
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
|
|
||||||
|
export let message;
|
||||||
|
export let wrapper = false;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if wrapper}
|
||||||
|
<div class="wrapper">
|
||||||
|
<div class="box">
|
||||||
|
<div class="container">
|
||||||
|
<div class="spinner">
|
||||||
|
<FontIcon icon="icon loading" />
|
||||||
|
</div>
|
||||||
|
{message}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="container">
|
||||||
|
<div class="spinner">
|
||||||
|
<FontIcon icon="icon loading" />
|
||||||
|
</div>
|
||||||
|
{message}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
font-size: 20pt;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
.wrapper {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
.box {
|
||||||
|
background-color: var(--thme-bg-2);
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid gray;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -9,6 +9,9 @@
|
|||||||
import * as databaseObjectAppObject from '../appobj/DatabaseObjectAppObject.svelte';
|
import * as databaseObjectAppObject from '../appobj/DatabaseObjectAppObject.svelte';
|
||||||
import SubColumnParamList from '../appobj/SubColumnParamList.svelte';
|
import SubColumnParamList from '../appobj/SubColumnParamList.svelte';
|
||||||
import { chevronExpandIcon } from '../icons/expandIcons';
|
import { chevronExpandIcon } from '../icons/expandIcons';
|
||||||
|
import ErrorInfo from './ErrorInfo.svelte';
|
||||||
|
import axios from '../utility/axios';
|
||||||
|
import LoadingInfo from './LoadingInfo.svelte';
|
||||||
|
|
||||||
export let conid;
|
export let conid;
|
||||||
export let database;
|
export let database;
|
||||||
@@ -26,20 +29,43 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleRefreshDatabase = () => {
|
||||||
|
axios.post('database-connections/refresh', { conid, database });
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<SearchBoxWrapper>
|
{#if $status && $status.name == 'error'}
|
||||||
<SearchInput placeholder="Search tables or objects" bind:value={filter} />
|
<WidgetsInnerContainer>
|
||||||
<InlineButton>Refresh</InlineButton>
|
<ErrorInfo message={$status.message} icon="img error" />
|
||||||
</SearchBoxWrapper>
|
<InlineButton on:click={handleRefreshDatabase}>Refresh</InlineButton>
|
||||||
<WidgetsInnerContainer>
|
</WidgetsInnerContainer>
|
||||||
<AppObjectList
|
{:else if objectList.length == 0 && $status && $status.name != 'pending' && $objects}
|
||||||
list={objectList.map(x => ({ ...x, conid, database }))}
|
<WidgetsInnerContainer>
|
||||||
module={databaseObjectAppObject}
|
<ErrorInfo
|
||||||
groupFunc={data => _.startCase(data.objectTypeField)}
|
message={`Database ${database} is empty or structure is not loaded, press Refresh button to reload structure`}
|
||||||
subItemsComponent={SubColumnParamList}
|
icon="img alert"
|
||||||
isExpandable={data => data.objectTypeField == 'tables' || data.objectTypeField == 'views'}
|
/>
|
||||||
expandIconFunc={chevronExpandIcon}
|
<InlineButton on:click={handleRefreshDatabase}>Refresh</InlineButton>
|
||||||
{filter}
|
</WidgetsInnerContainer>
|
||||||
/>
|
{:else}
|
||||||
</WidgetsInnerContainer>
|
<SearchBoxWrapper>
|
||||||
|
<SearchInput placeholder="Search tables or objects" bind:value={filter} />
|
||||||
|
<InlineButton on:click={handleRefreshDatabase}>Refresh</InlineButton>
|
||||||
|
</SearchBoxWrapper>
|
||||||
|
<WidgetsInnerContainer>
|
||||||
|
{#if ($status && $status.name == 'pending' && $objects) || !$objects}
|
||||||
|
<LoadingInfo message="Loading database structure" />
|
||||||
|
{:else}
|
||||||
|
<AppObjectList
|
||||||
|
list={objectList.map(x => ({ ...x, conid, database }))}
|
||||||
|
module={databaseObjectAppObject}
|
||||||
|
groupFunc={data => _.startCase(data.objectTypeField)}
|
||||||
|
subItemsComponent={SubColumnParamList}
|
||||||
|
isExpandable={data => data.objectTypeField == 'tables' || data.objectTypeField == 'views'}
|
||||||
|
expandIconFunc={chevronExpandIcon}
|
||||||
|
{filter}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</WidgetsInnerContainer>
|
||||||
|
{/if}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { currentDatabase } from '../stores';
|
import { currentDatabase } from '../stores';
|
||||||
|
import ErrorInfo from './ErrorInfo.svelte';
|
||||||
import SqlObjectList from './SqlObjectList.svelte';
|
import SqlObjectList from './SqlObjectList.svelte';
|
||||||
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
||||||
|
|
||||||
@@ -11,5 +12,7 @@
|
|||||||
{#if conid && database}
|
{#if conid && database}
|
||||||
<SqlObjectList {conid} {database} />
|
<SqlObjectList {conid} {database} />
|
||||||
{:else}
|
{:else}
|
||||||
<WidgetsInnerContainer>Database not selected</WidgetsInnerContainer>
|
<WidgetsInnerContainer>
|
||||||
|
<ErrorInfo message="Database not selected" icon="img alert" />
|
||||||
|
</WidgetsInnerContainer>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user