feat: create component for activity page

This commit is contained in:
Arman committed 2022-11-03 10:51:14 +01:00
1 parent a45c54a7fc
commit 24eb342fcd
7 files changed
+117 -469

No files matched your search

+101
View File
@@ -0,0 +1,101 @@
<script lang="ts">
import { Empty, Pagination, Trim } from '$lib/components';
import { Button } from '$lib/elements/forms';
import {
Table,
TableBody,
TableHeader,
TableRow,
TableCellHead,
TableCell,
TableCellText
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { toLocaleDateTime } from '$lib/helpers/date';
import { sdkForConsole } from '$lib/stores/sdk';
import { PAGE_LIMIT } from '$lib/constants';
import type { Models } from '@aw-labs/appwrite-console';
export let logs: Models.LogList;
export let path: string;
export let offset = 0;
const getBrowser = (clientCode: string) => {
return sdkForConsole.avatars.getBrowser(clientCode, 40, 40);
};
</script>
<Container>
{#if logs.total}
<Table>
<TableHeader>
<TableCellHead>Client</TableCellHead>
<TableCellHead>Event</TableCellHead>
<TableCellHead>Location</TableCellHead>
<TableCellHead>IP</TableCellHead>
<TableCellHead>Date</TableCellHead>
</TableHeader>
<TableBody>
{#each logs.logs as log}
<TableRow>
<TableCell title="Client">
{#if log.clientName}
<div class="u-flex u-cross-center u-gap-12">
<div class="avatar is-small">
<img
height="20"
width="20"
src={getBrowser(log.clientCode).toString()}
alt={log.clientName} />
</div>
<Trim>
{log.clientName}
{log.clientVersion}
on {log.osName}
{log.osVersion}
</Trim>
</div>
{:else}
<div class="u-flex u-cross-center u-gap-12">
<span class="avatar is-color-empty" />
<p class="text u-trim">Unknown</p>
</div>
{/if}
</TableCell>
<TableCellText title="Event">{log.event}</TableCellText>
<TableCellText title="Location">
{#if log.countryCode !== '--'}
{log.countryName}
{:else}
Unknown
{/if}
</TableCellText>
<TableCellText title="IP">{log.ip}</TableCellText>
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
</TableRow>
{/each}
</TableBody>
</Table>
{:else}
<Empty>
<div class="u-flex u-flex-vertical u-cross-center">
<div class="common-section">
<p>No logs available</p>
</div>
<div class="common-section">
<Button
external
secondary
href="https://appwrite.io/docs/server/authentication?sdk=nodejs-default#usersGetLogs">
Documentation
</Button>
</div>
</div>
</Empty>
{/if}
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {logs.total}</p>
<Pagination limit={PAGE_LIMIT} {path} {offset} sum={logs.total} />
</div>
</Container>
+1
View File
@@ -13,3 +13,4 @@ export { default as WizardStep } from './wizardStep.svelte';
export { default as Breadcrumbs } from './breadcrumbs.svelte';
export { default as Unauthenticated } from './unauthenticated.svelte';
export { default as Usage, type UsagePeriods } from './usage.svelte';
export { default as Activity } from './activity.svelte';
@@ -1,105 +1,9 @@
<script lang="ts">
import { Empty, Pagination } from '$lib/components';
import { Button } from '$lib/elements/forms';
import {
Table,
TableBody,
TableHeader,
TableRow,
TableCellHead,
TableCell,
TableCellText
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { toLocaleDateTime } from '$lib/helpers/date';
import { sdkForConsole } from '$lib/stores/sdk';
import { Activity } from '$lib/layout';
import type { PageData } from './$types';
import { PAGE_LIMIT } from '$lib/constants';
export let data: PageData;
const getBrowser = (clientCode: string) => {
return sdkForConsole.avatars.getBrowser(clientCode, 40, 40);
};
const path = '/console/account/activity';
</script>
<Container>
{#if data.logs.total}
<Table>
<TableHeader>
<TableCellHead>Date</TableCellHead>
<TableCellHead>Event</TableCellHead>
<TableCellHead>Client</TableCellHead>
<TableCellHead>Location</TableCellHead>
<TableCellHead>IP</TableCellHead>
</TableHeader>
<TableBody>
{#each data.logs.logs as log}
<TableRow>
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
<TableCellText title="Event">{log.event}</TableCellText>
<TableCell title="Client">
{#if log.clientName}
<div class="u-flex u-cross-center u-gap-12">
<div class="avatar is-small">
<img
height="20"
width="20"
src={getBrowser(log.clientCode).toString()}
alt={log.clientName} />
</div>
<p
class="text u-trim"
title={`${log.clientName} ${log.clientVersion} on ${log.osName} ${log.osVersion}`}>
{log.clientName}
{log.clientVersion}
on {log.osName}
{log.osVersion}
</p>
</div>
{:else}
<div class="u-flex u-cross-center u-gap-12">
<span class="avatar is-color-empty" />
<p class="text u-trim">Unknown</p>
</div>
{/if}
</TableCell>
<TableCellText title="Location">
{#if log.countryCode !== '--'}
{log.countryName}
{:else}
Unknown
{/if}
</TableCellText>
<TableCellText title="IP">{log.ip}</TableCellText>
</TableRow>
{/each}
</TableBody>
</Table>
{:else}
<Empty>
<div class="u-flex u-flex-vertical u-cross-center">
<div class="common-section">
<p>No logs available</p>
</div>
<div class="common-section">
<Button
external
secondary
href="https://appwrite.io/docs/server/authentication?sdk=nodejs-default#usersGetLogs"
>Documentation</Button>
</div>
</div>
</Empty>
{/if}
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.logs.total}</p>
<Pagination
limit={PAGE_LIMIT}
path="/console/account/activity"
offset={data.offset}
sum={data.logs.total} />
</div>
</Container>
<Activity {path} logs={data.logs} offset={data.offset} />
@@ -1,100 +1,10 @@
<script lang="ts">
import { Empty, Pagination } from '$lib/components';
import { Button } from '$lib/elements/forms';
import {
Table,
TableBody,
TableHeader,
TableRow,
TableCellHead,
TableCell,
TableCellText
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { toLocaleDateTime } from '$lib/helpers/date';
import { sdkForProject } from '$lib/stores/sdk';
import type { PageData } from './$types';
import { PAGE_LIMIT } from '$lib/constants';
import { page } from '$app/stores';
import { Activity } from '$lib/layout';
export let data: PageData;
const getBrowser = (clientCode: string) => sdkForProject.avatars.getBrowser(clientCode, 80, 80);
const path = `/console/project-${$page.params.project}/authentication/teams/team-${$page.params.team}/activity`;
</script>
<Container>
{#if data.logs.total}
<Table>
<TableHeader>
<TableCellHead>Client</TableCellHead>
<TableCellHead>Event</TableCellHead>
<TableCellHead>Location</TableCellHead>
<TableCellHead>IP</TableCellHead>
<TableCellHead>Date</TableCellHead>
</TableHeader>
<TableBody>
{#each data.logs.logs as log}
<TableRow>
<TableCell title="Client">
{#if log.clientName}
<div class="u-flex u-cross-center u-gap-12">
<div class="avatar is-small">
<img
height="20"
width="20"
src={getBrowser(log.clientCode).toString()}
alt={log.clientName} />
</div>
<p class="text u-trim">
{log.clientName}
{log.clientVersion}
on {log.osName}
{log.osVersion}
</p>
</div>
{:else}
<div class="u-flex u-cross-center u-gap-12">
<p class="text u-trim">
<span class="avatar is-color-empty" />
Unknown
</p>
</div>
{/if}
</TableCell>
<TableCellText title="Event">{log.event}</TableCellText>
<TableCellText title="Location">
{#if log.countryCode !== '--'}
{log.countryName}
{:else}
Unknown
{/if}
</TableCellText>
<TableCellText title="IP">{log.ip}</TableCellText>
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
</TableRow>
{/each}
</TableBody>
</Table>
{:else}
<Empty>
<div class="u-flex u-flex-vertical u-cross-center">
<div class="common-section">
<p>No logs available</p>
</div>
<div class="common-section">
<Button external secondary href="https://appwrite.io/docs/server/teams">
Documentation
</Button>
</div>
</div>
</Empty>
{/if}
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.logs.total}</p>
<Pagination
limit={PAGE_LIMIT}
path={`/console/project-${$page.params.project}/authentication/teams/team-${$page.params.team}/activity`}
offset={data.offset}
sum={data.logs.total} />
</div>
</Container>
<Activity {path} logs={data.logs} offset={data.offset} />
@@ -1,98 +1,10 @@
<script lang="ts">
import { Empty, Pagination } from '$lib/components';
import { Button } from '$lib/elements/forms';
import {
Table,
TableBody,
TableHeader,
TableRow,
TableCellHead,
TableCell,
TableCellText
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { toLocaleDateTime } from '$lib/helpers/date';
import { sdkForProject } from '$lib/stores/sdk';
import type { PageData } from './$types';
import { PAGE_LIMIT } from '$lib/constants';
import { page } from '$app/stores';
import { Activity } from '$lib/layout';
export let data: PageData;
const getBrowser = (clientCode: string) => sdkForProject.avatars.getBrowser(clientCode, 80, 80);
const path = `/console/project-${$page.params.project}/authentication/user-${$page.params.user}/activity`;
</script>
<Container>
{#if data.logs.total}
<Table>
<TableHeader>
<TableCellHead>Client</TableCellHead>
<TableCellHead>Event</TableCellHead>
<TableCellHead>Location</TableCellHead>
<TableCellHead>IP</TableCellHead>
<TableCellHead>Date</TableCellHead>
</TableHeader>
<TableBody>
{#each data.logs.logs as log}
<TableRow>
<TableCell title="Client">
{#if log.clientName}
<div class="u-flex u-cross-center u-gap-12">
<div class="avatar is-small">
<img
height="20"
width="20"
src={getBrowser(log.clientCode).toString()}
alt={log.clientName} />
</div>
<p class="text u-trim">
{log.clientName}
{log.clientVersion}
on {log.osName}
{log.osVersion}
</p>
</div>
{:else}
<div class="u-flex u-cross-center u-gap-12">
<p class="text u-trim">
<span class="avatar is-color-empty" />
Unknown
</p>
</div>
{/if}
</TableCell>
<TableCellText title="Event">{log.event}</TableCellText>
<TableCellText title="Location">
{#if log.countryCode !== '--'}
{log.countryName}
{:else}
Unknown
{/if}
</TableCellText>
<TableCellText title="IP">{log.ip}</TableCellText>
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
</TableRow>
{/each}
</TableBody>
</Table>
{:else}
<Empty single>
<p>No logs available</p>
<Button
external
secondary
href="https://appwrite.io/docs/server/authentication?sdk=nodejs-default#usersGetLogs"
>Documentation</Button>
</Empty>
{/if}
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.logs.total}</p>
<Pagination
limit={PAGE_LIMIT}
path={`/console/project-${$page.params.project}/authentication/user-${$page.params.user}/activity`}
offset={data.offset}
sum={data.logs.total} />
</div>
</Container>
<Activity {path} logs={data.logs} offset={data.offset} />
@@ -1,100 +1,10 @@
<script lang="ts">
import { Empty, Pagination } from '$lib/components';
import { Button } from '$lib/elements/forms';
import {
Table,
TableBody,
TableHeader,
TableRow,
TableCellHead,
TableCell,
TableCellText
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { toLocaleDateTime } from '$lib/helpers/date';
import { sdkForProject } from '$lib/stores/sdk';
import type { PageData } from './$types';
import { PAGE_LIMIT } from '$lib/constants';
import { page } from '$app/stores';
import { Activity } from '$lib/layout';
export let data: PageData;
const getBrowser = (clientCode: string) => sdkForProject.avatars.getBrowser(clientCode, 80, 80);
const path = `/console/project-${$page.params.project}/authentication/databases/database-${$page.params.team}/collection-${$page.params.collection}/document-${$page.params.document}/activity`;
</script>
<Container>
{#if data.logs.total}
<Table>
<TableHeader>
<TableCellHead>Client</TableCellHead>
<TableCellHead>Event</TableCellHead>
<TableCellHead>Location</TableCellHead>
<TableCellHead>IP</TableCellHead>
<TableCellHead>Date</TableCellHead>
</TableHeader>
<TableBody>
{#each data.logs.logs as log}
<TableRow>
<TableCell title="Client">
{#if log.clientName}
<div class="u-flex u-cross-center u-gap-12">
<div class="avatar is-small">
<img
height="20"
width="20"
src={getBrowser(log.clientCode).toString()}
alt={log.clientName} />
</div>
<p class="text u-trim">
{log.clientName}
{log.clientVersion}
on {log.osName}
{log.osVersion}
</p>
</div>
{:else}
<div class="u-flex u-cross-center u-gap-12">
<p class="text u-trim">
<span class="avatar is-color-empty" />
Unknown
</p>
</div>
{/if}
</TableCell>
<TableCellText title="Event">{log.event}</TableCellText>
<TableCellText title="Location">
{#if log.countryCode !== '--'}
{log.countryName}
{:else}
Unknown
{/if}
</TableCellText>
<TableCellText title="IP">{log.ip}</TableCellText>
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
</TableRow>
{/each}
</TableBody>
</Table>
{:else}
<Empty>
<div class="u-flex u-flex-vertical u-cross-center">
<div class="common-section">
<p>No logs available</p>
</div>
<div class="common-section">
<Button external secondary href="https://appwrite.io/docs/server/database">
Documentation
</Button>
</div>
</div>
</Empty>
{/if}
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.logs.total}</p>
<Pagination
limit={PAGE_LIMIT}
path={`/console/project-${$page.params.project}/authentication/databases/database-${$page.params.team}/collection-${$page.params.collection}/document-${$page.params.document}/activity`}
offset={data.offset}
sum={data.logs.total} />
</div>
</Container>
<Activity {path} logs={data.logs} offset={data.offset} />
@@ -1,100 +1,10 @@
<script lang="ts">
import { Empty, Pagination } from '$lib/components';
import { Button } from '$lib/elements/forms';
import {
Table,
TableBody,
TableHeader,
TableRow,
TableCellHead,
TableCell,
TableCellText
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { toLocaleDateTime } from '$lib/helpers/date';
import { sdkForProject } from '$lib/stores/sdk';
import type { PageData } from './$types';
import { PAGE_LIMIT } from '$lib/constants';
import { page } from '$app/stores';
import { Activity } from '$lib/layout';
export let data: PageData;
const getBrowser = (clientCode: string) => sdkForProject.avatars.getBrowser(clientCode, 80, 80);
const path = `/console/project-${$page.params.project}/authentication/databases/database-${$page.params.team}/collection-${$page.params.collection}/document-${$page.params.document}/activity`;
</script>
<Container>
{#if data.logs.total}
<Table>
<TableHeader>
<TableCellHead>Client</TableCellHead>
<TableCellHead>Event</TableCellHead>
<TableCellHead>Location</TableCellHead>
<TableCellHead>IP</TableCellHead>
<TableCellHead>Date</TableCellHead>
</TableHeader>
<TableBody>
{#each data.logs.logs as log}
<TableRow>
<TableCell title="Client">
{#if log.clientName}
<div class="u-flex u-cross-center u-gap-12">
<div class="avatar is-small">
<img
height="20"
width="20"
src={getBrowser(log.clientCode).toString()}
alt={log.clientName} />
</div>
<p class="text u-trim">
{log.clientName}
{log.clientVersion}
on {log.osName}
{log.osVersion}
</p>
</div>
{:else}
<div class="u-flex u-cross-center u-gap-12">
<p class="text u-trim">
<span class="avatar is-color-empty" />
Unknown
</p>
</div>
{/if}
</TableCell>
<TableCellText title="Event">{log.event}</TableCellText>
<TableCellText title="Location">
{#if log.countryCode !== '--'}
{log.countryName}
{:else}
Unknown
{/if}
</TableCellText>
<TableCellText title="IP">{log.ip}</TableCellText>
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
</TableRow>
{/each}
</TableBody>
</Table>
{:else}
<Empty>
<div class="u-flex u-flex-vertical u-cross-center">
<div class="common-section">
<p>No logs available</p>
</div>
<div class="common-section">
<Button external secondary href="https://appwrite.io/docs/server/database">
Documentation
</Button>
</div>
</div>
</Empty>
{/if}
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.logs.total}</p>
<Pagination
limit={PAGE_LIMIT}
path={`/console/project-${$page.params.project}/authentication/databases/database-${$page.params.team}/collection-${$page.params.collection}/document-${$page.params.document}/activity`}
offset={data.offset}
sum={data.logs.total} />
</div>
</Container>
<Activity {path} logs={data.logs} offset={data.offset} />