mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-21 16:02:28 +00:00
feat: local dev page on the web and compatible with vscode extension
This commit is contained in:
+1
-16
@@ -1,13 +1,5 @@
|
||||
import getPort from "https://deno.land/x/getport@v2.1.2/mod.ts";
|
||||
import {
|
||||
Application,
|
||||
Command,
|
||||
Router,
|
||||
UserService,
|
||||
log,
|
||||
open,
|
||||
path,
|
||||
} from "./deps.ts";
|
||||
import { Application, Command, Router, log, open, path } from "./deps.ts";
|
||||
import { GlobalOptions } from "./types.ts";
|
||||
import { ignoreF } from "./sync.ts";
|
||||
import { requireLogin, resolveWorkspace } from "./context.ts";
|
||||
@@ -17,9 +9,6 @@ async function dev(opts: GlobalOptions & { filter?: string }) {
|
||||
const workspace = await resolveWorkspace(opts);
|
||||
await requireLogin(opts);
|
||||
|
||||
const username = (await UserService.whoami({ workspace: workspace.name }))
|
||||
.username;
|
||||
|
||||
log.info("Started dev mode");
|
||||
let currentLastEdit: LastEdit | undefined = undefined;
|
||||
|
||||
@@ -65,8 +54,6 @@ async function dev(opts: GlobalOptions & { filter?: string }) {
|
||||
content,
|
||||
path: wmPath,
|
||||
language: lang,
|
||||
workspace: workspace.workspaceId,
|
||||
username,
|
||||
};
|
||||
broadcast_changes(currentLastEdit);
|
||||
log.info("Updated " + wmPath);
|
||||
@@ -76,8 +63,6 @@ async function dev(opts: GlobalOptions & { filter?: string }) {
|
||||
content: string;
|
||||
path: string;
|
||||
language: string;
|
||||
workspace: string;
|
||||
username: string;
|
||||
};
|
||||
|
||||
const connectedClients = new Set<WebSocket>();
|
||||
|
||||
@@ -31,12 +31,12 @@ if (BROWSER) {
|
||||
const workspace = get(workspaceStore)
|
||||
const user = get(userStore)
|
||||
|
||||
if (workspace && user && !user.is_super_admin && !user.is_admin) {
|
||||
if (workspace && user) {
|
||||
userStore.set(await getUserExt(workspace))
|
||||
console.log('refreshed user')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Could not refresh user', e)
|
||||
}
|
||||
}, 30000)
|
||||
}, 300000)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import LogPanel from '$lib/components/scriptEditor/LogPanel.svelte'
|
||||
import { CompletedJob, Job, JobService, Preview } from '$lib/gen'
|
||||
import { inferArgs } from '$lib/infer'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { userStore, workspaceStore } from '$lib/stores'
|
||||
import { emptySchema, getModifierKey } from '$lib/utils'
|
||||
import { faPlay } from '@fortawesome/free-solid-svg-icons'
|
||||
import { Pane, Splitpanes } from 'svelte-splitpanes'
|
||||
@@ -27,8 +27,6 @@
|
||||
content: string
|
||||
path: string
|
||||
language: Preview.language
|
||||
workspace: string
|
||||
username: string
|
||||
}
|
||||
|
||||
let currentScript: LastEdit | undefined = undefined
|
||||
@@ -41,14 +39,16 @@
|
||||
const port = searchParams?.get('port') || '3001'
|
||||
const socket = new WebSocket(`ws://localhost:${port}/ws`)
|
||||
|
||||
let lm: any = undefined
|
||||
window.addEventListener(
|
||||
'message',
|
||||
(event) => {
|
||||
if (event.type == 'runTest') {
|
||||
lm = event.data
|
||||
if (event.data.type == 'runTest') {
|
||||
runTest()
|
||||
return
|
||||
}
|
||||
replaceData(event.data)
|
||||
replaceScript(event.data)
|
||||
},
|
||||
false
|
||||
)
|
||||
@@ -72,7 +72,6 @@
|
||||
if (!currentScript) {
|
||||
return
|
||||
}
|
||||
$workspaceStore = currentScript.workspace
|
||||
//@ts-ignore
|
||||
testJobLoader.runPreview(
|
||||
currentScript.path,
|
||||
@@ -89,9 +88,9 @@
|
||||
}
|
||||
console.log('Loading past tests')
|
||||
pastPreviews = await JobService.listCompletedJobs({
|
||||
workspace: currentScript.workspace,
|
||||
workspace: $workspaceStore!,
|
||||
jobKinds: 'preview',
|
||||
createdBy: currentScript.username.split('@')[0].toLowerCase(),
|
||||
createdBy: $userStore?.username,
|
||||
scriptPathExact: currentScript.path
|
||||
})
|
||||
}
|
||||
@@ -104,15 +103,15 @@
|
||||
}
|
||||
|
||||
let lastPath: string | undefined = undefined
|
||||
async function replaceScript(LastEdit: LastEdit) {
|
||||
currentScript = LastEdit
|
||||
if (lastPath !== LastEdit.path) {
|
||||
async function replaceScript(lastEdit: LastEdit) {
|
||||
currentScript = lastEdit
|
||||
if (lastPath !== lastEdit.path) {
|
||||
schema = emptySchema()
|
||||
}
|
||||
try {
|
||||
await inferArgs(LastEdit.language, LastEdit.content, schema)
|
||||
await inferArgs(lastEdit.language, lastEdit.content, schema)
|
||||
schema = schema
|
||||
lastPath = LastEdit.path
|
||||
lastPath = lastEdit.path
|
||||
validCode = true
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
import { SettingsService, UserService, WorkspaceService } from '$lib/gen'
|
||||
import { OpenAPI, SettingsService, UserService, WorkspaceService } from '$lib/gen'
|
||||
import { logoutWithRedirect } from '$lib/logout'
|
||||
import {
|
||||
enterpriseLicense,
|
||||
superadmin,
|
||||
userStore,
|
||||
usersWorkspaceStore,
|
||||
workspaceStore
|
||||
} from '$lib/stores'
|
||||
import { enterpriseLicense, userStore, usersWorkspaceStore, workspaceStore } from '$lib/stores'
|
||||
import { getUserExt } from '$lib/user'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import { onMount } from 'svelte'
|
||||
import github from 'svelte-highlight/styles/github'
|
||||
import { refreshSuperadmin } from '$lib/refreshUser'
|
||||
|
||||
let token = $page.url.searchParams.get('wm_token') ?? undefined
|
||||
if (token) {
|
||||
OpenAPI.WITH_CREDENTIALS = true
|
||||
OpenAPI.TOKEN = $page.url.searchParams.get('wm_token')!
|
||||
}
|
||||
|
||||
const monacoEditorUnhandledErrors = [
|
||||
'Model not found',
|
||||
'Connection is disposed.',
|
||||
@@ -45,10 +45,6 @@
|
||||
if ($workspaceStore) {
|
||||
if ($userStore) {
|
||||
console.log(`Welcome back ${$userStore.username} to ${$workspaceStore}`)
|
||||
} else if ($superadmin) {
|
||||
console.log(
|
||||
`You are a superadmin, you can go wherever you please, even at ${$workspaceStore}`
|
||||
)
|
||||
} else {
|
||||
$userStore = await getUserExt($workspaceStore)
|
||||
if (!$userStore) {
|
||||
|
||||
Reference in New Issue
Block a user