mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Make specs dynamic using new specs API
This commit is contained in:
1 parent
3841d2f104
commit
c85195fc64
3 files changed
+32
-53
No files matched your search
@@ -8,15 +8,17 @@ import type { LayoutLoad } from './$types';
|
||||
export const load: LayoutLoad = async ({ depends }) => {
|
||||
depends(Dependencies.FUNCTION_INSTALLATIONS);
|
||||
|
||||
const [runtimesList, installations] = await Promise.all([
|
||||
const [runtimesList, installations, specs] = await Promise.all([
|
||||
sdk.forProject.functions.listRuntimes(),
|
||||
sdk.forProject.vcs.listInstallations([Query.limit(100)])
|
||||
sdk.forProject.vcs.listInstallations([Query.limit(100)]),
|
||||
sdk.forProject.functions.getSpecs()
|
||||
]);
|
||||
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs,
|
||||
runtimesList,
|
||||
installations
|
||||
installations,
|
||||
specs
|
||||
};
|
||||
};
|
||||
+22
-50
@@ -10,7 +10,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { func } from '../store';
|
||||
import InputSelect from '$lib/elements/forms/inputSelect.svelte';
|
||||
import { runtimesList } from '../../store';
|
||||
import { runtimesList, specs } from '../../store';
|
||||
import { isValueOfStringEnum } from '$lib/helpers/types';
|
||||
import { Runtime } from '@appwrite.io/console';
|
||||
|
||||
@@ -20,52 +20,8 @@
|
||||
let cpus: number = null;
|
||||
|
||||
let options = [];
|
||||
|
||||
let cpuOptions = [
|
||||
{
|
||||
value: 1,
|
||||
label: '1 CPU Core'
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
label: '2 CPU Cores'
|
||||
},
|
||||
{
|
||||
value: 4,
|
||||
label: '4 CPU Cores'
|
||||
},
|
||||
{
|
||||
value: 8,
|
||||
label: '8 CPU Cores'
|
||||
}
|
||||
];
|
||||
|
||||
let memoryOptions = [
|
||||
{
|
||||
value: 512,
|
||||
label: '512 MB'
|
||||
},
|
||||
{
|
||||
value: 1024,
|
||||
label: '1 GB'
|
||||
},
|
||||
{
|
||||
value: 2048,
|
||||
label: '2 GB'
|
||||
},
|
||||
{
|
||||
value: 4096,
|
||||
label: '4 GB'
|
||||
},
|
||||
{
|
||||
value: 8192,
|
||||
label: '8 GB'
|
||||
},
|
||||
{
|
||||
value: 16384,
|
||||
label: '16 GB'
|
||||
}
|
||||
];
|
||||
let cpuOptions = [];
|
||||
let memoryOptions = [];
|
||||
|
||||
onMount(async () => {
|
||||
runtime ??= $func.runtime;
|
||||
@@ -73,10 +29,28 @@
|
||||
cpus ??= $func.cpus;
|
||||
|
||||
let runtimes = await $runtimesList;
|
||||
let specs = await $specs;
|
||||
options = runtimes.runtimes.map((runtime) => ({
|
||||
label: `${runtime.name} - ${runtime.version}`,
|
||||
value: runtime.$id
|
||||
}));
|
||||
|
||||
memoryOptions = specs.memory.map((memory) =>
|
||||
memory > 1024
|
||||
? {
|
||||
label: `${memory / 1024} GB`,
|
||||
value: memory
|
||||
}
|
||||
: {
|
||||
label: `${memory} MB`,
|
||||
value: memory
|
||||
}
|
||||
);
|
||||
|
||||
cpuOptions = specs.cpus.map((cpu) => ({
|
||||
label: cpu === 1 ? `${cpu} CPU Cores` : `${cpu} CPU Core`,
|
||||
value: cpu
|
||||
}));
|
||||
});
|
||||
|
||||
async function updateRuntime() {
|
||||
@@ -120,9 +94,7 @@
|
||||
}
|
||||
|
||||
$: isUpdateButtonEnabled =
|
||||
runtime !== $func?.runtime ||
|
||||
cpus !== $func?.cpus ||
|
||||
memory !== $func?.memory;
|
||||
runtime !== $func?.runtime || cpus !== $func?.cpus || memory !== $func?.memory;
|
||||
</script>
|
||||
|
||||
<Form onSubmit={updateRuntime}>
|
||||
|
||||
@@ -7,6 +7,11 @@ export const runtimesList = derived(
|
||||
async ($page) => (await $page.data.runtimesList) as Models.RuntimeList
|
||||
);
|
||||
|
||||
export const specs = derived(
|
||||
page,
|
||||
async ($page) => (await $page.data.specs) as Models.Specs
|
||||
);
|
||||
|
||||
export const baseRuntimesList = derived(runtimesList, async ($runtimesList) => {
|
||||
const baseRuntimes = new Map<string, Models.Runtime>();
|
||||
for (const runtime of (await $runtimesList).runtimes) {
|
||||
|
||||
Reference in new issue
Block a user