From c0141f23c54e58146c5d04af2ecae9abfeb19cb8 Mon Sep 17 00:00:00 2001 From: MohamedElmdary Date: Thu, 26 Oct 2023 17:28:23 +0300 Subject: [PATCH] Add tour to fvm --- packages/playground/package.json | 3 +- packages/playground/public/intro/fvm.yaml | 52 +++++++++++++++++++ .../src/components/dynamic_tabs.vue | 3 +- .../src/components/expandable_layout.vue | 2 + packages/playground/src/utils/intro.ts | 38 ++++++++++++++ packages/playground/src/weblets/full_vm.vue | 39 ++++++-------- 6 files changed, 111 insertions(+), 26 deletions(-) create mode 100644 packages/playground/public/intro/fvm.yaml create mode 100644 packages/playground/src/utils/intro.ts diff --git a/packages/playground/package.json b/packages/playground/package.json index 8584da2b36..6486765444 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -31,7 +31,8 @@ "vue-router": "^4.1.6", "vuetify": "^3.1.15", "web-ssh-keygen": "^0.1.2", - "intro.js": "^7.2.0" + "intro.js": "^7.2.0", + "js-yaml": "^4.1.0" }, "devDependencies": { "@types/jsdom": "^21.1.0", diff --git a/packages/playground/public/intro/fvm.yaml b/packages/playground/public/intro/fvm.yaml new file mode 100644 index 0000000000..9be5f19be2 --- /dev/null +++ b/packages/playground/public/intro/fvm.yaml @@ -0,0 +1,52 @@ +disableInteraction: false +exitOnEsc: false +exitOnOverlayClick: false +steps: + - element: .fvm-config + title: Configuration Tab + intro: Fill required configuration in order to be able to deploy full virtual machine on tfgrid. + + - element: .fvm-name + title: Instance Name + intro: "Choose a name for your instance or leave the auto-generated name.

Note: only lower-case letters and numbers allowed." + + - element: .vm-image + title: Choose Virtual Machine Image + intro: "You can choose a supported VM image or import a custom fList.

Find More" + + - element: .vm-capacity + title: Select you instance capacity + intro: "You can choose a preconfigured capacity settings or set your own custom capacity." + + - element: .select-networks + title: Network Options + intro: "Select a network for your workload connection." + + - element: .fvm-gpu + title: Nodes With GPU + intro: "Selecting a Node with GPU. When selecting a node with GPU resources, please make sure that you have a rented node. To rent a node and gain access to GPU capabilities, you can use our dashboard." + + - element: .fvm-dedicated + title: Dedicated Nodes + intro: "Find More" + + - element: .fvm-certified + title: Certified Nodes + intro: Renting capacity on certified nodes is charged 25% extra. + + - element: .select-node + title: Select Node + intro: "Select a node ID to deploy on." + + - element: .fvm-disks + triggerClick: true + title: Disks Tab + intro: "Config your VM's disks as needed." + + - element: .expandable-plus + title: Add a disk + intro: "Click the + button to add a disk to your deployment. This is optional for full VM." + + - element: .fvm-deloy + title: Deploy + intro: "Once you're ready, click deploy." diff --git a/packages/playground/src/components/dynamic_tabs.vue b/packages/playground/src/components/dynamic_tabs.vue index bf5a1a818b..d156025482 100644 --- a/packages/playground/src/components/dynamic_tabs.vue +++ b/packages/playground/src/components/dynamic_tabs.vue @@ -1,6 +1,6 @@ @@ -32,6 +33,7 @@ @click="remove(index)" v-if="!required.includes(index)" v-bind="props" + class="expandable-remove" /> diff --git a/packages/playground/src/utils/intro.ts b/packages/playground/src/utils/intro.ts new file mode 100644 index 0000000000..9cb224ca43 --- /dev/null +++ b/packages/playground/src/utils/intro.ts @@ -0,0 +1,38 @@ +import introJs from "intro.js"; +import type { IntroStep } from "intro.js/src/core/steps"; +import type { Options } from "intro.js/src/option"; +import yaml from "js-yaml"; + +function wait(time = 1000): Promise { + return new Promise(res => setTimeout(res, time)); +} + +export async function startGuide(file: `${string}.yaml` | `${string}.json`) { + const res = await fetch(`/intro/${file}`); + + let options: Partial; + + if (file.endsWith(".json")) { + options = await res.json(); + } else { + const text = await res.text(); + options = yaml.load(text) as Partial; + } + + type Step = Partial; + + const steps = options.steps as Step[]; + + const intro = introJs().setOptions(options); + + intro.onchange(async el => { + const step = steps[intro.currentStep()]; + if (step.triggerClick) { + el.click(); + step.triggerClick = false; + } + }); + + await wait(); // to await changes in ui + return intro.start(); +} diff --git a/packages/playground/src/weblets/full_vm.vue b/packages/playground/src/weblets/full_vm.vue index af4cab48bd..73fee04829 100644 --- a/packages/playground/src/weblets/full_vm.vue +++ b/packages/playground/src/weblets/full_vm.vue @@ -9,9 +9,10 @@ :dedicated="dedicated" title-image="images/icons/vm.png" > - + - + - + @@ -187,8 +194,7 @@