From 343b9f987fcbe5aadef7ba9704d75767ee61a030 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 8 Jul 2024 10:22:34 +0200 Subject: [PATCH] feat: download button --- package-lock.json | 8 +++--- package.json | 2 +- src/lib/sdk/functions.ts | 26 ------------------- src/lib/stores/sdk.ts | 4 +-- .../deployment-[deployment]/+page.svelte | 13 ++++++++++ .../function-[function]/table.svelte | 17 ++++++------ 6 files changed, 27 insertions(+), 43 deletions(-) delete mode 100644 src/lib/sdk/functions.ts diff --git a/package-lock.json b/package-lock.json index 2de8854a7..8dec65e39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "@appwrite/console", "dependencies": { - "@appwrite.io/console": "npm:matej-appwrite-console-16x@0.6.6", + "@appwrite.io/console": "npm:matej-appwrite-console-16x@0.6.7", "@appwrite.io/pink": "0.23.0", "@appwrite.io/pink-icons": "0.23.0", "@popperjs/core": "^2.11.8", @@ -150,9 +150,9 @@ }, "node_modules/@appwrite.io/console": { "name": "matej-appwrite-console-16x", - "version": "0.6.6", - "resolved": "https://registry.npmjs.org/matej-appwrite-console-16x/-/matej-appwrite-console-16x-0.6.6.tgz", - "integrity": "sha512-QkHHFqFgfMftRcr5L1fz6784+MLEvL3tKNNpBU5W5mzdfFiAwRoBUigrCSmCIfK2IeiAtZBfGrcf/4k83YbnWA==" + "version": "0.6.7", + "resolved": "https://registry.npmjs.org/matej-appwrite-console-16x/-/matej-appwrite-console-16x-0.6.7.tgz", + "integrity": "sha512-orhonLVjV0vzJE/OrI49DRJ75EAkEa+8QzWy30h1N04jNyAcEGFfx4OKmhWg4uG5XRrmWrrDj9nobHKCiBaDCg==" }, "node_modules/@appwrite.io/pink": { "version": "0.23.0", diff --git a/package.json b/package.json index 709b9258e..7fb2d9f0c 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "e2e:ui": "playwright test tests/e2e --ui" }, "dependencies": { - "@appwrite.io/console": "npm:matej-appwrite-console-16x@0.6.6", + "@appwrite.io/console": "npm:matej-appwrite-console-16x@0.6.7", "@appwrite.io/pink": "0.23.0", "@appwrite.io/pink-icons": "0.23.0", "@popperjs/core": "^2.11.8", diff --git a/src/lib/sdk/functions.ts b/src/lib/sdk/functions.ts deleted file mode 100644 index df494e54e..000000000 --- a/src/lib/sdk/functions.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { Client } from '@appwrite.io/console'; - -export class Func { - client: Client; - - constructor(client: Client) { - this.client = client; - } - - async downloadDeployment(functionId: string, deploymentId: string): Promise { - const path = `/functions/${functionId}/deployments/${deploymentId}/download`; - const params = { - functionId, - deploymentId - }; - const uri = new URL(this.client.config.endpoint + path); - return await this.client.call( - 'GET', - uri, - { - 'content-type': 'application/json' - }, - params - ); - } -} diff --git a/src/lib/stores/sdk.ts b/src/lib/stores/sdk.ts index a3e31c050..8dacdc079 100644 --- a/src/lib/stores/sdk.ts +++ b/src/lib/stores/sdk.ts @@ -23,7 +23,6 @@ import { } from '@appwrite.io/console'; import { Billing } from '../sdk/billing'; import { Sources } from '$lib/sdk/sources'; -import { Func } from '$lib/sdk/functions'; const endpoint = VARS.APPWRITE_ENDPOINT ?? `${globalThis?.location?.origin}/v1`; @@ -75,8 +74,7 @@ export const sdk = { console: new Console(clientConsole), assistant: new Assistant(clientConsole), billing: new Billing(clientConsole), - sources: new Sources(clientConsole), - func: new Func(clientConsole) + sources: new Sources(clientConsole) }, get forProject() { const projectId = getProjectId(); diff --git a/src/routes/console/project-[project]/functions/function-[function]/deployment-[deployment]/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/deployment-[deployment]/+page.svelte index 4e38f0fbf..50cf9d442 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/deployment-[deployment]/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/deployment-[deployment]/+page.svelte @@ -29,6 +29,13 @@ invalidate(Dependencies.DEPLOYMENTS); } + function getDownload(deploymentId: string) { + return ( + sdk.forProject.functions.getDeploymentDownload($func.$id, deploymentId).toString() + + '&mode=admin' + ); + } + onMount(() => { logs = $deployment.buildLogs; if ($deployment.status === 'ready') { @@ -61,6 +68,12 @@ showCancel = true; }}>Cancel {/if} + + {#if $deployment.status === 'ready'} + + {/if}