feat: plan limit,table row for exeded limit, container header component

This commit is contained in:
Arman committed 2023-07-26 20:24:14 +02:00
1 parent ed7a4e0868
commit aea9042a32
6 files changed
+124 -29

No files matched your search

+25 -8
View File
@@ -260,22 +260,31 @@ export const eventServices: Array<EventService> = [
export const usageRates = {
'tier-0': [
{ 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' },
{
id: 'members',
resource: 'Organization members',
amount: 1,
unit: '',
rate: '$20/member'
},
{ id: 'bandwith', resource: 'Bandwidth', amount: 10, unit: 'GB', rate: '$0.04/GB' },
{ id: 'storage', resource: 'Storage', amount: 2, unit: 'GB', rate: '$0.025/GB' },
{
id: 'executions',
resource: 'Function executions',
amount: 3500000,
amount: 750000,
unit: 'executions',
rate: '$2/1M executions'
},
{
id: 'users',
resource: 'Active users',
amount: 200000,
unit: 'AU',
rate: '$0.0012/user'
},
{
id: 'connections',
resource: 'Concurrent connections',
amount: 750,
unit: 'connections',
@@ -284,26 +293,30 @@ export const usageRates = {
],
'tier-1': [
{
id: 'members',
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' },
{ id: 'bandwith', resource: 'Bandwidth', amount: 1, unit: 'TB', rate: '$0.04/GB' },
{ id: 'storage', resource: 'Storage', amount: 150, unit: 'GB', rate: '$0.025/GB' },
{
id: 'executions',
resource: 'Function executions',
amount: 3500000,
unit: 'executions',
rate: '$2/1M executions'
},
{
id: 'users',
resource: 'Active users',
amount: 200000,
unit: 'AU',
rate: '$0.0012/user'
},
{
id: 'connections',
resource: 'Concurrent connections',
amount: 750,
unit: 'connections',
@@ -312,26 +325,30 @@ export const usageRates = {
],
'tier-2': [
{
id: 'members',
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' },
{ id: 'bandwith', resource: 'Bandwidth', amount: 1, unit: 'TB', rate: '$0.04/GB' },
{ id: 'storage', resource: 'Storage', amount: 150, unit: 'GB', rate: '$0.025/GB' },
{
id: 'executions',
resource: 'Function executions',
amount: 3500000,
unit: 'executions',
rate: '$2/1M executions'
},
{
id: 'users',
resource: 'Active users',
amount: 200000,
unit: 'AU',
rate: '$0.0012/user'
},
{
id: 'connections',
resource: 'Concurrent connections',
amount: 750,
unit: 'connections',
+21 -6
View File
@@ -1,20 +1,35 @@
<script lang="ts">
import { usageRates } from '$lib/constants';
import { organization } from '$lib/stores/organization';
import { wizard } from '$lib/stores/wizard';
import { isCloud } from '$lib/system';
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
import { Button } from '../forms';
export let limitReached = true;
export let name: string = null;
let tableBody: HTMLDivElement;
export let service: string = null;
export let name = service;
let rows = 0;
$: limitReached = isCloud ? usageRates[$organization?.billingPlan ?? 'tier-0'] : false;
$: if (tableBody) {
rows = tableBody?.parentNode?.querySelectorAll('.table-thead-col')?.length;
}
</script>
<div class="table-tbody" role="rowgroup">
<div class="table-tbody" role="rowgroup" bind:this={tableBody}>
<slot />
</div>
{#if isCloud && limitReached && name}
{#if isCloud && limitReached && service}
<tr class="table-row">
<td class="table-col" width="100%">
<td class="table-col" width="100%" colspan={rows}>
<span class="u-flex u-gap-24 u-main-center u-cross-center">
<span class="text">Upgrade your plan to add {name} to your organization</span>
<Button secondary on:click={() => console.log('test')}>Change plan</Button>
<Button secondary on:click={() => wizard.start(ChangeOrganizationTierCloud)}>
Change plan
</Button>
</span>
</td>
</tr>
+62
View File
@@ -0,0 +1,62 @@
<script lang="ts">
import { tierToPlan, type Tier } from '$lib/stores/billing';
import { tooltip } from '$lib/actions/tooltip';
import { Heading } from '$lib/components';
import { Pill } from '$lib/elements';
import { organization } from '$lib/stores/organization';
import { isCloud } from '$lib/system';
import { tick } from 'svelte';
import { wizard } from '$lib/stores/wizard';
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
export let title: string;
let tooltipContent: HTMLDivElement;
// TODO: fix limit
const limit = 1000;
$: tier = tierToPlan($organization?.billingPlan as Tier)?.name;
</script>
<div class="u-flex u-gap-12 common-section u-main-space-between">
<div class="u-flex u-cross-child-center u-gap-16">
<Heading tag="h2" size="5">{title}</Heading>
{#if isCloud}
<div
use:tooltip={{
interactive: true,
allowHTML: true,
trigger: 'click',
onShow(instance) {
tick().then(() => {
instance.setContent(tooltipContent);
});
}
}}>
<Pill button>
<span class="icon-info" />{title} limited
</Pill>
</div>
{/if}
</div>
<slot />
</div>
{#if isCloud}
<div class="u-hide">
<div bind:this={tooltipContent}>
<p class="text">
Your are limited to {limit}
{title.toLocaleLowerCase()} per project on the {tier}.
</p>
<button
class="link"
type="button"
on:click|preventDefault={() => wizard.start(ChangeOrganizationTierCloud)}
>Upgrade</button>
for addtional {title.toLocaleLowerCase()}.
</div>
</div>
{/if}
+1
View File
@@ -16,3 +16,4 @@ export { default as Usage, type UsagePeriods } from './usage.svelte';
export { default as Activity } from './activity.svelte';
export { default as Progress } from './progress.svelte';
export { default as GridHeader } from './gridHeader.svelte';
export { default as ContainerHeader } from './containerHeader.svelte';
@@ -2,7 +2,7 @@
import { invalidate } from '$app/navigation';
import { page } from '$app/stores';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { AvatarInitials, Heading, PaginationWithLimit } from '$lib/components';
import { AvatarInitials, PaginationWithLimit } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Pill } from '$lib/elements';
import { Button } from '$lib/elements/forms';
@@ -15,7 +15,7 @@
TableRow,
TableScroll
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { Container, ContainerHeader } from '$lib/layout';
import { addNotification } from '$lib/stores/notifications';
import { members, newMemberModal, organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
@@ -57,14 +57,12 @@
<Container>
{#if data.organizationMembers.total}
<div class="u-flex u-gap-12 common-section u-main-space-between">
<Heading tag="h2" size="5">Members</Heading>
<ContainerHeader title="Members">
<Button on:click={() => newMemberModal.set(true)} event="invite">
<span class="icon-plus" aria-hidden="true" />
<span class="text">Invite</span>
</Button>
</div>
</ContainerHeader>
<TableScroll>
<TableHeader>
@@ -73,7 +71,7 @@
<TableCellHead width={90} />
<TableCellHead width={30} />
</TableHeader>
<TableBody>
<TableBody service="members">
{#each data.organizationMembers.memberships as member}
<TableRow>
<TableCell title="Name">
@@ -8,18 +8,20 @@
export let data;
$: requests = data.requests;
// $: network = data.response.network;
// $: executions = data.response.executions;
// $: documents = data.response.documents;
// $: databases = data.response.databases;
// $: users = data.response.users;
// $: storage = data.response.storage;
// $: buckets = data.response.buckets;
// $: network = data.network;
// $: executions = data.executions;
// $: documents = data.documents;
// $: databases = data.databases;
// $: users = data.users;
// $: storage = data.storage;
// $: buckets = data.buckets;
$: console.log(data);
</script>
<Container>
<div class="u-flex u-main-space-between common-section">
<Heading tag="h2" size="5">Functions</Heading>
<Heading tag="h2" size="5">Usage</Heading>
<SecondaryTabs>
<SecondaryTabsItem
href={`/console/project-${data.project.$id}/settings/usage/24h`}