mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: logs quick filters
This commit is contained in:
1 parent
3f31834ce5
commit
9c8b9ca4a9
2 files changed
+120
-52
No files matched your search
@@ -1,59 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { EmptySearch, PaginationWithLimit, SearchQuery, ViewSelector } from '$lib/components';
|
||||
import { EmptyFilter, PaginationWithLimit, ViewSelector } from '$lib/components';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
// import { getServiceLimit } from '$lib/stores/billing';
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import Table from './table.svelte';
|
||||
import { queries } from '$lib/components/filters';
|
||||
import { QuickFilters } from '$lib/components/filters';
|
||||
import { Card, Empty, Layout } from '@appwrite.io/pink-svelte';
|
||||
import { View } from '$lib/helpers/load';
|
||||
import { columns } from './store';
|
||||
|
||||
export let data;
|
||||
|
||||
// const logs = getServiceLimit('logs');
|
||||
|
||||
const columns = writable<Column[]>([
|
||||
{ id: '$id', title: 'Log ID', type: 'string', show: true, width: 150 },
|
||||
|
||||
{
|
||||
id: 'requestPath',
|
||||
title: 'Path',
|
||||
type: 'string',
|
||||
show: true,
|
||||
width: 90,
|
||||
format: 'string'
|
||||
},
|
||||
{
|
||||
id: '$createdAt',
|
||||
title: 'Created',
|
||||
type: 'datetime',
|
||||
show: true,
|
||||
width: 120,
|
||||
format: 'datetime',
|
||||
elements: [
|
||||
{
|
||||
value: 5 * 60 * 1000,
|
||||
label: 'last 5 minutes'
|
||||
},
|
||||
{
|
||||
value: 60 * 60 * 1000,
|
||||
label: 'last 1 hour'
|
||||
},
|
||||
{
|
||||
value: 24 * 60 * 60 * 1000,
|
||||
label: 'last 24 hours'
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
let search = '';
|
||||
|
||||
onMount(() => {
|
||||
return sdk.forConsole.client.subscribe('console', (response) => {
|
||||
if (response.events.includes('sites.*.executions.*')) {
|
||||
@@ -65,7 +27,7 @@
|
||||
|
||||
<Container>
|
||||
<Layout.Stack direction="row" justifyContent="space-between">
|
||||
<SearchQuery search={data.search} placeholder="Search by ID" disabled={!data.logs.total} />
|
||||
<QuickFilters {columns} analyticsSource="site_logs" />
|
||||
{#if data.logs.total}
|
||||
<ViewSelector view={View.Table} {columns} hideView />
|
||||
{/if}
|
||||
@@ -80,16 +42,7 @@
|
||||
offset={data.offset}
|
||||
total={data.logs.total} />
|
||||
{:else if data?.query}
|
||||
<EmptySearch hidePages bind:search>
|
||||
<svelte:fragment slot="actions">
|
||||
<Button
|
||||
secondary
|
||||
on:click={() => {
|
||||
queries.clearAll();
|
||||
queries.apply();
|
||||
}}>Clear filters</Button>
|
||||
</svelte:fragment>
|
||||
</EmptySearch>
|
||||
<EmptyFilter resource="logs"></EmptyFilter>
|
||||
{:else}
|
||||
<Card.Base padding="none">
|
||||
<Empty
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const columns = writable<Column[]>([
|
||||
{ id: '$id', title: 'Log ID', type: 'string', show: true, width: 150 },
|
||||
{
|
||||
id: 'requestPath',
|
||||
title: 'Path',
|
||||
type: 'string',
|
||||
show: true,
|
||||
width: 90,
|
||||
format: 'string'
|
||||
},
|
||||
|
||||
{
|
||||
id: 'trigger',
|
||||
title: 'Trigger',
|
||||
type: 'string',
|
||||
show: false,
|
||||
width: 90,
|
||||
array: true,
|
||||
format: 'enum',
|
||||
elements: [
|
||||
{ value: 'http', label: 'HTTP' },
|
||||
{ value: 'schedule', label: 'Schedule' },
|
||||
{ value: 'event', label: 'Event' }
|
||||
],
|
||||
filter: false,
|
||||
hide: true
|
||||
},
|
||||
{
|
||||
id: 'requestMethod',
|
||||
title: 'Method',
|
||||
type: 'string',
|
||||
show: false,
|
||||
width: 70,
|
||||
array: true,
|
||||
format: 'enum',
|
||||
elements: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
|
||||
hide: true
|
||||
},
|
||||
{
|
||||
id: 'responseStatusCode',
|
||||
title: 'Status code',
|
||||
type: 'integer',
|
||||
show: false,
|
||||
width: 100,
|
||||
format: 'integer',
|
||||
elements: [
|
||||
{
|
||||
value: 299,
|
||||
label: 'Success (200-299)'
|
||||
},
|
||||
{
|
||||
value: 399,
|
||||
label: 'Redirect (300-399)'
|
||||
},
|
||||
{
|
||||
value: 499,
|
||||
label: 'Client error (400-499)'
|
||||
},
|
||||
{
|
||||
value: 599,
|
||||
label: 'Server error (500-599)'
|
||||
}
|
||||
],
|
||||
hide: true,
|
||||
filter: false //TODO: re-enable
|
||||
},
|
||||
|
||||
{
|
||||
id: 'duration',
|
||||
title: 'Duration',
|
||||
type: 'integer',
|
||||
show: true,
|
||||
width: 80,
|
||||
format: 'integer',
|
||||
elements: [
|
||||
{
|
||||
value: 1,
|
||||
label: 'more than 1 second'
|
||||
},
|
||||
{
|
||||
value: 5,
|
||||
label: 'more than 5 seconds'
|
||||
},
|
||||
{
|
||||
value: 30,
|
||||
label: 'more than 30 seconds'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: '$createdAt',
|
||||
title: 'Created',
|
||||
type: 'datetime',
|
||||
show: true,
|
||||
width: 120,
|
||||
format: 'datetime',
|
||||
elements: [
|
||||
{
|
||||
value: 5 * 60 * 1000,
|
||||
label: 'last 5 minutes'
|
||||
},
|
||||
{
|
||||
value: 60 * 60 * 1000,
|
||||
label: 'last 1 hour'
|
||||
},
|
||||
{
|
||||
value: 24 * 60 * 60 * 1000,
|
||||
label: 'last 24 hours'
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
Reference in new issue
Block a user