mirror of
https://github.com/luc-github/ESP3D-WEBUI.git
synced 2026-02-19 17:01:20 +01:00
Better notification to extensions for isVisible
Add notification to extension: isConnected to track WS status and inform extensions Bump version
This commit is contained in:
BIN
dist/CNC/GRBL/index.html.gz
vendored
BIN
dist/CNC/GRBL/index.html.gz
vendored
Binary file not shown.
BIN
dist/CNC/GRBLHal/index.html.gz
vendored
BIN
dist/CNC/GRBLHal/index.html.gz
vendored
Binary file not shown.
BIN
dist/Plotter/HP-GL/index.html.gz
vendored
BIN
dist/Plotter/HP-GL/index.html.gz
vendored
Binary file not shown.
BIN
dist/Printer3D/Marlin-embedded/index.html.gz
vendored
BIN
dist/Printer3D/Marlin-embedded/index.html.gz
vendored
Binary file not shown.
BIN
dist/Printer3D/Marlin/index.html.gz
vendored
BIN
dist/Printer3D/Marlin/index.html.gz
vendored
Binary file not shown.
BIN
dist/Printer3D/Repetier/index.html.gz
vendored
BIN
dist/Printer3D/Repetier/index.html.gz
vendored
Binary file not shown.
BIN
dist/Printer3D/Smoothieware/index.html.gz
vendored
BIN
dist/Printer3D/Smoothieware/index.html.gz
vendored
Binary file not shown.
BIN
dist/SandTable/GRBL/index.html.gz
vendored
BIN
dist/SandTable/GRBL/index.html.gz
vendored
Binary file not shown.
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
import { h } from "preact"
|
||||
import { webUIbuild } from "../../targets"
|
||||
export const webUIversion = "3.0.0-a78"
|
||||
export const webUIversion = "3.0.0-a79"
|
||||
export const Esp3dVersion = () => (
|
||||
<span>
|
||||
{webUIversion}.{webUIbuild}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
import { Fragment, h } from "preact"
|
||||
import { useState, useEffect, useCallback, useRef, useMemo } from "preact/hooks"
|
||||
import { espHttpURL } from "../Helpers"
|
||||
import { espHttpURL, dispatchToExtensions } from "../Helpers"
|
||||
import { useHttpFn } from "../../hooks"
|
||||
import { ButtonImg, ContainerHelper } from "../Controls"
|
||||
import { T } from "../Translations"
|
||||
@@ -47,15 +47,23 @@ const ExtraContentItem = ({
|
||||
const { createNewRequest } = useHttpFn
|
||||
const element_id = id.replace("extra_content_", type)
|
||||
const refreshIntervalRef = useRef(null)
|
||||
console.log(`Rendering ExtraContentItem ${id} at ${Date.now()}`);
|
||||
//console.log(`Rendering ExtraContentItem ${id} at ${Date.now()}`);
|
||||
if (visibilityState[id] === undefined) {
|
||||
visibilityState[id] = target=="panel" ? isVisibleOnStart : true;
|
||||
visibilityState[id] = false;
|
||||
if (type=="extension" && isLoadedState[id]){
|
||||
const iframeElement = element.querySelector('iframe.extensionContainer');
|
||||
if (iframeElement){
|
||||
iframeElement.contentWindow.postMessage(
|
||||
{ type: "notification", content: {isVisible: msg.isVisible}, id },
|
||||
"*"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isLoadedState[id] === undefined) {
|
||||
isLoadedState[id] = false;
|
||||
}
|
||||
|
||||
|
||||
const handleContentSuccess = useCallback((result) => {
|
||||
let blob
|
||||
switch (type) {
|
||||
@@ -133,7 +141,6 @@ const ExtraContentItem = ({
|
||||
loadContent()
|
||||
}
|
||||
if ('isVisible' in msg) {
|
||||
|
||||
if (element) {
|
||||
//console.log("Updating visibility for element " + id + " to " + msg.isVisible)
|
||||
element.style.display = msg.isVisible ? 'block' : 'none';
|
||||
@@ -220,6 +227,12 @@ const ExtraContentItem = ({
|
||||
css.forEach((csstag) => {
|
||||
doc.head.appendChild(csstag.cloneNode(true))
|
||||
})
|
||||
if (iframeElement){
|
||||
iframeElement.contentWindow.postMessage(
|
||||
{ type: "notification", content: {isConnected: true, isVisible: visibilityState[id]}, id },
|
||||
"*"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,10 @@ import {
|
||||
useHttpQueueContext,
|
||||
} from "../contexts"
|
||||
import { useHttpFn } from "../hooks"
|
||||
import { getCookie, splitArrayByLines } from "../components/Helpers"
|
||||
import { getCookie, splitArrayByLines, dispatchToExtensions } from "../components/Helpers"
|
||||
import { T } from "../components/Translations"
|
||||
|
||||
|
||||
/*
|
||||
* Local const
|
||||
*
|
||||
@@ -160,10 +161,14 @@ const WsContextProvider = ({ children }) => {
|
||||
//Clear all opened modals
|
||||
modals.clearModals()
|
||||
//TODO: Stop polling
|
||||
//Notify extensions
|
||||
dispatchToExtensions("notification", { isConnected: false }, "all")
|
||||
}
|
||||
|
||||
const onOpenCB = (e) => {
|
||||
reconnectCounter.current = 0
|
||||
//Notify extensions
|
||||
dispatchToExtensions("notification", { isConnected: true }, "all")
|
||||
ping(true)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user