mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 02:36:01 +00:00
redis: add item to key
This commit is contained in:
@@ -3,13 +3,25 @@
|
|||||||
|
|
||||||
export let keyInfo;
|
export let keyInfo;
|
||||||
export let item;
|
export let item;
|
||||||
|
export let onChangeItem;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="props">
|
<div class="props">
|
||||||
{#each keyInfo.tableColumns as column}
|
{#each keyInfo.tableColumns as column}
|
||||||
<div class="colname">{column.name}</div>
|
<div class="colname">{column.name}</div>
|
||||||
<div class="colvalue">
|
<div class="colvalue">
|
||||||
<AceEditor readOnly value={item && item[column.name]} />
|
<AceEditor
|
||||||
|
readOnly={!onChangeItem}
|
||||||
|
value={item && item[column.name]}
|
||||||
|
on:input={e => {
|
||||||
|
if (onChangeItem) {
|
||||||
|
onChangeItem({
|
||||||
|
...item,
|
||||||
|
[column.name]: e.detail,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,36 +1,47 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
import FormStyledButton from '../buttons/FormStyledButton.svelte';
|
||||||
import DbKeyItemDetail from '../dbkeyvalue/DbKeyItemDetail.svelte';
|
import DbKeyItemDetail from '../dbkeyvalue/DbKeyItemDetail.svelte';
|
||||||
|
|
||||||
import FormProvider from '../forms/FormProvider.svelte';
|
import FormProvider from '../forms/FormProvider.svelte';
|
||||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
|
||||||
import FormTextField from '../forms/FormTextField.svelte';
|
|
||||||
import ModalBase from './ModalBase.svelte';
|
import ModalBase from './ModalBase.svelte';
|
||||||
import { closeCurrentModal } from './modalTools';
|
import { closeCurrentModal } from './modalTools';
|
||||||
|
|
||||||
export let keyInfo;
|
export let keyInfo;
|
||||||
export let value;
|
|
||||||
export let label;
|
export let label;
|
||||||
export let onConfirm;
|
export let onConfirm;
|
||||||
|
|
||||||
const handleSubmit = async values => {
|
let item = {};
|
||||||
const { value } = values;
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
closeCurrentModal();
|
closeCurrentModal();
|
||||||
onConfirm(value);
|
onConfirm(item);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<FormProvider initialValues={{ value }}>
|
<FormProvider>
|
||||||
<ModalBase {...$$restProps}>
|
<ModalBase {...$$restProps}>
|
||||||
<svelte:fragment slot="header">
|
<svelte:fragment slot="header">Add item</svelte:fragment>
|
||||||
Add item
|
|
||||||
</svelte:fragment>
|
|
||||||
|
|
||||||
<DbKeyItemDetail {keyInfo} />
|
<div class="container">
|
||||||
|
<DbKeyItemDetail
|
||||||
|
{keyInfo}
|
||||||
|
{item}
|
||||||
|
onChangeItem={value => {
|
||||||
|
item = value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<svelte:fragment slot="footer">
|
<svelte:fragment slot="footer">
|
||||||
<FormSubmit value="OK" on:click={e => handleSubmit(e.detail)} />
|
<FormStyledButton value="OK" on:click={e => handleSubmit()} />
|
||||||
<FormStyledButton type="button" value="Cancel" on:click={closeCurrentModal} />
|
<FormStyledButton type="button" value="Cancel" on:click={closeCurrentModal} />
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</ModalBase>
|
</ModalBase>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
height: 30vh;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -83,7 +83,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function addItem(keyInfo) {
|
async function addItem(keyInfo) {
|
||||||
showModal(DbKeyAddItemModal, { keyInfo });
|
showModal(DbKeyAddItemModal, {
|
||||||
|
keyInfo,
|
||||||
|
onConfirm: async row => {
|
||||||
|
await apiCall('database-connections/call-method', {
|
||||||
|
conid,
|
||||||
|
database,
|
||||||
|
method: keyInfo.addMethod,
|
||||||
|
args: [keyInfo.key, ...keyInfo.tableColumns.map(col => row[col.name])],
|
||||||
|
});
|
||||||
|
refresh();
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user