mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
@@ -153,3 +153,4 @@ dist
|
||||
|
||||
# Sentry Config File
|
||||
.sentryclirc
|
||||
.idea
|
||||
|
||||
Generated
+1349
-224
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -19,7 +19,7 @@
|
||||
"e2e:ui": "playwright test tests/e2e --ui"
|
||||
},
|
||||
"dependencies": {
|
||||
"@appwrite.io/console": "1.0.1",
|
||||
"@appwrite.io/console": "1.1.0",
|
||||
"@appwrite.io/pink": "0.25.0",
|
||||
"@appwrite.io/pink-icons": "0.25.0",
|
||||
"@popperjs/core": "^2.11.8",
|
||||
|
||||
Generated
+425
-415
File diff suppressed because it is too large
Load Diff
+4
-3
@@ -20,15 +20,16 @@
|
||||
export async function updateBoolean(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
|
||||
data: Partial<Models.AttributeBoolean>
|
||||
data: Partial<Models.AttributeBoolean>,
|
||||
originalKey?: string
|
||||
) {
|
||||
await sdk.forProject.databases.updateBooleanAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.default
|
||||
data.default,
|
||||
data.key !== originalKey ? data.key : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
+4
-2
@@ -21,14 +21,16 @@
|
||||
export async function updateDatetime(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeDatetime>
|
||||
data: Partial<Models.AttributeDatetime>,
|
||||
originalKey?: string
|
||||
) {
|
||||
await sdk.forProject.databases.updateDatetimeAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.default
|
||||
data.default,
|
||||
data.key !== originalKey ? data.key : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
+6
-3
@@ -16,6 +16,7 @@
|
||||
|
||||
const databaseId = $page.params.database;
|
||||
const collectionId = $page.params.collection;
|
||||
let originalKey = '';
|
||||
|
||||
let error: string;
|
||||
let currentAttr: Attributes;
|
||||
@@ -32,7 +33,7 @@
|
||||
|
||||
async function submit() {
|
||||
try {
|
||||
await option.update(databaseId, collectionId, selectedAttribute);
|
||||
await option.update(databaseId, collectionId, selectedAttribute, originalKey);
|
||||
await invalidate(Dependencies.COLLECTION);
|
||||
if (!$page.url.pathname.includes('attributes')) {
|
||||
await goto(
|
||||
@@ -53,7 +54,10 @@
|
||||
|
||||
$: if (showEdit) {
|
||||
currentAttr ??= { ...selectedAttribute };
|
||||
originalKey = currentAttr.key;
|
||||
error = null;
|
||||
} else {
|
||||
currentAttr = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -76,8 +80,7 @@
|
||||
label="Attribute Key"
|
||||
placeholder="Enter Key"
|
||||
bind:value={selectedAttribute.key}
|
||||
autofocus
|
||||
readonly />
|
||||
autofocus />
|
||||
{/if}
|
||||
{#if option}
|
||||
<svelte:component
|
||||
|
||||
+4
-2
@@ -22,14 +22,16 @@
|
||||
export async function updateEmail(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeEmail>
|
||||
data: Partial<Models.AttributeEmail>,
|
||||
originalKey?: string
|
||||
) {
|
||||
await sdk.forProject.databases.updateEmailAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.default
|
||||
data.default,
|
||||
data.key !== originalKey ? data.key : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
+4
-2
@@ -22,7 +22,8 @@
|
||||
export async function updateEnum(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeEnum>
|
||||
data: Partial<Models.AttributeEnum>,
|
||||
originalKey?: string
|
||||
) {
|
||||
await sdk.forProject.databases.updateEnumAttribute(
|
||||
databaseId,
|
||||
@@ -30,7 +31,8 @@
|
||||
data.key,
|
||||
data.elements,
|
||||
data.required,
|
||||
data.default
|
||||
data.default,
|
||||
data.key !== originalKey ? data.key : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
+4
-2
@@ -23,7 +23,8 @@
|
||||
export async function updateFloat(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeFloat>
|
||||
data: Partial<Models.AttributeFloat>,
|
||||
originalKey?: string
|
||||
) {
|
||||
await sdk.forProject.databases.updateFloatAttribute(
|
||||
databaseId,
|
||||
@@ -32,7 +33,8 @@
|
||||
data.required,
|
||||
data.min,
|
||||
data.max,
|
||||
data.default
|
||||
data.default,
|
||||
data.key !== originalKey ? data.key : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
+4
-2
@@ -23,7 +23,8 @@
|
||||
export async function updateInteger(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeInteger>
|
||||
data: Partial<Models.AttributeInteger>,
|
||||
originalKey?: string
|
||||
) {
|
||||
await sdk.forProject.databases.updateIntegerAttribute(
|
||||
databaseId,
|
||||
@@ -32,7 +33,8 @@
|
||||
data.required,
|
||||
data.min,
|
||||
data.max,
|
||||
data.default
|
||||
data.default,
|
||||
data.key !== originalKey ? data.key : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
+4
-2
@@ -20,14 +20,16 @@
|
||||
export async function updateIp(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeIp>
|
||||
data: Partial<Models.AttributeIp>,
|
||||
originalKey?: string
|
||||
) {
|
||||
await sdk.forProject.databases.updateIpAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.default
|
||||
data.default,
|
||||
data.key !== originalKey ? data.key : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
+6
-4
@@ -29,16 +29,19 @@
|
||||
export async function updateRelationship(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeRelationship>
|
||||
data: Partial<Models.AttributeRelationship>,
|
||||
originalKey?: string
|
||||
) {
|
||||
if (!isValueOfStringEnum(RelationMutate, data.onDelete)) {
|
||||
throw new Error(`Invalid on delete: ${data.onDelete}`);
|
||||
}
|
||||
|
||||
await sdk.forProject.databases.updateRelationshipAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.onDelete
|
||||
originalKey,
|
||||
data.onDelete,
|
||||
data.key !== originalKey ? data.key : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
@@ -187,7 +190,6 @@
|
||||
placeholder="Enter Key"
|
||||
bind:value={data.key}
|
||||
autofocus
|
||||
readonly={editing}
|
||||
required />
|
||||
|
||||
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small u-cross-center">
|
||||
|
||||
+6
-1
@@ -32,7 +32,12 @@ export type Option = {
|
||||
key: string,
|
||||
data: Partial<Attributes>
|
||||
) => Promise<void>;
|
||||
update: (databaseId: string, collectionId: string, data: Partial<Attributes>) => Promise<void>;
|
||||
update: (
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Attributes>,
|
||||
originalKey: string
|
||||
) => Promise<void>;
|
||||
format?: 'email' | 'ip' | 'url' | 'enum';
|
||||
icon: string;
|
||||
};
|
||||
|
||||
+7
-10
@@ -21,14 +21,17 @@
|
||||
export async function updateString(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeString>
|
||||
data: Partial<Models.AttributeString>,
|
||||
originalKey?: string
|
||||
) {
|
||||
await sdk.forProject.databases.updateStringAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
originalKey,
|
||||
data.required,
|
||||
data.default
|
||||
data.default,
|
||||
data.size,
|
||||
data.key !== originalKey ? data.key : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
@@ -69,13 +72,7 @@
|
||||
$: handleDefaultState($required || $array);
|
||||
</script>
|
||||
|
||||
<InputNumber
|
||||
id="size"
|
||||
label="Size"
|
||||
placeholder="Enter size"
|
||||
bind:value={data.size}
|
||||
required={!editing}
|
||||
readonly={editing} />
|
||||
<InputNumber id="size" label="Size" placeholder="Enter size" bind:value={data.size} />
|
||||
{#if data.size >= 50}
|
||||
<InputTextarea
|
||||
id="default"
|
||||
|
||||
+4
-2
@@ -21,14 +21,16 @@
|
||||
export async function updateUrl(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeUrl>
|
||||
data: Partial<Models.AttributeUrl>,
|
||||
originalKey?: string
|
||||
) {
|
||||
await sdk.forProject.databases.updateUrlAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.default
|
||||
data.default,
|
||||
data.key !== originalKey ? data.key : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<script context="module" lang="ts">
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export async function submitString(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
key: string,
|
||||
data: Partial<Models.AttributeString>
|
||||
) {
|
||||
await sdk.forProject.databases.createStringAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
key,
|
||||
data.size,
|
||||
data.required,
|
||||
data.default,
|
||||
data.array
|
||||
);
|
||||
}
|
||||
export async function updateString(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeString>,
|
||||
originalKey?: string
|
||||
) {
|
||||
await sdk.forProject.databases.updateStringAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
originalKey,
|
||||
data.required,
|
||||
data.default,
|
||||
data.size,
|
||||
data.key !== originalKey ? data.key : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { InputChoice, InputNumber, InputText, InputTextarea } from '$lib/elements/forms';
|
||||
import { createConservative } from '$lib/helpers/stores';
|
||||
|
||||
export let data: Partial<Models.AttributeString> = {
|
||||
required: false,
|
||||
size: 0,
|
||||
default: null,
|
||||
array: false
|
||||
};
|
||||
export let editing = false;
|
||||
|
||||
let savedDefault = data.default;
|
||||
|
||||
function handleDefaultState(hideDefault: boolean) {
|
||||
if (hideDefault) {
|
||||
savedDefault = data.default;
|
||||
data.default = null;
|
||||
} else {
|
||||
data.default = savedDefault;
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
stores: { required, array },
|
||||
listen
|
||||
} = createConservative<Partial<Models.AttributeString>>({
|
||||
required: false,
|
||||
array: false,
|
||||
...data
|
||||
});
|
||||
$: listen(data);
|
||||
|
||||
$: handleDefaultState($required || $array);
|
||||
</script>
|
||||
|
||||
<InputNumber
|
||||
id="size"
|
||||
label="Size"
|
||||
placeholder="Enter size"
|
||||
bind:value={data.size}
|
||||
required={!editing}
|
||||
readonly={editing} />
|
||||
{#if data.size >= 50}
|
||||
<InputTextarea
|
||||
id="default"
|
||||
label="Default"
|
||||
placeholder="Enter string"
|
||||
disabled={data.required || data.array}
|
||||
nullable={!data.required && !data.array}
|
||||
maxlength={data.size}
|
||||
bind:value={data.default} />
|
||||
{:else}
|
||||
<InputText
|
||||
id="default"
|
||||
label="Default"
|
||||
placeholder="Enter string"
|
||||
disabled={data.required || data.array}
|
||||
nullable={!data.required && !data.array}
|
||||
maxlength={data.size}
|
||||
bind:value={data.default} />
|
||||
{/if}
|
||||
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
|
||||
Indicate whether this is a required attribute
|
||||
</InputChoice>
|
||||
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
|
||||
Indicate whether this attribute should act as an array, with the default value set as an empty
|
||||
array.
|
||||
</InputChoice>
|
||||
Reference in New Issue
Block a user