fix: implement nag patching for pc and mobile web (#193)
Co-authored-by: Meliox <na>
This commit is contained in:
parent
c67bbbacf7
commit
6b1f76160f
@ -1 +1,42 @@
|
||||
gain
|
||||
--- /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js 2026-05-26 16:26:59.000000000 +0200
|
||||
+++ /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js 2026-06-10 21:12:31.349760790 +0200
|
||||
@@ -599,37 +599,8 @@
|
||||
Ext.Msg.alert(gettext('Error'), res.htmlStatus || res.result.message),
|
||||
|
||||
checked_command: function (orig_cmd) {
|
||||
- Proxmox.Utils.API2Request({
|
||||
- url: '/nodes/localhost/subscription',
|
||||
- method: 'GET',
|
||||
- failure: function (response, opts) {
|
||||
- Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
||||
- },
|
||||
- success: function (response, opts) {
|
||||
- let res = response.result;
|
||||
- if (
|
||||
- res === null ||
|
||||
- res === undefined ||
|
||||
- !res ||
|
||||
- res.data.status.toLowerCase() !== 'active'
|
||||
- ) {
|
||||
- Ext.Msg.show({
|
||||
- title: gettext('No valid subscription'),
|
||||
- icon: Ext.Msg.WARNING,
|
||||
- message: Proxmox.Utils.getNoSubKeyHtml(res.data.url),
|
||||
- buttons: Ext.Msg.OK,
|
||||
- callback: function (btn) {
|
||||
- if (btn !== 'ok') {
|
||||
- return;
|
||||
- }
|
||||
- orig_cmd();
|
||||
- },
|
||||
- });
|
||||
- } else {
|
||||
- orig_cmd();
|
||||
- }
|
||||
- },
|
||||
- });
|
||||
+ // disable subscription nag screen
|
||||
+ orig_cmd();
|
||||
},
|
||||
|
||||
assemble_field_data: function (values, data) {
|
||||
26
src/NagScreen/patches/02-index-html-tpl-mobilenag.patch
Normal file
26
src/NagScreen/patches/02-index-html-tpl-mobilenag.patch
Normal file
@ -0,0 +1,26 @@
|
||||
--- /usr/share/pve-yew-mobile-gui/index.html.tpl 2026-06-10 21:39:42.012286927 +0200
|
||||
+++ /usr/share/pve-yew-mobile-gui/index.html.tpl 2026-06-10 21:40:47.815781830 +0200
|
||||
@@ -59,3 +59,23 @@
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+<!-- MANAGED BLOCK FOR MOBILE NAG -->
|
||||
+<script>
|
||||
+ function removeSubscriptionElements() {
|
||||
+ document.querySelectorAll('dialog.pwt-outer-dialog').forEach(dialog => {
|
||||
+ if ((dialog.textContent || '').toLowerCase().includes('subscription')) {
|
||||
+ dialog.remove();
|
||||
+ }
|
||||
+ });
|
||||
+ document.querySelectorAll('.pwt-card.pwt-p-2.pwt-d-flex.pwt-interactive.pwt-justify-content-center').forEach(card => {
|
||||
+ if (!card.querySelector('button') && (card.textContent || '').toLowerCase().includes('subscription')) {
|
||||
+ card.remove();
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+ const observer = new MutationObserver(removeSubscriptionElements);
|
||||
+ observer.observe(document.body, { childList: true, subtree: true });
|
||||
+ removeSubscriptionElements();
|
||||
+ setInterval(removeSubscriptionElements, 300);
|
||||
+ setTimeout(() => { observer.disconnect(); }, 10000);
|
||||
+</script>
|
||||
@ -2,3 +2,4 @@
|
||||
# Format: <patch-file> [section.key=value]
|
||||
|
||||
01-proxmoxlib-js-nagscreen.patch
|
||||
02-index-html-tpl-mobilenag.patch
|
||||
|
||||
@ -1,26 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# post-apply hook for the nag_screen mod.
|
||||
# Runs after nag_screen patches are applied. Provided env: MOD_CONF, STASH_DIR,
|
||||
# CONFD_DIR. Replaces the minified proxmoxlib with a symlink to the patched
|
||||
# unminified copy so the browser serves the patched code. The original minified
|
||||
# file is stashed (it is a non-patch binary replacement, so `patch -R` cannot
|
||||
# restore it). Exit codes: 0 = no change, 100 = changed, other = error.
|
||||
# CONFD_DIR. Requests a pveproxy restart so the patched UI is served.
|
||||
# Exit codes: 0 = no change, 100 = changed (restart pveproxy), other = error.
|
||||
|
||||
set -u
|
||||
|
||||
PROXMOXLIB_JS="/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js"
|
||||
PROXMOXLIB_MIN_JS="/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.min.js"
|
||||
STASH_DIR="${STASH_DIR:-/var/lib/pve-mod/backup}"
|
||||
|
||||
if [[ ! -L "$PROXMOXLIB_MIN_JS" ]]; then
|
||||
mkdir -p "$STASH_DIR"
|
||||
if [[ -f "$PROXMOXLIB_MIN_JS" ]]; then
|
||||
mv "$PROXMOXLIB_MIN_JS" \
|
||||
"$STASH_DIR/proxmoxlib.min.js.$(date +%Y%m%d_%H%M%S)" 2>/dev/null || true
|
||||
fi
|
||||
ln -sf "$PROXMOXLIB_JS" "$PROXMOXLIB_MIN_JS"
|
||||
echo "[pve-mod] Symlinked proxmoxlib.min.js -> proxmoxlib.js"
|
||||
exit 100
|
||||
fi
|
||||
|
||||
exit 0
|
||||
exit 100
|
||||
@ -1,23 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# post-revert hook for the nag_screen mod.
|
||||
# Runs before nag_screen patches are reverted. Provided env: MOD_CONF,
|
||||
# STASH_DIR, CONFD_DIR. Removes the min.js symlink and restores the original
|
||||
# minified file from the stash. Exit codes: 0 = no change, 100 = changed.
|
||||
# STASH_DIR, CONFD_DIR. Requests a pveproxy restart so the original UI is served.
|
||||
# Exit codes: 0 = no change, 100 = changed (restart pveproxy), other = error.
|
||||
|
||||
set -u
|
||||
|
||||
PROXMOXLIB_MIN_JS="/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.min.js"
|
||||
STASH_DIR="${STASH_DIR:-/var/lib/pve-mod/backup}"
|
||||
|
||||
if [[ -L "$PROXMOXLIB_MIN_JS" ]]; then
|
||||
rm -f "$PROXMOXLIB_MIN_JS"
|
||||
latest=$(find "$STASH_DIR" -name "proxmoxlib.min.js.*" -type f -printf '%T+ %p\n' 2>/dev/null \
|
||||
| sort -r | head -n1 | awk '{print $2}')
|
||||
if [[ -n "$latest" ]]; then
|
||||
cp "$latest" "$PROXMOXLIB_MIN_JS"
|
||||
echo "[pve-mod] Restored proxmoxlib.min.js from stash"
|
||||
fi
|
||||
exit 100
|
||||
fi
|
||||
|
||||
exit 0
|
||||
exit 100
|
||||
|
||||
Loading…
Reference in New Issue
Block a user