mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-09-14 18:56:52 +00:00
Beta cycle bundle over 1.2.4.1
- **VM/LXC modal** — PVE tags (dots on list cards, editable pills in modal with click-to-edit) using NVIDIA-style hash colour and SAPC contrast; Status tab redesign (single card, always-visible subsections, Edit button, autostart toggle, blue subsection icons); Backups and Firewall tabs now fill the full modal height with sticky headers/notes; stopped VMs no longer shift the metrics grid; mount-point card brightness unified across breakpoints. - **Disks modal** — Overview / SMART / History / Schedule tabs adopt the VM/LXC modal size and the mobile icon-only tab pattern; SMART attributes table drops the 15-row cap and gains a sticky "View full SMART report" footer; Print/Save-as-PDF collapses to two icons in the report; loose i18n and layout follow-ups. - **NVIDIA driver installer (#298)** — version picker cross-checks kernel + NVIDIA's Production/New Feature/Legacy branch classification (scraped from `nvidia.com/en-us/drivers/unix/`) + the PCI Device IDs of every host GPU, with a release-count heuristic to keep superseded production branches selectable while dropping Vulkan-beta ones; Recommended follows same-branch head when a driver is installed, Production Branch head on a fresh install; Hardware card now shows installed alongside available driver version. - **Custom notifications (#297)** — `event_type: "custom"` accepts `title`/`message` at the root or nested under `data`; defensive strip of stray `[TITLE]`/`[BODY]` markers echoed by the AI enhancer. - **App tab** — new "Exclude from the LXC updates counter" toggle; the CT's aggregate updates badge now sums OS packages plus registered apps (respecting the flag); Docs page updated; App suggestion no longer treats bare OS helper slugs (alpine/ubuntu/debian…) as installable apps. - **i18n and copy** — Monitor UI available in EN / ES / DE / FR / IT / PT / SV / SK (thanks @vaso73) surfaced as the first entry in the What's New modal with a link to the contributor's profile; ES cleanup pass (`Historial`, `Velocidad de rotación`, `Consumo actual`, `Ejecutar`, `Eliminar`, `Activar`, `Ver contenido`, `Repuesto disp.`, `Registrar`, `Ocultar`, `Descartar`); redundant "Tip: search any Linux/Proxmox command" line removed from the terminal command search across all locales.
This commit is contained in:
@@ -808,12 +808,21 @@ def send_notification():
|
||||
if not _validate_severity(severity):
|
||||
return _bad_request('Invalid severity')
|
||||
|
||||
# Accept `title`/`message` either at the root of the payload
|
||||
# or nested under `data` — the public docs show the nested
|
||||
# form (`data.message`) as the primary example, so falling
|
||||
# back to it prevents "empty title/message" custom events
|
||||
# (issue #297).
|
||||
payload_body = data.get('data') if isinstance(data.get('data'), dict) else {}
|
||||
title = data.get('title') or payload_body.get('title') or ''
|
||||
message = data.get('message') or payload_body.get('message') or ''
|
||||
|
||||
result = notification_manager.send_notification(
|
||||
event_type=event_type,
|
||||
severity=severity,
|
||||
title=data.get('title', ''),
|
||||
message=data.get('message', ''),
|
||||
data=data.get('data', {}),
|
||||
title=title,
|
||||
message=message,
|
||||
data=payload_body,
|
||||
source='api'
|
||||
)
|
||||
return jsonify(result)
|
||||
|
||||
@@ -6196,7 +6196,12 @@ def get_proxmox_vms():
|
||||
'netout': resource.get('netout', 0),
|
||||
'diskread': resource.get('diskread', 0),
|
||||
'diskwrite': resource.get('diskwrite', 0),
|
||||
'maxcpu': resource.get('maxcpu', 0)
|
||||
'maxcpu': resource.get('maxcpu', 0),
|
||||
# PVE tags carried straight through — the string
|
||||
# comes back from `pvesh get /cluster/resources`
|
||||
# already in PVE's own canonical `tag1;tag2`
|
||||
# format; the client splits + colours them.
|
||||
'tags': resource.get('tags', ''),
|
||||
}
|
||||
# Decorate LXC rows with the apt update status if the
|
||||
# managed_installs registry has it. Absent key means
|
||||
@@ -6214,6 +6219,32 @@ def get_proxmox_vms():
|
||||
if app_list:
|
||||
vm_data['app_watches'] = app_list
|
||||
|
||||
# Fold registered-app updates into the CT's
|
||||
# aggregate updates badge so the list card
|
||||
# counter reflects OS + apps in one number.
|
||||
# Apps flagged `exclude_from_badge` are
|
||||
# omitted from the count (pinned versions,
|
||||
# tracker-locked apps, etc.) — see the
|
||||
# validator in lxc_apps.py for the full
|
||||
# rationale. Independent from
|
||||
# `notifications_enabled`.
|
||||
if app_list:
|
||||
app_upd_count = sum(
|
||||
1 for a in app_list
|
||||
if a.get('update_available') is True
|
||||
and not a.get('exclude_from_badge')
|
||||
)
|
||||
if app_upd_count:
|
||||
uc = vm_data.get('update_check') or {}
|
||||
# Synthesize a minimal update_check
|
||||
# entry when the CT has no apt/apk
|
||||
# data (OCI, non-Debian, checker off)
|
||||
# but at least one counted app.
|
||||
uc = dict(uc) if uc else {}
|
||||
uc['count'] = int(uc.get('count') or 0) + app_upd_count
|
||||
uc['available'] = True
|
||||
vm_data['update_check'] = uc
|
||||
|
||||
# PVE's cluster resources API reports disk=0 for most
|
||||
# QEMU VMs — it can't see inside the guest filesystem
|
||||
# for the common storage backends. For running QEMU
|
||||
@@ -14160,6 +14191,109 @@ def api_vm_firewall_log(vmid):
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/vms/<int:vmid>/config', methods=['POST'])
|
||||
@require_auth
|
||||
def api_vm_config_set(vmid):
|
||||
"""Update a small allow-list of `.conf` fields on a VM or LXC.
|
||||
|
||||
Distinct from `api_vm_config_update` (PUT on the same path plus
|
||||
/description) which is the legacy notes editor. Flask keys
|
||||
endpoints by function name, so this one has its own.
|
||||
|
||||
Currently only `onboot` (start-with-host). Kept intentionally
|
||||
narrow — the Status tab exposes one toggle for it and this
|
||||
endpoint is what backs it. Adding a new field is one line in
|
||||
ALLOWED + one line in the payload handler; every field must
|
||||
map to a `qm set` / `pct set` --option that PVE applies
|
||||
without a reboot.
|
||||
|
||||
Body: {"onboot": 0|1} (bool accepted too, coerced)
|
||||
|
||||
Returns 200 with the applied value on success; the modal cache
|
||||
is invalidated so the next open renders the fresh state.
|
||||
"""
|
||||
ALLOWED = {'onboot', 'tags'}
|
||||
try:
|
||||
data = request.get_json(silent=True) or {}
|
||||
updates = {k: v for k, v in data.items() if k in ALLOWED}
|
||||
if not updates:
|
||||
return jsonify({'error': f'No allowed fields in body. Allowed: {sorted(ALLOWED)}'}), 400
|
||||
|
||||
# Coerce onboot to strict 0/1
|
||||
if 'onboot' in updates:
|
||||
v = updates['onboot']
|
||||
if isinstance(v, bool):
|
||||
v = 1 if v else 0
|
||||
try:
|
||||
v = int(v)
|
||||
except (TypeError, ValueError):
|
||||
return jsonify({'error': 'onboot must be 0 or 1'}), 400
|
||||
if v not in (0, 1):
|
||||
return jsonify({'error': 'onboot must be 0 or 1'}), 400
|
||||
updates['onboot'] = v
|
||||
|
||||
# tags: canonicalise to PVE's `tag1;tag2;tag3` form.
|
||||
# Accepts either a list (client-friendly) or an already-joined
|
||||
# string. Reject anything with characters PVE would refuse
|
||||
# (whitespace, backslash) — spaces inside a tag are the
|
||||
# commonest slip and PVE just drops them silently, so we
|
||||
# fail loud instead. Empty string clears all tags.
|
||||
if 'tags' in updates:
|
||||
v = updates['tags']
|
||||
if isinstance(v, list):
|
||||
parts = [str(t).strip() for t in v]
|
||||
elif isinstance(v, str):
|
||||
# Accept both ';' and ',' as separators, same as PVE
|
||||
parts = [t.strip() for t in re.split(r'[;,]', v)]
|
||||
else:
|
||||
return jsonify({'error': 'tags must be a list or a string'}), 400
|
||||
parts = [p for p in parts if p]
|
||||
for p in parts:
|
||||
if not re.match(r'^[a-zA-Z0-9._\-+]+$', p):
|
||||
return jsonify({
|
||||
'error': f'Invalid tag "{p}": use letters, digits, and . _ - + only',
|
||||
}), 400
|
||||
updates['tags'] = ';'.join(parts)
|
||||
|
||||
# Resolve VM type + node from cluster resources cache
|
||||
resources = get_cached_pvesh_cluster_resources_vm()
|
||||
if not resources:
|
||||
return jsonify({'error': 'Failed to enumerate cluster VMs'}), 500
|
||||
vm_info = next((r for r in resources if r.get('vmid') == vmid), None)
|
||||
if not vm_info:
|
||||
return jsonify({'error': f'VM/LXC {vmid} not found'}), 404
|
||||
vm_type = 'lxc' if vm_info.get('type') == 'lxc' else 'qemu'
|
||||
node = vm_info.get('node', 'pve')
|
||||
|
||||
# `qm set` / `pct set` — hot-applied for onboot, no reboot
|
||||
# needed. Build the argv from the ALLOWED map so a future
|
||||
# extension of the payload naturally lands here.
|
||||
binary = '/usr/sbin/pct' if vm_type == 'lxc' else '/usr/sbin/qm'
|
||||
argv = [binary, 'set', str(vmid)]
|
||||
for k, v in updates.items():
|
||||
argv.extend([f'--{k}', str(v)])
|
||||
|
||||
result = subprocess.run(argv, capture_output=True, text=True, timeout=15)
|
||||
if result.returncode != 0:
|
||||
stderr = (result.stderr or result.stdout or '').strip()
|
||||
return jsonify({
|
||||
'error': stderr[:500] or f'{binary} set failed with exit {result.returncode}',
|
||||
}), 500
|
||||
|
||||
# Reflect the change in the modal cache immediately so the
|
||||
# next open of the guest shows the new value without waiting
|
||||
# for a natural refresh.
|
||||
_vm_cache_invalidate(vmid, _vm_details_cache)
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'vmid': vmid,
|
||||
'applied': updates,
|
||||
})
|
||||
except Exception as e:
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/vms/<int:vmid>/control', methods=['POST'])
|
||||
@require_auth
|
||||
def api_vm_control(vmid):
|
||||
|
||||
@@ -816,6 +816,19 @@ def validate_config(payload: dict) -> tuple[bool, Any]:
|
||||
if ne is not None:
|
||||
conf["notifications_enabled"] = bool(ne)
|
||||
|
||||
# Optional per-app switch for the CT's aggregate updates badge.
|
||||
# Default is False (include). Set to True when the user knowingly
|
||||
# keeps a specific version (e.g. qBittorrent pinned to the version
|
||||
# their private tracker requires) and doesn't want the LXC list
|
||||
# badge blinking about an "available" update that doesn't apply to
|
||||
# them. Independent from `notifications_enabled` on purpose — a
|
||||
# user may still want the outbound notification and just hide the
|
||||
# counter, or the reverse. The App tab itself always shows the
|
||||
# real state (purple update signal, editor version fields).
|
||||
efb = payload.get("exclude_from_badge")
|
||||
if efb is not None:
|
||||
conf["exclude_from_badge"] = bool(efb)
|
||||
|
||||
return True, conf
|
||||
|
||||
|
||||
@@ -1872,6 +1885,10 @@ def _summarise_app(app: dict) -> dict:
|
||||
# this app.
|
||||
"update_command": app.get("update_command") or "",
|
||||
"hide_no_updater_notice": bool(app.get("hide_no_updater_notice")),
|
||||
# Whether this app should be counted in the CT's aggregate
|
||||
# updates badge (default: yes). See validator for full context.
|
||||
"exclude_from_badge": bool(app.get("exclude_from_badge")),
|
||||
"notifications_enabled": app.get("notifications_enabled", True) is not False,
|
||||
# Community-scripts slug that the Register-chip flow attaches
|
||||
# to the app. Surfaced so the Updates tab helper section can
|
||||
# match this registered app against the CT's helper_slug and
|
||||
@@ -2366,6 +2383,18 @@ def get_suggestions(vmid) -> dict:
|
||||
break
|
||||
meta = _helper_slug_meta(vmid) or {}
|
||||
slug = meta.get("slug")
|
||||
# Suppress base-OS helper slugs from the suggestion pipeline.
|
||||
# community-scripts publishes bare-OS templates (alpine, debian,
|
||||
# ubuntu, fedora, archlinux, gentoo, opensuse) under the same
|
||||
# helpers_cache the App tab uses to seed detection, so a CT that
|
||||
# only has the OS installed was showing up as "detected app:
|
||||
# Alpine Linux" and inviting the user to register the OS as if
|
||||
# it were an application. These are not trackable apps — treat
|
||||
# the slug as absent for suggestion purposes so the panel goes
|
||||
# straight to the empty state instead.
|
||||
if slug in {"alpine", "archlinux", "archlinux-vm", "debian", "fedora", "gentoo", "opensuse", "ubuntu"}:
|
||||
slug = None
|
||||
meta = {}
|
||||
# Tracking hint pipeline: catalog + curated hints merged.
|
||||
# • catalog (community-scripts helpers_cache.json) covers ~430
|
||||
# apps with name+repo+port+upstream_version, zero curation
|
||||
|
||||
@@ -583,10 +583,46 @@ def get_lxc_mount_points_static(vmid: str) -> dict[str, Any]:
|
||||
"host_source_is_mountpoint": host_src["is_mountpoint"],
|
||||
})
|
||||
|
||||
# Cheap hint so the client can render the Mount Points tab
|
||||
# immediately for CTs that ONLY have ad-hoc NFS/CIFS mounts done
|
||||
# from inside the container (nothing in .conf, so `out` is
|
||||
# empty). Without this hint the tab appears only after the
|
||||
# runtime endpoint returns 200-500 ms later, pushing the other
|
||||
# tabs sideways. Reading /proc/<pid>/mounts is a pure file read
|
||||
# (~1 ms, no subprocess), filter by remote fs family so only
|
||||
# storage counts — plain bind mounts of /dev/* passthrough
|
||||
# devices don't inflate the count.
|
||||
#
|
||||
# IMPORTANT: exclude runtime targets that match a declared mp.
|
||||
# When a host mp source is itself a remote share (e.g. mp0 binds
|
||||
# /mnt/pve/Piblic which is a CIFS mount on the host), the same
|
||||
# mount surfaces in /proc/<pid>/mounts with an `nfs`/`cifs`
|
||||
# fstype from the CT's perspective. Without the filter the hint
|
||||
# double-counted it, so the badge showed mp+1 when the tab really
|
||||
# only had `mp` cards to render.
|
||||
ad_hoc_hint_count = 0
|
||||
running, host_pid = _ct_status(vmid)
|
||||
if running and host_pid:
|
||||
try:
|
||||
config_targets = {
|
||||
entry.get("target", "")
|
||||
for entry in config_entries
|
||||
if entry.get("target")
|
||||
}
|
||||
for rt in _read_ct_proc_mounts(host_pid):
|
||||
if not _REMOTE_FS_RE.match(rt.get("rt_fstype", "")):
|
||||
continue
|
||||
if rt.get("rt_target") in config_targets:
|
||||
continue
|
||||
ad_hoc_hint_count += 1
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return {
|
||||
"ok": True,
|
||||
"vmid": vmid,
|
||||
"mount_points": out,
|
||||
"ad_hoc_hint_count": ad_hoc_hint_count,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2409,7 +2409,20 @@ class AIEnhancer:
|
||||
if title_match and body_match:
|
||||
title_content = title_match.group(1).strip()
|
||||
body_content = body_match.group(1).strip()
|
||||
|
||||
|
||||
# Strip stray `[TITLE]` / `[BODY]` markers the AI may
|
||||
# have echoed back inside the content itself (issue #297
|
||||
# "additional note": PVE events arriving in Telegram
|
||||
# with a literal `[TITLE]` in the title). The parser
|
||||
# regex above splits on the FIRST occurrence, so any
|
||||
# extra marker the model dropped into its title/body
|
||||
# ends up inside the extracted string. Users see the
|
||||
# markers verbatim in Telegram because they are only
|
||||
# supposed to be structural separators, never content.
|
||||
marker_re = re.compile(r'\[\s*(?:TITLE|BODY)\s*\]', re.IGNORECASE)
|
||||
title_content = marker_re.sub('', title_content).strip()
|
||||
body_content = marker_re.sub('', body_content).strip()
|
||||
|
||||
# Remove any "Original message/text" sections the AI might have added.
|
||||
# Anchored at start-of-line (`(?:^|\n)\s*`) so legitimate prose
|
||||
# like "we received the original message earlier" mid-paragraph
|
||||
|
||||
Reference in New Issue
Block a user