mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-10 08:07:03 +00:00
add tutorial progress backend
This commit is contained in:
@@ -19,6 +19,7 @@ export interface UserExt {
|
||||
|
||||
const persistedWorkspace = BROWSER && localStorage.getItem('workspace')
|
||||
|
||||
export const tutorialsToDo = writable<number[]>([])
|
||||
export const globalEmailInvite = writable<string>('')
|
||||
export const awarenessStore = writable<Record<string, string>>(undefined)
|
||||
export const enterpriseLicense = writable<string | undefined>(undefined)
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { get } from "svelte/store";
|
||||
import { tutorialsToDo } from "./stores";
|
||||
import { UserService } from "./gen";
|
||||
|
||||
const MAX_TUTORIAL_ID = 6
|
||||
|
||||
export async function updateProgress(id: number) {
|
||||
const bef = get(tutorialsToDo)
|
||||
const aft = bef.filter((x) => x != id)
|
||||
tutorialsToDo.set(aft)
|
||||
let bits = 0
|
||||
for (let i = 0; i <= MAX_TUTORIAL_ID; i++) {
|
||||
let mask = 1 << i;
|
||||
if (!aft.includes(i)) {
|
||||
bits = bits | mask
|
||||
}
|
||||
}
|
||||
await UserService.updateTutorialProgress({requestBody: { progress: bits}})
|
||||
|
||||
}
|
||||
|
||||
export async function skipAllTodos() {
|
||||
let bits = 0
|
||||
for (let i = 0; i <= MAX_TUTORIAL_ID; i++) {
|
||||
let mask = 1 << i;
|
||||
bits = bits | mask
|
||||
}
|
||||
tutorialsToDo.set([])
|
||||
await UserService.updateTutorialProgress({requestBody: { progress: bits}})
|
||||
|
||||
}
|
||||
|
||||
export async function resetAllTodos() {
|
||||
let todos: number[] = []
|
||||
for (let i = 0; i <= MAX_TUTORIAL_ID; i++) {
|
||||
todos.push(i)
|
||||
}
|
||||
tutorialsToDo.set(todos)
|
||||
await UserService.updateTutorialProgress({requestBody: { progress: 0 }})
|
||||
}
|
||||
|
||||
export async function syncTutorialsTodos() {
|
||||
const bits: number = (await UserService.getTutorialProgress()).progress!
|
||||
const todos: number[] = []
|
||||
for (let i = 0; i <= MAX_TUTORIAL_ID; i++) {
|
||||
let mask = 1 << i;
|
||||
if ((bits & mask) == 0) {
|
||||
todos.push(i)
|
||||
}
|
||||
}
|
||||
tutorialsToDo.set(todos)
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
ScriptService,
|
||||
UserService
|
||||
} from '$lib/gen'
|
||||
import { classNames } from '$lib/utils'
|
||||
import { classNames, sendUserToast } from '$lib/utils'
|
||||
|
||||
import WorkspaceMenu from '$lib/components/sidebar/WorkspaceMenu.svelte'
|
||||
import SidebarContent from '$lib/components/sidebar/SidebarContent.svelte'
|
||||
@@ -20,6 +20,7 @@
|
||||
enterpriseLicense,
|
||||
starStore,
|
||||
superadmin,
|
||||
tutorialsToDo,
|
||||
usageStore,
|
||||
userStore,
|
||||
workspaceStore
|
||||
@@ -34,6 +35,7 @@
|
||||
import { SUPERADMIN_SETTINGS_HASH, USER_SETTINGS_HASH } from '$lib/components/sidebar/settings'
|
||||
import { isCloudHosted } from '$lib/cloud'
|
||||
import MultiplayerMenu from '$lib/components/sidebar/MultiplayerMenu.svelte'
|
||||
import { syncTutorialsTodos, updateProgress } from '$lib/tutorialUtils'
|
||||
|
||||
OpenAPI.WITH_CREDENTIALS = true
|
||||
let menuOpen = false
|
||||
@@ -74,6 +76,7 @@
|
||||
function onLoad() {
|
||||
loadFavorites()
|
||||
loadUsage()
|
||||
syncTutorialsTodos()
|
||||
}
|
||||
|
||||
async function loadUsage() {
|
||||
|
||||
Reference in New Issue
Block a user