feat: initialize team activitya & members page

This commit is contained in:
Arman committed 2022-06-07 15:13:18 +02:00
1 parent 6b918bac05
commit 1b2a2acd8f
2 files changed
+159

No files matched your search

@@ -0,0 +1,80 @@
<script lang="ts">
import { page } from '$app/stores';
import { Empty, Pagination } from '$lib/components';
import { Button } from '$lib/elements/forms';
import {
Table,
TableBody,
TableHeader,
TableRow,
TableCellHead,
TableCellText
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { sdkForProject } from '$lib/stores/sdk';
let offset = 0;
const limit = 25;
$: request = sdkForProject.teams.listLogs($page.params.team, limit, offset);
</script>
<Container>
{#await request}
<div aria-busy="true" />
{:then response}
{#if response.total}
<Table>
<TableHeader>
<TableCellHead>Date</TableCellHead>
<TableCellHead>Event</TableCellHead>
<TableCellHead>Client</TableCellHead>
<TableCellHead>Location</TableCellHead>
<TableCellHead>IP</TableCellHead>
</TableHeader>
<TableBody>
{#each response.logs as log}
<TableRow>
<TableCellText title="Date">{log.time}</TableCellText>
<TableCellText title="Event">{log.event}</TableCellText>
<TableCellText title="Client">
{log.clientName}
{log.clientVersion} on {log.osName}
{log.osVersion}
</TableCellText>
<TableCellText title="Location">
{#if log.countryCode !== '--'}
<img
src={sdkForProject.avatars
.getFlag(log.countryCode, 32, 32)
.toString()}
alt={log.countryName} />{log.countryName}
{:else}
Unknown
{/if}
</TableCellText>
<TableCellText title="IP">{log.ip}</TableCellText>
</TableRow>
{/each}
</TableBody>
</Table>
<Pagination {limit} bind:offset sum={response.total} />
{:else}
<Empty centered>
<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 common-section u-main-space-between">
<p class="text">Total results: {response.total}</p>
<Pagination {limit} bind:offset sum={response.total} />
</div>
{/await}
</Container>
@@ -0,0 +1,79 @@
<script lang="ts">
import { page } from '$app/stores';
import { Card, Pagination, Empty } from '$lib/components';
import {
Table,
TableHeader,
TableBody,
TableRow,
TableCell,
TableCellHead,
TableCellLink,
TableCellText
} from '$lib/elements/table';
import { Button } from '$lib/elements/forms';
import { Container } from '$lib/layout';
// import { addNotification } from '$lib/stores/notifications';
import { sdkForProject } from '$lib/stores/sdk';
const getAvatar = (name: string) => sdkForProject.avatars.getInitials(name, 30, 30).toString();
let offset = 0;
const limit = 25;
$: request = sdkForProject.teams.getMemberships($page.params.team);
</script>
<Container>
{#await request}
<div aria-busy="true" />
{:then response}
{#if response.total}
<Card>
<Table>
<TableHeader>
<TableCellHead width={30} />
<TableCellHead>Name</TableCellHead>
<TableCellHead>Role</TableCellHead>
<TableCellHead width={30} />
</TableHeader>
<TableBody>
{#each response.memberships as membership}
<TableRow>
<TableCell onlyDesktop>
<div class="image">
<img
class="avatar"
width="30"
height="30"
src={getAvatar(membership.userName)}
alt={membership.userName} />
</div>
</TableCell>
<TableCellLink href="#" title="Name">
{membership.userName ? membership.userName : 'n/a'}
</TableCellLink>
<TableCellText title="Role">ROLE</TableCellText>
</TableRow>
{/each}
</TableBody>
</Table>
</Card>
{:else}
<Empty centered>
<div class="u-flex u-flex-vertical u-cross-center">
<div class="common-section">
<p>No members available</p>
</div>
<div class="common-section">
<Button external secondary>Documentation</Button>
</div>
</div>
</Empty>
{/if}
<div class="u-flex common-section u-main-space-between">
<p class="text">Total results: {response.total}</p>
<Pagination {limit} bind:offset sum={response.total} />
</div>
{/await}
</Container>