mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: readOnly, plan limits, fixes
This commit is contained in:
1 parent
a6bf8e1315
commit
9bdaa4caaf
14 files changed
+108
-79
No files matched your search
@@ -35,6 +35,7 @@
|
||||
{required}
|
||||
type="checkbox"
|
||||
class:switch={type === 'switchbox'}
|
||||
aria-checked={value}
|
||||
bind:this={element}
|
||||
bind:checked={value}
|
||||
on:invalid={handleInvalid} />
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
export function abbreviateNumber(num: number, decimals: number = 1): string {
|
||||
if (isNaN(num)) return String(num);
|
||||
if (num >= 1000000) {
|
||||
const result = num / 1000000;
|
||||
return result.toFixed(result % 1 !== 0 ? decimals : 0) + 'M';
|
||||
} else if (num >= 1000) {
|
||||
const result = num / 1000;
|
||||
return result.toFixed(result % 1 !== 0 ? decimals : 0) + 'K';
|
||||
} else {
|
||||
return num.toString();
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,11 @@
|
||||
export let buttonText: string = null;
|
||||
export let buttonMethod: () => void = null;
|
||||
export let buttonEvent: string = buttonText?.toLocaleLowerCase();
|
||||
export let buttonDisabled = false;
|
||||
|
||||
let tooltipContent: HTMLDivElement;
|
||||
|
||||
const limit = getServiceLimit(serviceId)?.amount ?? Infinity;
|
||||
const limit = getServiceLimit(serviceId) || Infinity;
|
||||
|
||||
$: tier = tierToPlan($organization?.billingPlan as Tier)?.name;
|
||||
</script>
|
||||
@@ -76,7 +77,7 @@
|
||||
<Button
|
||||
on:click={buttonMethod}
|
||||
event={buttonEvent}
|
||||
disabled={limit !== 'unlimited' && total >= limit}>
|
||||
disabled={(limit !== 'unlimited' && total >= limit) || buttonDisabled}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">{buttonText}</span>
|
||||
</Button>
|
||||
|
||||
@@ -13,6 +13,7 @@ export const addressList = derived(page, ($page) => $page.data.addressList as Ad
|
||||
export const plansInfo = derived(page, ($page) => $page.data.plansInfo as PlansInfo);
|
||||
export const daysLeftInTrial = writable<number>(0);
|
||||
export const trialEndDate = writable<Date>();
|
||||
export const readOnly = writable<boolean>(false);
|
||||
|
||||
export function tierToPlan(tier: Tier) {
|
||||
switch (tier) {
|
||||
|
||||
@@ -259,6 +259,7 @@
|
||||
|
||||
checkForTrialEnding();
|
||||
paymentExpired();
|
||||
checkForUsageLimit();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -286,6 +287,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
function checkForUsageLimit() {
|
||||
console.log('test');
|
||||
}
|
||||
|
||||
async function paymentExpired() {
|
||||
if (!$organization?.paymentMethodId) return;
|
||||
const payment = await sdk.forConsole.billing.getPaymentMethod(
|
||||
|
||||
@@ -4,8 +4,6 @@ import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ parent }) => {
|
||||
const { organizations } = await parent();
|
||||
console.log(organizations);
|
||||
console.log('test');
|
||||
if (organizations.total) {
|
||||
const teamId = localStorage.getItem('organization') ?? organizations.teams[0].$id;
|
||||
throw redirect(303, `${base}/console/organization-${teamId}`);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { ID } from '@appwrite.io/console';
|
||||
import { openImportWizard } from '../project-[project]/settings/migrations/(import)';
|
||||
import { readOnly } from '$lib/stores/billing';
|
||||
|
||||
export let data;
|
||||
|
||||
@@ -119,7 +120,7 @@
|
||||
<Heading tag="h2" size="5">Projects</Heading>
|
||||
|
||||
<DropList bind:show={showDropdown} placement="bottom-end">
|
||||
<Button on:click={handleCreateProject} event="create_project">
|
||||
<Button on:click={handleCreateProject} event="create_project" disabled={$readOnly}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create project</span>
|
||||
</Button>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { PageData } from './$types';
|
||||
import Delete from '../deleteMember.svelte';
|
||||
import { readOnly } from '$lib/stores/billing';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
@@ -61,7 +62,8 @@
|
||||
title="Members"
|
||||
total={data.organizationMembers.total}
|
||||
buttonText="Invite"
|
||||
buttonMethod={() => newMemberModal.set(true)} />
|
||||
buttonMethod={() => newMemberModal.set(true)}
|
||||
buttonDisabled={$readOnly} />
|
||||
|
||||
<TableScroll>
|
||||
<TableHeader>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
import { app } from '$lib/stores/app';
|
||||
import type { PageData } from './$types';
|
||||
import { ContainerHeader } from '$lib/layout';
|
||||
import { getServiceLimit } from '$lib/stores/billing';
|
||||
import { getServiceLimit, readOnly } from '$lib/stores/billing';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
@@ -82,7 +82,8 @@
|
||||
<DropList bind:show={showDropdown} placement="bottom-start">
|
||||
<Button
|
||||
on:click={() => (showDropdown = !showDropdown)}
|
||||
disabled={data?.platforms?.platforms?.length >= getServiceLimit('platforms')?.amount}>
|
||||
disabled={data?.platforms?.platforms?.length >= getServiceLimit('platforms') ||
|
||||
$readOnly}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Add platform</span>
|
||||
</Button>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
import ExportModal from './exportModal.svelte';
|
||||
import Status from '$lib/components/status.svelte';
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import { readOnly } from '$lib/stores/billing';
|
||||
|
||||
export let data;
|
||||
let details: string | null = null;
|
||||
@@ -251,8 +252,9 @@
|
||||
<span class="icon-cloud" />
|
||||
</div>
|
||||
</div>
|
||||
<Button class="u-margin-block-start-48" secondary on:click={deployToCloud}
|
||||
>Deploy to Cloud</Button>
|
||||
<Button class="u-margin-block-start-48" secondary on:click={deployToCloud}>
|
||||
Deploy to Cloud
|
||||
</Button>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
@@ -281,7 +283,8 @@
|
||||
<Button
|
||||
class="u-margin-block-start-48"
|
||||
secondary
|
||||
on:click={() => (showExport = true)}>Export data</Button>
|
||||
on:click={() => (showExport = true)}
|
||||
disabled={$readOnly}>Export data</Button>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
import { getServiceLimit, tierToPlan, type Tier } from '$lib/stores/billing';
|
||||
import { getServiceLimit, tierToPlan, type Tier, readOnly } from '$lib/stores/billing';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
|
||||
@@ -114,12 +114,12 @@
|
||||
<div
|
||||
use:tooltip={{
|
||||
content: `Upgrade to add more files`,
|
||||
disabled: data.files.total < getServiceLimit('storage')?.amount
|
||||
disabled: data.files.total < getServiceLimit('storage')
|
||||
}}>
|
||||
<Button
|
||||
on:click={() => ($showCreate = true)}
|
||||
event="create_file"
|
||||
disabled={data.files.total >= getServiceLimit('storage')?.amount}>
|
||||
disabled={data.files.total >= getServiceLimit('storage') || $readOnly}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create file</span>
|
||||
</Button>
|
||||
|
||||
+37
-53
@@ -61,7 +61,9 @@
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
FormItem,
|
||||
FormList,
|
||||
InputChoice,
|
||||
InputSelect,
|
||||
InputSwitch,
|
||||
InputTags,
|
||||
@@ -78,6 +80,7 @@
|
||||
import Delete from '../deleteBucket.svelte';
|
||||
import { bucket } from '../store';
|
||||
import UpdateMaxFileSize from './updateMaxFileSize.svelte';
|
||||
import { readOnly } from '$lib/stores/billing';
|
||||
|
||||
let showDelete = false;
|
||||
|
||||
@@ -229,7 +232,9 @@
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={enabled === $bucket.enabled} submit>Update</Button>
|
||||
<Button disabled={enabled === $bucket.enabled || $readOnly} submit>
|
||||
Update
|
||||
</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
@@ -243,13 +248,15 @@
|
||||
id="name"
|
||||
label="Name"
|
||||
placeholder="Enter name"
|
||||
autocomplete={false}
|
||||
readonly={$readOnly}
|
||||
bind:value={bucketName} />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={bucketName === $bucket.name || !bucketName} submit>
|
||||
<Button
|
||||
disabled={bucketName === $bucket.name || !bucketName || $readOnly}
|
||||
submit>
|
||||
Update
|
||||
</Button>
|
||||
</svelte:fragment>
|
||||
@@ -301,7 +308,9 @@
|
||||
</p>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={bucketFileSecurity === $bucket.fileSecurity} submit>
|
||||
<Button
|
||||
disabled={bucketFileSecurity === $bucket.fileSecurity || $readOnly}
|
||||
submit>
|
||||
Update
|
||||
</Button>
|
||||
</svelte:fragment>
|
||||
@@ -317,54 +326,29 @@
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<li class="form-item">
|
||||
<label class="choice-item" for="encryption">
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
name="encryption"
|
||||
id="encryption"
|
||||
type="checkbox"
|
||||
class="switch"
|
||||
role="switch"
|
||||
aria-checked={encryption}
|
||||
bind:checked={encryption} />
|
||||
</div>
|
||||
<div class="choice-item-content">
|
||||
<div class="choice-item-title">Encryption</div>
|
||||
<FormItem>
|
||||
<InputChoice
|
||||
label="Encryption"
|
||||
id="encryption"
|
||||
type="switchbox"
|
||||
bind:value={encryption}>
|
||||
This parameter allows you to configure whether or not the files
|
||||
inside the bucket will be encrypted. We don't encrypt files bigger
|
||||
than 20MB.
|
||||
</InputChoice>
|
||||
</FormItem>
|
||||
|
||||
<div class="choice-item-paragraph">
|
||||
This parameter allows you to configure whether or not the
|
||||
files inside the bucket will be encrypted. We don't encrypt
|
||||
files bigger than 20MB.
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</li>
|
||||
<li class="form-item">
|
||||
<label class="choice-item" for="antivirus">
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
name="antivirus"
|
||||
id="antivirus"
|
||||
type="checkbox"
|
||||
class="switch"
|
||||
role="switch"
|
||||
aria-checked={antivirus}
|
||||
bind:checked={antivirus} />
|
||||
</div>
|
||||
<div class="choice-item-content">
|
||||
<div class="choice-item-title">Antivirus</div>
|
||||
|
||||
<div class="choice-item-paragraph">
|
||||
This parameter allows you to configure whether or not the
|
||||
files inside the bucket should be scanned by the Appwrite
|
||||
Antivirus scanner.
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</li>
|
||||
|
||||
<li />
|
||||
<FormItem>
|
||||
<InputChoice
|
||||
label="Antivirus"
|
||||
id="antivirus"
|
||||
type="switchbox"
|
||||
bind:value={antivirus}>
|
||||
This parameter allows you to configure whether or not the files
|
||||
inside the bucket should be scanned by the Appwrite Antivirus
|
||||
scanner.
|
||||
</InputChoice>
|
||||
</FormItem>
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -406,7 +390,7 @@
|
||||
|
||||
<Form onSubmit={updateAllowedExtensions}>
|
||||
<CardGrid hideOverflow>
|
||||
<Heading tag="h6" size="7" id="extensions">File Extensions</Heading>
|
||||
<Heading tag="h6" size="7" id="extensions">Allowed file Extensions</Heading>
|
||||
<p class="text">
|
||||
Allowed file extensions. A maximum of 100 file extensions can be added. Leave
|
||||
blank to allow all file types.
|
||||
@@ -439,7 +423,7 @@
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={isExtensionsDisabled} submit>Update</Button>
|
||||
<Button disabled={isExtensionsDisabled || $readOnly} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
|
||||
+4
-2
@@ -4,7 +4,7 @@
|
||||
import { Button, Form, InputNumber, InputSelect } from '$lib/elements/forms';
|
||||
import { humanFileSize } from '$lib/helpers/sizeConvertion';
|
||||
import { createByteUnitPair } from '$lib/helpers/unit';
|
||||
import { getServiceLimit } from '$lib/stores/billing';
|
||||
import { getServiceLimit, readOnly } from '$lib/stores/billing';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { isCloud } from '$lib/system';
|
||||
@@ -55,6 +55,7 @@
|
||||
<InputNumber
|
||||
id="size"
|
||||
label="Size"
|
||||
disabled={$readOnly}
|
||||
placeholder={$bucket.maximumFileSize.toString()}
|
||||
min={0}
|
||||
max={isCloud ? service.amount : Infinity}
|
||||
@@ -64,7 +65,8 @@
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={$baseValue === $bucket.maximumFileSize} submit>Update</Button>
|
||||
<Button disabled={$baseValue === $bucket.maximumFileSize || $readOnly} submit
|
||||
>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
@@ -13,6 +13,7 @@
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { createOrganization } from './store';
|
||||
import { plansInfo } from '$lib/stores/billing';
|
||||
import { abbreviateNumber } from '$lib/helpers/numbers';
|
||||
|
||||
export let show = false;
|
||||
export let tier: string;
|
||||
@@ -29,24 +30,24 @@
|
||||
{
|
||||
id: 'members',
|
||||
resource: 'Organization members',
|
||||
unit: ''
|
||||
unit: 'member'
|
||||
},
|
||||
{ id: 'bandwith', resource: 'Bandwidth', unit: 'GB' },
|
||||
{ id: 'bandwidth', resource: 'Bandwidth', unit: 'GB' },
|
||||
{ id: 'storage', resource: 'Storage', unit: 'GB' },
|
||||
{
|
||||
id: 'executions',
|
||||
resource: 'Function executions',
|
||||
unit: 'executions'
|
||||
unit: ' executions'
|
||||
},
|
||||
{
|
||||
id: 'users',
|
||||
resource: 'Active users',
|
||||
unit: 'AU'
|
||||
unit: ' AU'
|
||||
},
|
||||
{
|
||||
id: 'realtime',
|
||||
resource: 'Concurrent connections',
|
||||
unit: 'connections'
|
||||
unit: ' connections'
|
||||
}
|
||||
];
|
||||
</script>
|
||||
@@ -65,11 +66,28 @@
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each planData as usage}
|
||||
<TableRow>
|
||||
<TableCellText title="resource">{usage.resource}</TableCellText>
|
||||
<TableCellText title="limit">{plan[usage.id]}{usage?.unit}</TableCellText>
|
||||
<TableCellText title="rate">{plan[`${usage.id}Addon`]}</TableCellText>
|
||||
</TableRow>
|
||||
{#if usage['id'] === 'members'}
|
||||
<TableRow>
|
||||
<TableCellText title="resource">{usage.resource}</TableCellText>
|
||||
<TableCellText title="limit">
|
||||
{plan[usage.id] || 'Unlimited'}
|
||||
</TableCellText>
|
||||
<TableCellText title="rate"
|
||||
>${plan.memberAddon.price}/{usage?.unit}</TableCellText>
|
||||
</TableRow>
|
||||
{:else}
|
||||
{@const addon = plan[`${usage.id}Addon`]}
|
||||
<TableRow>
|
||||
<TableCellText title="resource">{usage.resource}</TableCellText>
|
||||
<TableCellText title="limit">
|
||||
{abbreviateNumber(plan[usage.id])}{usage?.unit}
|
||||
</TableCellText>
|
||||
<TableCellText title="rate"
|
||||
>${addon?.price}/{['MB', 'GB', 'TB'].includes(addon?.unit)
|
||||
? addon?.value
|
||||
: abbreviateNumber(addon?.value, 0)}{usage?.unit}</TableCellText>
|
||||
</TableRow>
|
||||
{/if}
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
Reference in new issue
Block a user