Add sortable dashboard; extend telemetry data

Dashboard: add sortable table UI and client-side sorting support — CSS for sortable headers, data-sort attributes, default sort on Created (desc), timestamp formatting, header click handling, and inclusion of sort param in paginated fetches. Records now show a formatted Created column with full timestamp in the title. Initialize sortable headers on load.

Telemetry/client: switch to sending a full JSON payload (allows create if initial PATCH failed) and include extra fields (ct_type, disk_size, core_count, ram_size, os_type, os_version, pve_version, method). pve_version is detected when available.

Server: extend FetchRecordsPaginated to accept a sort field, validate allowed sort fields to prevent injection, use the sort when building the PB API request (default -created), and propagate the sort query param from the HTTP handler to the fetch call.

Overall this enables server-side sorted pagination from the dashboard and richer telemetry records.
This commit is contained in:
CanbiZ (MickLesk)
2026-02-10 16:20:26 +01:00
parent f4ccccfb32
commit 1dcd83abea
3 changed files with 121 additions and 14 deletions

View File

@@ -421,8 +421,14 @@ post_update_to_api() {
duration=$(($(date +%s) - INSTALL_START_TIME))
fi
# Update payload: only fields that change (status, error, exit_code, duration, gpu)
# The Go service will find the record by random_id and PATCH only these fields
# Get PVE version
local pve_version=""
if command -v pveversion &>/dev/null; then
pve_version=$(pveversion 2>/dev/null | awk -F'[/ ]' '{print $2}') || true
fi
# Full payload including all fields - allows record creation if initial call failed
# The Go service will find the record by random_id and PATCH, or create if not found
local JSON_PAYLOAD
JSON_PAYLOAD=$(
cat <<EOF
@@ -431,6 +437,14 @@ post_update_to_api() {
"type": "${TELEMETRY_TYPE:-lxc}",
"nsapp": "${NSAPP:-unknown}",
"status": "${pb_status}",
"ct_type": ${CT_TYPE:-1},
"disk_size": ${DISK_SIZE:-0},
"core_count": ${CORE_COUNT:-0},
"ram_size": ${RAM_SIZE:-0},
"os_type": "${var_os:-}",
"os_version": "${var_version:-}",
"pve_version": "${pve_version}",
"method": "${METHOD:-default}",
"exit_code": ${exit_code},
"error": "${error}",
"error_category": "${error_category}",