fix: settings

This commit is contained in:
Arman
2024-11-22 15:30:24 +01:00
parent 744113e68f
commit e00d2256ea
6 changed files with 43 additions and 46 deletions
@@ -12,7 +12,7 @@
export let site: Models.Site;
export let frameworks: Models.Framework[];
let selectedFramework = null;
let selectedFramework: Models.Framework = null;
let installCommand = undefined;
let buildCommand = undefined;
let outputDirectory = undefined;
@@ -22,10 +22,9 @@
onMount(async () => {
selectedFramework ??= frameworks.find((framework) => framework.key === site.framework);
// TODO: ask backend to add missing defaults
installCommand = site?.installCommand ?? selectedFramework.installCommand;
buildCommand = site?.buildCommand ?? selectedFramework.buildCommand;
outputDirectory = site?.outputDirectory ?? selectedFramework.outputDirectory;
installCommand = site?.installCommand ?? selectedFramework.defaultInstallCommand;
buildCommand = site?.buildCommand ?? selectedFramework.defaultBuildCommand;
outputDirectory = site?.outputDirectory ?? selectedFramework.defaultOutputDirectory;
});
async function updateName() {
@@ -33,14 +32,14 @@
await sdk.forProject.sites.update(
site.$id,
site.name,
Framework[selectedFramework.key],
selectedFramework.key as Framework,
site.enabled || undefined,
site.timeout || undefined,
installCommand || undefined,
buildCommand || undefined,
outputDirectory || undefined,
BuildRuntime[site?.buildRuntime] || undefined,
ServeRuntime[site?.serveRuntime] || undefined,
(site?.buildRuntime as BuildRuntime) || undefined,
(site?.serveRuntime as ServeRuntime) || undefined,
site.fallbackFile || undefined,
site.installationId || undefined,
site.providerRepositoryId || undefined,
@@ -104,7 +103,7 @@
id="installCommand"
label="Install command"
bind:value={installCommand}
placeholder={frameworkData?.installCommand} />
placeholder={frameworkData.defaultInstallCommand} />
<Button secondary size="s" on:click={() => (installCommand = '')}>Reset</Button>
</Layout.Stack>
<Layout.Stack gap="s" direction="row" alignItems="flex-end">
@@ -112,7 +111,7 @@
id="buildCommand"
label="Build command"
bind:value={buildCommand}
placeholder={frameworkData?.buildCommand} />
placeholder={frameworkData.defaultBuildCommand} />
<Button secondary size="s" on:click={() => (buildCommand = '')}>Reset</Button>
</Layout.Stack>
<Layout.Stack gap="s" direction="row" alignItems="flex-end">
@@ -120,7 +119,7 @@
id="outputDirectory"
label="Output directory"
bind:value={outputDirectory}
placeholder={frameworkData?.outputDirectory} />
placeholder={frameworkData.defaultOutputDirectory} />
<Button secondary size="s" on:click={() => (outputDirectory = '')}>Reset</Button>
</Layout.Stack>
</svelte:fragment>
@@ -21,14 +21,14 @@
await sdk.forProject.sites.update(
site.$id,
siteName,
Framework[site?.framework],
site?.framework as Framework,
site.enabled || undefined,
site.timeout || undefined,
site.installCommand || undefined,
site.buildCommand || undefined,
site.outputDirectory || undefined,
BuildRuntime[site?.buildRuntime] || undefined,
ServeRuntime[site?.serveRuntime] || undefined,
(site?.buildRuntime as BuildRuntime) || undefined,
(site?.serveRuntime as ServeRuntime) || undefined,
site.fallbackFile || undefined,
site.installationId || undefined,
site.providerRepositoryId || undefined,
@@ -67,14 +67,14 @@
await sdk.forProject.sites.update(
site.$id,
site.name,
Framework[site?.framework],
site?.framework as Framework,
site.enabled || undefined,
site.timeout || undefined,
site.installCommand || undefined,
site.buildCommand || undefined,
site.outputDirectory || undefined,
BuildRuntime[site?.buildRuntime] || undefined,
ServeRuntime[site?.serveRuntime] || undefined,
(site?.buildRuntime as BuildRuntime) || undefined,
(site?.serveRuntime as ServeRuntime) || undefined,
site.fallbackFile || undefined,
site.installationId || undefined,
site.providerRepositoryId || undefined,
@@ -11,40 +11,36 @@
export let site: Models.Site;
export let frameworks: Models.Framework[];
let buildRuntime: string = null;
let serveRuntime: string = null;
const framework = frameworks.find((framework) => framework.key === site.framework);
let buildRuntime = site?.buildRuntime;
let serveRuntime = site?.serveRuntime;
let buildRuntimeOptions = [];
let serveRuntimeOptions = [];
let buildRuntimeOptions = framework.buildRuntimes.map((runtime) => ({
label: runtime,
value: runtime
}));
let serveRuntimeOptions = framework.serveRuntimes.map((runtime) => ({
label: runtime,
value: runtime
}));
onMount(async () => {
buildRuntime ??= site.buildRuntime;
serveRuntime ??= site.serveRuntime;
const framework = frameworks.find((framework) => framework.key === site.framework);
buildRuntimeOptions = framework.buildRuntimes.map((runtime) => ({
label: runtime,
value: runtime
}));
serveRuntimeOptions = framework.serveRuntimes.map((runtime) => ({
label: runtime,
value: runtime
}));
buildRuntime ??= framework.defaultBuildRuntime;
serveRuntime ??= framework.defaultBuildCommand;
});
async function updateRuntime() {
try {
await sdk.forProject.sites.update(
site.$id,
site.name,
Framework[site?.framework] || undefined,
site?.framework as Framework,
site.enabled || undefined,
site.timeout || undefined,
site.installCommand || undefined,
site.buildCommand || undefined,
site.outputDirectory || undefined,
BuildRuntime[site?.buildRuntime] || undefined,
ServeRuntime[site?.serveRuntime] || undefined,
(buildRuntime as BuildRuntime) || undefined,
(serveRuntime as ServeRuntime) || undefined,
site.fallbackFile || undefined,
site.installationId || undefined,
site.providerRepositoryId || undefined,
@@ -66,6 +62,8 @@
trackError(error, Submit.SiteUpdateTimeout);
}
}
$: console.log('test');
</script>
<Form onSubmit={updateRuntime}>
@@ -25,14 +25,14 @@
await sdk.forProject.sites.update(
site.$id,
site.name,
Framework[site?.framework],
site?.framework as Framework,
site.enabled || undefined,
site.timeout || undefined,
site.installCommand || undefined,
site.buildCommand || undefined,
site.outputDirectory || undefined,
BuildRuntime[site?.buildRuntime] || undefined,
ServeRuntime[site?.serveRuntime] || undefined,
(site?.buildRuntime as BuildRuntime) || undefined,
(site?.serveRuntime as ServeRuntime) || undefined,
fallback,
site.installationId || undefined,
site.providerRepositoryId || undefined,
@@ -10,11 +10,10 @@
import { BuildRuntime, Framework, ServeRuntime, type Models } from '@appwrite.io/console';
export let site: Models.Site;
let timeout = site.timeout;
let timeout = 0;
onMount(async () => {
timeout = site.timeout;
console.log(timeout);
timeout ??= site.timeout;
});
async function updateTimeout() {
@@ -22,14 +21,14 @@
await sdk.forProject.sites.update(
site.$id,
site.name,
Framework[site?.framework] || undefined,
site?.framework as Framework,
site.enabled || undefined,
timeout || undefined,
site.installCommand || undefined,
site.buildCommand || undefined,
site.outputDirectory || undefined,
BuildRuntime[site?.buildRuntime] || undefined,
ServeRuntime[site?.serveRuntime] || undefined,
(site?.buildRuntime as BuildRuntime) || undefined,
(site?.serveRuntime as ServeRuntime) || undefined,
site.fallbackFile || undefined,
site.installationId || undefined,
site.providerRepositoryId || undefined,
@@ -64,6 +63,7 @@
id="time"
label="Time (in seconds)"
placeholder="Enter timeout"
required
bind:value={timeout} />
</svelte:fragment>