From af142546e784672b855fd310552ea11fe224bc3e Mon Sep 17 00:00:00 2001
From: Arman
Date: Fri, 15 Nov 2024 16:48:40 +0100
Subject: [PATCH] feat: add usage to deployments
---
src/lib/components/repositories.svelte | 25 +-
.../site-[site]/deployments/+page.svelte | 289 ++++++++++++------
.../createGitDeploymentModal.svelte | 37 ++-
.../deployments/deploymentCard.svelte | 121 --------
.../site-[site]/deployments/usageCard.svelte | 19 ++
5 files changed, 266 insertions(+), 225 deletions(-)
delete mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCard.svelte
create mode 100644 src/routes/(console)/project-[project]/sites/site-[site]/deployments/usageCard.svelte
diff --git a/src/lib/components/repositories.svelte b/src/lib/components/repositories.svelte
index 46152bc57..329e3a629 100644
--- a/src/lib/components/repositories.svelte
+++ b/src/lib/components/repositories.svelte
@@ -18,19 +18,32 @@
export let selectedRepository: string = null;
export let hasInstallations = false;
export let action: 'button' | 'select' = 'select';
+ export let installationList = $installations;
$: {
- hasInstallations = $installations?.total > 0;
+ hasInstallations = installationList?.total > 0;
}
let selectedInstallation = null;
async function loadInstallations() {
- const { installations } = await sdk.forProject.vcs.listInstallations();
- if (installations.length) {
- selectedInstallation = installations[0].$id;
- installation.set(installations.find((entry) => entry.$id === selectedInstallation));
+ if (installationList) {
+ if (installationList.installations.length) {
+ selectedInstallation = installationList.installations[0].$id;
+ installation.set(
+ installationList.installations.find(
+ (entry) => entry.$id === selectedInstallation
+ )
+ );
+ }
+ return installationList.installations;
+ } else {
+ const { installations } = await sdk.forProject.vcs.listInstallations();
+ if (installations.length) {
+ selectedInstallation = installations[0].$id;
+ installation.set(installations.find((entry) => entry.$id === selectedInstallation));
+ }
+ return installations;
}
- return installations;
}
let search = '';
diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.svelte
index 7001737f0..372c25f42 100644
--- a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.svelte
+++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/+page.svelte
@@ -1,9 +1,9 @@
-
-
-
-
-
-
-
- {#if $tags?.length}
-
-
-
-
- {/if}
+
+
+
+
+ Metrics for {range !== SiteUsageRange.TwentyFourHours
+ ? `${toLocaleDate(
+ new Date(
+ now.getTime() -
+ parseInt(range.split('d')[0]) * 24 * 60 * 60 * 1000
+ ).toString()
+ )} to`
+ : ''}
+ {toLocaleDate(now.toString())}
+
+
+
+
+
+
+ {#each metrics as metric}
+
+ {/each}
+
+
+
+
+
+
+
+
+
+ {#if $tags?.length}
+
+
+
+
+ {/if}
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ More filters
+
+
+
+
+
+
+ {#if $deploymentList.total}
+
+
+
+ {:else if data?.query}
+
+ {/if}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- More filters
-
-
-
-
-
-
- {#if $deploymentList.total}
-
- {:else if data?.query}
-
- {/if}
-
-
-
{#if selectedDeployment}
{/if}
diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/createGitDeploymentModal.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/createGitDeploymentModal.svelte
index 1af9e9fca..78136cbd3 100644
--- a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/createGitDeploymentModal.svelte
+++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/createGitDeploymentModal.svelte
@@ -1,10 +1,23 @@
@@ -12,7 +25,25 @@
Enter a valid commit reference to create a new deployment from or
use the CLI to deploy. Learn more
-
+
+
+
+
+
+ name
+
+
+
+
+ console.log('test')} />
diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCard.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCard.svelte
deleted file mode 100644
index e304a32ce..000000000
--- a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/deploymentCard.svelte
+++ /dev/null
@@ -1,121 +0,0 @@
-
-
-
-
-
-
-
-
-
Deployment ID
-
-
- {deployment.$id}
-
-
-
-
- {@const status = deployment.status}
- {@const deploymentSize = humanFileSize(deployment.size)}
- {@const buildSize = humanFileSize(deployment.buildSize)}
- {@const totalSize = humanFileSize(deployment.buildSize + deployment.size)}
-
- -
-
Status
-
-
-
-
- {status === 'ready' ? 'active' : status}
-
-
-
-
- -
-
Build time
-
- {calculateTime(deployment.buildTime)}
-
-
- -
-
Total size
-
- {totalSize.value + totalSize.unit}
-
- Build size: ${buildSize.value + buildSize.unit}
- `,
- allowHTML: true,
- appendTo: 'parent'
- }}>
-
-
-
-
-
- Updated
-
-
-
-
-
-
-
-
- {#if $proxyRuleList?.rules?.length}
-
- {/if}
-
-
-
-
-
-
-
-
diff --git a/src/routes/(console)/project-[project]/sites/site-[site]/deployments/usageCard.svelte b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/usageCard.svelte
new file mode 100644
index 000000000..700c37dd5
--- /dev/null
+++ b/src/routes/(console)/project-[project]/sites/site-[site]/deployments/usageCard.svelte
@@ -0,0 +1,19 @@
+
+
+
+
+ {#if value !== null && value !== undefined}
+ {value}
+ {:else}
+
+ {/if}
+
+ {description}
+
+
+