diff --git a/src/lib/components/gridItem1.svelte b/src/lib/components/gridItem1.svelte index e5041f9da..ac1bb8ea0 100644 --- a/src/lib/components/gridItem1.svelte +++ b/src/lib/components/gridItem1.svelte @@ -7,7 +7,7 @@
- +
diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts index f891b8255..e978959bf 100644 --- a/src/lib/components/index.ts +++ b/src/lib/components/index.ts @@ -54,3 +54,5 @@ export { default as PaginationWithLimit } from './paginationWithLimit.svelte'; export { default as ClickableList } from './clickableList.svelte'; export { default as ClickableListItem } from './clickableListItem.svelte'; export { default as Id } from './id.svelte'; +export { default as ProgressBar } from './progressBar.svelte'; +export { default as ProjectUsage } from './projectUsage.svelte'; diff --git a/src/lib/components/progressBar.svelte b/src/lib/components/progressBar.svelte new file mode 100644 index 000000000..73d77c5c7 --- /dev/null +++ b/src/lib/components/progressBar.svelte @@ -0,0 +1,38 @@ + + +
+
+

+ {#if icon} +

+

+ {progress}% +

+
+
+
+ {used} + {max}{unit} +
+
diff --git a/src/lib/components/projectUsage.svelte b/src/lib/components/projectUsage.svelte new file mode 100644 index 000000000..2b4a2f7ca --- /dev/null +++ b/src/lib/components/projectUsage.svelte @@ -0,0 +1,40 @@ + + + +
+
+
+ {title} +
+
status
+ +
+
    + {#each data as project} +
  • + +
  • + {/each} +
+
+ +
+
diff --git a/src/routes/console/organization-[organization]/header.svelte b/src/routes/console/organization-[organization]/header.svelte index a7df69d70..ff5151485 100644 --- a/src/routes/console/organization-[organization]/header.svelte +++ b/src/routes/console/organization-[organization]/header.svelte @@ -36,6 +36,12 @@ event: 'settings', title: 'Settings' }, + { + href: `${path}/usage`, + event: 'usage', + title: 'Usage', + hasChildren: true + }, { href: `${path}/billing`, event: 'billing', diff --git a/src/routes/console/organization-[organization]/usage/[[period]]/+page.svelte b/src/routes/console/organization-[organization]/usage/[[period]]/+page.svelte new file mode 100644 index 000000000..10397aa48 --- /dev/null +++ b/src/routes/console/organization-[organization]/usage/[[period]]/+page.svelte @@ -0,0 +1,31 @@ + + + + Usage +
+

+ Metrics are estimates updated every 24 hours and may not accurately reflect your + invoice. +

+
+

Usage period:

+ + JANUARY 2021 +
+
+
    + {#each data.projectUsage as projectUsage} + {@const usage} + + {/each} +
+
diff --git a/src/routes/console/organization-[organization]/usage/[[period]]/+page.ts b/src/routes/console/organization-[organization]/usage/[[period]]/+page.ts new file mode 100644 index 000000000..3b202da76 --- /dev/null +++ b/src/routes/console/organization-[organization]/usage/[[period]]/+page.ts @@ -0,0 +1,22 @@ +import type { PageLoad } from './$types'; +import { error } from '@sveltejs/kit'; + +export const load: PageLoad = async ({ params }) => { + try { + return { + projectUsage: [ + { + title: 'Total', + usage: { + name: 'badwidth', + max: 100, + used: 50, + unit: 'GB' + } + } + ] + }; + } catch (e) { + throw error(e.code, e.message); + } +}; diff --git a/src/routes/console/project-[project]/functions/function-[function]/usage/[[period]]/+page.ts b/src/routes/console/project-[project]/functions/function-[function]/usage/[[period]]/+page.ts index ba0a4b097..20d256478 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/usage/[[period]]/+page.ts +++ b/src/routes/console/project-[project]/functions/function-[function]/usage/[[period]]/+page.ts @@ -9,7 +9,7 @@ export const load: PageLoad = async ({ params }) => { params.function, params.period ?? '30d' ); - + console.log(response); return { count: response.executionsTotal as unknown as Models.Metric[], errors: response.buildsFailure as unknown as Models.Metric[] diff --git a/src/routes/console/project-[project]/settings/header.svelte b/src/routes/console/project-[project]/settings/header.svelte index b6c51f014..86fe3726d 100644 --- a/src/routes/console/project-[project]/settings/header.svelte +++ b/src/routes/console/project-[project]/settings/header.svelte @@ -21,6 +21,17 @@ href: `${path}/webhooks`, title: 'Webhooks', event: 'webhooks' + }, + { + href: `${path}/usage`, + title: 'Usage', + event: 'usage', + hasChildren: true + }, + { + href: `${path}/billing`, + title: 'Billing', + event: 'billing' } ]; diff --git a/src/routes/console/project-[project]/settings/usage/[[period]]/+page.svelte b/src/routes/console/project-[project]/settings/usage/[[period]]/+page.svelte new file mode 100644 index 000000000..3ab991246 --- /dev/null +++ b/src/routes/console/project-[project]/settings/usage/[[period]]/+page.svelte @@ -0,0 +1,64 @@ + + + +
+ Functions + + + 24h + + + 30d + + + 90d + + +
+ {#if count} + + {total(count)} +

Executions

+
+ [e.date, e.value])] + } + ]} /> + + {/if} + {#if errors} + + {total(errors)} +

Errors

+
+ [e.date, e.value])] + } + ]} /> + + {/if} + diff --git a/src/routes/console/project-[project]/settings/usage/[[period]]/+page.ts b/src/routes/console/project-[project]/settings/usage/[[period]]/+page.ts new file mode 100644 index 000000000..ad4566362 --- /dev/null +++ b/src/routes/console/project-[project]/settings/usage/[[period]]/+page.ts @@ -0,0 +1,20 @@ +// import type { Models } from '@appwrite.io/console'; +// import { sdk } from '$lib/stores/sdk'; +// import type { PageLoad } from './$types'; +// import { error } from '@sveltejs/kit'; + +// export const load: PageLoad = async ({ params }) => { +// try { +// const response = await sdk.forProject.functions.getFunctionUsage( +// params.function, +// params.period ?? '30d' +// ); + +// return { +// count: response.executionsTotal as unknown as Models.Metric[], +// errors: response.buildsFailure as unknown as Models.Metric[] +// }; +// } catch (e) { +// throw error(e.code, e.message); +// } +// };