Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import { organization } from '$lib/stores/organization';
import type { Aggregation, CreditList, Invoice, Plan } from '$lib/sdk/billing';
import { abbreviateNumber, formatCurrency, formatNumberWithCommas } from '$lib/helpers/numbers';
import { humanFileSize } from '$lib/helpers/sizeConvertion';
import { BillingPlan } from '$lib/constants';
import { Click, trackEvent } from '$lib/actions/analytics';
import {
Expand Down Expand Up @@ -35,21 +34,6 @@
new Date($organization?.billingStartDate).getTime() - today.getTime() > 0 &&
$plansInfo.get($organization.billingPlan)?.trialDays;
const extraUsage = currentInvoice ? currentInvoice.amount - currentPlan?.price : 0;
function usageNameToLabel(name: string): string {
switch (name) {
case 'executions':
return 'Executions';
case 'storage':
return 'Storage';
case 'users':
return 'Users';
case 'bandwidth':
return 'Bandwidth';
default:
return '';
}
}
</script>

{#if $organization}
Expand Down Expand Up @@ -112,69 +96,29 @@
{#if i > 0 || currentAggregation.additionalMembers}
<Divider />
{/if}
{#if ['storage', 'bandwidth'].includes(excess.name)}
{@const excessValue = humanFileSize(excess.value)}
<Layout.Stack gap="xxxs">
<Layout.Stack
direction="row"
justifyContent="space-between">
<Typography.Text
color="--fgcolor-neutral-primary"
>{usageNameToLabel(
excess.name
)}</Typography.Text>
<Typography.Text
>{formatCurrency(
excess.amount
)}</Typography.Text>
</Layout.Stack>
<Layout.Stack direction="row">
<Layout.Stack direction="row">
<Tooltip
placement="bottom"
disabled={excess.value <=
1_000_000_000}>
<svelte:fragment slot="tooltip">
{formatNumberWithCommas(
excess.value ?? 0
)} bytes
</svelte:fragment>
<span
>{excessValue.value ??
0}{excessValue.unit}</span>
</Tooltip>
</Layout.Stack>
</Layout.Stack>

<Layout.Stack gap="xxxs">
<Layout.Stack
direction="row"
justifyContent="space-between">
<Typography.Text color="--fgcolor-neutral-primary">
{excess.name}
</Typography.Text>
<Typography.Text>
{formatCurrency(excess.amount)}
</Typography.Text>
</Layout.Stack>
{/if}
{#if ['users', 'executions'].includes(excess.name)}
<Layout.Stack gap="xxxs">
<Layout.Stack
direction="row"
justifyContent="space-between">
<Typography.Text
color="--fgcolor-neutral-primary"
>{usageNameToLabel(
excess.name
)}</Typography.Text>
<Typography.Text
>{formatCurrency(
excess.amount
)}</Typography.Text>
</Layout.Stack>
<Layout.Stack direction="row">
<Tooltip
placement="bottom"
disabled={excess.value <= 1000}>
<svelte:fragment slot="tooltip">
{formatNumberWithCommas(excess.value)}
</svelte:fragment>
<span
>{abbreviateNumber(excess.value)}</span>
</Tooltip>
</Layout.Stack>
<Layout.Stack direction="row">
<Tooltip
placement="bottom"
disabled={excess.value <= 1000}>
<svelte:fragment slot="tooltip">
{formatNumberWithCommas(excess.value)}
</svelte:fragment>
<span>{abbreviateNumber(excess.value)}</span>
</Tooltip>
</Layout.Stack>
{/if}
</Layout.Stack>
{/each}
{/if}
</Layout.Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { onMount } from 'svelte';
import { Accordion, Table } from '@appwrite.io/pink-svelte';
import { base } from '$app/paths';
import type { PageData } from './$types';

type Metric =
| 'users'
Expand All @@ -21,7 +22,7 @@

type DatabaseOperationMetric = Extract<Metric, 'databasesReads' | 'databasesWrites'>;

export let data;
export let data: PageData;
export let projects: OrganizationUsage['projects'];
export let metric: Metric | undefined = undefined;
export let estimate: Estimate | undefined = undefined;
Expand Down Expand Up @@ -137,7 +138,7 @@
{#if !$canSeeProjects}
<Table.Row.Base {root}>
<Table.Cell column="project" {root}>
{data.projectNames[project.projectId]?.name ?? 'Unknown'}
{data.projects[project.projectId]?.name ?? 'Unknown'}
</Table.Cell>
<Table.Cell column="reads" {root}>
{format(project.databasesReads ?? 0)}
Expand All @@ -155,7 +156,7 @@
{:else}
<Table.Row.Link href={getProjectUsageLink(project.projectId)} {root}>
<Table.Cell column="project" {root}>
{data.projectNames[project.projectId]?.name ?? 'Unknown'}
{data.projects[project.projectId]?.name ?? 'Unknown'}
</Table.Cell>
<Table.Cell column="reads" {root}>
{format(project.databasesReads ?? 0)}
Expand Down