mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 23:06:00 +00:00
194 lines
6.3 KiB
Svelte
194 lines
6.3 KiB
Svelte
<script lang="ts">
|
|
import _ from 'lodash';
|
|
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
|
import Link from '../elements/Link.svelte';
|
|
import TabControl from '../elements/TabControl.svelte';
|
|
|
|
import FormCheckboxField from '../forms/FormCheckboxField.svelte';
|
|
import FormFieldTemplateLarge from '../forms/FormFieldTemplateLarge.svelte';
|
|
import FormSelectField from '../forms/FormSelectField.svelte';
|
|
import FormTextField from '../forms/FormTextField.svelte';
|
|
import FormValues from '../forms/FormValues.svelte';
|
|
import SelectField from '../forms/SelectField.svelte';
|
|
import SettingsFormProvider from '../forms/SettingsFormProvider.svelte';
|
|
import FontIcon from '../icons/FontIcon.svelte';
|
|
|
|
import ModalBase from '../modals/ModalBase.svelte';
|
|
import { closeCurrentModal } from '../modals/modalTools';
|
|
import { EDITOR_THEMES, FONT_SIZES } from '../query/AceEditor.svelte';
|
|
import SqlEditor from '../query/SqlEditor.svelte';
|
|
import { currentEditorFontSize, currentEditorTheme, extensions, selectedWidget } from '../stores';
|
|
import { isMac } from '../utility/common';
|
|
import getElectron from '../utility/getElectron';
|
|
import ThemeSkeleton from './ThemeSkeleton.svelte';
|
|
|
|
const electron = getElectron();
|
|
let restartWarning = false;
|
|
|
|
export let selectedTab = 0;
|
|
|
|
const sqlPreview = `-- example query
|
|
SELECT
|
|
MAX(Album.AlbumId) AS max_album,
|
|
MAX(Album.Title) AS max_title,
|
|
Artist.ArtistId,
|
|
'album' AS test_string,
|
|
123 AS test_number
|
|
FROM
|
|
Album
|
|
INNER JOIN Artist ON Album.ArtistId = Artist.ArtistId
|
|
GROUP BY
|
|
Artist.ArtistId
|
|
ORDER BY
|
|
Artist.Name ASC
|
|
`;
|
|
|
|
function openThemePlugins() {
|
|
closeCurrentModal();
|
|
$selectedWidget = 'plugins';
|
|
}
|
|
</script>
|
|
|
|
<SettingsFormProvider>
|
|
<ModalBase {...$$restProps} noPadding>
|
|
<div slot="header">Settings</div>
|
|
|
|
<FormValues let:values>
|
|
<TabControl
|
|
bind:value={selectedTab}
|
|
isInline
|
|
tabs={[
|
|
{ label: 'General', slot: 1 },
|
|
{ label: 'Themes', slot: 2 },
|
|
]}
|
|
>
|
|
<svelte:fragment slot="1">
|
|
{#if electron}
|
|
<div class="heading">Appearance</div>
|
|
<FormCheckboxField
|
|
name="app.useNativeMenu"
|
|
label={isMac() ? 'Use native window title' : 'Use system native menu'}
|
|
on:change={() => {
|
|
restartWarning = true;
|
|
}}
|
|
/>
|
|
{#if restartWarning}
|
|
<div class="ml-5 mb-3">
|
|
<FontIcon icon="img warn" /> Native menu settings will be applied after app restart
|
|
</div>
|
|
{/if}
|
|
{/if}
|
|
|
|
<div class="heading">Data grid</div>
|
|
<FormTextField
|
|
name="dataGrid.pageSize"
|
|
label="Page size (number of rows for incremental loading, must be between 5 and 1000)"
|
|
defaultValue="100"
|
|
/>
|
|
<FormCheckboxField name="dataGrid.showHintColumns" label="Show foreign key hints" defaultValue={true} />
|
|
<!-- <FormCheckboxField name="dataGrid.showHintColumns" label="Show foreign key hints" defaultValue={true} /> -->
|
|
|
|
<FormCheckboxField name="dataGrid.thousandsSeparator" label="Use thousands separator for numbers" />
|
|
|
|
<div class="heading">Connection</div>
|
|
<FormCheckboxField
|
|
name="connection.autoRefresh"
|
|
label="Automatic refresh of database model on background"
|
|
defaultValue={false}
|
|
/>
|
|
<FormTextField
|
|
name="connection.autoRefreshInterval"
|
|
label="Interval between automatic refreshes in seconds"
|
|
defaultValue="30"
|
|
disabled={values['connection.autoRefresh'] === false}
|
|
/>
|
|
|
|
<div class="heading">Default actions</div>
|
|
<FormSelectField
|
|
label="Connection click"
|
|
name="defaultAction.connectionClick"
|
|
isNative
|
|
defaultValue='openDetails'
|
|
options={[
|
|
{ value: 'openDetails', label: 'Edit / open details' },
|
|
{ value: 'connect', label: 'Connect' },
|
|
]}
|
|
/>
|
|
</svelte:fragment>
|
|
<svelte:fragment slot="2">
|
|
<div class="heading">Application theme</div>
|
|
<div class="themes">
|
|
{#each $extensions.themes as theme}
|
|
<ThemeSkeleton {theme} />
|
|
{/each}
|
|
</div>
|
|
|
|
<div class="m-5">
|
|
More themes are available as <Link onClick={openThemePlugins}>plugins</Link>
|
|
<br />
|
|
After installing theme plugin (try search "theme" in available extensions) new themes will be available here.
|
|
</div>
|
|
|
|
<div class="heading">Editor theme</div>
|
|
|
|
<div class="flex">
|
|
<div class="col-6">
|
|
<FormFieldTemplateLarge label="Theme" type="combo">
|
|
<SelectField
|
|
isNative
|
|
notSelected="(use theme default)"
|
|
options={EDITOR_THEMES.map(theme => ({ label: theme, value: theme }))}
|
|
value={$currentEditorTheme}
|
|
on:change={e => ($currentEditorTheme = e.detail)}
|
|
/>
|
|
</FormFieldTemplateLarge>
|
|
</div>
|
|
|
|
<div class="col-6">
|
|
<FormFieldTemplateLarge label="Font size " type="combo">
|
|
<SelectField
|
|
isNative
|
|
notSelected="(default)"
|
|
options={FONT_SIZES}
|
|
value={$currentEditorFontSize}
|
|
on:change={e => ($currentEditorFontSize = e.detail)}
|
|
/>
|
|
</FormFieldTemplateLarge>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="editor">
|
|
<SqlEditor value={sqlPreview} readOnly />
|
|
</div>
|
|
</svelte:fragment>
|
|
</TabControl>
|
|
</FormValues>
|
|
|
|
<div slot="footer">
|
|
<!-- <FormSubmit value="OK" on:click={handleOk} /> -->
|
|
<FormStyledButton value="Close" on:click={closeCurrentModal} />
|
|
</div>
|
|
</ModalBase>
|
|
</SettingsFormProvider>
|
|
|
|
<style>
|
|
.heading {
|
|
font-size: 20px;
|
|
margin: 5px;
|
|
margin-left: var(--dim-large-form-margin);
|
|
margin-top: var(--dim-large-form-margin);
|
|
}
|
|
|
|
.themes {
|
|
overflow-x: scroll;
|
|
display: flex;
|
|
}
|
|
|
|
.editor {
|
|
position: relative;
|
|
height: 200px;
|
|
width: 400px;
|
|
margin-left: var(--dim-large-form-margin);
|
|
}
|
|
</style>
|