diff --git a/package.json b/package.json index d942ead4e..6142c536d 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "e2e:ui": "playwright test tests/e2e --ui" }, "dependencies": { - "@appwrite.io/console": "1.5.1", + "@appwrite.io/console": "1.5.2", "@appwrite.io/pink": "0.25.0", "@appwrite.io/pink-icons": "0.25.0", "@popperjs/core": "^2.11.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c8fc1d7b8..72072365e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@appwrite.io/console': - specifier: 1.5.1 - version: 1.5.1 + specifier: 1.5.2 + version: 1.5.2 '@appwrite.io/pink': specifier: 0.25.0 version: 0.25.0 @@ -199,8 +199,8 @@ packages: '@analytics/type-utils@0.6.2': resolution: {integrity: sha512-TD+xbmsBLyYy/IxFimW/YL/9L2IEnM7/EoV9Aeh56U64Ify8o27HJcKjo38XY9Tcn0uOq1AX3thkKgvtWvwFQg==} - '@appwrite.io/console@1.5.1': - resolution: {integrity: sha512-H0fkBprsxXjOhbrE+MqXt1e4Gx4QeRdHuvMs7UxqGr2fAVEqh4ez2yk40A0ZSQvvN+rqLduoItMHQFl+sCPbtQ==} + '@appwrite.io/console@1.5.2': + resolution: {integrity: sha512-9nNZzxoQcpm5C5pKlGJLWxsEJ4sr5mdt01Hg6M8QpfMtsRe0gjaPa7WGrGBepRnZVKPDNpozh3Hua7nqgx4aEA==} '@appwrite.io/pink-icons@0.25.0': resolution: {integrity: sha512-0O3i2oEuh5mWvjO80i+X6rbzrWLJ1m5wmv2/M3a1p2PyBJsFxN8xQMTEmTn3Wl/D26SsM7SpzbdW6gmfgoVU9Q==} @@ -3837,7 +3837,7 @@ snapshots: '@analytics/type-utils@0.6.2': {} - '@appwrite.io/console@1.5.1': {} + '@appwrite.io/console@1.5.2': {} '@appwrite.io/pink-icons@0.25.0': {} diff --git a/src/lib/components/progressBarBig.svelte b/src/lib/components/progressBarBig.svelte index 01d47ed26..c5ba00a0b 100644 --- a/src/lib/components/progressBarBig.svelte +++ b/src/lib/components/progressBarBig.svelte @@ -6,7 +6,7 @@ export let maxValue: string | undefined = undefined; export let maxUnit: string | undefined = undefined; export let progressValue: number; - export let progressMax: number; + export let progressMax: number | undefined = undefined; export let showBar = true; export let progressBarData: Array = []; @@ -14,20 +14,24 @@
- {#if currentValue !== undefined && currentUnit !== undefined && progress !== undefined && maxValue !== undefined} + {#if currentValue !== undefined && currentUnit !== undefined && progress !== undefined}

{currentValue} {currentUnit}

-

{progress}%

+ {#if progressMax !== undefined} +

{progress}%

+ {/if}
-

- {maxValue} - {maxUnit ? maxUnit : ''} -

+ {#if maxValue !== undefined} +

+ {maxValue} + {maxUnit ? maxUnit : ''} +

+ {/if}
{/if} {#if showBar && progressBarData.length > 0} diff --git a/src/lib/layout/usage.svelte b/src/lib/layout/usage.svelte index 638855386..d803244e9 100644 --- a/src/lib/layout/usage.svelte +++ b/src/lib/layout/usage.svelte @@ -68,12 +68,12 @@
{title} - - - 24h - - - 30d - - - 90d - - + {#if !hideSelectPeriod} + + + 24h + + + 30d + + + 90d + + + {/if}
{#if count} diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 9a686529e..68db777fb 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -1,8 +1,8 @@ -import type { Client, Models } from '@appwrite.io/console'; -import type { OrganizationError, Organization, OrganizationList } from '../stores/organization'; -import type { PaymentMethod } from '@stripe/stripe-js'; import type { Tier } from '$lib/stores/billing'; import type { Campaign } from '$lib/stores/campaigns'; +import type { Client, Models } from '@appwrite.io/console'; +import type { PaymentMethod } from '@stripe/stripe-js'; +import type { Organization, OrganizationError, OrganizationList } from '../stores/organization'; export type PaymentMethodData = { $id: string; @@ -213,11 +213,13 @@ export type OrganizationUsage = { executions: Array; databasesReads: Array; databasesWrites: Array; + imageTransformations: Array; executionsTotal: number; filesStorageTotal: number; buildsStorageTotal: number; databasesReadsTotal: number; databasesWritesTotal: number; + imageTransformationsTotal: number; deploymentsStorageTotal: number; executionsMBSecondsTotal: number; buildsMBSecondsTotal: number; @@ -235,6 +237,7 @@ export type OrganizationUsage = { users: number; authPhoneTotal: number; authPhoneEstimate: number; + imageTransformations: number; }>; authPhoneTotal: number; authPhoneEstimate: number; @@ -313,6 +316,7 @@ export type Plan = { order: number; bandwidth: number; storage: number; + imageTransformations: number; webhooks: number; users: number; teams: number; diff --git a/src/lib/sdk/usage.ts b/src/lib/sdk/usage.ts index 304bad1f6..b446bfa50 100644 --- a/src/lib/sdk/usage.ts +++ b/src/lib/sdk/usage.ts @@ -185,6 +185,14 @@ export type UsageBuckets = { * Aggregated statistics of bucket storage files per period. */ storage: Metric[]; + /** + * Aggregated statistics of bucket image transformations per period. + */ + imageTransformations: Metric[]; + /** + * Total aggregated number of bucket image transformations. + */ + imageTransformationsTotal: number; }; /** * UsageFunctions @@ -311,7 +319,17 @@ export type UsageProject = { authPhoneEstimate: number; /** - * Aggregated statistics of total number SMS by country + * Aggregated statistics of total number SMS by country. */ authPhoneCountriesBreakdown: Models.MetricBreakdown[]; + + /** + * Array of image transformations per period. + */ + imageTransformations: Metric[]; + + /** + * Aggregated statistics of total number of image transformations. + */ + imageTransformationsTotal: number; }; diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 83cb2d1d6..dd698c912 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -1,37 +1,37 @@ -import { page } from '$app/stores'; -import { derived, get, writable } from 'svelte/store'; -import { sdk } from './sdk'; -import { organization, type Organization, type OrganizationError } from './organization'; -import type { - InvoiceList, - AddressesList, - Invoice, - PaymentList, - PlansMap, - PaymentMethodData, - Plan, - Aggregation -} from '$lib/sdk/billing'; -import { isCloud } from '$lib/system'; -import { cachedStore } from '$lib/helpers/cache'; -import { Query } from '@appwrite.io/console'; -import { headerAlert } from './headerAlert'; -import PaymentAuthRequired from '$lib/components/billing/alerts/paymentAuthRequired.svelte'; -import { addNotification, notifications } from './notifications'; +import { browser } from '$app/environment'; import { goto } from '$app/navigation'; import { base } from '$app/paths'; -import { activeHeaderAlert, orgMissingPaymentMethod } from '$routes/(console)/store'; -import MarkedForDeletion from '$lib/components/billing/alerts/markedForDeletion.svelte'; -import { BillingPlan, NEW_DEV_PRO_UPGRADE_COUPON } from '$lib/constants'; -import PaymentMandate from '$lib/components/billing/alerts/paymentMandate.svelte'; -import MissingPaymentMethod from '$lib/components/billing/alerts/missingPaymentMethod.svelte'; -import LimitReached from '$lib/components/billing/alerts/limitReached.svelte'; +import { page } from '$app/stores'; import { trackEvent } from '$lib/actions/analytics'; +import LimitReached from '$lib/components/billing/alerts/limitReached.svelte'; +import MarkedForDeletion from '$lib/components/billing/alerts/markedForDeletion.svelte'; +import MissingPaymentMethod from '$lib/components/billing/alerts/missingPaymentMethod.svelte'; import newDevUpgradePro from '$lib/components/billing/alerts/newDevUpgradePro.svelte'; +import PaymentAuthRequired from '$lib/components/billing/alerts/paymentAuthRequired.svelte'; +import PaymentMandate from '$lib/components/billing/alerts/paymentMandate.svelte'; +import { BillingPlan, NEW_DEV_PRO_UPGRADE_COUPON } from '$lib/constants'; +import { cachedStore } from '$lib/helpers/cache'; import { sizeToBytes, type Size } from '$lib/helpers/sizeConvertion'; -import { user } from './user'; -import { browser } from '$app/environment'; +import type { + AddressesList, + Aggregation, + Invoice, + InvoiceList, + PaymentList, + PaymentMethodData, + Plan, + PlansMap +} from '$lib/sdk/billing'; +import { isCloud } from '$lib/system'; +import { activeHeaderAlert, orgMissingPaymentMethod } from '$routes/(console)/store'; +import { Query } from '@appwrite.io/console'; +import { derived, get, writable } from 'svelte/store'; +import { headerAlert } from './headerAlert'; +import { addNotification, notifications } from './notifications'; +import { organization, type Organization, type OrganizationError } from './organization'; import { canSeeBilling } from './roles'; +import { sdk } from './sdk'; +import { user } from './user'; export type Tier = 'tier-0' | 'tier-1' | 'tier-2' | 'auto-1' | 'cont-1' | 'ent-1'; @@ -130,7 +130,8 @@ export type PlanServices = | 'users' | 'usersAddon' | 'webhooks' - | 'authPhone'; + | 'authPhone' + | 'imageTransformations'; export function getServiceLimit(serviceId: PlanServices, tier: Tier = null, plan?: Plan): number { if (!isCloud) return 0; diff --git a/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte b/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte index c798830d7..d66381cbc 100644 --- a/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte +++ b/src/routes/(console)/organization-[organization]/usage/[[invoice]]/+page.svelte @@ -1,6 +1,16 @@ + + diff --git a/src/routes/(console)/project-[project]/storage/bucket-[bucket]/usage/[[period]]/+page.ts b/src/routes/(console)/project-[project]/storage/bucket-[bucket]/usage/[[period]]/+page.ts index de6a068c6..468fe7363 100644 --- a/src/routes/(console)/project-[project]/storage/bucket-[bucket]/usage/[[period]]/+page.ts +++ b/src/routes/(console)/project-[project]/storage/bucket-[bucket]/usage/[[period]]/+page.ts @@ -1,8 +1,7 @@ -import { sdk } from '$lib/stores/sdk'; -import type { Metric, UsageBuckets } from '$lib/sdk/usage'; -import type { PageLoad } from './$types'; -import { StorageUsageRange } from '@appwrite.io/console'; import { isValueOfStringEnum } from '$lib/helpers/types'; +import { sdk } from '$lib/stores/sdk'; +import { StorageUsageRange, type Models } from '@appwrite.io/console'; +import type { PageLoad } from './$types'; export const load: PageLoad = async ({ params }) => { const period = isValueOfStringEnum(StorageUsageRange, params.period) @@ -11,10 +10,12 @@ export const load: PageLoad = async ({ params }) => { const response = (await sdk.forProject.storage.getBucketUsage( params.bucket, period - )) as unknown as UsageBuckets; + )) as unknown as Models.UsageBuckets; return { filesTotal: response.filesTotal, - files: response.files as Metric[] + files: response.files as Models.Metric[], + imageTransformationsTotal: response.imageTransformationsTotal, + imageTransformations: response.imageTransformations as Models.Metric[] }; };