add some more fixes

This commit is contained in:
Torsten Dittmann committed 2022-03-26 00:23:14 +03:00
1 parent 506e735d72
commit ca140f7818
11 files changed
+212 -80

No files matched your search

+1 -3
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import 'chart.js/auto';
import { Chart, type ChartConfiguration, type ChartDataset } from 'chart.js';
import { Chart, type ChartDataset } from 'chart.js';
import { onMount } from 'svelte';
let element: HTMLCanvasElement;
@@ -8,8 +8,6 @@
export let datasets: ChartDataset<'line'>[];
onMount(() => {
console.log(labels);
console.log(datasets);
new Chart(element, {
type: 'line',
data: {
+25 -11
View File
@@ -4,16 +4,30 @@
export let outline = false;
export let danger = false;
export let disabled = false;
export let href: string = null;
</script>
<button
on:click
{disabled}
class="button"
class:is-secondary={secondary}
class:is-outline={outline}
class:is-danger={danger}
type={submit ? 'submit' : 'button'}
>
<slot />
</button>
{#if href}
<a
{disabled}
{href}
class="button"
class:is-secondary={secondary}
class:is-outline={outline}
class:is-danger={danger}
>
<slot />
</a>
{:else}
<button
on:click
{disabled}
class="button"
class:is-secondary={secondary}
class:is-outline={outline}
class:is-danger={danger}
type={submit ? 'submit' : 'button'}
>
<slot />
</button>
{/if}
+12 -14
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { onMount } from 'svelte';
import { onMount, tick } from 'svelte';
import { FormItem } from '.';
export let id: string;
@@ -7,23 +7,26 @@
export let value = '';
export let placeholder = '';
export let required = false;
export let disabled = false;
export let autofocus = false;
let element: HTMLInputElement;
let unique = true;
let bench = '';
$: {
const toggle = async () => {
unique = !unique;
if (unique) {
bench = value;
value = 'unique()';
disabled = true;
} else {
value = '';
disabled = false;
value = bench;
await tick();
element.focus();
}
}
};
onMount(() => {
value = 'unique()';
if (element && autofocus) {
element.focus();
}
@@ -35,19 +38,14 @@
<div class="input-text-wrapper is-with-end-button">
<input
{placeholder}
{disabled}
{required}
type="text"
class="input-text"
disabled={unique}
bind:value
bind:this={element}
/>
<button
class="input-button"
aria-label="Switch"
on:click={() => (unique = !unique)}
type="button"
>
<button class="input-button" aria-label="Switch" on:click={toggle} type="button">
<span class:icon-edit={unique} class:icon-shuffle={!unique} aria-hidden="true" />
</button>
</div>
+1 -1
View File
@@ -15,7 +15,7 @@
<FormItem>
<label class="label" for={id}>{label}</label>
<div class="select">
<select {value} {required} {disabled}>
<select bind:value {required} {disabled}>
{#each options as option}
<option value={option.value} selected={option.value === value}>
{option.label}
@@ -0,0 +1,25 @@
<script lang="ts">
import InputSelect from '$lib/elements/forms/inputSelect.svelte';
import { collection } from './store';
export let queries: string[] = [];
let selectedOption: string;
$: currentIndex = $collection.indexes.find((i) => i.key === selectedOption);
const options = $collection.indexes.map((i) => {
return {
value: i.key,
label: i.key
};
});
</script>
<InputSelect id="currentIndex" label="Index" {options} bind:value={selectedOption} />
{#if currentIndex}
{#each currentIndex.attributes as a}
<p>{a}</p>
{/each}
{/if}
@@ -12,6 +12,7 @@
import { option, options } from './attributes/store';
import { collection } from './store';
import { Container } from '$lib/layout';
import { Pill } from '$lib/elements';
let showCreateDropdown = false;
</script>
@@ -29,7 +30,15 @@
<TableBody>
{#each $collection.attributes as attribute}
<TableRow>
<TableCellText title="Status">{attribute.status}</TableCellText>
<TableCellText title="Status">
<Pill
success={attribute.status === 'available'}
pending={attribute.status === 'processing'}
failed={['deleting', 'stuck', 'failed'].includes(attribute.status)}
>
{attribute.status}
</Pill>
</TableCellText>
<TableCellText title="Key">{attribute.key}</TableCellText>
<TableCellText title="Type">
{'format' in attribute ? attribute.format : attribute.type}
@@ -0,0 +1,75 @@
<script lang="ts">
import { page } from '$app/stores';
import { Back, Card, Copy } from '$lib/components';
import { Button, Form } from '$lib/elements/forms';
import { sdkForProject } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { collection } from '../store';
import { doc } from './[document]/store';
import { addNotification } from '$lib/stores/notifications';
import Document from './[document]/_document.svelte';
import { goto } from '$app/navigation';
import InputCustomId from '$lib/elements/forms/inputCustomId.svelte';
import { Container, Cover } from '$lib/layout';
$: projectId = $page.params.project;
onMount(() => {
doc.set({
$collection: $page.params.collection,
$id: null,
$read: [],
$write: []
});
});
const createDocument = async () => {
try {
const created = await sdkForProject.database.createDocument(
$collection.$id,
$doc.$id,
{
...$doc,
$id: undefined
},
$doc.$read,
$doc.$write
);
addNotification({
message: 'Document was created!',
type: 'success'
});
await goto(
`/console/${projectId}/database/collection/${created.$collection}/document/${created.$id}`
);
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
}
};
</script>
<svelte:head>
<title>Appwrite - Document</title>
</svelte:head>
{#if $doc && $collection}
<Cover>
<Back href={`/console/${projectId}/database/collection/${$collection.$id}`}>
Collection - {$collection.name}
</Back>
<h1>Create Document</h1>
</Cover>
<Container>
<Card>
<Form on:submit={createDocument}>
<InputCustomId id="id" label="Document ID" bind:value={$doc.$id} />
<Document />
<Button submit>Create</Button>
</Form>
</Card>
</Container>
{:else}
<div aria-busy="true" />
{/if}
@@ -0,0 +1,48 @@
<script lang="ts">
import { Collapsible } from '$lib/components';
import { Button, InputTags } from '$lib/elements/forms';
import { collection } from '../../store';
import { doc } from './store';
import Attribute from './_attribute.svelte';
</script>
{#each $collection.attributes.filter((a) => a.status === 'available') as attribute}
{#if attribute.array}
{#each $doc[attribute.key] as _v, index}
<Attribute
{attribute}
id={`${attribute.key}-${index}`}
label={index === 0 ? attribute.key : ''}
bind:value={$doc[attribute.key][index]}
/>
<Button on:click={() => doc.removeAttribute(attribute.key, index)}>X</Button>
{:else}
<p>{attribute.key}</p>
{/each}
<Button on:click={() => doc.addAttribute(attribute.key)}>Add Attribute</Button>
{:else}
<Attribute
{attribute}
id={attribute.key}
label={attribute.key}
bind:value={$doc[attribute.key]}
/>
{/if}
{/each}
<Collapsible>
<svelte:fragment slot="header">Permissions</svelte:fragment>
<InputTags
id="read"
label="Read Permissions"
bind:tags={$doc.$read}
helper="Add 'role:all' for wildcard access"
placeholder="User ID, Team ID or Role"
/>
<InputTags
id="write"
label="Write Permissions"
bind:tags={$doc.$write}
helper="Add 'role:all' for wildcard access"
placeholder="User ID, Team ID or Role"
/>
</Collapsible>
@@ -1,13 +1,13 @@
<script lang="ts">
import { page } from '$app/stores';
import { Card, Collapsible, Copy } from '$lib/components';
import { Button, Form, InputTags } from '$lib/elements/forms';
import { Card, Copy } from '$lib/components';
import { Button, Form } from '$lib/elements/forms';
import { sdkForProject } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { collection } from '../../store';
import { doc } from './store';
import { addNotification } from '$lib/stores/notifications';
import Attribute from './_attribute.svelte';
import Document from './_document.svelte';
$: documentId = $page.params.document;
@@ -46,46 +46,7 @@
{#if $doc}
<Form on:submit={updateDocument}>
<Copy value={$doc.$id} />
{#each $collection.attributes.filter((a) => a.status === 'available') as attribute}
{#if attribute.array}
{#each $doc[attribute.key] as _v, index}
<Attribute
{attribute}
id={`${attribute.key}-${index}`}
label={index === 0 ? attribute.key : ''}
bind:value={$doc[attribute.key][index]}
/>
<Button on:click={() => doc.removeAttribute(attribute.key, index)}>X</Button>
{:else}
<p>{attribute.key}</p>
{/each}
<Button on:click={() => doc.addAttribute(attribute.key)}>Add Attribute</Button>
{:else}
<Attribute
{attribute}
id={attribute.key}
label={attribute.key}
bind:value={$doc[attribute.key]}
/>
{/if}
{/each}
<Collapsible>
<svelte:fragment slot="header">Permissions</svelte:fragment>
<InputTags
id="read"
label="Read Permissions"
bind:tags={$doc.$read}
helper="Add 'role:all' for wildcard access"
placeholder="User ID, Team ID or Role"
/>
<InputTags
id="write"
label="Write Permissions"
bind:tags={$doc.$write}
helper="Add 'role:all' for wildcard access"
placeholder="User ID, Team ID or Role"
/>
</Collapsible>
<Document />
<Button submit>Update</Button>
</Form>
{:else}
@@ -12,6 +12,7 @@
import { Empty, Pagination } from '$lib/components';
import { collection } from './store';
import { Container } from '$lib/layout';
import { Button } from '$lib/elements/forms';
let offset = 0;
@@ -63,5 +64,8 @@
Add your first document to get started.
</Empty>
{/if}
<Button href={`/console/${project}/database/collection/${$collection.$id}/document/@create`}
>Create Document</Button
>
{/await}
</Container>
+7 -7
View File
@@ -2231,31 +2231,31 @@ namespace Models {
/**
* Aggregated stats for number of requests.
*/
requests: MetricList[];
requests: any[];
/**
* Aggregated stats for consumed bandwidth.
*/
network: MetricList[];
network: any[];
/**
* Aggregated stats for function executions.
*/
functions: MetricList[];
functions: any[];
/**
* Aggregated stats for number of documents.
*/
documents: MetricList[];
documents: any[];
/**
* Aggregated stats for number of collections.
*/
collections: MetricList[];
collections: any[];
/**
* Aggregated stats for number of users.
*/
users: MetricList[];
users: any[];
/**
* Aggregated stats for the occupied storage size (in bytes).
*/
storage: MetricList[];
storage: any[];
};
}