pikvm/pikvm#1312: Option to close GPIO menu after click

This commit is contained in:
Maxim Devaev 2024-05-12 03:43:57 +03:00
parent ee982946be
commit d2bc31d1cd
2 changed files with 9 additions and 2 deletions

View File

@ -383,15 +383,19 @@ class UserGpio:
def __make_item_output(self, parts: list[str]) -> dict: def __make_item_output(self, parts: list[str]) -> dict:
assert len(parts) >= 1 assert len(parts) >= 1
confirm = False confirm = False
hide = False
text = "Click" text = "Click"
if len(parts) == 2: if len(parts) == 2:
text = parts[1] text = parts[1]
elif len(parts) == 3: elif len(parts) == 3:
confirm = (parts[1] == "confirm") opts = parts[1].split(",")
confirm = ("confirm" in opts)
hide = ("hide" in opts)
text = parts[2] text = parts[2]
return { return {
"type": UserGpioModes.OUTPUT, "type": UserGpioModes.OUTPUT,
"channel": parts[0], "channel": parts[0],
"confirm": confirm, "confirm": confirm,
"hide": hide,
"text": text, "text": text,
} }

View File

@ -150,7 +150,10 @@ export function Gpio(__recorder) {
if (item.scheme.pulse.delay) { if (item.scheme.pulse.delay) {
controls.push(` controls.push(`
<td><button disabled id="gpio-button-${item.channel}" class="gpio-button" <td><button disabled id="gpio-button-${item.channel}" class="gpio-button"
data-channel="${item.channel}" data-confirm="${confirm}">${item.text}</button></td> ${item.hide ? "data-force-hide-menu" : ""}
data-channel="${item.channel}" data-confirm="${confirm}">
${(item.hide ? "&bull; " : "") + item.text}
</button></td>
`); `);
} }
return `<table><tr>${controls.join("<td>&nbsp;&nbsp;&nbsp;</td>")}</tr></table>`; return `<table><tr>${controls.join("<td>&nbsp;&nbsp;&nbsp;</td>")}</tr></table>`;