mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
update: use new usageMultiple component for database r&w metrics.
This commit is contained in:
1 parent
f143d34365
commit
e3774be0aa
5 files changed
+56
-68
No files matched your search
@@ -10,7 +10,7 @@
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { bytesToSize, humanFileSize, mbSecondsToGBHours } from '$lib/helpers/sizeConvertion';
|
||||
import { BarChart } from '$lib/charts';
|
||||
import { BarChart, Legend } from '$lib/charts';
|
||||
import ProjectBreakdown from './ProjectBreakdown.svelte';
|
||||
import { formatNum } from '$lib/helpers/string';
|
||||
import { accumulateFromEndingTotal, total } from '$lib/layout/usage.svelte';
|
||||
@@ -29,6 +29,11 @@
|
||||
const plan = data?.plan ?? undefined;
|
||||
|
||||
$: project = (data.organizationUsage as OrganizationUsage).projects;
|
||||
|
||||
$: legendData = [
|
||||
{ name: 'Reads', value: data.organizationUsage.databasesReadsTotal },
|
||||
{ name: 'Writes', value: data.organizationUsage.databasesWritesTotal }
|
||||
];
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -200,7 +205,6 @@
|
||||
The total number of database reads and writes across all projects in your organization.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<!-- types need to be added to console sdk -->
|
||||
{#if data.organizationUsage.databasesReads || data.organizationUsage.databasesWrites}
|
||||
<div style:margin-top="-1.5em">
|
||||
<BarChart
|
||||
@@ -232,6 +236,9 @@
|
||||
}
|
||||
]} />
|
||||
</div>
|
||||
|
||||
<Legend {legendData} />
|
||||
|
||||
{#if project?.length > 0}
|
||||
<ProjectBreakdown
|
||||
{data}
|
||||
|
||||
@@ -33,7 +33,7 @@ export const load: PageLoad = async ({ params, parent }) => {
|
||||
databasesReads: null,
|
||||
databasesWrites: null,
|
||||
databasesReadsTotal: null,
|
||||
databasesWritesTotal: null,
|
||||
databasesWritesTotal: null
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+9
-18
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Usage } from '$lib/layout';
|
||||
import { Usage, UsageMultiple } from '$lib/layout';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
export let data: PageData;
|
||||
@@ -27,20 +27,11 @@
|
||||
title: 'Total collections'
|
||||
}} />
|
||||
|
||||
<Usage
|
||||
title="Databases reads"
|
||||
total={readsTotal}
|
||||
count={reads}
|
||||
countMetadata={{
|
||||
legend: 'Databases reads',
|
||||
title: 'Total database reads'
|
||||
}} />
|
||||
|
||||
<Usage
|
||||
title="Databases writes"
|
||||
total={writesTotal}
|
||||
count={writes}
|
||||
countMetadata={{
|
||||
legend: 'Databases writes',
|
||||
title: 'Total databases'
|
||||
}} />
|
||||
<UsageMultiple
|
||||
title="Reads and writes"
|
||||
total={[readsTotal, writesTotal]}
|
||||
count={[reads, writes]}
|
||||
legendData={[
|
||||
{ name: 'Reads', value: readsTotal },
|
||||
{ name: 'Writes', value: writesTotal }
|
||||
]} />
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Usage } from '$lib/layout';
|
||||
import { Usage, UsageMultiple } from '$lib/layout';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
export let data: PageData;
|
||||
@@ -26,20 +26,11 @@
|
||||
title: 'Total databases'
|
||||
}} />
|
||||
|
||||
<Usage
|
||||
title="Databases reads"
|
||||
total={readsTotal}
|
||||
count={reads}
|
||||
countMetadata={{
|
||||
legend: 'Databases reads',
|
||||
title: 'Total database reads'
|
||||
}} />
|
||||
|
||||
<Usage
|
||||
title="Databases writes"
|
||||
total={writesTotal}
|
||||
count={writes}
|
||||
countMetadata={{
|
||||
legend: 'Databases writes',
|
||||
title: 'Total databases'
|
||||
}} />
|
||||
<UsageMultiple
|
||||
title="Reads and writes"
|
||||
total={[readsTotal, writesTotal]}
|
||||
count={[reads, writes]}
|
||||
legendData={[
|
||||
{ name: 'Reads', value: readsTotal },
|
||||
{ name: 'Writes', value: writesTotal }
|
||||
]} />
|
||||
@@ -14,7 +14,7 @@
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { bytesToSize, humanFileSize, mbSecondsToGBHours } from '$lib/helpers/sizeConvertion';
|
||||
import { BarChart } from '$lib/charts';
|
||||
import { BarChart, Legend } from '$lib/charts';
|
||||
import { formatNum } from '$lib/helpers/string';
|
||||
import { total } from '$lib/layout/usage.svelte';
|
||||
import { BillingPlan } from '$lib/constants.js';
|
||||
@@ -40,9 +40,15 @@
|
||||
// types need to be added to console sdk.
|
||||
$: dbReads = data.usage.databasesReads;
|
||||
$: dbReadsTotal = data.usage.databasesReadsTotal;
|
||||
|
||||
$: dbWrites = data.usage.databasesWrites;
|
||||
$: dbWritesTotal = data.usage.databasesWritesTotal;
|
||||
|
||||
$: legendData = [
|
||||
{ name: 'Reads', value: data.usage.databasesReadsTotal },
|
||||
{ name: 'Writes', value: data.usage.databasesWritesTotal }
|
||||
];
|
||||
|
||||
const tier = data?.currentInvoice?.plan ?? $organization?.billingPlan;
|
||||
const plan = tierToPlan(tier).name;
|
||||
|
||||
@@ -209,35 +215,28 @@
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
{#if dbReads || dbWrites}
|
||||
{@const currentReads = formatNum(dbReadsTotal)}
|
||||
{@const currentWrites = formatNum(dbWritesTotal)}
|
||||
|
||||
<div class="u-flex u-flex-vertical">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<p>
|
||||
<span class="heading-level-4">{currentReads}/{currentWrites}</span>
|
||||
<span class="body-text-1 u-bold">Reads/Writes</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<BarChart
|
||||
options={{
|
||||
yAxis: {
|
||||
axisLabel: {
|
||||
formatter: formatNum
|
||||
<div style:margin-top="-1.5em">
|
||||
<BarChart
|
||||
options={{
|
||||
yAxis: {
|
||||
axisLabel: {
|
||||
formatter: formatNum
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
series={[
|
||||
{
|
||||
name: 'Reads',
|
||||
data: [...dbReads.map((e) => [e.date, e.value])]
|
||||
},
|
||||
{
|
||||
name: 'Writes',
|
||||
data: [...dbWrites.map((e) => [e.date, e.value])]
|
||||
}
|
||||
]} />
|
||||
}}
|
||||
series={[
|
||||
{
|
||||
name: 'Reads',
|
||||
data: [...dbReads.map((e) => [e.date, e.value])]
|
||||
},
|
||||
{
|
||||
name: 'Writes',
|
||||
data: [...dbWrites.map((e) => [e.date, e.value])]
|
||||
}
|
||||
]} />
|
||||
</div>
|
||||
|
||||
<Legend {legendData} />
|
||||
{:else}
|
||||
<Card isDashed>
|
||||
<div class="u-flex u-cross-center u-flex-vertical u-main-center u-flex">
|
||||
|
||||
Reference in new issue
Block a user