diff --git a/app/srv/ws/sync/editor/code/watcher.ts b/app/srv/ws/sync/editor/code/watcher.ts index e47b8840..b4d46ff8 100644 --- a/app/srv/ws/sync/editor/code/watcher.ts +++ b/app/srv/ws/sync/editor/code/watcher.ts @@ -72,7 +72,7 @@ export const startCodeWatcher = async (code: DBCode) => { .forEach((item, ws) => { sendWS(ws, { type: SyncType.Event, - evant: "code", + event: "code", data: { name: code.name, id: code.id, @@ -97,7 +97,7 @@ export const startCodeWatcher = async (code: DBCode) => { .forEach((item, ws) => { sendWS(ws, { type: SyncType.Event, - evant: "code", + event: "code", data: { name: code.name, id: code.id, diff --git a/app/web/src/render/ed/logic/ed-global.ts b/app/web/src/render/ed/logic/ed-global.ts index f634ba7a..9f3cd872 100644 --- a/app/web/src/render/ed/logic/ed-global.ts +++ b/app/web/src/render/ed/logic/ed-global.ts @@ -112,9 +112,12 @@ export const EDGlobal = { popup: { code: { init: false, - open: false, + open: true, id: "", - name: "", + name: "site", + log: "", + loading: false, + show_log: false, }, site: null as null | ((site_id: string) => void | Promise), site_form: null as null | { diff --git a/app/web/src/render/ed/logic/ed-sync.tsx b/app/web/src/render/ed/logic/ed-sync.tsx index ae8baa91..f9e17b9a 100644 --- a/app/web/src/render/ed/logic/ed-sync.tsx +++ b/app/web/src/render/ed/logic/ed-sync.tsx @@ -63,6 +63,15 @@ export const edInitSync = (p: PG) => { page_id: params.page_id, events: { code(arg) { + if (arg.event === "pkg-install-start") { + p.ui.popup.code.loading = true; + p.render(); + } else if (arg.event === "pkg-install-end") { + if (typeof arg.content === "string") + p.ui.popup.code.log = arg.content; + p.ui.popup.code.loading = false; + p.render(); + } console.log(arg); }, activity(arg) {}, diff --git a/app/web/src/render/ed/panel/popup/code/code.tsx b/app/web/src/render/ed/panel/popup/code/code.tsx index 3773d0d1..2d0cf3b7 100644 --- a/app/web/src/render/ed/panel/popup/code/code.tsx +++ b/app/web/src/render/ed/panel/popup/code/code.tsx @@ -4,24 +4,25 @@ import { Modal } from "../../../../../utils/ui/modal"; import { useEffect } from "react"; import { isLocalhost } from "../../../../../utils/ui/is-localhost"; import { Loading } from "../../../../../utils/ui/loading"; +import { Tooltip } from "../../../../../utils/ui/tooltip"; +import { Popover } from "../../../../../utils/ui/popover"; export const EdPopCode = () => { const p = useGlobal(EDGlobal, "EDITOR"); - const local = useLocal({ id_code: "" }); useEffect(() => { (async () => { - if (p.ui.popup.code.init) { + if (!p.ui.popup.code.init) { const id_code = await p.sync.activity("site", { action: p.ui.popup.code.open ? "open" : "close", id: p.site.id, type: "code", - name: "main", + name: p.ui.popup.code.name, }); if (id_code) { - local.id_code = id_code; - local.render(); + p.ui.popup.code.id = id_code; + p.render(); } } p.ui.popup.code.init = true; @@ -46,33 +47,76 @@ export const EdPopCode = () => { >
+
{p.ui.popup.code.name}
+
+
+
`, + }} + >
+
+
+
`, + }} + >
+
+
+
+ + { + p.ui.popup.code.show_log = !p.ui.popup.code.show_log; + p.render(); + }} + > + {p.ui.popup.code.show_log && ( +
+ )}
`, + __html: p.ui.popup.code.loading + ? `` + : ``, }} >
-
Site
-
+
- {!local.id_code ? ( + {p.ui.popup.code.show_log && ( +
+
{p.ui.popup.code.log || "stdout is empty..."}
+
+ )} + {!p.ui.popup.code.open || !p.ui.popup.code.id ? (
) : ( )} diff --git a/app/web/src/render/ed/panel/script/code/code.tsx b/app/web/src/render/ed/panel/script/code/code.tsx deleted file mode 100644 index 93214b18..00000000 --- a/app/web/src/render/ed/panel/script/code/code.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { useGlobal } from "web-utils"; -import { EDGlobal } from "../../../logic/ed-global"; -import { EdMonaco } from "../monaco/monaco"; -import { useEffect } from "react"; - -export const EdCode = () => { - const p = useGlobal(EDGlobal, "EDITOR"); - - useEffect(() => { - p.sync.activity("site", { - type: "code", - id: p.site.id, - action: p.ui.popup.code.open ? "open" : "close", - name: p.ui.popup.code.name, - }); - }, [p.ui.popup.code.open]); - - if (!p.ui.popup.code.open) return null; - - return ( - {}, - }} - onClose={() => {}} - /> - ); -}; diff --git a/app/web/src/render/live/logic/mobile.ts b/app/web/src/render/live/logic/mobile.ts index a4bb6c6d..3b45c6ce 100644 --- a/app/web/src/render/live/logic/mobile.ts +++ b/app/web/src/render/live/logic/mobile.ts @@ -1,6 +1,5 @@ -import { apiClient } from "web-utils"; -import { PG } from "./global"; import { w } from "../../../utils/script/init-api"; +import { PG } from "./global"; type NOTIF_ARG = { user_id: any; diff --git a/app/web/src/utils/sync/ws-client.ts b/app/web/src/utils/sync/ws-client.ts index 8d409920..c6655933 100644 --- a/app/web/src/utils/sync/ws-client.ts +++ b/app/web/src/utils/sync/ws-client.ts @@ -78,7 +78,7 @@ export const clientStartSync = async (arg: { code: (arg: { name: string; id: string; - event: "pkg-install-start" | "pkg-isntall-end"; + event: "pkg-install-start" | "pkg-install-end"; content?: string; }) => void; activity: (arg: { @@ -200,7 +200,6 @@ const connect = ( resolve(); } else if (msg.type === SyncType.Event) { const eventName = msg.event as ClientEvent; - if (event[eventName]) { if (offlineEvents.includes(eventName)) { saveEventOffline(eventName, msg.data); @@ -210,12 +209,12 @@ const connect = ( } else if (msg.type === SyncType.ActionResult) { const pending = runtime.action.pending[msg.argid]; if (pending) { + pending.resolve(msg.val); delete runtime.action.pending[msg.argid]; const idb = conf.idb; if (idb) { await set(msg.argid, msg.val, idb); } - pending.resolve(msg.val); } } }; diff --git a/pkgs/core/server/create.ts b/pkgs/core/server/create.ts index 5b4afe78..9c3a4318 100644 --- a/pkgs/core/server/create.ts +++ b/pkgs/core/server/create.ts @@ -133,7 +133,6 @@ export const createServer = async () => { ); } catch (e) { g.log.error(e); - return new Response("Loading..."); } };