Skip to content

Commit

Permalink
Add runtime memory and CPU Controls
Browse files Browse the repository at this point in the history
  • Loading branch information
PineappleIOnic committed Jun 11, 2024
1 parent e1169fa commit 3841d2f
Showing 1 changed file with 76 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,61 @@
const functionId = $page.params.function;
let runtime: string = null;
let memory: number = null;
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'
}
];
onMount(async () => {
runtime ??= $func.runtime;
memory ??= $func.memory;
cpus ??= $func.cpus;
let runtimes = await $runtimesList;
options = runtimes.runtimes.map((runtime) => ({
Expand Down Expand Up @@ -50,11 +100,13 @@
$func.providerRepositoryId || undefined,
$func.providerBranch || undefined,
$func.providerSilentMode || undefined,
$func.providerRootDirectory || undefined
$func.providerRootDirectory || undefined,
memory,
cpus
);
await invalidate(Dependencies.FUNCTION);
addNotification({
message: 'Runtime has been updated',
message: 'Runtime settings have been updated',
type: 'success'
});
trackEvent(Submit.FunctionUpdateName);
Expand All @@ -66,6 +118,11 @@
trackError(error, Submit.FunctionUpdateName);
}
}
$: isUpdateButtonEnabled =
runtime !== $func?.runtime ||
cpus !== $func?.cpus ||
memory !== $func?.memory;
</script>

<Form onSubmit={updateRuntime}>
Expand All @@ -82,11 +139,27 @@
{options}
required
hideRequired />
<InputSelect
label="Memory Limit"
id="memory"
placeholder="Select memory"
bind:value={memory}
options={memoryOptions}
required
hideRequired />
<InputSelect
label="CPU Limit"
id="cpus"
placeholder="Select cpu cores"
bind:value={cpus}
options={cpuOptions}
required
hideRequired />
</FormList>
</svelte:fragment>

<svelte:fragment slot="actions">
<Button disabled={runtime === $func.runtime} submit>Update</Button>
<Button disabled={!isUpdateButtonEnabled} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>

0 comments on commit 3841d2f

Please sign in to comment.