mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: excess modal
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import ChangeOrganizationTierCloud from '../changeOrganizationTierCloud.svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { last } from '$lib/helpers/array';
|
||||
|
||||
export let show = false;
|
||||
const plan = $plansInfo.plans.find((plan) => plan.$id === $organization.billingPlan);
|
||||
@@ -30,18 +31,24 @@
|
||||
});
|
||||
|
||||
function calculateExcess() {
|
||||
const totBandwidth = usage?.bandwidth?.length > 0 ? usage.bandwidth[0].value : 0;
|
||||
const totUsers = usage?.users?.length > 0 ? usage.users[0].value : 0;
|
||||
const totBandwidth = usage?.bandwidth?.length > 0 ? last(usage.bandwidth).value : 0;
|
||||
const totUsers = usage?.users?.length > 0 ? last(usage.users).value : 0;
|
||||
|
||||
excess = {
|
||||
bandwidth: totBandwidth > plan.bandwidth ? totBandwidth - plan.bandwidth : 0,
|
||||
storage:
|
||||
usage?.storage[0] > sizeToBytes(plan.storage, 'GB')
|
||||
? usage.storage[0] - plan.storage
|
||||
usage?.storage > sizeToBytes(plan.storage, 'GB')
|
||||
? usage.storage - sizeToBytes(plan.storage, 'GB')
|
||||
: 0,
|
||||
users: totUsers > plan.users ? totUsers - plan.users : 0,
|
||||
users: totUsers > (plan.users || Infinity) ? totUsers - plan.users : 0,
|
||||
executions:
|
||||
usage?.executions[0] > plan.executions ? usage.executions[0] - plan.executions : 0,
|
||||
members: members?.total > plan.members ? members.total - (plan.members || Infinity) : 0
|
||||
usage?.executions > sizeToBytes(plan.executions, 'GB')
|
||||
? usage.executions - sizeToBytes(plan.executions, 'GB')
|
||||
: 0,
|
||||
members:
|
||||
members?.total > (plan.members || Infinity)
|
||||
? members.total - (plan.members || Infinity)
|
||||
: 0
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { humanFileSize } from '$lib/helpers/sizeConvertion';
|
||||
import { abbreviateNumber } from '$lib/helpers/numbers';
|
||||
import { formatNum } from '$lib/helpers/string';
|
||||
|
||||
export let excess: {
|
||||
bandwidth?: number;
|
||||
@@ -27,6 +28,8 @@
|
||||
|
||||
const plan = $plansInfo.plans.find((p) => p.$id === currentTier);
|
||||
const collaboratorPrice = plan?.addons.member?.price ?? 0;
|
||||
|
||||
$: console.log(excess);
|
||||
</script>
|
||||
|
||||
<Alert type="error">
|
||||
@@ -48,24 +51,25 @@
|
||||
{/if}
|
||||
{/if}
|
||||
{#if excess?.bandwidth > 0 || excess?.executions > 0 || excess?.storage > 0 || excess?.users}
|
||||
The Starter plan has a limit of one organization member. By proceeding, all but the creator
|
||||
of the organization admin will be removed. Until you reduce your usage, you will be unable
|
||||
to add to the resources listed below in all projects within your organization. The current
|
||||
billing cycle will end on {toLocaleDate($organization.billingCurrentInvoiceDate)}. Any
|
||||
executions, bandwidth, or messaging usage will be reset at that time.
|
||||
Until you reduce your usage, you will be unable to add to the resources listed below in all
|
||||
projects within your organization. The current billing cycle will end on {toLocaleDate(
|
||||
$organization.billingCurrentInvoiceDate
|
||||
)}. Any executions, bandwidth, or messaging usage will be reset at that time.
|
||||
{/if}
|
||||
|
||||
<svelte:fragment slot="buttons">
|
||||
{#if currentTier === 'tier-0'}
|
||||
<Button
|
||||
text
|
||||
href="https://appwrite.io/docs/advanced/platform/starter#reaching-resource-limits"
|
||||
>Learn more</Button>
|
||||
href="https://appwrite.io/docs/advanced/platform/starter#reaching-resource-limits">
|
||||
Learn more
|
||||
</Button>
|
||||
{:else if currentTier === 'tier-1'}
|
||||
<Button
|
||||
text
|
||||
href="https://appwrite.io/docs/advanced/platform/pro#reaching-resource-limits"
|
||||
>Learn more</Button>
|
||||
href="https://appwrite.io/docs/advanced/platform/pro#reaching-resource-limits">
|
||||
Learn more
|
||||
</Button>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</Alert>
|
||||
@@ -110,7 +114,12 @@
|
||||
<TableCell title="excess">
|
||||
<p class="u-color-text-danger">
|
||||
<span class="icon-arrow-up" />
|
||||
{excess?.executions} executions
|
||||
<span
|
||||
title={excess?.executions
|
||||
? excess.executions.toString()
|
||||
: 'executions'}>
|
||||
{formatNum(excess?.executions)} executions
|
||||
</span>
|
||||
</p>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
@@ -124,7 +133,9 @@
|
||||
<TableCell title="excess">
|
||||
<p class="u-color-text-danger">
|
||||
<span class="icon-arrow-up" />
|
||||
{excess?.users} users
|
||||
<span title={excess?.users ? excess.users.toString() : 'users'}>
|
||||
{formatNum(excess?.users)} users
|
||||
</span>
|
||||
</p>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
Reference in New Issue
Block a user