fix(webui): restore resilient aw-rus ui patching
This commit is contained in:
@@ -809,8 +809,21 @@
|
|||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- aw_webui_ru_index.stat.exists
|
- aw_webui_ru_index.stat.exists
|
||||||
|
- (aw_webui_ru_index.stat.size | default(0) | int) > 0
|
||||||
fail_msg: "Не найден index.html WebUI для применения RU patch."
|
fail_msg: "Не найден index.html WebUI для применения RU patch."
|
||||||
|
|
||||||
|
- name: Проверить, что index.html не опустел после применения RU patch
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ aw_server_webui_dir }}/index.html"
|
||||||
|
register: aw_webui_ru_index_after_patch
|
||||||
|
|
||||||
|
- name: Подтвердить, что index.html остался непустым
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- aw_webui_ru_index_after_patch.stat.exists
|
||||||
|
- (aw_webui_ru_index_after_patch.stat.size | default(0) | int) > 0
|
||||||
|
fail_msg: "index.html WebUI пуст после RU patch."
|
||||||
|
|
||||||
- name: Удалить старые теги RU patch из index.html
|
- name: Удалить старые теги RU patch из index.html
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: "{{ aw_server_webui_dir }}/index.html"
|
path: "{{ aw_server_webui_dir }}/index.html"
|
||||||
|
|||||||
@@ -37,6 +37,17 @@ CATEGORY_HELPER_REPLACEMENT='hostname:t.hostnameChoices.filter((function(t){retu
|
|||||||
[[ -f "$HOST_GROUPS_SRC" ]] || { echo "missing $HOST_GROUPS_SRC" >&2; exit 1; }
|
[[ -f "$HOST_GROUPS_SRC" ]] || { echo "missing $HOST_GROUPS_SRC" >&2; exit 1; }
|
||||||
[[ -f "$INDEX_HTML" ]] || { echo "missing $INDEX_HTML" >&2; exit 1; }
|
[[ -f "$INDEX_HTML" ]] || { echo "missing $INDEX_HTML" >&2; exit 1; }
|
||||||
|
|
||||||
|
if [[ ! -s "$INDEX_HTML" ]]; then
|
||||||
|
latest_nonempty_backup="$(find "$WEBUI_DIR" -maxdepth 1 -type f -name 'index.html.bak.*' -size +0c | sort | tail -n 1 || true)"
|
||||||
|
if [[ -n "$latest_nonempty_backup" ]]; then
|
||||||
|
cp "$latest_nonempty_backup" "$INDEX_HTML"
|
||||||
|
echo "restored empty index.html from backup: $latest_nonempty_backup"
|
||||||
|
else
|
||||||
|
echo "index.html is empty and no non-empty backup exists: $INDEX_HTML" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
install -d "$WEBUI_DIR/js"
|
install -d "$WEBUI_DIR/js"
|
||||||
install -m 0644 "$PATCH_JS_SRC" "$PATCH_TARGET"
|
install -m 0644 "$PATCH_JS_SRC" "$PATCH_TARGET"
|
||||||
install -m 0644 "$SW_CLEANUP_SRC" "$SW_TARGET"
|
install -m 0644 "$SW_CLEANUP_SRC" "$SW_TARGET"
|
||||||
@@ -132,6 +143,11 @@ path.write_text(content)
|
|||||||
PY
|
PY
|
||||||
cp "$SW_CLEANUP_SRC" "$SERVICE_WORKER"
|
cp "$SW_CLEANUP_SRC" "$SERVICE_WORKER"
|
||||||
|
|
||||||
|
if [[ ! -s "$INDEX_HTML" ]]; then
|
||||||
|
echo "index.html became empty after RU patch: $INDEX_HTML" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
trends_chunk="$(grep -Rsl "$TRENDS_NEEDLE" "$WEBUI_DIR/js"/*.js 2>/dev/null | head -n 1 || true)"
|
trends_chunk="$(grep -Rsl "$TRENDS_NEEDLE" "$WEBUI_DIR/js"/*.js 2>/dev/null | head -n 1 || true)"
|
||||||
if [[ -n "$trends_chunk" ]]; then
|
if [[ -n "$trends_chunk" ]]; then
|
||||||
cp "$trends_chunk" "$trends_chunk.bak.$TS"
|
cp "$trends_chunk" "$trends_chunk.bak.$TS"
|
||||||
|
|||||||
@@ -382,15 +382,23 @@
|
|||||||
|
|
||||||
function enforceSafeActivityViewForPveHost() {
|
function enforceSafeActivityViewForPveHost() {
|
||||||
const hash = window.location.hash || "";
|
const hash = window.location.hash || "";
|
||||||
const match = hash.match(/^#\/activity\/([^/]+)\/day\/([^/]+)\/view\/([^/?#]+)/i);
|
const match = hash.match(/^#\/activity\/([^/]+)(?:\/day\/([^/]+))?\/view\/([^/?#]+)/i);
|
||||||
if (!match) return;
|
if (!match) return;
|
||||||
const host = decodeURIComponent(match[1] || "");
|
const host = decodeURIComponent(match[1] || "");
|
||||||
const day = decodeURIComponent(match[2] || "");
|
const day = match[2] ? decodeURIComponent(match[2]) : "";
|
||||||
const viewId = decodeURIComponent(match[3] || "");
|
const viewId = decodeURIComponent(match[3] || "");
|
||||||
if (!isPveLikeHost(host)) return;
|
const prefix = day
|
||||||
const safeHash = "#/activity/" + encodeURIComponent(host) + "/day/" + encodeURIComponent(day) + "/view/" + encodeURIComponent("pve_audit");
|
? "#/activity/" + encodeURIComponent(host) + "/day/" + encodeURIComponent(day) + "/view/"
|
||||||
if (safeHash !== hash && !/^pve_audit$/i.test(viewId)) {
|
: "#/activity/" + encodeURIComponent(host) + "/view/";
|
||||||
window.location.replace(safeHash);
|
if (isPveLikeHost(host)) {
|
||||||
|
const safeHash = prefix + encodeURIComponent("pve_audit");
|
||||||
|
if (safeHash !== hash && !/^pve_audit$/i.test(viewId)) {
|
||||||
|
window.location.replace(safeHash);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (/^pve_audit$/i.test(viewId)) {
|
||||||
|
window.location.replace(prefix + encodeURIComponent("summary"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1542,6 +1550,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hidePveAuditTabForRegularHost(root) {
|
||||||
|
const hash = window.location.hash || "";
|
||||||
|
const match = hash.match(/^#\/activity\/([^/]+)/i);
|
||||||
|
const host = match && match[1] ? decodeURIComponent(match[1]) : "";
|
||||||
|
if (!host || isPveLikeHost(host)) return;
|
||||||
|
Array.from(root.querySelectorAll('a[href*="/view/pve_audit"]')).forEach(function (link) {
|
||||||
|
link.style.display = "none";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function injectDlpAlertsCenter(root) {
|
function injectDlpAlertsCenter(root) {
|
||||||
if (!isAlertsRoute()) return;
|
if (!isAlertsRoute()) return;
|
||||||
const host = window.__awRuPatchSettingsHost || getCurrentHostFromHash();
|
const host = window.__awRuPatchSettingsHost || getCurrentHostFromHash();
|
||||||
@@ -1578,6 +1596,10 @@
|
|||||||
center.setAttribute("data-aw-ru-loaded", "1");
|
center.setAttribute("data-aw-ru-loaded", "1");
|
||||||
refreshDlpAlertsCenter(center, host);
|
refreshDlpAlertsCenter(center, host);
|
||||||
}
|
}
|
||||||
|
Array.from(heading.parentElement.children).forEach(function (child) {
|
||||||
|
if (child === heading || child === center) return;
|
||||||
|
child.style.display = "none";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let trendsRedirectInFlight = false;
|
let trendsRedirectInFlight = false;
|
||||||
@@ -1646,6 +1668,9 @@
|
|||||||
.finally(function () {
|
.finally(function () {
|
||||||
settingsHostFetchInFlight = false;
|
settingsHostFetchInFlight = false;
|
||||||
injectDlpNavigation(document.body);
|
injectDlpNavigation(document.body);
|
||||||
|
if (isAlertsRoute()) {
|
||||||
|
scheduleApplyPatch();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1854,6 +1879,7 @@
|
|||||||
walk(document.body);
|
walk(document.body);
|
||||||
translateAttributes(document.body);
|
translateAttributes(document.body);
|
||||||
hideNoiseNavigation(document.body);
|
hideNoiseNavigation(document.body);
|
||||||
|
hidePveAuditTabForRegularHost(document.body);
|
||||||
patchActivityHeading(document.body);
|
patchActivityHeading(document.body);
|
||||||
patchCategoryBuilderHostLabel(document.body);
|
patchCategoryBuilderHostLabel(document.body);
|
||||||
staticPatchRouteKey = routeKey;
|
staticPatchRouteKey = routeKey;
|
||||||
|
|||||||
@@ -30,10 +30,5 @@
|
|||||||
{ "type": "category_tree", "size": 3, "props": {} },
|
{ "type": "category_tree", "size": 3, "props": {} },
|
||||||
{ "type": "top_apps", "size": 3, "props": {} }
|
{ "type": "top_apps", "size": 3, "props": {} }
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "pve_audit",
|
|
||||||
"name": "PVE Audit",
|
|
||||||
"elements": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user