mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Use new DB Storage metrics
This commit is contained in:
1 parent
02169a2bd4
commit
fee2b39b41
5 files changed
+69
-4
No files matched your search
@@ -24,6 +24,7 @@ import {
|
||||
import { Billing } from '../sdk/billing';
|
||||
import { Sources } from '$lib/sdk/sources';
|
||||
import { SpecsFunctions } from '$lib/sdk/functionsSpec';
|
||||
import { ProjectDBStorage } from '$lib/sdk/usageDatabaseStorage';
|
||||
|
||||
const endpoint = VARS.APPWRITE_ENDPOINT ?? `${globalThis?.location?.origin}/v1`;
|
||||
|
||||
@@ -45,6 +46,7 @@ const sdkForProject = {
|
||||
messaging: new Messaging(clientProject),
|
||||
project: new Project(clientProject),
|
||||
projectApi: new ProjectApi(clientProject),
|
||||
projectDatabaseStorage: new ProjectDBStorage(clientProject),
|
||||
storage: new Storage(clientProject),
|
||||
teams: new Teams(clientProject),
|
||||
users: new Users(clientProject),
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
export let data: PageData;
|
||||
$: total = data.databasesTotal;
|
||||
$: count = data.databases;
|
||||
$: totalStorage = data.databasesStorageTotal;
|
||||
$: countStorage = data.databasesStorage;
|
||||
</script>
|
||||
|
||||
<Usage
|
||||
@@ -17,3 +19,13 @@
|
||||
legend: 'Databases',
|
||||
title: 'Total databases'
|
||||
}} />
|
||||
|
||||
<Usage
|
||||
title="Database storage"
|
||||
path={`/console/project-${$page.params.project}/databases/usage`}
|
||||
total={totalStorage}
|
||||
count={countStorage}
|
||||
countMetadata={{
|
||||
legend: 'Databases',
|
||||
title: 'Total database storage'
|
||||
}} />
|
||||
@@ -9,7 +9,7 @@ export const load: PageLoad = async ({ params }) => {
|
||||
? params.period
|
||||
: DatabaseUsageRange.ThirtyDays;
|
||||
try {
|
||||
return sdk.forProject.databases.getUsage(period);
|
||||
return sdk.forProject.projectDatabaseStorage.getDBUsage(period);
|
||||
} catch (e) {
|
||||
error(e.code, e.message);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
$: executions = data.usage.executions;
|
||||
$: executionsTotal = data.usage.executionsTotal;
|
||||
$: storage = data.usage.filesStorageTotal;
|
||||
$: databasesStorage = data.usage.databasesStorageTotal;
|
||||
|
||||
const tier = data?.currentInvoice?.tier ?? $organization?.billingPlan;
|
||||
const plan = tierToPlan(tier).name;
|
||||
@@ -264,7 +265,7 @@
|
||||
|
||||
<p class="text">
|
||||
Calculated for all your files, deployments, builds and databases. While in beta, only
|
||||
file storage is counted against your plan limits.
|
||||
file and database storage is counted against your plan limits.
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
@@ -273,6 +274,7 @@
|
||||
<div class="u-flex u-flex-vertical">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<p>
|
||||
<span class="heading-level-5">Files - </span>
|
||||
<span class="heading-level-4">{humanized.value}</span>
|
||||
<span class="body-text-1 u-bold">{humanized.unit}</span>
|
||||
</p>
|
||||
@@ -312,7 +314,56 @@
|
||||
class="icon-chart-square-bar text-large"
|
||||
aria-hidden="true"
|
||||
style="font-size: 32px;" />
|
||||
<p class="u-bold">No data to show</p>
|
||||
<p class="u-bold">No data to show for files storage</p>
|
||||
</div>
|
||||
</Card>
|
||||
{/if}
|
||||
{#if databasesStorage}
|
||||
{@const humanized = humanFileSize(databasesStorage)}
|
||||
<div class="u-flex u-flex-vertical">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<p>
|
||||
<span class="heading-level-5">Databases - </span>
|
||||
<span class="heading-level-4">{humanized.value}</span>
|
||||
<span class="body-text-1 u-bold">{humanized.unit}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{#if data.usage.databasesStorageBreakdown.length > 0}
|
||||
<Table noMargin noStyles>
|
||||
<TableHeader>
|
||||
<TableCellHead width={285}>Database</TableCellHead>
|
||||
<TableCellHead>Usage</TableCellHead>
|
||||
<TableCellHead width={140} />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.usage.databasesStorageBreakdown.sort((a, b) => b.value - a.value) as database}
|
||||
{@const humanized = humanFileSize(database.value)}
|
||||
<TableRow>
|
||||
<TableCell title="Function">
|
||||
{database.name ?? database.resourceId}
|
||||
</TableCell>
|
||||
<TableCell title="Usage">
|
||||
{humanized.value}{humanized.unit}
|
||||
</TableCell>
|
||||
<TableCellLink
|
||||
href={`${base}/databases/database-${database.resourceId}`}
|
||||
title="View database">
|
||||
View database
|
||||
</TableCellLink>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{/if}
|
||||
{:else}
|
||||
<Card isDashed>
|
||||
<div class="u-flex u-cross-center u-flex-vertical u-main-center u-flex">
|
||||
<span
|
||||
class="icon-chart-square-bar text-large"
|
||||
aria-hidden="true"
|
||||
style="font-size: 32px;" />
|
||||
<p class="u-bold">No data to show for databases storage</p>
|
||||
</div>
|
||||
</Card>
|
||||
{/if}
|
||||
|
||||
@@ -29,7 +29,7 @@ export const load: PageLoad = async ({ params, parent }) => {
|
||||
/**
|
||||
* Workaround because project id might not be populated yet.
|
||||
*/
|
||||
getSdkForProject(project).project.getUsage(startDate, endDate)
|
||||
getSdkForProject(project).projectDatabaseStorage.getUsage(startDate, endDate)
|
||||
]);
|
||||
|
||||
if (invoice) {
|
||||
|
||||
Reference in new issue
Block a user