From 2712eb4f6ae91afc34ca643aad14e69ab9902cb9 Mon Sep 17 00:00:00 2001 From: Jan Lauber Date: Sat, 4 Nov 2023 13:58:08 +0100 Subject: [PATCH] feat: add confirmation for lab stop Signed-off-by: Jan Lauber --- .../src/lib/components/base/SideOver.svelte | 28 +++++++++++++------ .../dashboard/RunningExercises.svelte | 1 + .../src/lib/components/labs/Exercise.svelte | 25 +++++++++++------ .../src/routes/app/profile/+page.svelte | 2 +- .../src/routes/labs/[id]/[id]/+layout.svelte | 2 +- 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/kubelab-ui/src/lib/components/base/SideOver.svelte b/kubelab-ui/src/lib/components/base/SideOver.svelte index c7bcfa4..a388681 100644 --- a/kubelab-ui/src/lib/components/base/SideOver.svelte +++ b/kubelab-ui/src/lib/components/base/SideOver.svelte @@ -6,7 +6,7 @@ LabSessionsResponse } from "$lib/pocketbase/generated-types"; import { exercise_sessions, lab_sessions, updateDataStores } from "$lib/stores/data"; - import { Pause, Play, TestTube2, X } from "lucide-svelte"; + import { AlertTriangle, Pause, Play, TestTube2, X } from "lucide-svelte"; import SvelteMarkdown from "svelte-markdown"; import CodeSpanComponent from "$lib/components/markdown/CodeSpanComponent.svelte"; import CodeComponent from "$lib/components/markdown/CodeComponent.svelte"; @@ -16,9 +16,11 @@ import { client } from "$lib/pocketbase"; import { sidebar_exercise_sessions, sidebar_lab, sidebar_lab_session } from "$lib/stores/sidebar"; import Exercise from "../labs/Exercise.svelte"; + import { Button, Modal } from "flowbite-svelte"; let docs: string; export let drawerHidden = true; + let confirmation = false; async function getMarkdown() { fetch($sidebar_lab.docs) @@ -227,17 +229,25 @@ {/if} {:else} - + {:else if confirmation} + + {:else} + + + {/if} {/if} diff --git a/kubelab-ui/src/lib/components/dashboard/RunningExercises.svelte b/kubelab-ui/src/lib/components/dashboard/RunningExercises.svelte index 3a96e74..df5ccb3 100644 --- a/kubelab-ui/src/lib/components/dashboard/RunningExercises.svelte +++ b/kubelab-ui/src/lib/components/dashboard/RunningExercises.svelte @@ -18,6 +18,7 @@ import { Pause, Terminal } from "lucide-svelte"; import toast from "svelte-french-toast"; + let running_exercises: ExerciseSessionsResponse[] = $exercise_sessions.filter( (exercise_session) => exercise_session.agentRunning ); diff --git a/kubelab-ui/src/lib/components/labs/Exercise.svelte b/kubelab-ui/src/lib/components/labs/Exercise.svelte index 2609565..d07f251 100644 --- a/kubelab-ui/src/lib/components/labs/Exercise.svelte +++ b/kubelab-ui/src/lib/components/labs/Exercise.svelte @@ -23,12 +23,13 @@ sidebar_lab_session } from "$lib/stores/sidebar"; import { getDeltaTime } from "$lib/utils/time"; - import { CheckCircle, Info, MoreHorizontal, Pause, Play, Terminal } from "lucide-svelte"; + import { AlertTriangle, CheckCircle, Info, MoreHorizontal, Pause, Play, Terminal } from "lucide-svelte"; import { onMount } from "svelte"; import toast from "svelte-french-toast"; export let this_exercise_session: ExerciseSessionsResponse; export let index: number; let this_exercise: ExercisesResponse; + let confirmation = false; onMount(() => { let exercise = $sidebar_exercises.find( @@ -150,9 +151,7 @@ client .collection("exercise_session_logs") .create(exercise_session_log_data) - .then((response) => { - - }) + .then((response) => {}) .catch((error) => { console.log(error); }); @@ -185,9 +184,7 @@