From 41430b43868ec54c25932ecb0585854cc5efae49 Mon Sep 17 00:00:00 2001 From: KOWX712 Date: Tue, 11 Feb 2025 17:20:22 +0800 Subject: [PATCH] allow save empty --- module/webui/locales/A-template.json | 2 +- module/webui/locales/en-US.json | 2 +- module/webui/locales/es-ES.json | 2 +- module/webui/locales/ja-JP.json | 2 +- module/webui/locales/ru-RU.json | 2 +- module/webui/locales/tl-PH.json | 2 +- module/webui/locales/tr-TR.json | 2 +- module/webui/locales/zh-CN.json | 2 +- module/webui/locales/zh-TW.json | 2 +- module/webui/scripts/security_patch.js | 33 +++++++++++++++++++++++--- 10 files changed, 39 insertions(+), 12 deletions(-) diff --git a/module/webui/locales/A-template.json b/module/webui/locales/A-template.json index bb1f835..ed31e8d 100644 --- a/module/webui/locales/A-template.json +++ b/module/webui/locales/A-template.json @@ -100,7 +100,7 @@ "auto_failed": "Failed to enable auto config", "save_success": "Security patch saved successfully", "save_failed": "Failed to save security patch", - "value_empty": "Value cannot be empty", + "value_empty": "Security patch configuration is disabled.", "invalid_all": "Invalid format.", "invalid_boot": "Invalid boot format.", "invalid_system": "Invalid system format.", diff --git a/module/webui/locales/en-US.json b/module/webui/locales/en-US.json index bb1f835..ed31e8d 100644 --- a/module/webui/locales/en-US.json +++ b/module/webui/locales/en-US.json @@ -100,7 +100,7 @@ "auto_failed": "Failed to enable auto config", "save_success": "Security patch saved successfully", "save_failed": "Failed to save security patch", - "value_empty": "Value cannot be empty", + "value_empty": "Security patch configuration is disabled.", "invalid_all": "Invalid format.", "invalid_boot": "Invalid boot format.", "invalid_system": "Invalid system format.", diff --git a/module/webui/locales/es-ES.json b/module/webui/locales/es-ES.json index ab77e96..4f14af7 100644 --- a/module/webui/locales/es-ES.json +++ b/module/webui/locales/es-ES.json @@ -100,7 +100,7 @@ "auto_failed": "Error al habilitar la configuración automática", "save_success": "Parche de seguridad guardado con éxito", "save_failed": "Error al guardar el parche de seguridad", - "value_empty": "El valor no puede estar vacío", + "value_empty": "La configuración del parche de seguridad está deshabilitada.", "invalid_all": "Formato inválido.", "invalid_boot": "Formato de arranque inválido.", "invalid_system": "Formato de sistema inválido.", diff --git a/module/webui/locales/ja-JP.json b/module/webui/locales/ja-JP.json index d92d51f..272fd89 100644 --- a/module/webui/locales/ja-JP.json +++ b/module/webui/locales/ja-JP.json @@ -100,7 +100,7 @@ "auto_failed": "自動設定を有効にできませんでした", "save_success": "セキュリティパッチが正常に保存されました", "save_failed": "セキュリティパッチの保存に失敗しました", - "value_empty": "値は空にできません", + "value_empty": "セキュリティパッチの設定は無効です。", "invalid_all": "無効な形式です。", "invalid_boot": "無効なブート形式です。", "invalid_system": "無効なシステム形式です。", diff --git a/module/webui/locales/ru-RU.json b/module/webui/locales/ru-RU.json index 3f3bc30..bddf8c3 100644 --- a/module/webui/locales/ru-RU.json +++ b/module/webui/locales/ru-RU.json @@ -100,7 +100,7 @@ "auto_failed": "Не удалось включить автоматическую конфигурацию", "save_success": "Патч безопасности успешно сохранен", "save_failed": "Не удалось сохранить патч безопасности", - "value_empty": "Значение не может быть пустым", + "value_empty": "Конфигурация патча безопасности отключена.", "invalid_all": "Неверный формат.", "invalid_boot": "Неверный формат загрузки.", "invalid_system": "Неверный формат системы.", diff --git a/module/webui/locales/tl-PH.json b/module/webui/locales/tl-PH.json index 8c42512..ac50c6f 100644 --- a/module/webui/locales/tl-PH.json +++ b/module/webui/locales/tl-PH.json @@ -100,7 +100,7 @@ "auto_failed": "Nabigong i-enable ang auto config", "save_success": "Matagumpay na na-save ang security patch", "save_failed": "Nabigong i-save ang security patch", - "value_empty": "Hindi pwedeng walang laman ang value", + "value_empty": "Naka-disable ang configuration ng security patch.", "invalid_all": "Invalid format.", "invalid_boot": "Invalid boot format.", "invalid_system": "Invalid system format.", diff --git a/module/webui/locales/tr-TR.json b/module/webui/locales/tr-TR.json index 9b39253..ae627de 100644 --- a/module/webui/locales/tr-TR.json +++ b/module/webui/locales/tr-TR.json @@ -100,7 +100,7 @@ "auto_failed": "Otomatik yapılandırma etkinleştirilemedi", "save_success": "Güvenlik parçası başarıyla kaydedildi", "save_failed": "Güvenlik parçası kaydedilemedi", - "value_empty": "Değer boş olamaz", + "value_empty": "Güvenlik parçası yapılandırması devre dışı bırakıldı.", "invalid_all": "Geçersiz format", "invalid_boot": "Geçersiz başlatma formatı", "invalid_system": "Geçersiz sistem formatı", diff --git a/module/webui/locales/zh-CN.json b/module/webui/locales/zh-CN.json index da37e57..853485b 100644 --- a/module/webui/locales/zh-CN.json +++ b/module/webui/locales/zh-CN.json @@ -100,7 +100,7 @@ "auto_failed": "无法启用自动配置", "save_success": "安全补丁成功保存", "save_failed": "保存安全补丁失败", - "value_empty": "值不能为空", + "value_empty": "安全补丁配置已禁用。", "invalid_all": "无效格式。", "invalid_boot": "无效启动格式。", "invalid_system": "无效系统格式。", diff --git a/module/webui/locales/zh-TW.json b/module/webui/locales/zh-TW.json index e2e467b..8ad9f0f 100644 --- a/module/webui/locales/zh-TW.json +++ b/module/webui/locales/zh-TW.json @@ -100,7 +100,7 @@ "auto_failed": "無法啟用自動配置", "save_success": "安全補丁成功保存", "save_failed": "保存安全補丁失敗", - "value_empty": "值不能為空", + "value_empty": "安全補丁配置已禁用。", "invalid_all": "無效格式。", "invalid_boot": "無效啟動格式。", "invalid_system": "無效系統格式。", diff --git a/module/webui/scripts/security_patch.js b/module/webui/scripts/security_patch.js index 331b148..535262b 100644 --- a/module/webui/scripts/security_patch.js +++ b/module/webui/scripts/security_patch.js @@ -13,7 +13,6 @@ const autoButton = document.getElementById('auto-config'); const saveButton = document.getElementById('save-patch'); export function showSecurityPatchDialog() { - overlay.style.display = 'block'; card.style.display = 'block'; setTimeout(() => { @@ -132,6 +131,10 @@ export function securityPatch() { autoButton.addEventListener('click', async () => { try { await execCommand(`sed -i "s/^auto_config=.*/auto_config=1/" /data/adb/security_patch`); + allPatchInput.value = ''; + bootPatchInput.value = ''; + systemPatchInput.value = ''; + vendorPatchInput.value = ''; showPrompt('security_patch.auto_success'); } catch (error) { showPrompt('security_patch.auto_failed'); @@ -146,7 +149,17 @@ export function securityPatch() { // Normal mode validation const allValue = allPatchInput.value.trim(); if (!allValue) { - showPrompt('security_patch.value_empty'); + // Allow saving empty value + try { + await execCommand(` + sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch + > /data/adb/tricky_store/security_patch.txt + `); + showPrompt('security_patch.value_empty'); + } catch (error) { + showPrompt('security_patch.save_failed'); + } + hideSecurityPatchDialog(); return; } if (!isValid8Digit(allValue)) { @@ -158,6 +171,9 @@ export function securityPatch() { sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch echo all=${allValue} > /data/adb/tricky_store/security_patch.txt `); + bootPatchInput.value = ''; + systemPatchInput.value = ''; + vendorPatchInput.value = ''; showPrompt('security_patch.save_success'); } catch (error) { showPrompt('security_patch.save_failed'); @@ -169,7 +185,17 @@ export function securityPatch() { const vendorValue = vendorPatchInput.value.trim(); if (!bootValue && !systemValue && !vendorValue) { - showPrompt('security_patch.value_empty'); + // Allow saving empty values for advanced mode as well + try { + await execCommand(` + sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch + > /data/adb/tricky_store/security_patch.txt + `); + showPrompt('security_patch.value_empty'); + } catch (error) { + showPrompt('security_patch.save_failed'); + } + hideSecurityPatchDialog(); return; } @@ -198,6 +224,7 @@ export function securityPatch() { sed -i "s/^auto_config=.*/auto_config=0/" /data/adb/security_patch echo "${config.join(' ')}" > /data/adb/tricky_store/security_patch.txt `); + allPatchInput.value = ''; showPrompt('security_patch.save_success'); hideSecurityPatchDialog(); } catch (error) {