Skip to content

Commit

Permalink
Merge branch 'feat-pink-v2' of https://github.com/appwrite/console in…
Browse files Browse the repository at this point in the history
…to feat-pink-v2
  • Loading branch information
TorstenDittmann committed Jan 30, 2025
2 parents 0677634 + 3c09c7b commit ee807c4
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@appwrite.io/console';
import { Badge, Layout, Spinner, Typography } from '@appwrite.io/pink-svelte';
import { Badge, Card, Layout, Logs, Spinner, Typography } from '@appwrite.io/pink-svelte';
import ansicolor from 'ansicolor';
import { onMount } from 'svelte';
Expand Down Expand Up @@ -129,9 +129,7 @@
</Layout.Stack>
</div>
</Layout.Stack>
<pre>
<code>{formatLogs(buildLogs)}</code>
</pre>
<Logs logs={formatLogs(buildLogs)} />
<!-- <div>
<Code lang="text" code={buildLogs.replace(/\\n/g, '\n')} />
</div> -->
Expand All @@ -141,13 +139,3 @@
{/if}
</Layout.Stack>
</Layout.Stack>

<style>
/* TODO: move to pink */
pre {
max-height: 600px;
overflow-y: scroll;
display: flex;
flex-direction: column-reverse;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@
import type { Models } from '@appwrite.io/console';
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
import { Badge, Icon, Layout, Table, Tabs, Typography } from '@appwrite.io/pink-svelte';
import { onMount } from 'svelte';
export let selectedLog: Models.Execution;
let requestTab: 'parameters' | 'headers' | 'body' = 'parameters';
let parameters = [];
onMount(() => {
try {
// Add dummy base URL to parse relative paths
const url = new URL(selectedLog.requestPath, 'http://dummy.local');
if (url.search) {
parameters = Array.from(url.searchParams.entries()).map(([name, value]) => ({
name,
value: decodeURIComponent(value)
}));
}
} catch (error) {
parameters = [];
}
});
</script>

<Layout.Stack>
Expand All @@ -14,6 +32,7 @@
active={requestTab === 'parameters'}
on:click={() => (requestTab = 'parameters')}>
Parameters
<Badge variant="secondary" size="s" content={parameters?.length?.toString()} />
</Tabs.Item.Button>
<Tabs.Item.Button
active={requestTab === 'headers'}
Expand All @@ -28,7 +47,22 @@
</Tabs.Item.Button>
</Tabs.Root>
{#if requestTab === 'parameters'}
<Typography.Code>No parameters found.</Typography.Code>
{#if parameters?.length}
<Table.Root>
<svelte:fragment slot="header">
<Table.Header.Cell>Key</Table.Header.Cell>
<Table.Header.Cell>Value</Table.Header.Cell>
</svelte:fragment>
{#each parameters as parameter}
<Table.Row>
<Table.Cell>{parameter.name}</Table.Cell>
<Table.Cell>{parameter.value}</Table.Cell>
</Table.Row>
{/each}
</Table.Root>
{:else}
<Typography.Code>No parameters found.</Typography.Code>
{/if}
{:else if requestTab === 'headers'}
{#if selectedLog.requestHeaders?.length}
<Table.Root>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import type { Models } from '@appwrite.io/console';
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
import { Badge, Icon, Layout, Table, Tabs, Typography } from '@appwrite.io/pink-svelte';
import { Badge, Icon, Layout, Logs, Table, Tabs, Typography } from '@appwrite.io/pink-svelte';
export let selectedLog: Models.Execution;
Expand Down Expand Up @@ -32,13 +32,13 @@
</Tabs.Root>
{#if responseTab === 'logs'}
{#if selectedLog.logs}
{selectedLog.logs}
<Logs logs={selectedLog.logs} />
{:else}
<Typography.Code>No logs found.</Typography.Code>
{/if}
{:else if responseTab === 'errors'}
{#if selectedLog.errors}
{selectedLog.errors}
<Logs logs={selectedLog.errors} />
{:else}
<Typography.Code>No errors found.</Typography.Code>
{/if}
Expand Down Expand Up @@ -67,7 +67,7 @@
{/if}
{:else if responseTab === 'body'}
{#if selectedLog.responseBody}
{selectedLog.responseBody}
<Logs logs={selectedLog.responseBody} />
{:else}
<Typography.Code>No parameters found.</Typography.Code>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@
color="--color-fgcolor-neutral-tertiary">
Method
</Typography.Text>
<Typography.Text variant="m-400"
>{selectedLog.requestMethod}</Typography.Text>
<Typography.Text variant="m-400">
{selectedLog.requestMethod}
</Typography.Text>
</Layout.Stack>
<Layout.Stack gap="xs" inline>
<Typography.Text
Expand Down

0 comments on commit ee807c4

Please sign in to comment.