mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: org usage
This commit is contained in:
1 parent
2d44aa9044
commit
5b87816fb2
5 files changed
+226
-79
No files matched your search
+61
-18
@@ -260,39 +260,82 @@ export const eventServices: Array<EventService> = [
|
||||
|
||||
export const usageRates = {
|
||||
'tier-0': [
|
||||
{ resource: 'Organization members', limit: 'Unlimited', rate: '$20/member' },
|
||||
{ resource: 'Bandwidth', limit: '1TB', rate: '$0.04/GB' },
|
||||
{ resource: 'Storage', limit: '150GB', rate: '$0.025/GB' },
|
||||
{ resource: 'Organization members', amount: 'Unlimited', unit: '', rate: '$20/member' },
|
||||
{ resource: 'Bandwidth', amount: 1, unit: 'TB', rate: '$0.04/GB' },
|
||||
{ resource: 'Storage', amount: 150, unit: 'GB', rate: '$0.025/GB' },
|
||||
{
|
||||
resource: 'Function executions',
|
||||
limit: '3,500,000 executions',
|
||||
amount: 3500000,
|
||||
unit: 'executions',
|
||||
rate: '$2/1M executions'
|
||||
},
|
||||
{ resource: 'Active users', limit: '200,000 AU', rate: '$0.0012/user' },
|
||||
{ resource: 'Concurrent connections', limit: '750 connections', rate: '$5/1K connections' }
|
||||
{
|
||||
resource: 'Active users',
|
||||
amount: 200000,
|
||||
unit: 'AU',
|
||||
rate: '$0.0012/user'
|
||||
},
|
||||
{
|
||||
resource: 'Concurrent connections',
|
||||
amount: 750,
|
||||
unit: 'connections',
|
||||
rate: '$5/1K connections'
|
||||
}
|
||||
],
|
||||
'tier-1': [
|
||||
{ resource: 'Organization members', limit: 'Unlimited', rate: '$20/member' },
|
||||
{ resource: 'Bandwidth', limit: '1TB', rate: '$0.04/GB' },
|
||||
{ resource: 'Storage', limit: '150GB', rate: '$0.025/GB' },
|
||||
{
|
||||
resource: 'Organization members',
|
||||
amount: 'Unlimited',
|
||||
unit: '',
|
||||
rate: '$20/member'
|
||||
},
|
||||
{ resource: 'Bandwidth', amount: 1, unit: 'TB', rate: '$0.04/GB' },
|
||||
{ resource: 'Storage', amount: 150, unit: 'GB', rate: '$0.025/GB' },
|
||||
{
|
||||
resource: 'Function executions',
|
||||
limit: '3,500,000 executions',
|
||||
amount: 3500000,
|
||||
unit: 'executions',
|
||||
rate: '$2/1M executions'
|
||||
},
|
||||
{ resource: 'Active users', limit: '200,000 AU', rate: '$0.0012/user' },
|
||||
{ resource: 'Concurrent connections', limit: '750 connections', rate: '$5/1K connections' }
|
||||
{
|
||||
resource: 'Active users',
|
||||
amount: 200000,
|
||||
unit: 'AU',
|
||||
rate: '$0.0012/user'
|
||||
},
|
||||
{
|
||||
resource: 'Concurrent connections',
|
||||
amount: 750,
|
||||
unit: 'connections',
|
||||
rate: '$5/1K connections'
|
||||
}
|
||||
],
|
||||
'tier-2': [
|
||||
{ resource: 'Organization members', limit: 'Unlimited', rate: '$20/member' },
|
||||
{ resource: 'Bandwidth', limit: '1TB', rate: '$0.04/GB' },
|
||||
{ resource: 'Storage', limit: '150GB', rate: '$0.025/GB' },
|
||||
{
|
||||
resource: 'Organization members',
|
||||
amount: 'Unlimited',
|
||||
unit: '',
|
||||
rate: '$20/member'
|
||||
},
|
||||
{ resource: 'Bandwidth', amount: 1, unit: 'TB', rate: '$0.04/GB' },
|
||||
{ resource: 'Storage', amount: 150, unit: 'GB', rate: '$0.025/GB' },
|
||||
{
|
||||
resource: 'Function executions',
|
||||
limit: '3,500,000 executions',
|
||||
amount: 3500000,
|
||||
unit: 'executions',
|
||||
rate: '$2/1M executions'
|
||||
},
|
||||
{ resource: 'Active users', limit: '200,000 AU', rate: '$0.0012/user' },
|
||||
{ resource: 'Concurrent connections', limit: '750 connections', rate: '$5/1K connections' }
|
||||
{
|
||||
resource: 'Active users',
|
||||
amount: 200000,
|
||||
unit: 'AU',
|
||||
rate: '$0.0012/user'
|
||||
},
|
||||
{
|
||||
resource: 'Concurrent connections',
|
||||
amount: 750,
|
||||
unit: 'connections',
|
||||
rate: '$5/1K connections'
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -236,7 +236,10 @@ export class Billing {
|
||||
);
|
||||
}
|
||||
|
||||
async setOrganizationPaymentMethod(organizationId: string, paymentMethodId: string) {
|
||||
async setOrganizationPaymentMethod(
|
||||
organizationId: string,
|
||||
paymentMethodId: string
|
||||
): Promise<Organization> {
|
||||
const path = `/organizations/${organizationId}/payment-method`;
|
||||
const params = {
|
||||
organizationId,
|
||||
@@ -253,7 +256,10 @@ export class Billing {
|
||||
);
|
||||
}
|
||||
|
||||
async setOrganizationPaymentMethodBackup(organizationId: string, paymentMethodId: string) {
|
||||
async setOrganizationPaymentMethodBackup(
|
||||
organizationId: string,
|
||||
paymentMethodId: string
|
||||
): Promise<Organization> {
|
||||
const path = `/organizations/${organizationId}/payment-method/backup`;
|
||||
const params = {
|
||||
organizationId,
|
||||
|
||||
@@ -74,46 +74,46 @@
|
||||
}
|
||||
}
|
||||
|
||||
// async function removeDefaultMethod(){
|
||||
// try {
|
||||
// await sdk.forConsole.billing.remove(
|
||||
// $organization.$id,
|
||||
// $organization.paymentMethodId
|
||||
// );
|
||||
// addNotification({
|
||||
// type: 'success',
|
||||
// message: `The payment method has been removed from ${$organization.name}`
|
||||
// });
|
||||
// trackEvent(Submit.OrganizationPaymentRemoved);
|
||||
// invalidate(Dependencies.ORGANIZATION);
|
||||
// } catch (error) {
|
||||
// addNotification({
|
||||
// type: 'error',
|
||||
// message: error.message
|
||||
// });
|
||||
// trackError(error, Submit.OrganizationPaymentRemoved);
|
||||
// }
|
||||
// }
|
||||
// async function removeBackuptMethod(){
|
||||
// try {
|
||||
// await sdk.forConsole.billing.remove(
|
||||
// $organization.$id,
|
||||
// $organization.paymentMethodId
|
||||
// );
|
||||
// addNotification({
|
||||
// type: 'success',
|
||||
// message: `The payment method has been removed from ${$organization.name}`
|
||||
// });
|
||||
// trackEvent(Submit.OrganizationBackupPaymentRemoved);
|
||||
// invalidate(Dependencies.ORGANIZATION);
|
||||
// } catch (error) {
|
||||
// addNotification({
|
||||
// type: 'error',
|
||||
// message: error.message
|
||||
// });
|
||||
// trackError(error, Submit.OrganizationBackupPaymentRemoved);
|
||||
// }
|
||||
// }
|
||||
async function removeDefaultMethod() {
|
||||
if (!$organization.paymentMethodId || !$organization.backupPaymentMethodId) return;
|
||||
|
||||
try {
|
||||
await sdk.forConsole.billing.setOrganizationPaymentMethod($organization.$id, null);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `The payment method has been removed from ${$organization.name}`
|
||||
});
|
||||
trackEvent(Submit.OrganizationPaymentRemoved);
|
||||
invalidate(Dependencies.ORGANIZATION);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.OrganizationPaymentRemoved);
|
||||
}
|
||||
}
|
||||
async function removeBackuptMethod() {
|
||||
if (!$organization.paymentMethodId || !$organization.backupPaymentMethodId) return;
|
||||
try {
|
||||
await sdk.forConsole.billing.setOrganizationPaymentMethodBackup(
|
||||
$organization.$id,
|
||||
undefined
|
||||
);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `The payment method has been removed from ${$organization.name}`
|
||||
});
|
||||
trackEvent(Submit.OrganizationBackupPaymentRemoved);
|
||||
invalidate(Dependencies.ORGANIZATION);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.OrganizationBackupPaymentRemoved);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
@@ -126,10 +126,34 @@
|
||||
<svelte:fragment slot="aside">
|
||||
<h4 class="u-bold body-text-2">Default</h4>
|
||||
{#if $organization?.paymentMethodId}
|
||||
<CreditCardInfo
|
||||
isBox
|
||||
paymentMethod={defaultPaymentMethod}
|
||||
isDeleteDisabled={!$organization?.backupPaymentMethodId} />
|
||||
<CreditCardInfo isBox paymentMethod={defaultPaymentMethod}>
|
||||
<DropList bind:show={showDropdown} placement="bottom-start" noArrow>
|
||||
<Button
|
||||
round
|
||||
text
|
||||
ariaLabel="More options"
|
||||
on:click={() => {
|
||||
showDropdown = !showDropdown;
|
||||
}}>
|
||||
<span class="icon-dots-horizontal" aria-hidden="true" />
|
||||
</Button>
|
||||
<svelte:fragment slot="list">
|
||||
<DropListItem
|
||||
icon="pencil"
|
||||
on:click={() => {
|
||||
console.log('test');
|
||||
}}>
|
||||
Edit
|
||||
</DropListItem>
|
||||
<DropListItem
|
||||
disabled={!$organization?.backupPaymentMethodId}
|
||||
icon="trash"
|
||||
on:click={removeDefaultMethod}>
|
||||
Delete
|
||||
</DropListItem>
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
</CreditCardInfo>
|
||||
{:else}
|
||||
<article class="card u-grid u-cross-center u-width-full-line dashed">
|
||||
<div class="u-flex u-cross-center u-flex-vertical u-main-center u-flex">
|
||||
@@ -169,7 +193,34 @@
|
||||
{/if}
|
||||
<h4 class="u-bold body-text-2">Backup</h4>
|
||||
{#if $organization?.backupPaymentMethodId}
|
||||
<CreditCardInfo paymentMethod={backupPaymentMethod} />
|
||||
<CreditCardInfo isBox paymentMethod={backupPaymentMethod}>
|
||||
<DropList bind:show={showDropdownBackup} placement="bottom-start" noArrow>
|
||||
<Button
|
||||
round
|
||||
text
|
||||
ariaLabel="More options"
|
||||
on:click={() => {
|
||||
showDropdownBackup = !showDropdownBackup;
|
||||
}}>
|
||||
<span class="icon-dots-horizontal" aria-hidden="true" />
|
||||
</Button>
|
||||
<svelte:fragment slot="list">
|
||||
<DropListItem
|
||||
icon="pencil"
|
||||
on:click={() => {
|
||||
console.log('test');
|
||||
}}>
|
||||
Edit
|
||||
</DropListItem>
|
||||
<DropListItem
|
||||
disabled={!$organization?.paymentMethodId}
|
||||
icon="trash"
|
||||
on:click={removeBackuptMethod}>
|
||||
Delete
|
||||
</DropListItem>
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
</CreditCardInfo>
|
||||
{:else}
|
||||
<article class="card u-grid u-cross-center u-width-full-line dashed">
|
||||
<div class="u-flex u-cross-center u-flex-vertical u-main-center u-flex">
|
||||
|
||||
@@ -1,16 +1,34 @@
|
||||
<script lang="ts">
|
||||
import { Container } from '$lib/layout';
|
||||
import { CardGrid, Heading, ProgressBarBig, ProjectUsage } from '$lib/components';
|
||||
import { CardGrid, Heading, ProgressBarBig } from '$lib/components';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { usageRates } from '$lib/constants';
|
||||
import { base } from '$app/paths';
|
||||
|
||||
// export let data;
|
||||
export let data;
|
||||
|
||||
$: rates = usageRates[$organization.billingPlan];
|
||||
|
||||
$: bandwidth = data.usage.aggregations.reduce((acc, curr) => acc + curr.usageBandwidth, 0);
|
||||
$: bandwidthLimit = rates.filter((r) => r.resource === 'Bandwidth')[0].amount;
|
||||
|
||||
$: users = data.usage.aggregations.reduce((acc, curr) => acc + curr.usageUsers, 0);
|
||||
$: usersLimit = rates.filter((r) => r.resource === 'Active users')[0].amount;
|
||||
|
||||
$: executions = data.usage.aggregations.reduce((acc, curr) => acc + curr.usageExecutions, 0);
|
||||
$: executionsLimit = rates.filter((r) => r.resource === 'Function executions')[0].amount;
|
||||
|
||||
$: storage = data.usage.aggregations.reduce((acc, curr) => acc + curr.usageStorage, 0);
|
||||
$: storageLimit = rates.filter((r) => r.resource === 'Storage')[0].amount;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<Heading tag="h2" size="5">Usage</Heading>
|
||||
<div class="u-flex u-main-space-between common-section">
|
||||
<p class="text">
|
||||
Metrics are estimates updated every 24 hours and may not accurately reflect your
|
||||
invoice.
|
||||
If you exceed the limits of the Free plan, services for your projects may be disrupted. <a
|
||||
href={`${base}/console/`}>Upgrade for greater capacity</a
|
||||
>.
|
||||
</p>
|
||||
<div class="u-flex u-gap-8">
|
||||
<p class="text">Usage period:</p>
|
||||
@@ -18,14 +36,27 @@
|
||||
JANUARY 2021
|
||||
</div>
|
||||
</div>
|
||||
<ul
|
||||
class="grid-box common-section u-margin-block-start-32"
|
||||
style="--grid-gap:1.5rem; --grid-item-size:25rem;'}">
|
||||
<!-- TODO: show correct data -->
|
||||
{#each [] as project}
|
||||
<ProjectUsage title={project?.name} data={project?.projectUsage} />
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Bandwidth</Heading>
|
||||
|
||||
<p class="text">
|
||||
Calculated for all bandwidth used across all projects in your organization.
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<ProgressBarBig unit="TB" max={bandwidthLimit} used={bandwidth} />
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Active users</Heading>
|
||||
|
||||
<p class="text">Active users across all projects in your organization.</p>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<ProgressBarBig unit="AU" max={usersLimit} used={users} />
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Function executions</Heading>
|
||||
@@ -35,7 +66,23 @@
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<ProgressBarBig unit="executions" max={750000} used={125000} />
|
||||
<ProgressBarBig unit="executions" max={executionsLimit} used={executions} />
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Storage</Heading>
|
||||
|
||||
<p class="text">
|
||||
Calculated for all storage operations across all projects in your organization.
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<ProgressBarBig unit="GB" max={storageLimit} used={storage} />
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<p class="text common-section u-color-text-gray">
|
||||
Metrics are estimates updated every 24 hours and may not accurately reflect your invoice.
|
||||
</p>
|
||||
</Container>
|
||||
@@ -39,7 +39,7 @@
|
||||
{#each usageRates[tier] as usage}
|
||||
<TableRow>
|
||||
<TableCellText title="resource">{usage.resource}</TableCellText>
|
||||
<TableCellText title="limit">{usage.limit}</TableCellText>
|
||||
<TableCellText title="limit">{usage.amount}{usage?.unit}</TableCellText>
|
||||
<TableCellText title="rate">{usage.rate}</TableCellText>
|
||||
</TableRow>
|
||||
{/each}
|
||||
|
||||
Reference in new issue
Block a user