From 24f6921ed2ac588a5ebfc7de4ce5f70e95ce0769 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 11 Feb 2024 20:22:17 +0530 Subject: [PATCH 001/347] feat: initial commit --- src/lib/actions/analytics.ts | 1 + src/lib/sdk/auth.ts | 35 ++++ src/lib/stores/sdk.ts | 2 + .../auth/security/+page.svelte | 2 + .../auth/security/updateMockNumbers.svelte | 166 ++++++++++++++++++ src/routes/console/project-[project]/store.ts | 4 +- 6 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 src/lib/sdk/auth.ts create mode 100644 src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index 181592ef0..0d9b8bccd 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -183,6 +183,7 @@ export enum Submit { AuthPasswordHistoryUpdate = 'submit_auth_password_history_limit_update', AuthPasswordDictionaryUpdate = 'submit_auth_password_dictionary_update', AuthPersonalDataCheckUpdate = 'submit_auth_personal_data_check_update', + AuthMockNumbersUpdate = 'submit_auth_mock_numbers_update', SessionsLengthUpdate = 'submit_sessions_length_update', SessionsLimitUpdate = 'submit_sessions_limit_update', SessionDelete = 'submit_session_delete', diff --git a/src/lib/sdk/auth.ts b/src/lib/sdk/auth.ts new file mode 100644 index 000000000..4a77a485c --- /dev/null +++ b/src/lib/sdk/auth.ts @@ -0,0 +1,35 @@ +import type { Client, Models } from '@appwrite.io/console'; + +export type MockNumber = { + phone: string; + otp: string; +}; + +export type Project = Models.Project & { + authMockNumbers: MockNumber[]; +}; + +export class Auth { + client: Client; + + constructor(client: Client) { + this.client = client; + } + + async updateMockNumbers(projectId: string, numbers: MockNumber[]): Promise { + const path = `/projects/${projectId}/auth/mock-numbers`; + const params = { + projectId, + numbers: numbers + }; + const uri = new URL(this.client.config.endpoint + path); + return await this.client.call( + 'patch', + uri, + { + 'content-type': 'application/json' + }, + params + ); + } +} diff --git a/src/lib/stores/sdk.ts b/src/lib/stores/sdk.ts index caacafee7..aff27ae5a 100644 --- a/src/lib/stores/sdk.ts +++ b/src/lib/stores/sdk.ts @@ -21,6 +21,7 @@ import { Vcs } from '@appwrite.io/console'; import { Billing } from '../sdk/billing'; +import { Auth } from '$lib/sdk/auth'; const endpoint = VARS.APPWRITE_ENDPOINT ?? `${globalThis?.location?.origin}/v1`; @@ -65,6 +66,7 @@ export const sdk = { health: new Health(clientConsole), locale: new Locale(clientConsole), projects: new Projects(clientConsole), + auth: new Auth(clientConsole), teams: new Teams(clientConsole), users: new Users(clientConsole), migrations: new Migrations(clientConsole), diff --git a/src/routes/console/project-[project]/auth/security/+page.svelte b/src/routes/console/project-[project]/auth/security/+page.svelte index f69b91395..0e3ac4f68 100644 --- a/src/routes/console/project-[project]/auth/security/+page.svelte +++ b/src/routes/console/project-[project]/auth/security/+page.svelte @@ -1,5 +1,6 @@ + + + Mock Phone Numbers +

+ Create upto 10 mock phone numbers and verification codes for testing. These numbers + can be used to simulate the phone number verification without sending an SMS. +

+ + + + Use Mock phone numbers with caution + Please use fictious phone numbers and verification codes to avoid affecting real user accounts. + + + +
    + + + +
+
+ + {#if $numbers.length > 0} + + + Phone Number + Verification Code + + + + {#each $numbers as number, i} + + + + {number.phone} + + + + + + {number.otp} + + + + +
+ +
+
+
+ {/each} +
+
+ {/if} +
+ + + + +
diff --git a/src/routes/console/project-[project]/store.ts b/src/routes/console/project-[project]/store.ts index 6af331f1c..18d6eee6d 100644 --- a/src/routes/console/project-[project]/store.ts +++ b/src/routes/console/project-[project]/store.ts @@ -1,11 +1,11 @@ import { page } from '$app/stores'; -import type { Models } from '@appwrite.io/console'; +import type { Project } from '$lib/sdk/auth'; import type { BarSeriesOption } from 'echarts/charts'; import { derived, writable } from 'svelte/store'; export const project = derived( page, - ($page) => $page.data.project as Models.Project & { region?: string } + ($page) => $page.data.project as Project & { region?: string } ); export const onboarding = derived( project, From cd28d85d489f1b3da1afb1d63dd83e0a047fbe5a Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 11 Feb 2024 20:30:43 +0530 Subject: [PATCH 002/347] chore: linter --- .../auth/security/updateMockNumbers.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte index 327cf030d..fd86cfebe 100644 --- a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte +++ b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte @@ -30,7 +30,7 @@ let otp: string = null; onMount(async () => { - console.log($numbers) + console.log($numbers); }); async function updateMockNumbers() { @@ -92,8 +92,8 @@ Mock Phone Numbers

- Create upto 10 mock phone numbers and verification codes for testing. These numbers - can be used to simulate the phone number verification without sending an SMS. + Create upto 10 mock phone numbers and verification codes for testing. These numbers can be + used to simulate the phone number verification without sending an SMS.

From 7019113f57e33d99a2345635a131cf24ed7a2d19 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 16 Jun 2024 22:41:43 +0000 Subject: [PATCH 003/347] chore: sync and updates --- .../auth/security/updateMockNumbers.svelte | 172 ++++++++---------- 1 file changed, 73 insertions(+), 99 deletions(-) diff --git a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte index fd86cfebe..f82c73e92 100644 --- a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte +++ b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte @@ -1,17 +1,8 @@ + + + Execute function - Appwrite + + + + (showExitModal = true)}> + Execute function + + +
+ + {#if func?.version !== 'v3'} + + + Customizable execution data now available for functions v3.0 + + Update your function version to make use of new features including customizable + HTTP data in your executions. + + + + + + {:else} + + + + +
+

+ Headers + (optional) + +

+ + + {#if headers} + {#each headers as [name, value], index} + + + + + + + + {/each} + {/if} + + +
+ + + {/if} +
+
+ test +
+ + + + + +
From 739673cbce825a6bd3ef0fcf26582512422c5aea Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 18 Jun 2024 14:55:39 +0200 Subject: [PATCH 005/347] feat: input date and time compatible with formItemPart --- src/lib/elements/forms/inputDate.svelte | 9 ++++++--- src/lib/elements/forms/inputTime.svelte | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lib/elements/forms/inputDate.svelte b/src/lib/elements/forms/inputDate.svelte index 95cd6813c..a108130fc 100644 --- a/src/lib/elements/forms/inputDate.svelte +++ b/src/lib/elements/forms/inputDate.svelte @@ -1,6 +1,6 @@ - + @@ -93,4 +96,4 @@ {#if error} {error} {/if} - + diff --git a/src/lib/elements/forms/inputTime.svelte b/src/lib/elements/forms/inputTime.svelte index 2e0caf60b..42cad1017 100644 --- a/src/lib/elements/forms/inputTime.svelte +++ b/src/lib/elements/forms/inputTime.svelte @@ -1,6 +1,6 @@ - + @@ -68,4 +71,4 @@ {#if error} {error} {/if} - + From ee8a815cd7baa1e518909fb8b7e538a02aafb42c Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 18 Jun 2024 14:55:53 +0200 Subject: [PATCH 006/347] feat: executions new wizard --- src/lib/layout/wizardSecondaryContent.svelte | 4 +- .../executions/+page.svelte | 2 +- .../executions/execute-function/+page.svelte | 163 ++++++++++++++++-- .../executions/execute-function/+page.ts | 18 ++ 4 files changed, 170 insertions(+), 17 deletions(-) create mode 100644 src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.ts diff --git a/src/lib/layout/wizardSecondaryContent.svelte b/src/lib/layout/wizardSecondaryContent.svelte index 6b69d488a..908995692 100644 --- a/src/lib/layout/wizardSecondaryContent.svelte +++ b/src/lib/layout/wizardSecondaryContent.svelte @@ -4,8 +4,6 @@
-
- -
+
diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte index 6de32a50f..4806d3f8d 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte @@ -19,7 +19,7 @@ import { log } from '$lib/stores/logs'; import { sdk } from '$lib/stores/sdk'; import { onMount } from 'svelte'; - import { func, execute, showFunctionExecute } from '../store'; + import { func, execute } from '../store'; import type { Models } from '@appwrite.io/console'; import { organization } from '$lib/stores/organization'; import { getServiceLimit, showUsageRatesModal } from '$lib/stores/billing'; diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.svelte index 67463cd8b..08524b5d8 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.svelte @@ -3,20 +3,27 @@ import { base } from '$app/paths'; import { page } from '$app/stores'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; + import { timer } from '$lib/actions/timer'; import { tooltip } from '$lib/actions/tooltip'; - import { Alert } from '$lib/components'; + import { Alert, Card } from '$lib/components'; import { Dependencies } from '$lib/constants'; + import { Pill } from '$lib/elements'; import { Button, Form, FormItem, FormItemPart, FormList, + Helper, + InputDate, InputSelect, InputText, - InputTextarea + InputTextarea, + InputTime } from '$lib/elements/forms'; + import { humanFileSize } from '$lib/helpers/sizeConvertion'; + import { calculateTime } from '$lib/helpers/timeConversion'; import { WizardSecondaryContainer, WizardSecondaryContent, @@ -25,8 +32,19 @@ } from '$lib/layout'; import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; - import { ExecutionMethod } from '@appwrite.io/console'; + import { ExecutionMethod, type Models } from '@appwrite.io/console'; import { writable } from 'svelte/store'; + import DeploymentSource from '../../deploymentSource.svelte'; + import DeploymentDomains from '../../deploymentDomains.svelte'; + import { proxyRuleList } from '../../store'; + import DeploymentCreatedBy from '../../deploymentCreatedBy.svelte'; + import { + isSameDay, + toLocaleDate, + toLocaleDateISO, + toLocaleDateTime, + toLocaleTimeISO + } from '$lib/helpers/date'; let previousPage: string = `${base}/console`; let showExitModal = false; @@ -35,15 +53,10 @@ previousPage = from?.url?.pathname || previousPage; }); - let formComponent: Form; - let isSubmitting = writable(false); + export let data; - let path = '/'; - let method = ExecutionMethod.GET; - let body = ''; - let headers: [string, string][] = [['', '']]; - - const func = $page.data.function; + const func = data.function as Models.Function; + const deployment = data.activeDeployment as Models.Deployment; const keyList = [ { label: 'Authorization', value: 'Authorization' }, @@ -67,6 +80,14 @@ { label: 'OPTIONS', value: ExecutionMethod.OPTIONS } ]; + let formComponent: Form; + let isSubmitting = writable(false); + + let path = '/'; + let method = ExecutionMethod.GET; + let body = ''; + let headers: [string, string][] = [['', '']]; + async function handleSubmit() { try { const headersObject = {}; @@ -81,7 +102,8 @@ true, path, method, - headersObject + headersObject, + isScheduled ? dateTime : null ); if (!$page.url?.toString()?.includes('/executions')) { await goto( @@ -103,6 +125,16 @@ }); } } + let isScheduled: boolean = null; + let now = new Date(); + let minDate: string; + let date: string = toLocaleDateISO(now.getTime()); + let time: string = toLocaleTimeISO(now.getTime()); + $: minDate = toLocaleDateISO(now.getTime()); + $: minTime = isSameDay(new Date(date), new Date(minDate)) + ? toLocaleTimeISO(now.getTime()) + : '00:00'; + $: dateTime = new Date(`${date}T${time}`); @@ -231,10 +263,115 @@ placeholder={`Hello, World!`} id="body" bind:value={body} /> + +
  • + + {#if isScheduled} + + + + + {/if} + + {isScheduled + ? `Your function will be executed on ${toLocaleDateTime(dateTime?.toString())}` + : 'Your function will be executed immediately'} + +
  • {/if} - test + + +
    +

    Deployment ID

    + + {func.deployment} + +
    +
      +
    • +

      Status

      +

      + + active + + +

      +
    • +
    • +

      Build time

      +

      + {#if ['processing', 'building'].includes(deployment.status)} + + {:else} + {calculateTime(deployment.buildTime)} + {/if} +

      +
    • +
    • +

      Size

      +

      + {humanFileSize(deployment.size).value + + humanFileSize(deployment.size).unit} +

      +
    • +
    +
    +

    Source

    + + + +
    +
    +

    Domains

    + + + +
    +
    +

    Updated

    + + + +
    +
    +
    diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.ts b/src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.ts new file mode 100644 index 000000000..1d11c6734 --- /dev/null +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.ts @@ -0,0 +1,18 @@ +import { sdk } from '$lib/stores/sdk'; +import { Dependencies } from '$lib/constants'; +import type { PageLoad } from './$types'; + +export const load: PageLoad = async ({ params, depends, parent }) => { + const data = await parent(); + depends(Dependencies.DEPLOYMENTS); + + return { + func: data.function, + activeDeployment: data.function.deployment + ? await sdk.forProject.functions.getDeployment( + params.function, + data.function.deployment + ) + : null + }; +}; From 6d96d688598562cffefb78f3dc12801365de2b5d Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 18 Jun 2024 18:48:48 +0200 Subject: [PATCH 007/347] feat: replace routes --- src/lib/layout/containerButton.svelte | 4 +++- src/lib/layout/containerHeader.svelte | 4 +++- .../functions/function-[function]/+page.svelte | 8 +++----- .../functions/function-[function]/execute.svelte | 1 + .../function-[function]/executions/+page.svelte | 16 +++++++--------- .../settings/executeFunction.svelte | 11 ++++++----- .../functions/function-[function]/store.ts | 4 ++-- 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/lib/layout/containerButton.svelte b/src/lib/layout/containerButton.svelte index 97fb3efd7..facdf58c5 100644 --- a/src/lib/layout/containerButton.svelte +++ b/src/lib/layout/containerButton.svelte @@ -15,6 +15,7 @@ export let disabled: boolean; export let buttonText: string; export let buttonMethod: () => void | Promise; + export let buttonHref: string = null; export let buttonEvent: string = buttonText?.toLocaleLowerCase(); export let icon = 'plus'; export let showIcon = true; @@ -31,7 +32,8 @@ secondary={buttonType === 'secondary'} on:click={buttonMethod} event={buttonEvent} - {disabled}> + {disabled} + href={buttonHref}> {#if showIcon}
    From 4c3432774f16acd2d22ec494bcf57bfd87da0a22 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 20 Jun 2024 18:32:08 +0530 Subject: [PATCH 009/347] chore: fix reactivity --- src/lib/elements/forms/inputPhone.svelte | 3 +- .../auth/security/updateMockNumbers.svelte | 71 +++++++------------ 2 files changed, 27 insertions(+), 47 deletions(-) diff --git a/src/lib/elements/forms/inputPhone.svelte b/src/lib/elements/forms/inputPhone.svelte index 52b5e1153..095e06d65 100644 --- a/src/lib/elements/forms/inputPhone.svelte +++ b/src/lib/elements/forms/inputPhone.svelte @@ -90,7 +90,8 @@ autocomplete={autocomplete ? 'on' : 'off'} bind:value bind:this={element} - on:invalid={handleInvalid} /> + on:invalid={handleInvalid} + on:input /> {#if error} {error} diff --git a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte index 5401f4d79..ead494c1c 100644 --- a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte +++ b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte @@ -1,9 +1,8 @@ @@ -105,13 +80,17 @@ placeholder="Enter Phone Number" label="Phone Number" showLabel={index === 0 ? true : false} + on:input={onInputChanged} required /> {/if} - - {:else} - { - addPhoneNumber({ - phone: '', - otp: '' - }); - }}>Create a mock phone number - {/if} - + {:else} + { + addPhoneNumber({ + phone: '', + otp: '' + }); + }}>Create a mock phone number + {/if} + - - - - + + + + + From 06dcab01659b8e7548302b78093ed596395cc60b Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 20 Jun 2024 19:58:19 +0530 Subject: [PATCH 012/347] chore: update conditions --- .../auth/security/updateMockNumbers.svelte | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte index f6a33dc53..9fba534bd 100644 --- a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte +++ b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte @@ -11,21 +11,12 @@ import { Dependencies } from '$lib/constants'; import { writable } from 'svelte/store'; import Empty from '$lib/components/empty.svelte'; - import { onMount } from 'svelte'; let numbers = writable($project.authMockNumbers); let initialNumbers = []; let projectId: string = $project.$id; let submitDisabled = true; - // onMount(() => { - // initialNumbers = $project.authMockNumbers.map((num) => ({ ...num })); - // }); - - const onInputChanged = () => { - // submitDisabled = JSON.stringify($numbers) === JSON.stringify(initialNumbers); - }; - $: initialNumbers = $project.authMockNumbers.map((num) => ({ ...num })); $: submitDisabled = JSON.stringify($numbers) === JSON.stringify(initialNumbers); @@ -85,7 +76,6 @@ placeholder="Enter Phone Number" label="Phone Number" showLabel={index === 0 ? true : false} - on:input={onInputChanged} maxlength={16} required /> From c474e6a2842d578d173fb234ffcd0f13f97b3fcc Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 20 Jun 2024 20:33:55 +0530 Subject: [PATCH 013/347] Apply suggestions from code review Co-authored-by: Torsten Dittmann --- .../project-[project]/auth/security/updateMockNumbers.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte index 9fba534bd..ea63a5301 100644 --- a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte +++ b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte @@ -12,7 +12,7 @@ import { writable } from 'svelte/store'; import Empty from '$lib/components/empty.svelte'; - let numbers = writable($project.authMockNumbers); + const numbers = writable($project.authMockNumbers); let initialNumbers = []; let projectId: string = $project.$id; let submitDisabled = true; @@ -38,7 +38,7 @@ } } - const addPhoneNumber = (number?: MockNumber) => { + function addPhoneNumber(number?: MockNumber) { numbers.update((n) => [ ...n, { From b9e64b7b497e28962259a4a5dda4e66e1d2ca1b4 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 20 Jun 2024 20:36:24 +0530 Subject: [PATCH 014/347] fix: review comments --- .../project-[project]/auth/security/updateMockNumbers.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte index ea63a5301..a9c2463d7 100644 --- a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte +++ b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte @@ -48,7 +48,7 @@ ]); }; - const deletePhoneNumber = (index: number) => { + function deletePhoneNumber(index: number) { numbers.update((n) => { n.splice(index, 1); return n; From 760b664c49293225c89ec99cd7ace36fe5ad9cfa Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 20 Jun 2024 20:40:22 +0530 Subject: [PATCH 015/347] fix: review comments --- .../auth/security/updateMockNumbers.svelte | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte index a9c2463d7..b5e7adfea 100644 --- a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte +++ b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte @@ -38,12 +38,12 @@ } } - function addPhoneNumber(number?: MockNumber) { + function addPhoneNumber(number: MockNumber) { numbers.update((n) => [ ...n, { - phone: number?.phone, - otp: number?.otp + phone: number.phone, + otp: number.otp } ]); }; @@ -104,7 +104,10 @@ + + + +
    +
    +
    + +
    +
    + +
    +
    + +
    {#if !$func.logging}
    @@ -97,62 +124,8 @@
    {/if} - {#if data.executions.total} - - - Execution ID - Status - Created - Trigger - Method - Path - Duration - - - {#each data.executions.executions as execution} - showLogs(execution)}> - - {execution.$id} - - - {@const status = execution.status} -
    - - {#if status === 'scheduled'} - -
    -
    - - {timeFromNow(execution.$createdAt)} - - - - {execution.trigger} - - - - {execution.requestMethod} - - - {execution.requestPath} - - - {calculateTime(execution.duration)} - -
    - {/each} -
    -
    + {#if data?.executions?.total} + { depends(Dependencies.EXECUTIONS); const page = getPage(url); const limit = getLimit(url, route, PAGE_LIMIT); const offset = pageToOffset(page, limit); + const query = getQuery(url); + + const parsedQueries = queryParamToMap(query || '[]'); + queries.set(parsedQueries); return { offset, limit, + query, executions: await sdk.forProject.functions.listExecutions(params.function, [ Query.limit(limit), Query.offset(offset), - Query.orderDesc('') + Query.orderDesc(''), + ...parsedQueries.values() ]) }; }; diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/table.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/table.svelte new file mode 100644 index 000000000..37c21d3c8 --- /dev/null +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/table.svelte @@ -0,0 +1,104 @@ + + + + + {#each columns as column} + {#if column.show} + {column.title} + {/if} + {/each} + + + {#each data.executions.executions as execution (execution.$id)} + showLogs(execution)}> + {#each columns as column} + {#if column.show} + {#if column.id === '$id'} + {#key column.id} + + {execution.$id} + + {/key} + {:else if column.id === 'status'} + + {@const status = execution.status} +
    + + {#if status === 'scheduled'} + +
    +
    + {:else if column.id === '$createdAt'} + + {timeFromNow(execution.$createdAt)} + + {:else if column.id === 'trigger'} + + + {execution.trigger} + + + {:else if column.id === 'requestMethod'} + + {execution.requestMethod} + + {:else if column.id === 'requestPath'} + + {execution.requestPath} + + {:else if column.id === 'duration'} + + {calculateTime(execution.duration)} + + {/if} + {/if} + {/each} +
    + {/each} +
    +
    From e9ed38016d55a05622ced24264f37df0422e6d9c Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 21 Jun 2024 13:07:42 +0000 Subject: [PATCH 019/347] chore: remove imput --- src/lib/elements/forms/inputPhone.svelte | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/elements/forms/inputPhone.svelte b/src/lib/elements/forms/inputPhone.svelte index 095e06d65..52b5e1153 100644 --- a/src/lib/elements/forms/inputPhone.svelte +++ b/src/lib/elements/forms/inputPhone.svelte @@ -90,8 +90,7 @@ autocomplete={autocomplete ? 'on' : 'off'} bind:value bind:this={element} - on:invalid={handleInvalid} - on:input /> + on:invalid={handleInvalid} /> {#if error} {error} From 94dcccc27c85d5a29bbd05de213f03fba82eecef Mon Sep 17 00:00:00 2001 From: Arman Date: Fri, 21 Jun 2024 16:16:34 +0200 Subject: [PATCH 020/347] refactor: operators are now writable --- src/lib/components/filters/content.svelte | 4 ++-- src/lib/components/filters/store.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index d4de55a86..6c4a00bcb 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -24,14 +24,14 @@ $: column = $columns.find((c) => c.id === columnId) as Column; - $: operatorsForColumn = Object.entries(operators) + $: operatorsForColumn = Object.entries($operators) .filter(([, v]) => v.types.includes(column?.type)) .map(([k]) => ({ label: k, value: k })); - $: operator = operatorKey ? operators[operatorKey] : null; + $: operator = operatorKey ? $operators[operatorKey] : null; $: { columnId; operatorKey = null; diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index f919a9402..1f7777aba 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -1,6 +1,6 @@ import { goto } from '$app/navigation'; -import { derived, get, writable } from 'svelte/store'; +import { derived, get, writable, type Writable } from 'svelte/store'; import { page } from '$app/stores'; import deepEqual from 'deep-equal'; import type { Column, ColumnType } from '$lib/helpers/types'; @@ -105,7 +105,7 @@ export function addFilter( } } -export const operators: Record = { +export const operators: Writable> = writable({ 'starts with': { toQuery: Query.startsWith, toTag: (attribute, input) => `**${attribute}** starts with **${input}**`, @@ -172,7 +172,7 @@ export const operators: Record = { }, types: ['string', 'integer', 'double', 'boolean', 'datetime', 'enum'] } -}; +}); function formatArray(array: string[]) { if (!array?.length) return; From 013ca8e3b0621a6112c9edfe46c44942f694bf19 Mon Sep 17 00:00:00 2001 From: Arman Date: Fri, 21 Jun 2024 16:17:02 +0200 Subject: [PATCH 021/347] empty commit From e74876018d1c432ac62473dd1ff4c6f64d815808 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 24 Jun 2024 15:24:23 +0200 Subject: [PATCH 022/347] fix: droplist element not being full witdh --- src/lib/components/dropList.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/components/dropList.svelte b/src/lib/components/dropList.svelte index 0c802cffd..effecd4a6 100644 --- a/src/lib/components/dropList.svelte +++ b/src/lib/components/dropList.svelte @@ -36,10 +36,10 @@ }`}> {#if $$slots.list}
    + class="drop-section" + style={noMaxWidthList ? 'max-inline-size: 100%' : ''}>
    From b5648d6c72c4cefe5ee38581c2d2ec9c77c3633c Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 24 Jun 2024 16:05:45 +0200 Subject: [PATCH 023/347] feat: add elements to array --- package.json | 2 +- src/lib/components/filters/store.ts | 2 +- .../executions/+page.svelte | 69 +++++++++++++++++-- .../executions/table.svelte | 4 ++ 4 files changed, 69 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 42ec216dd..c49a3eae4 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "e2e:ui": "playwright test tests/e2e --ui" }, "dependencies": { - "@appwrite.io/console": "^0.6.2", + "@appwrite.io/console": "npm:khushboo-console@0.0.3", "@appwrite.io/pink": "0.23.0", "@appwrite.io/pink-icons": "0.23.0", "@popperjs/core": "^2.11.8", diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index 1f7777aba..ce4895420 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -96,7 +96,7 @@ export function addFilter( ) { const operator = operatorKey ? operators[operatorKey] : null; const column = columns.find((c) => c.id === columnId) as Column; - + console.log(column, operator); if (!column || !operator) return; if (column.array) { queries.addFilter({ column, operator, value: arrayValues }); diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte index 0d04ac273..4f341efb2 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte @@ -24,12 +24,69 @@ const columns = writable([ { id: '$id', title: 'Execution ID', type: 'string', show: true, width: 150 }, - { id: 'status', title: 'Status', type: 'string', show: true, width: 110 }, - { id: '$createdAt', title: 'Created', type: 'datetime', show: true, width: 140 }, - { id: 'trigger', title: 'Trigger', type: 'string', show: true, filter: false, width: 90 }, - { id: 'requestMethod', title: 'Method', type: 'string', show: true, width: 70 }, - { id: 'requestPath', title: 'Path', type: 'string', show: true, width: 90 }, - { id: 'duration', title: 'Duration', type: 'string', show: true, width: 80 } + { + id: 'status', + title: 'Status', + type: 'string', + show: true, + width: 110, + array: true, + format: 'enum', + elements: ['completed', 'scheduled', 'waiting', 'processing', 'cancelled', 'failed'] + }, + { + id: '$createdAt', + title: 'Created', + type: 'datetime', + show: true, + width: 140, + format: 'datetime' + }, + { + id: 'trigger', + title: 'Trigger', + type: 'string', + show: true, + width: 90, + array: true, + format: 'enum', + elements: ['http', 'scheduled', 'event'] + }, + { + id: 'requestMethod', + title: 'Method', + type: 'string', + show: true, + width: 70, + array: true, + format: 'enum', + elements: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'] + }, + { + id: 'responseStatusCode', + title: 'Status code', + type: 'string', + show: true, + width: 100, + array: true, + format: 'integer' + }, + { + id: 'requestPath', + title: 'Path', + type: 'string', + show: true, + width: 90, + format: 'string' + }, + { + id: 'duration', + title: 'Duration', + type: 'string', + show: true, + width: 80, + format: 'integer' + } ]); onMount(() => { diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/table.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/table.svelte index 37c21d3c8..89cead33b 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/table.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/table.svelte @@ -87,6 +87,10 @@ {execution.requestMethod} + {:else if column.id === 'responseStatusCode'} + + {execution.responseStatusCode} + {:else if column.id === 'requestPath'} {execution.requestPath} From 8ad01b38dcbc10ead7f37396619ad772151d0a76 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 24 Jun 2024 16:59:57 +0200 Subject: [PATCH 024/347] fix: operators is now a store not a const --- src/lib/components/filters/store.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index ce4895420..01de6d7f0 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -94,9 +94,8 @@ export function addFilter( value: any, // We cast to any to not cause type errors in the input components arrayValues: string[] = [] ) { - const operator = operatorKey ? operators[operatorKey] : null; + const operator = operatorKey ? get(operators)[operatorKey] : null; const column = columns.find((c) => c.id === columnId) as Column; - console.log(column, operator); if (!column || !operator) return; if (column.array) { queries.addFilter({ column, operator, value: arrayValues }); From 963217220296db917a7cf2035486adbefabdf27a Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 24 Jun 2024 18:07:21 +0200 Subject: [PATCH 025/347] feat: refactor operators --- src/lib/components/filters/store.ts | 317 ++++++++++++++++++++++------ 1 file changed, 250 insertions(+), 67 deletions(-) diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index 01de6d7f0..944d702f6 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -104,74 +104,212 @@ export function addFilter( } } -export const operators: Writable> = writable({ - 'starts with': { - toQuery: Query.startsWith, - toTag: (attribute, input) => `**${attribute}** starts with **${input}**`, - types: ['string'] - }, - 'ends with': { - toQuery: Query.endsWith, - toTag: (attribute, input) => `**${attribute}** ends with **${input}**`, - types: ['string'] - }, - 'greater than': { - toQuery: (attr, input) => Query.greaterThan(attr, Number(input)), - toTag: (attribute, input) => `**${attribute}** greater than **${input}**`, - types: ['integer', 'double', 'datetime'] - }, - 'greater than or equal': { - toQuery: (attr, input) => Query.greaterThanEqual(attr, Number(input)), - toTag: (attribute, input) => `**${attribute}** greater than or equal to **${input}**`, - types: ['integer', 'double', 'datetime'] - }, - 'less than': { - toQuery: Query.lessThan, - toTag: (attribute, input) => `**${attribute}** less than **${input}**`, - types: ['integer', 'double', 'datetime'] - }, - 'less than or equal': { - toQuery: Query.lessThanEqual, - toTag: (attribute, input) => `**${attribute}** less than or equal to **${input}**`, - types: ['integer', 'double', 'datetime'] - }, - equal: { - toQuery: Query.equal, - toTag: (attribute, input) => `**${attribute}** equal to **${input}**`, - types: ['string', 'integer', 'double', 'boolean'] - }, - 'not equal': { - toQuery: Query.notEqual, - toTag: (attribute, input) => `**${attribute}** not equal to **${input}**`, - types: ['string', 'integer', 'double', 'boolean'] - }, - 'is not null': { - toQuery: Query.isNotNull, - toTag: (attribute) => `**${attribute}** is not null`, - types: ['string', 'integer', 'double', 'boolean', 'datetime', 'relationship'], - hideInput: true - }, - 'is null': { - toQuery: Query.isNull, - toTag: (attribute) => `**${attribute}** is null`, - types: ['string', 'integer', 'double', 'boolean', 'datetime', 'relationship'], - hideInput: true - }, - contains: { - toQuery: Query.contains, - toTag: (attribute, input) => { - if (Array.isArray(input) && input.length > 2) { - return { - value: input, - tag: `**${attribute}** contains **${formatArray(input)}** ` - }; - } else { - return `**${attribute}** contains **${input}**`; - } - }, - types: ['string', 'integer', 'double', 'boolean', 'datetime', 'enum'] +// const defaultOperators: Record = { +// 'starts with': { +// toQuery: Query.startsWith, +// toTag: (attribute, input) => `**${attribute}** starts with **${input}**`, +// types: ['string'] +// }, +// 'ends with': { +// toQuery: Query.endsWith, +// toTag: (attribute, input) => `**${attribute}** ends with **${input}**`, +// types: ['string'] +// }, +// 'greater than': { +// toQuery: (attr, input) => Query.greaterThan(attr, Number(input)), +// toTag: (attribute, input) => `**${attribute}** greater than **${input}**`, +// types: ['integer', 'double', 'datetime'] +// }, +// 'greater than or equal': { +// toQuery: (attr, input) => Query.greaterThanEqual(attr, Number(input)), +// toTag: (attribute, input) => `**${attribute}** greater than or equal to **${input}**`, +// types: ['integer', 'double', 'datetime'] +// }, +// 'less than': { +// toQuery: Query.lessThan, +// toTag: (attribute, input) => `**${attribute}** less than **${input}**`, +// types: ['integer', 'double', 'datetime'] +// }, +// 'less than or equal': { +// toQuery: Query.lessThanEqual, +// toTag: (attribute, input) => `**${attribute}** less than or equal to **${input}**`, +// types: ['integer', 'double', 'datetime'] +// }, +// equal: { +// toQuery: Query.equal, +// toTag: (attribute, input) => `**${attribute}** equal to **${input}**`, +// types: ['string', 'integer', 'double', 'boolean'] +// }, +// 'not equal': { +// toQuery: Query.notEqual, +// toTag: (attribute, input) => `**${attribute}** not equal to **${input}**`, +// types: ['string', 'integer', 'double', 'boolean'] +// }, +// 'is not null': { +// toQuery: Query.isNotNull, +// toTag: (attribute) => `**${attribute}** is not null`, +// types: ['string', 'integer', 'double', 'boolean', 'datetime', 'relationship'], +// hideInput: true +// }, +// 'is null': { +// toQuery: Query.isNull, +// toTag: (attribute) => `**${attribute}** is null`, +// types: ['string', 'integer', 'double', 'boolean', 'datetime', 'relationship'], +// hideInput: true +// }, +// contains: { +// toQuery: Query.contains, +// toTag: (attribute, input) => { +// if (Array.isArray(input) && input.length > 2) { +// return { +// value: input, +// tag: `**${attribute}** contains **${formatArray(input)}** ` +// }; +// } else { +// return `**${attribute}** contains **${input}**`; +// } +// }, +// types: ['string', 'integer', 'double', 'boolean', 'datetime', 'enum'] +// } +// }; + +enum ValidOperators { + startsWith = 'starts with', + endsWith = 'ends with', + greaterThan = 'greater than', + greaterThanOrEqual = 'greater than or equal', + lessThan = 'less than', + lessThanOrEqual = 'less than or equal', + equal = 'equal', + notEqual = 'not equal', + isNotNull = 'is not null', + isNull = 'is null', + contains = 'contains' +} + +enum ValidTypes { + string = 'string', + integer = 'integer', + double = 'double', + boolean = 'boolean', + datetime = 'datetime', + relationship = 'relationship', + enum = 'enum' +} + +const operatorsMap = new Map< + ValidOperators, + { + name: ValidOperators; + query: (attr: string, input: string | number | string[]) => string; + types: ColumnType[]; + hideInput?: boolean; } -}); +>([ + [ + ValidOperators.startsWith, + { name: ValidOperators.startsWith, query: Query.startsWith, types: [ValidTypes.string] } + ], + [ + ValidOperators.endsWith, + { name: ValidOperators.endsWith, query: Query.endsWith, types: [ValidTypes.string] } + ], + [ + ValidOperators.greaterThan, + { + name: ValidOperators.greaterThan, + query: Query.greaterThan, + types: [ValidTypes.integer, ValidTypes.double, ValidTypes.datetime] + } + ], + [ + ValidOperators.greaterThanOrEqual, + { + name: ValidOperators.greaterThanOrEqual, + query: Query.greaterThanEqual, + types: [ValidTypes.integer, ValidTypes.double, ValidTypes.datetime] + } + ], + [ + ValidOperators.lessThan, + { + name: ValidOperators.lessThan, + query: Query.lessThan, + types: [ValidTypes.integer, ValidTypes.double, ValidTypes.datetime] + } + ], + [ + ValidOperators.lessThanOrEqual, + { + name: ValidOperators.lessThanOrEqual, + query: Query.lessThanEqual, + types: [ValidTypes.integer, ValidTypes.double, ValidTypes.datetime] + } + ], + [ + ValidOperators.equal, + { + name: ValidOperators.equal, + query: Query.equal, + types: [ValidTypes.string, ValidTypes.integer, ValidTypes.double, ValidTypes.boolean] + } + ], + [ + ValidOperators.notEqual, + { + name: ValidOperators.notEqual, + query: Query.notEqual, + types: [ValidTypes.string, ValidTypes.integer, ValidTypes.double, ValidTypes.boolean] + } + ], + [ + ValidOperators.isNotNull, + { + name: ValidOperators.isNotNull, + query: Query.isNotNull, + types: [ + ValidTypes.string, + ValidTypes.integer, + ValidTypes.double, + ValidTypes.boolean, + ValidTypes.datetime, + ValidTypes.relationship + ], + hideInput: true + } + ], + [ + ValidOperators.isNull, + { + name: ValidOperators.isNull, + query: Query.isNull, + types: [ + ValidTypes.string, + ValidTypes.integer, + ValidTypes.double, + ValidTypes.boolean, + ValidTypes.datetime, + ValidTypes.relationship + ], + hideInput: true + } + ], + [ + ValidOperators.contains, + { + name: ValidOperators.contains, + query: Query.contains, + types: [ + ValidTypes.string, + ValidTypes.integer, + ValidTypes.double, + ValidTypes.boolean, + ValidTypes.datetime, + ValidTypes.enum + ] + } + ] +]); function formatArray(array: string[]) { if (!array?.length) return; @@ -181,3 +319,48 @@ function formatArray(array: string[]) { return array.join(' or '); } } + +function createOperatorStore() { + const generateDefaultOperators = () => { + const operators: Record = {}; + operatorsMap.forEach((value, key) => { + operators[key] = { + toQuery: value.query, + toTag: (attribute, input = null) => { + if (input === null) { + return `**${attribute}** ${value.name}`; + } else if (Array.isArray(input) && input.length > 2) { + return { + value: input, + tag: `**${attribute}** ${value.name} **${formatArray(input)}** ` + }; + } else { + return `**${attribute}** ${value.name} **${input}**`; + } + }, + types: value.types, + hideInput: value.hideInput + }; + }); + return operators; + }; + + const { subscribe, set, update } = writable>({ + ...generateDefaultOperators() + }); + + return { + subscribe, + set, + update, + setOperatorType: (operator: ValidOperators, type: ColumnType[]) => { + if (!operatorsMap.has(operator)) return; + update((operators) => { + operators[operator].types = type; + return operators; + }); + } + }; +} + +export const operators = createOperatorStore(); From 7c0bdac7f5035e140ae23c1f1ae913fbde8c9b69 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 25 Jun 2024 16:38:01 +0200 Subject: [PATCH 026/347] refactor: operators store --- src/lib/components/filters/store.ts | 259 ++++++------------ .../executions/+page.svelte | 4 +- 2 files changed, 92 insertions(+), 171 deletions(-) diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index 944d702f6..bf15ba091 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -1,6 +1,6 @@ import { goto } from '$app/navigation'; -import { derived, get, writable, type Writable } from 'svelte/store'; +import { derived, get, writable } from 'svelte/store'; import { page } from '$app/stores'; import deepEqual from 'deep-equal'; import type { Column, ColumnType } from '$lib/helpers/types'; @@ -104,208 +104,123 @@ export function addFilter( } } -// const defaultOperators: Record = { -// 'starts with': { -// toQuery: Query.startsWith, -// toTag: (attribute, input) => `**${attribute}** starts with **${input}**`, -// types: ['string'] -// }, -// 'ends with': { -// toQuery: Query.endsWith, -// toTag: (attribute, input) => `**${attribute}** ends with **${input}**`, -// types: ['string'] -// }, -// 'greater than': { -// toQuery: (attr, input) => Query.greaterThan(attr, Number(input)), -// toTag: (attribute, input) => `**${attribute}** greater than **${input}**`, -// types: ['integer', 'double', 'datetime'] -// }, -// 'greater than or equal': { -// toQuery: (attr, input) => Query.greaterThanEqual(attr, Number(input)), -// toTag: (attribute, input) => `**${attribute}** greater than or equal to **${input}**`, -// types: ['integer', 'double', 'datetime'] -// }, -// 'less than': { -// toQuery: Query.lessThan, -// toTag: (attribute, input) => `**${attribute}** less than **${input}**`, -// types: ['integer', 'double', 'datetime'] -// }, -// 'less than or equal': { -// toQuery: Query.lessThanEqual, -// toTag: (attribute, input) => `**${attribute}** less than or equal to **${input}**`, -// types: ['integer', 'double', 'datetime'] -// }, -// equal: { -// toQuery: Query.equal, -// toTag: (attribute, input) => `**${attribute}** equal to **${input}**`, -// types: ['string', 'integer', 'double', 'boolean'] -// }, -// 'not equal': { -// toQuery: Query.notEqual, -// toTag: (attribute, input) => `**${attribute}** not equal to **${input}**`, -// types: ['string', 'integer', 'double', 'boolean'] -// }, -// 'is not null': { -// toQuery: Query.isNotNull, -// toTag: (attribute) => `**${attribute}** is not null`, -// types: ['string', 'integer', 'double', 'boolean', 'datetime', 'relationship'], -// hideInput: true -// }, -// 'is null': { -// toQuery: Query.isNull, -// toTag: (attribute) => `**${attribute}** is null`, -// types: ['string', 'integer', 'double', 'boolean', 'datetime', 'relationship'], -// hideInput: true -// }, -// contains: { -// toQuery: Query.contains, -// toTag: (attribute, input) => { -// if (Array.isArray(input) && input.length > 2) { -// return { -// value: input, -// tag: `**${attribute}** contains **${formatArray(input)}** ` -// }; -// } else { -// return `**${attribute}** contains **${input}**`; -// } -// }, -// types: ['string', 'integer', 'double', 'boolean', 'datetime', 'enum'] -// } -// }; - -enum ValidOperators { - startsWith = 'starts with', - endsWith = 'ends with', - greaterThan = 'greater than', - greaterThanOrEqual = 'greater than or equal', - lessThan = 'less than', - lessThanOrEqual = 'less than or equal', - equal = 'equal', - notEqual = 'not equal', - isNotNull = 'is not null', - isNull = 'is null', - contains = 'contains' +export enum ValidOperators { + StartsWith = 'starts with', + EndsWith = 'ends with', + GreaterThan = 'greater than', + GreaterThanOrEqual = 'greater than or equal', + LessThan = 'less than', + LessThanOrEqual = 'less than or equal', + Equal = 'equal', + NotEqual = 'not equal', + IsNotNull = 'is not null', + IsNull = 'is null', + Contains = 'contains' } -enum ValidTypes { - string = 'string', - integer = 'integer', - double = 'double', - boolean = 'boolean', - datetime = 'datetime', - relationship = 'relationship', - enum = 'enum' +export enum ValidTypes { + String = 'string', + Integer = 'integer', + Double = 'double', + Boolean = 'boolean', + Datetime = 'datetime', + Relationship = 'relationship', + Enum = 'enum' } -const operatorsMap = new Map< +const operatorsDefault = new Map< ValidOperators, { - name: ValidOperators; query: (attr: string, input: string | number | string[]) => string; types: ColumnType[]; hideInput?: boolean; } >([ + [ValidOperators.StartsWith, { query: Query.startsWith, types: [ValidTypes.String] }], + [ValidOperators.EndsWith, { query: Query.endsWith, types: [ValidTypes.String] }], [ - ValidOperators.startsWith, - { name: ValidOperators.startsWith, query: Query.startsWith, types: [ValidTypes.string] } - ], - [ - ValidOperators.endsWith, - { name: ValidOperators.endsWith, query: Query.endsWith, types: [ValidTypes.string] } - ], - [ - ValidOperators.greaterThan, + ValidOperators.GreaterThan, { - name: ValidOperators.greaterThan, query: Query.greaterThan, - types: [ValidTypes.integer, ValidTypes.double, ValidTypes.datetime] + types: [ValidTypes.Integer, ValidTypes.Double, ValidTypes.Datetime] } ], [ - ValidOperators.greaterThanOrEqual, + ValidOperators.GreaterThanOrEqual, { - name: ValidOperators.greaterThanOrEqual, query: Query.greaterThanEqual, - types: [ValidTypes.integer, ValidTypes.double, ValidTypes.datetime] + types: [ValidTypes.Integer, ValidTypes.Double, ValidTypes.Datetime] } ], [ - ValidOperators.lessThan, + ValidOperators.LessThan, { - name: ValidOperators.lessThan, query: Query.lessThan, - types: [ValidTypes.integer, ValidTypes.double, ValidTypes.datetime] + types: [ValidTypes.Integer, ValidTypes.Double, ValidTypes.Datetime] } ], [ - ValidOperators.lessThanOrEqual, + ValidOperators.LessThanOrEqual, { - name: ValidOperators.lessThanOrEqual, query: Query.lessThanEqual, - types: [ValidTypes.integer, ValidTypes.double, ValidTypes.datetime] + types: [ValidTypes.Integer, ValidTypes.Double, ValidTypes.Datetime] } ], [ - ValidOperators.equal, + ValidOperators.Equal, { - name: ValidOperators.equal, query: Query.equal, - types: [ValidTypes.string, ValidTypes.integer, ValidTypes.double, ValidTypes.boolean] + types: [ValidTypes.String, ValidTypes.Integer, ValidTypes.Double, ValidTypes.Boolean] } ], [ - ValidOperators.notEqual, + ValidOperators.NotEqual, { - name: ValidOperators.notEqual, query: Query.notEqual, - types: [ValidTypes.string, ValidTypes.integer, ValidTypes.double, ValidTypes.boolean] + types: [ValidTypes.String, ValidTypes.Integer, ValidTypes.Double, ValidTypes.Boolean] } ], [ - ValidOperators.isNotNull, + ValidOperators.IsNotNull, { - name: ValidOperators.isNotNull, query: Query.isNotNull, types: [ - ValidTypes.string, - ValidTypes.integer, - ValidTypes.double, - ValidTypes.boolean, - ValidTypes.datetime, - ValidTypes.relationship + ValidTypes.String, + ValidTypes.Integer, + ValidTypes.Double, + ValidTypes.Boolean, + ValidTypes.Datetime, + ValidTypes.Relationship ], hideInput: true } ], [ - ValidOperators.isNull, + ValidOperators.IsNull, { - name: ValidOperators.isNull, query: Query.isNull, types: [ - ValidTypes.string, - ValidTypes.integer, - ValidTypes.double, - ValidTypes.boolean, - ValidTypes.datetime, - ValidTypes.relationship + ValidTypes.String, + ValidTypes.Integer, + ValidTypes.Double, + ValidTypes.Boolean, + ValidTypes.Datetime, + ValidTypes.Relationship ], hideInput: true } ], [ - ValidOperators.contains, + ValidOperators.Contains, { - name: ValidOperators.contains, query: Query.contains, types: [ - ValidTypes.string, - ValidTypes.integer, - ValidTypes.double, - ValidTypes.boolean, - ValidTypes.datetime, - ValidTypes.enum + ValidTypes.String, + ValidTypes.Integer, + ValidTypes.Double, + ValidTypes.Boolean, + ValidTypes.Datetime, + ValidTypes.Enum ] } ] @@ -320,31 +235,31 @@ function formatArray(array: string[]) { } } -function createOperatorStore() { - const generateDefaultOperators = () => { - const operators: Record = {}; - operatorsMap.forEach((value, key) => { - operators[key] = { - toQuery: value.query, - toTag: (attribute, input = null) => { - if (input === null) { - return `**${attribute}** ${value.name}`; - } else if (Array.isArray(input) && input.length > 2) { - return { - value: input, - tag: `**${attribute}** ${value.name} **${formatArray(input)}** ` - }; - } else { - return `**${attribute}** ${value.name} **${input}**`; - } - }, - types: value.types, - hideInput: value.hideInput - }; - }); - return operators; - }; +function generateDefaultOperators() { + const operators: Record = {}; + operatorsDefault.forEach((operator, operatorName) => { + operators[operatorName] = { + toQuery: operator.query, + toTag: (attribute, input = null) => { + if (input === null) { + return `**${attribute}** ${operatorName}`; + } else if (Array.isArray(input) && input.length > 2) { + return { + value: input, + tag: `**${attribute}** ${operatorName} **${formatArray(input)}** ` + }; + } else { + return `**${attribute}** ${operatorName} **${input}**`; + } + }, + types: operator.types, + hideInput: operator.hideInput + }; + }); + return operators; +} +function createOperatorStore() { const { subscribe, set, update } = writable>({ ...generateDefaultOperators() }); @@ -353,10 +268,16 @@ function createOperatorStore() { subscribe, set, update, - setOperatorType: (operator: ValidOperators, type: ColumnType[]) => { - if (!operatorsMap.has(operator)) return; + reset: () => { + update(() => { + return { ...generateDefaultOperators() }; + }); + }, + setActiveOperators: (activeOperators: ValidOperators[]) => { update((operators) => { - operators[operator].types = type; + operatorsDefault.forEach((value, key) => { + operators[key].types = activeOperators.includes(key) ? value.types : []; + }); return operators; }); } diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte index 4f341efb2..2b0794b8c 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte @@ -22,6 +22,8 @@ export let data; + const logs = getServiceLimit('logs'); + const columns = writable([ { id: '$id', title: 'Execution ID', type: 'string', show: true, width: 150 }, { @@ -96,8 +98,6 @@ } }); }); - - const logs = getServiceLimit('logs'); From afce6892910ec9edea039b40bfd88a231a66ef6e Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 25 Jun 2024 16:39:10 +0200 Subject: [PATCH 027/347] refactor: operators doesn't need to be a store --- src/lib/components/filters/content.svelte | 4 ++-- src/lib/components/filters/store.ts | 29 ++--------------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index e29c7698b..6bd854c4c 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -24,14 +24,14 @@ $: column = $columns.find((c) => c.id === columnId) as Column; - $: operatorsForColumn = Object.entries($operators) + $: operatorsForColumn = Object.entries(operators) .filter(([, v]) => v.types.includes(column?.type)) .map(([k]) => ({ label: k, value: k })); - $: operator = operatorKey ? $operators[operatorKey] : null; + $: operator = operatorKey ? operators[operatorKey] : null; $: { columnId; operatorKey = null; diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index bf15ba091..af66910f1 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -94,7 +94,7 @@ export function addFilter( value: any, // We cast to any to not cause type errors in the input components arrayValues: string[] = [] ) { - const operator = operatorKey ? get(operators)[operatorKey] : null; + const operator = operatorKey ? operators[operatorKey] : null; const column = columns.find((c) => c.id === columnId) as Column; if (!column || !operator) return; if (column.array) { @@ -259,29 +259,4 @@ function generateDefaultOperators() { return operators; } -function createOperatorStore() { - const { subscribe, set, update } = writable>({ - ...generateDefaultOperators() - }); - - return { - subscribe, - set, - update, - reset: () => { - update(() => { - return { ...generateDefaultOperators() }; - }); - }, - setActiveOperators: (activeOperators: ValidOperators[]) => { - update((operators) => { - operatorsDefault.forEach((value, key) => { - operators[key].types = activeOperators.includes(key) ? value.types : []; - }); - return operators; - }); - } - }; -} - -export const operators = createOperatorStore(); +export const operators = generateDefaultOperators(); From 049f3a358788a4ff6d663b3e7bde758320f7c748 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 25 Jun 2024 16:52:34 +0200 Subject: [PATCH 028/347] feat: add datetime filter --- src/lib/components/filters/content.svelte | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index 6bd854c4c..b954e1514 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -6,7 +6,8 @@ InputText, InputTags, FormList, - InputSelectCheckbox + InputSelectCheckbox, + InputDateTime } from '$lib/elements/forms'; import { createEventDispatcher, onMount } from 'svelte'; import { tags, queries, type TagValue, operators, addFilter } from './store'; @@ -138,6 +139,8 @@ { label: 'False', value: false } ].filter(Boolean)} bind:value /> + {:else if column.type === 'datetime'} + {:else} {/if} From 45cb5971cfe4dfe6213700f8a29ee51c268b78a6 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 25 Jun 2024 16:52:51 +0200 Subject: [PATCH 029/347] fix: use colum title in the tag, not id --- src/lib/components/filters/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index af66910f1..eb20d01e2 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -39,7 +39,7 @@ function initQueries(initialValue = new Map()) { function addFilter({ column, operator, value }: AddFilterArgs) { queries.update((map) => { - map.set(operator.toTag(column.id, value), operator.toQuery(column.id, value)); + map.set(operator.toTag(column.title, value), operator.toQuery(column.id, value)); return map; }); } From ca30a2ddeee7c77940e85a17b7a90e8487248c25 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 26 Jun 2024 16:33:39 +0200 Subject: [PATCH 030/347] feat: create tagList component, fix logic for enums and arrays --- src/lib/components/filters/content.svelte | 48 ++--------------- src/lib/components/filters/filters.svelte | 6 ++- src/lib/components/filters/index.ts | 1 + src/lib/components/filters/store.ts | 16 +++++- src/lib/components/filters/tagList.svelte | 51 +++++++++++++++++++ .../executions/+page.svelte | 5 +- 6 files changed, 76 insertions(+), 51 deletions(-) create mode 100644 src/lib/components/filters/tagList.svelte diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index b954e1514..6bba3b686 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -10,10 +10,10 @@ InputDateTime } from '$lib/elements/forms'; import { createEventDispatcher, onMount } from 'svelte'; - import { tags, queries, type TagValue, operators, addFilter } from './store'; + import { tags, operators, addFilter } from './store'; import type { Column } from '$lib/helpers/types'; import type { Writable } from 'svelte/store'; - import { tooltip } from '$lib/actions/tooltip'; + import { TagList } from '.'; // We cast to any to not cause type errors in the input components /* eslint @typescript-eslint/no-explicit-any: 'off' */ @@ -52,21 +52,6 @@ arrayValues = []; } - function tagFormat(node: HTMLElement) { - node.innerHTML = node.innerHTML.replace(/\*\*(.*?)\*\*/g, '$1'); - } - - function isTypeTagValue(obj: any): obj is TagValue { - if (typeof obj === 'string') return false; - return ( - obj && - typeof obj.tag === 'string' && - (typeof obj.value === 'string' || - typeof obj.value === 'number' || - Array.isArray(obj.value)) - ); - } - const dispatch = createEventDispatcher<{ clear: void; apply: { applied: number }; @@ -154,34 +139,7 @@
      - {#each $tags as tag (tag)} - {#if isTypeTagValue(tag)} - - {:else} - - {/if} - {/each} +
    diff --git a/src/lib/components/filters/filters.svelte b/src/lib/components/filters/filters.svelte index 45e121eb7..f56584fe0 100644 --- a/src/lib/components/filters/filters.svelte +++ b/src/lib/components/filters/filters.svelte @@ -39,7 +39,7 @@ } function apply() { - if (selectedColumn && operatorKey && value) { + if (selectedColumn && operatorKey && (value || arrayValues.length)) { addFilter($columns, selectedColumn, operatorKey, value, arrayValues); selectedColumn = null; value = null; @@ -53,7 +53,9 @@ selectedColumn = null; } - $: isButtonDisabled = $queriesAreDirty ? false : !selectedColumn || !operatorKey || !value; + $: isButtonDisabled = $queriesAreDirty + ? false + : !selectedColumn || !operatorKey || (!value && !arrayValues.length);
    diff --git a/src/lib/components/filters/index.ts b/src/lib/components/filters/index.ts index 223e43ebf..7d3b7f3d2 100644 --- a/src/lib/components/filters/index.ts +++ b/src/lib/components/filters/index.ts @@ -1,2 +1,3 @@ export { default as Filters } from './filters.svelte'; +export { default as TagList } from './tagList.svelte'; export { hasPageQueries, queryParamToMap, queries } from '$lib/components/filters/store'; diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index eb20d01e2..a3a94bd31 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -170,14 +170,26 @@ const operatorsDefault = new Map< ValidOperators.Equal, { query: Query.equal, - types: [ValidTypes.String, ValidTypes.Integer, ValidTypes.Double, ValidTypes.Boolean] + types: [ + ValidTypes.String, + ValidTypes.Integer, + ValidTypes.Double, + ValidTypes.Boolean, + ValidTypes.Enum + ] } ], [ ValidOperators.NotEqual, { query: Query.notEqual, - types: [ValidTypes.String, ValidTypes.Integer, ValidTypes.Double, ValidTypes.Boolean] + types: [ + ValidTypes.String, + ValidTypes.Integer, + ValidTypes.Double, + ValidTypes.Boolean, + ValidTypes.Enum + ] } ], [ diff --git a/src/lib/components/filters/tagList.svelte b/src/lib/components/filters/tagList.svelte new file mode 100644 index 000000000..6b69efa4c --- /dev/null +++ b/src/lib/components/filters/tagList.svelte @@ -0,0 +1,51 @@ + + +{#each $tags as tag (tag)} + {#if isTypeTagValue(tag)} + + {:else} + + {/if} +{/each} diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte index 2b0794b8c..963022919 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte @@ -14,7 +14,7 @@ import Create from '../create.svelte'; import { abbreviateNumber } from '$lib/helpers/numbers'; import { base } from '$app/paths'; - import { Filters } from '$lib/components/filters'; + import { Filters, TagList } from '$lib/components/filters'; import { writable } from 'svelte/store'; import type { Column } from '$lib/helpers/types'; import { View } from '$lib/helpers/load'; @@ -29,7 +29,7 @@ { id: 'status', title: 'Status', - type: 'string', + type: 'enum', show: true, width: 110, array: true, @@ -101,6 +101,7 @@ +

    The {tier} plan has limits

    From 0e72ef72531c0c1a519282c0d79a24199e960aca Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:28:16 +0100 Subject: [PATCH 031/347] feat: cancel & delete executions --- src/lib/actions/analytics.ts | 2 + .../executions/+page.svelte | 86 +++++++++++++++++-- .../executions/cancel.svelte | 47 ++++++++++ .../executions/delete.svelte | 47 ++++++++++ 4 files changed, 176 insertions(+), 6 deletions(-) create mode 100644 src/routes/console/project-[project]/functions/function-[function]/executions/cancel.svelte create mode 100644 src/routes/console/project-[project]/functions/function-[function]/executions/delete.svelte diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index 744a4e351..446536878 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -233,6 +233,8 @@ export enum Submit { DeploymentDelete = 'submit_deployment_delete', DeploymentUpdate = 'submit_deployment_update', ExecutionCreate = 'submit_execution_create', + ExecutionDelete = 'submit_execution_delete', + ExecutionCancel = 'submit_execution_cancel', VariableCreate = 'submit_variable_create', VariableDelete = 'submit_variable_delete', VariableUpdate = 'submit_variable_update', diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte index c9eae98f7..c669a7d9a 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte @@ -1,6 +1,15 @@ + + +

    Are you sure you want to cancel this execution?

    + + + + +
    diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/delete.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/delete.svelte new file mode 100644 index 000000000..f9bde2f5f --- /dev/null +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/delete.svelte @@ -0,0 +1,47 @@ + + + +

    Are you sure you want to delete this execution?

    + + + + +
    From 9a4bfe892a54e5cc5ad3ec850b23a56d2758895b Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:32:06 +0100 Subject: [PATCH 032/347] chore: unused imports --- .../functions/function-[function]/executions/+page.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte index c669a7d9a..44dc48105 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte @@ -1,11 +1,9 @@ - - -

    Are you sure you want to cancel this execution?

    - - - - -
    diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/delete.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/delete.svelte index f9bde2f5f..bf99d4745 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/delete.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/delete.svelte @@ -14,7 +14,7 @@ async function handleSubmit() { try { // TODO: update SDK to use the new function - // await sdk.forProject.functions.deleteExecution(selectedExecution.$id); + /// await sdk.forProject.functions.deleteExecution(selectedExecution.$id); await invalidate(Dependencies.FUNCTION); showDelete = false; addNotification({ From b49b03de8083876690460929a58347b43c7b6093 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 27 Jun 2024 13:27:40 +0100 Subject: [PATCH 035/347] chore: arman review --- .../function-[function]/executions/+page.svelte | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte index b75f84d3a..e76b6f9bf 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte @@ -166,14 +166,15 @@ bind:show={showDropdown[index]} placement="bottom-start" noArrow> - + Date: Thu, 27 Jun 2024 14:36:23 +0200 Subject: [PATCH 036/347] feat: new layout --- src/lib/components/filters/content.svelte | 36 +++++++++++++---- src/lib/components/filters/filters.svelte | 39 +++++++++++++------ src/lib/components/filters/store.ts | 24 +++++++----- .../executions/+page.svelte | 34 ++++++++++++++-- 4 files changed, 100 insertions(+), 33 deletions(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index 6bba3b686..b43bddd85 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -22,6 +22,7 @@ export let columnId: string | null = null; export let arrayValues: string[] = []; export let operatorKey: string | null = null; + export let singleCondition = false; $: column = $columns.find((c) => c.id === columnId) as Column; @@ -42,6 +43,12 @@ onMount(() => { value = column?.array ? [] : null; + if (column?.type === 'datetime') { + const today = new Date(); + console.log(today.toISOString()); + value = today.toISOString(); + console.log(value); + } }); function addFilterAndReset() { @@ -57,6 +64,13 @@ apply: { applied: number }; }>(); dispatch('apply', { applied: $tags.length }); + + // $: if (column?.type === 'datetime' && !value) { + // const today = new Date(); + // console.log(today.toISOString()); + // value = today.toISOString(); + // console.log('value', value); + // }
    @@ -125,22 +139,28 @@ ].filter(Boolean)} bind:value /> {:else if column.type === 'datetime'} - + {#key value} + + {/key} {:else} {/if} {/if} {/if} - + {#if !singleCondition} + + {/if} -
      - -
    + {#if !singleCondition} +
      + +
    + {/if}
    From e7a91e22087fec2230752d0691e41985b85bbe66 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:38:40 +0100 Subject: [PATCH 049/347] feat: add lightning icon --- .../functions/function-[function]/+page.svelte | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte index f64ffa767..86a97c98c 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte @@ -241,7 +241,10 @@ {#if activeDeployment?.$id === deployment?.$id} - active + {:else} Date: Fri, 28 Jun 2024 17:39:49 +0100 Subject: [PATCH 050/347] chore: fmt --- .../functions/function-[function]/+page.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte index 86a97c98c..ed44d630a 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte @@ -241,8 +241,8 @@ {#if activeDeployment?.$id === deployment?.$id} -
    - +
    {:else if data?.query}
    diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte index 1adbd4754..c548a8ad0 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/+page.svelte @@ -164,7 +164,7 @@
    - + From 0123f18e90711c1916a567d7dc1f4859f7e56425 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 3 Jul 2024 13:32:47 +0200 Subject: [PATCH 068/347] chore: bump sdk, fix mock numbers --- package-lock.json | 8 ++++---- package.json | 2 +- src/lib/elements/forms/inputPhone.svelte | 2 ++ .../auth/security/updateMockNumbers.svelte | 11 +++++++---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index ec829eefd..303408b06 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.4", + "@appwrite.io/console": "npm:matej-appwrite-console-16x@0.6.5", "@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.4", - "resolved": "https://registry.npmjs.org/matej-appwrite-console-16x/-/matej-appwrite-console-16x-0.6.4.tgz", - "integrity": "sha512-hovc+6HFyC20lUmlD0R5kAsDMBLXXJWEES2mUAaKG56aQ1wOwQRhVOIUGmvX/1EasiUOq5dH/5uzrU+fl5C+Dw==" + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/matej-appwrite-console-16x/-/matej-appwrite-console-16x-0.6.5.tgz", + "integrity": "sha512-VjRVSqN9U9uhNHfN7E1iKoFCtV6tj/aCd4mwMQoS8WR4mQat6iJ171W597zvlQyZaHBlVf+KHrg9jY6EHsDp5A==" }, "node_modules/@appwrite.io/pink": { "version": "0.23.0", diff --git a/package.json b/package.json index cf05a91e8..77589f9a6 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.4", + "@appwrite.io/console": "npm:matej-appwrite-console-16x@0.6.5", "@appwrite.io/pink": "0.23.0", "@appwrite.io/pink-icons": "0.23.0", "@popperjs/core": "^2.11.8", diff --git a/src/lib/elements/forms/inputPhone.svelte b/src/lib/elements/forms/inputPhone.svelte index 52b5e1153..a14e87fda 100644 --- a/src/lib/elements/forms/inputPhone.svelte +++ b/src/lib/elements/forms/inputPhone.svelte @@ -13,6 +13,7 @@ export let readonly = false; export let autofocus = false; export let autocomplete = false; + export let minlength: number = null; export let maxlength: number = null; export let popover: typeof SvelteComponent = null; export let popoverProps: Record = {}; @@ -83,6 +84,7 @@ {placeholder} {disabled} {required} + {minlength} {maxlength} {pattern} {readonly} diff --git a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte index bb7aa97da..134c7f49a 100644 --- a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte +++ b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte @@ -11,17 +11,17 @@ import Empty from '$lib/components/empty.svelte'; import type { Models } from '@appwrite.io/console'; - let numbers: Models.MockNumber[] = $project?.authMockNumbers?.numbers ?? []; + // @ts-expect-error wrong SDK type + let numbers: Models.MockNumber[] = $project?.authMockNumbers ?? []; let initialNumbers = []; let projectId: string = $project.$id; - $: initialNumbers = $project?.authMockNumbers?.numbers?.map((num) => ({ ...num })) ?? []; + // @ts-expect-error wrong SDK type + $: initialNumbers = $project?.authMockNumbers?.map((num) => ({ ...num })) ?? []; $: submitDisabled = JSON.stringify(numbers) === JSON.stringify(initialNumbers); async function updateMockNumbers() { try { - // TODO: fix once SDK is updated - //@ts-expect-error numbers is the wrong type in the SDK await sdk.forConsole.projects.updateMockNumbers(projectId, numbers); await invalidate(Dependencies.PROJECT); addNotification({ @@ -50,6 +50,8 @@ numbers.splice(index, 1); numbers = numbers; } + + $: console.log(numbers, initialNumbers);
    @@ -72,6 +74,7 @@ placeholder="Enter Phone Number" label="Phone Number" showLabel={index === 0 ? true : false} + minlength={8} maxlength={16} required /> Date: Wed, 3 Jul 2024 13:37:29 +0200 Subject: [PATCH 069/347] chore: bump sdk, fix types --- package-lock.json | 8 ++++---- package.json | 2 +- src/lib/actions/analytics.ts | 2 +- .../auth/security/updateMockNumbers.svelte | 2 -- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 303408b06..2de8854a7 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.5", + "@appwrite.io/console": "npm:matej-appwrite-console-16x@0.6.6", "@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.5", - "resolved": "https://registry.npmjs.org/matej-appwrite-console-16x/-/matej-appwrite-console-16x-0.6.5.tgz", - "integrity": "sha512-VjRVSqN9U9uhNHfN7E1iKoFCtV6tj/aCd4mwMQoS8WR4mQat6iJ171W597zvlQyZaHBlVf+KHrg9jY6EHsDp5A==" + "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==" }, "node_modules/@appwrite.io/pink": { "version": "0.23.0", diff --git a/package.json b/package.json index 77589f9a6..709b9258e 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.5", + "@appwrite.io/console": "npm:matej-appwrite-console-16x@0.6.6", "@appwrite.io/pink": "0.23.0", "@appwrite.io/pink-icons": "0.23.0", "@popperjs/core": "^2.11.8", diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index 5f4c5e18b..156fca4fc 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -227,7 +227,7 @@ export enum Submit { FunctionUpdateLogging = 'submit_function_update_logging', FunctionUpdateTimeout = 'submit_function_update_timeout', FunctionUpdateEvents = 'submit_function_update_events', - FunctionUpdateScopes = 'submit_function_update_scopes', + FunctionUpdateScopes = 'submit_function_key_update_scopes', FunctionConnectRepo = 'submit_function_connect_repo', FunctionDisconnectRepo = 'submit_function_disconnect_repo', FunctionRedeploy = 'submit_function_redeploy', diff --git a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte index 134c7f49a..353783dbc 100644 --- a/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte +++ b/src/routes/console/project-[project]/auth/security/updateMockNumbers.svelte @@ -11,12 +11,10 @@ import Empty from '$lib/components/empty.svelte'; import type { Models } from '@appwrite.io/console'; - // @ts-expect-error wrong SDK type let numbers: Models.MockNumber[] = $project?.authMockNumbers ?? []; let initialNumbers = []; let projectId: string = $project.$id; - // @ts-expect-error wrong SDK type $: initialNumbers = $project?.authMockNumbers?.map((num) => ({ ...num })) ?? []; $: submitDisabled = JSON.stringify(numbers) === JSON.stringify(initialNumbers); From 742d13ced505cc17c3bfee0f2fdac043cb6eeba7 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 3 Jul 2024 13:49:55 +0200 Subject: [PATCH 070/347] fix: deployment total --- .../functions/function-[function]/+page.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte index a53afac58..c81c2650a 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte @@ -89,8 +89,8 @@ - {#if data?.activeDeployment} - {@const activeDeployment = data.activeDeployment} + {#if data?.deploymentList?.total} + {@const activeDeployment = data?.activeDeployment}
    Active
    From 6d625f5576daf41a1991cf5f1abe9b64d71232a8 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 3 Jul 2024 13:52:04 +0200 Subject: [PATCH 071/347] fix: reset values on dropdown close --- src/lib/components/filters/filters.svelte | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/components/filters/filters.svelte b/src/lib/components/filters/filters.svelte index 8d16ef03a..5c4b193f6 100644 --- a/src/lib/components/filters/filters.svelte +++ b/src/lib/components/filters/filters.svelte @@ -52,6 +52,9 @@ $: if (!showFiltersDesktop && !showFiltersMobile) { selectedColumn = null; + value = null; + operatorKey = null; + arrayValues = []; } $: isButtonDisabled = $queriesAreDirty From 279582264bb211448e0d0fc1faa98df9fa2ed71e Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 3 Jul 2024 13:54:05 +0200 Subject: [PATCH 072/347] fix: manual deployment commands input --- .../functions/function-[function]/createManual.svelte | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/createManual.svelte b/src/routes/console/project-[project]/functions/function-[function]/createManual.svelte index 9e3d33160..deedf8dee 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/createManual.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/createManual.svelte @@ -1,5 +1,12 @@ -
    +
    (isOverflowing = v)}>
    {/if} -
    +
    All deployments -
    +
    From bc4a6ef742015fa5b9f8d6fd13855dd72eba7390 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 3 Jul 2024 15:33:56 +0200 Subject: [PATCH 075/347] feat: stack vercally filter inputs on mobile --- src/lib/components/filters/content.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index c0477e6ee..9fde006b6 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -66,7 +66,7 @@
    - From 1061887b6b3914a219c8d4ba8d06d58938e9359b Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 17 Jul 2024 13:49:04 +0200 Subject: [PATCH 115/347] fix: initial loading --- src/app.html | 2 +- static/{global.css => css/loading.css} | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) rename static/{global.css => css/loading.css} (86%) diff --git a/src/app.html b/src/app.html index 1cc214611..fc20fea01 100644 --- a/src/app.html +++ b/src/app.html @@ -128,7 +128,7 @@ type="font/woff2" crossorigin /> - + %sveltekit.head% diff --git a/static/global.css b/static/css/loading.css similarity index 86% rename from static/global.css rename to static/css/loading.css index efb524eac..99fb3e955 100644 --- a/static/global.css +++ b/static/css/loading.css @@ -1,3 +1,12 @@ +body { + margin: 0; +} + +[data-loading='true'] .load-screen { + visibility: visible; + opacity: 1; +} + .load-screen { visibility: hidden; opacity: 0; @@ -7,12 +16,7 @@ width: 100%; background-color: #000; top: 0; - transition: all .2s ease-in-out; -} - -[data-loading='true'] .load-screen { - visibility: visible; - opacity: 1; + transition: all 0.2s ease-in-out; } .load-screen .animation { @@ -30,10 +34,10 @@ width: 124px; height: 124px; margin: 10px; - border: 10px solid hsl(var(--color-primary-200)); + border: 10px solid rgb(219, 26, 90); border-radius: 50%; animation: animation 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite; - border-color: hsl(var(--color-primary-200)) transparent transparent transparent; + border-color: rgb(219, 26, 90) transparent transparent transparent; } .load-screen .animation > div:nth-child(1) { animation-delay: -0.45s; From d5d62417f0a61e0c455251b14a617c7d7cae7496 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 17 Jul 2024 14:29:31 +0200 Subject: [PATCH 116/347] feat: filtered headers list --- .../executions/execute-function/+page.svelte | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.svelte index 51f6e5b4b..866d327e9 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/executions/execute-function/+page.svelte @@ -18,6 +18,7 @@ Helper, InputDate, InputSelect, + InputSelectSearch, InputText, InputTextarea, InputTime @@ -44,6 +45,7 @@ toLocaleDateTime, toLocaleTimeISO } from '$lib/helpers/date'; + import { last } from '$lib/helpers/array'; let previousPage: string = `${base}/console`; @@ -131,6 +133,12 @@ ? toLocaleTimeISO(now.getTime()) : '00:00'; $: dateTime = new Date(`${date}T${time}`); + + $: filteredKeyList = keyList.filter((key) => { + const name = last(headers)[0]; + if (!name) return true; + return key.value.toLowerCase().includes(name?.toLowerCase()); + }); @@ -195,14 +203,15 @@ {#if headers} {#each headers as [name, value], index} - + bind:value={name} + bind:search={name} /> Date: Wed, 17 Jul 2024 14:38:23 +0200 Subject: [PATCH 117/347] fix: page loader theme --- src/app.html | 6 ++--- static/css/loading.css | 51 +++++++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/app.html b/src/app.html index fc20fea01..2dc25b673 100644 --- a/src/app.html +++ b/src/app.html @@ -154,7 +154,7 @@ document.body.setAttribute('class', `theme-${themeInUse}`);
    %sveltekit.body%
    -
    +
    @@ -165,13 +165,13 @@ src="/console/images/appwrite-logo-light.svg" width="120" height="22" - class="u-only-light" + class="logo-light" alt="Appwrite Logo" /> Appwrite Logo
    diff --git a/static/css/loading.css b/static/css/loading.css index 99fb3e955..38f0dd187 100644 --- a/static/css/loading.css +++ b/static/css/loading.css @@ -2,24 +2,52 @@ body { margin: 0; } -[data-loading='true'] .load-screen { +[data-loading='true'] .page-loader { visibility: visible; opacity: 1; } -.load-screen { +.theme-dark .page-loader { + --p-page-loader-background-color: #000; +} +.theme-light .page-loader { + --p-page-loader-background-color: #fff; +} + +.theme-light .page-loader { + background-color: #fff; +} + +.page-loader { visibility: hidden; opacity: 0; z-index: 100000; position: fixed; height: 100%; width: 100%; - background-color: #000; + background-color: var(--p-page-loader-background-color); top: 0; transition: all 0.2s ease-in-out; } -.load-screen .animation { +.page-loader img { + visibility: hidden; + position: absolute; + max-width: 100%; + bottom: 60px; + left: 50%; + transform: translate(-50%, -50%); +} + +.theme-dark .page-loader .logo-dark { + visibility: visible; +} + +.theme-light .page-loader .logo-light { + visibility: visible; +} + +.page-loader .animation { position: absolute; top: 45%; left: 50%; @@ -27,7 +55,7 @@ body { width: 140px; height: 140px; } -.load-screen .animation > div { +.page-loader .animation > div { box-sizing: border-box; display: block; position: absolute; @@ -39,13 +67,13 @@ body { animation: animation 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite; border-color: rgb(219, 26, 90) transparent transparent transparent; } -.load-screen .animation > div:nth-child(1) { +.page-loader .animation > div:nth-child(1) { animation-delay: -0.45s; } -.load-screen .animation > div:nth-child(2) { +.page-loader .animation > div:nth-child(2) { animation-delay: -0.3s; } -.load-screen .animation > div:nth-child(3) { +.page-loader .animation > div:nth-child(3) { animation-delay: -0.15s; } @keyframes animation { @@ -56,10 +84,3 @@ body { transform: rotate(360deg); } } -.load-screen img { - position: absolute; - max-width: 100%; - bottom: 60px; - left: 50%; - transform: translate(-50%, -50%); -} From 54dbc7aa6e4e37cf8409e331ff4af3aebb42b03a Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 17 Jul 2024 14:49:30 +0200 Subject: [PATCH 118/347] fix: precompress --- svelte.config.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/svelte.config.js b/svelte.config.js index fefeaa9fb..8a2ef7e09 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -13,8 +13,7 @@ const config = { $routes: './src/routes' }, adapter: adapter({ - fallback: 'index.html', - precompress: true + fallback: 'index.html' }), paths: { base: '/console' From 940c00b3f1067204ecfcbdd24176505c93f0781f Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 17 Jul 2024 14:57:27 +0200 Subject: [PATCH 119/347] fix: e2e tests --- tests/e2e/steps/pro-project.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/steps/pro-project.ts b/tests/e2e/steps/pro-project.ts index 2d7dc5466..6f90a0ea3 100644 --- a/tests/e2e/steps/pro-project.ts +++ b/tests/e2e/steps/pro-project.ts @@ -42,7 +42,7 @@ export async function createProProject(page: Page): Promise { await page.locator('label').filter({ hasText: 'frankfurt' }).click(); await page.getByRole('button', { name: 'create' }).click(); await page.waitForURL('./project-**/overview/platforms'); - expect(page.url()).toContain('./project-'); + expect(page.url()).toContain('/project-'); return getProjectIdFromUrl(page.url()); }); From 1c3dbe806b1c8b98bedb8a61dcd6ed2dd68a3789 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 17 Jul 2024 14:59:45 +0200 Subject: [PATCH 120/347] fix: melt-ui breaking change --- src/lib/elements/forms/inputDateRange.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/elements/forms/inputDateRange.svelte b/src/lib/elements/forms/inputDateRange.svelte index 495818d67..852fcf11e 100644 --- a/src/lib/elements/forms/inputDateRange.svelte +++ b/src/lib/elements/forms/inputDateRange.svelte @@ -14,7 +14,7 @@ endSegment, trigger }, - states: { months, headingValue, daysOfWeek, segmentContents, value }, + states: { months, headingValue, weekdays, segmentContents, value }, helpers: { isDateDisabled, isDateUnavailable } } = createDateRangePicker(); @@ -75,7 +75,7 @@
    - {#each $daysOfWeek as day} + {#each $weekdays as day}