mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 01:03:58 +00:00
#63 - keyboard modal, settings icon
This commit is contained in:
@@ -72,6 +72,7 @@
|
|||||||
}
|
}
|
||||||
.iconbar {
|
.iconbar {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
display: flex;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: var(--dim-header-top);
|
top: var(--dim-header-top);
|
||||||
bottom: var(--dim-statusbar-height);
|
bottom: var(--dim-statusbar-height);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
'icon cell-data': 'mdi mdi-details',
|
'icon cell-data': 'mdi mdi-details',
|
||||||
'icon sql-generator': 'mdi mdi-cog-transfer',
|
'icon sql-generator': 'mdi mdi-cog-transfer',
|
||||||
'icon keyboard': 'mdi mdi-keyboard-settings',
|
'icon keyboard': 'mdi mdi-keyboard-settings',
|
||||||
|
'icon settings': 'mdi mdi-cog',
|
||||||
|
|
||||||
'icon database': 'mdi mdi-database',
|
'icon database': 'mdi mdi-database',
|
||||||
'icon server': 'mdi mdi-server',
|
'icon server': 'mdi mdi-server',
|
||||||
|
|||||||
@@ -1,25 +1,40 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
import FormStyledButton from '../elements/FormStyledButton.svelte';
|
import FormStyledButton from '../elements/FormStyledButton.svelte';
|
||||||
|
import InlineButton from '../elements/InlineButton.svelte';
|
||||||
|
|
||||||
import FormProvider from '../forms/FormProvider.svelte';
|
import FormProvider from '../forms/FormProvider.svelte';
|
||||||
|
import FormProviderCore from '../forms/FormProviderCore.svelte';
|
||||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
import FormSubmit from '../forms/FormSubmit.svelte';
|
||||||
import FormTextField from '../forms/FormTextField.svelte';
|
import FormTextField from '../forms/FormTextField.svelte';
|
||||||
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
import { customKeyboardShortcuts } from '../stores';
|
import { customKeyboardShortcuts } from '../stores';
|
||||||
|
import KeyboardModal from './KeyboardModal.svelte';
|
||||||
import ModalBase from './ModalBase.svelte';
|
import ModalBase from './ModalBase.svelte';
|
||||||
import { closeCurrentModal } from './modalTools';
|
import { closeCurrentModal, showModal } from './modalTools';
|
||||||
|
|
||||||
export let command;
|
export let command;
|
||||||
|
|
||||||
|
let values = writable(command);
|
||||||
|
|
||||||
|
function handleKeyboard() {
|
||||||
|
showModal(KeyboardModal, { onChange: value => values.update(x => ({ ...x, keyText: value })) });
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<FormProvider initialValues={command}>
|
<FormProviderCore {values}>
|
||||||
<ModalBase {...$$restProps}>
|
<ModalBase {...$$restProps}>
|
||||||
<svelte:fragment slot="header">Configure commmand</svelte:fragment>
|
<svelte:fragment slot="header">Configure commmand</svelte:fragment>
|
||||||
|
|
||||||
<FormTextField label="Category" name="category" disabled />
|
<FormTextField label="Category" name="category" disabled />
|
||||||
<FormTextField label="Name" name="name" disabled />
|
<FormTextField label="Name" name="name" disabled />
|
||||||
<FormTextField label="Keyboard shortcut" name="keyText" />
|
|
||||||
|
<div class="row">
|
||||||
|
<FormTextField label="Keyboard shortcut" name="keyText" templateProps={{ noMargin: true }} focused />
|
||||||
|
<FormStyledButton type="button" value="Keyboard" on:click={handleKeyboard} />
|
||||||
|
</div>
|
||||||
|
|
||||||
<svelte:fragment slot="footer">
|
<svelte:fragment slot="footer">
|
||||||
<FormSubmit
|
<FormSubmit
|
||||||
@@ -46,4 +61,10 @@
|
|||||||
<FormStyledButton type="button" value="Close" on:click={closeCurrentModal} />
|
<FormStyledButton type="button" value="Close" on:click={closeCurrentModal} />
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</ModalBase>
|
</ModalBase>
|
||||||
</FormProvider>
|
</FormProviderCore>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.row {
|
||||||
|
margin: var(--dim-large-form-margin);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
47
packages/web/src/modals/KeyboardModal.svelte
Normal file
47
packages/web/src/modals/KeyboardModal.svelte
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
import TextField from '../forms/TextField.svelte';
|
||||||
|
import keycodes from '../utility/keycodes';
|
||||||
|
import ModalBase from './ModalBase.svelte';
|
||||||
|
import { closeCurrentModal } from './modalTools';
|
||||||
|
|
||||||
|
export let onChange;
|
||||||
|
let value;
|
||||||
|
|
||||||
|
function handleKeyDown(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
if (e.keyCode == keycodes.escape) {
|
||||||
|
closeCurrentModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.keyCode == keycodes.enter && value) {
|
||||||
|
onChange(value);
|
||||||
|
closeCurrentModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let keyText = '';
|
||||||
|
if (e.ctrlKey) keyText += 'Ctrl+';
|
||||||
|
if (e.shiftKey) keyText += 'Shift+';
|
||||||
|
if (e.altKey) keyText += 'Alt+';
|
||||||
|
if (e.key != 'Control' && e.key != 'Alt' && e.key != 'Shift') {
|
||||||
|
keyText += _.upperFirst(e.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = keyText;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ModalBase {...$$restProps} simple>
|
||||||
|
<div class="mb-2">Show desired key combination and press ENTER</div>
|
||||||
|
<div class="largeFormMarker">
|
||||||
|
<TextField on:keydown={handleKeyDown} bind:value focused />
|
||||||
|
</div>
|
||||||
|
</ModalBase>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
export let fullScreen = false;
|
export let fullScreen = false;
|
||||||
export let noPadding = false;
|
export let noPadding = false;
|
||||||
|
export let simple = false;
|
||||||
export let modalId;
|
export let modalId;
|
||||||
|
|
||||||
function handleCloseModal() {
|
function handleCloseModal() {
|
||||||
@@ -32,7 +33,7 @@
|
|||||||
<!-- The Modal -->
|
<!-- The Modal -->
|
||||||
<div id="myModal" class="bglayer">
|
<div id="myModal" class="bglayer">
|
||||||
<!-- Modal content -->
|
<!-- Modal content -->
|
||||||
<div class="window" class:fullScreen use:clickOutside on:clickOutside={handleCloseModal}>
|
<div class="window" class:fullScreen class:simple use:clickOutside on:clickOutside={handleCloseModal}>
|
||||||
{#if $$slots.header}
|
{#if $$slots.header}
|
||||||
<div class="header" class:fullScreen>
|
<div class="header" class:fullScreen>
|
||||||
<div><slot name="header" /></div>
|
<div><slot name="header" /></div>
|
||||||
@@ -46,9 +47,11 @@
|
|||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if $$slots.footer}
|
||||||
<div class="footer" class:fullScreen>
|
<div class="footer" class:fullScreen>
|
||||||
<slot name="footer" />
|
<slot name="footer" />
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -74,7 +77,7 @@
|
|||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.window:not(.fullScreen) {
|
.window:not(.fullScreen):not(.simple) {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
margin-top: 15vh;
|
margin-top: 15vh;
|
||||||
@@ -89,6 +92,12 @@
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.window.simple {
|
||||||
|
margin: auto;
|
||||||
|
margin-top: 25vh;
|
||||||
|
width: 30%;
|
||||||
|
}
|
||||||
|
|
||||||
.close {
|
.close {
|
||||||
font-size: 12pt;
|
font-size: 12pt;
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { update } from 'lodash';
|
import { update } from 'lodash';
|
||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
import { selectedWidget, visibleCommandPalette, visibleToolbar } from '../stores';
|
import { currentDropDownMenu, selectedWidget, visibleCommandPalette, visibleToolbar } from '../stores';
|
||||||
|
|
||||||
|
let domSettings;
|
||||||
|
|
||||||
const widgets = [
|
const widgets = [
|
||||||
{
|
{
|
||||||
@@ -39,7 +41,7 @@
|
|||||||
title: 'Selected cell data detail view',
|
title: 'Selected cell data detail view',
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// icon: 'fa-cog',
|
// icon: 'icon settings',
|
||||||
// name: 'settings',
|
// name: 'settings',
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
@@ -52,18 +54,34 @@
|
|||||||
$selectedWidget = name == $selectedWidget ? null : name;
|
$selectedWidget = name == $selectedWidget ? null : name;
|
||||||
}
|
}
|
||||||
//const handleChangeWidget= e => (selectedWidget.set(item.name))
|
//const handleChangeWidget= e => (selectedWidget.set(item.name))
|
||||||
|
|
||||||
|
function handleSettingsMenu() {
|
||||||
|
const rect = domSettings.getBoundingClientRect();
|
||||||
|
const left = rect.right;
|
||||||
|
const top = rect.top;
|
||||||
|
const items = [{ command: 'settings.commands' }];
|
||||||
|
currentDropDownMenu.set({ left, top, items });
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if !$visibleToolbar}
|
<div class="main">
|
||||||
|
{#if !$visibleToolbar}
|
||||||
<div class="wrapper mb-3" on:click={() => ($visibleCommandPalette = true)}>
|
<div class="wrapper mb-3" on:click={() => ($visibleCommandPalette = true)}>
|
||||||
<FontIcon icon="icon menu" />
|
<FontIcon icon="icon menu" />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#each widgets as item}
|
{#each widgets as item}
|
||||||
<div class="wrapper" class:selected={item.name == $selectedWidget} on:click={() => handleChangeWidget(item.name)}>
|
<div class="wrapper" class:selected={item.name == $selectedWidget} on:click={() => handleChangeWidget(item.name)}>
|
||||||
<FontIcon icon={item.icon} title={item.title} />
|
<FontIcon icon={item.icon} title={item.title} />
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
|
<div class="flex1"> </div>
|
||||||
|
|
||||||
|
<div class="wrapper" on:click={handleSettingsMenu} bind:this={domSettings}>
|
||||||
|
<FontIcon icon="icon settings" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.wrapper {
|
.wrapper {
|
||||||
@@ -81,4 +99,9 @@
|
|||||||
color: var(--theme-font-inv-1);
|
color: var(--theme-font-inv-1);
|
||||||
background: var(--theme-bg-inv-3);
|
background: var(--theme-bg-inv-3);
|
||||||
}
|
}
|
||||||
|
.main {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user