|
8 | 8 | import { sdk } from '$lib/stores/sdk'; |
9 | 9 | import { Adapter, BuildRuntime, Framework, type Models } from '@appwrite.io/console'; |
10 | 10 | import Link from '$lib/elements/link.svelte'; |
11 | | - import { Alert } from '@appwrite.io/pink-svelte'; |
| 11 | + import { Alert, Icon, Tooltip } from '@appwrite.io/pink-svelte'; |
| 12 | + import { IconInfo } from '@appwrite.io/pink-icons-svelte'; |
12 | 13 | import { getChangePlanUrl, isStarterPlan } from '$lib/stores/billing'; |
13 | 14 | import { isCloud } from '$lib/system'; |
14 | 15 | import { organization } from '$lib/stores/organization'; |
|
17 | 18 | export let site: Models.Site; |
18 | 19 | export let specs: Models.SpecificationList; |
19 | 20 |
|
20 | | - let specification = site.buildSpecification; |
21 | | - let originalSpecification = site.buildSpecification; |
| 21 | + let buildSpecification = site.buildSpecification; |
| 22 | + let runtimeSpecification = site.runtimeSpecification; |
| 23 | + let originalBuild = site.buildSpecification; |
| 24 | + let originalRuntime = site.runtimeSpecification; |
22 | 25 |
|
23 | | - async function updateLogging() { |
| 26 | + let siteId: string | undefined = undefined; |
| 27 | + $: if (site.$id !== siteId) { |
| 28 | + siteId = site.$id; |
| 29 | + buildSpecification = site.buildSpecification; |
| 30 | + runtimeSpecification = site.runtimeSpecification; |
| 31 | + } |
| 32 | + $: { |
| 33 | + originalBuild = site.buildSpecification; |
| 34 | + originalRuntime = site.runtimeSpecification; |
| 35 | + } |
| 36 | +
|
| 37 | + async function updateResourceLimits() { |
24 | 38 | try { |
25 | 39 | await sdk.forProject(page.params.region, page.params.project).sites.update({ |
26 | 40 | siteId: site.$id, |
|
40 | 54 | providerBranch: site?.providerBranch || undefined, |
41 | 55 | providerSilentMode: site?.providerSilentMode || undefined, |
42 | 56 | providerRootDirectory: site?.providerRootDirectory || undefined, |
43 | | - buildSpecification: specification || undefined |
| 57 | + buildSpecification: buildSpecification || undefined, |
| 58 | + runtimeSpecification: runtimeSpecification || undefined |
44 | 59 | }); |
45 | 60 | await invalidate(Dependencies.SITE); |
46 | | - originalSpecification = specification; |
47 | 61 |
|
48 | 62 | addNotification({ |
49 | 63 | type: 'success', |
50 | 64 | message: 'Resource limits have been updated' |
51 | 65 | }); |
52 | | - trackEvent(Submit.FunctionUpdateLogging); |
| 66 | + trackEvent(Submit.SiteUpdateResourceLimits); |
53 | 67 | } catch (error) { |
54 | 68 | addNotification({ |
55 | 69 | type: 'error', |
56 | 70 | message: error.message |
57 | 71 | }); |
58 | | - trackError(error, Submit.FunctionUpdateLogging); |
| 72 | + trackError(error, Submit.SiteUpdateResourceLimits); |
59 | 73 | } |
60 | 74 | } |
61 | 75 |
|
|
66 | 80 | })); |
67 | 81 | </script> |
68 | 82 |
|
69 | | -<Form onSubmit={updateLogging}> |
| 83 | +<Form onSubmit={updateResourceLimits}> |
70 | 84 | <CardGrid> |
71 | 85 | <svelte:fragment slot="title">Resource limits</svelte:fragment> |
72 | | - Define your sites's compute specifications, including CPU and memory, to optimize performance |
73 | | - for your workloads. <Link |
74 | | - href="https://appwrite.io/docs/advanced/platform/compute" |
75 | | - external> |
| 86 | + Define your site's compute specifications, including CPU and memory, to optimize performance for |
| 87 | + your workloads. <Link href="https://appwrite.io/docs/advanced/platform/compute" external> |
76 | 88 | Learn more |
77 | 89 | </Link>. |
78 | 90 | <svelte:fragment slot="aside"> |
79 | 91 | <InputSelect |
80 | | - label="CPU and memory" |
81 | | - id="resources" |
| 92 | + label="Build specification" |
| 93 | + id="build-specification" |
| 94 | + required |
| 95 | + disabled={options.length < 1} |
| 96 | + bind:value={buildSpecification} |
| 97 | + {options}> |
| 98 | + <Tooltip slot="info"> |
| 99 | + <Icon icon={IconInfo} size="s" /> |
| 100 | + <span slot="tooltip"> |
| 101 | + CPU and memory used when installing dependencies and building your site for |
| 102 | + deployment. |
| 103 | + </span> |
| 104 | + </Tooltip> |
| 105 | + </InputSelect> |
| 106 | + <InputSelect |
| 107 | + label="Runtime specification" |
| 108 | + id="runtime-specification" |
82 | 109 | required |
83 | 110 | disabled={options.length < 1} |
84 | | - bind:value={specification} |
85 | | - {options} /> |
| 111 | + bind:value={runtimeSpecification} |
| 112 | + {options}> |
| 113 | + <Tooltip slot="info"> |
| 114 | + <Icon icon={IconInfo} size="s" /> |
| 115 | + <span slot="tooltip"> |
| 116 | + CPU and memory used when your site serves traffic, including server-side |
| 117 | + rendering (SSR). |
| 118 | + </span> |
| 119 | + </Tooltip> |
| 120 | + </InputSelect> |
86 | 121 |
|
87 | 122 | <!-- always show upgrade on starters --> |
88 | 123 | {@const isStarter = isStarterPlan($organization.billingPlanId)} |
|
97 | 132 | </svelte:fragment> |
98 | 133 |
|
99 | 134 | <svelte:fragment slot="actions"> |
100 | | - <Button disabled={originalSpecification === specification} submit>Update</Button> |
| 135 | + <Button |
| 136 | + disabled={originalBuild === buildSpecification && |
| 137 | + originalRuntime === runtimeSpecification} |
| 138 | + submit>Update</Button> |
101 | 139 | </svelte:fragment> |
102 | 140 | </CardGrid> |
103 | 141 | </Form> |
0 commit comments