|
|
@@ -124,7 +124,7 @@
|
|
|
<button onclick="confirmSquidUpdate()" id="squid-update-btn" class="action-btn update-btn relative flex items-center gap-2 px-4 py-2 rounded-lg font-semibold text-sm bg-gradient-to-r from-emerald-600 to-emerald-400 text-white shadow hover:from-emerald-700 hover:to-emerald-600 hover:-translate-y-0.5 transition-all duration-300" data-base-tooltip="{{ _("Actualizar paquetes y configuración de Squid") }}">
|
|
|
<span id="squid-update-badge" class="update-badge update-badge--squid hidden">1</span>
|
|
|
<i id="squid-update-icon" class="fas fa-sync-alt"></i>
|
|
|
- <span>{{ _("Squid") }}</span>
|
|
|
+ <span id="squid-update-label" data-loading-label="{{ _('Actualizando...') }} Squid">{{ _("Squid") }}</span>
|
|
|
</button>
|
|
|
<div id="squid-update-tooltip" class="update-tooltip"></div>
|
|
|
</div>
|
|
|
@@ -133,7 +133,7 @@
|
|
|
<button onclick="confirmWebUpdate()" id="web-update-btn" class="action-btn update-btn relative flex items-center gap-2 px-4 py-2 rounded-lg font-semibold text-sm bg-gradient-to-r from-purple-600 to-purple-400 text-white shadow hover:from-purple-700 hover:to-purple-600 hover:-translate-y-0.5 transition-all duration-300" data-base-tooltip="{{ _("Actualizar aplicación web SquidStats") }}">
|
|
|
<span id="web-update-badge" class="update-badge update-badge--web hidden">1</span>
|
|
|
<i id="web-update-icon" class="fas fa-cloud-download-alt"></i>
|
|
|
- <span>{{ _("Web") }}</span>
|
|
|
+ <span id="web-update-label" data-loading-label="{{ _('Actualizando...') }} SquidStats">{{ _("Web") }}</span>
|
|
|
</button>
|
|
|
<div id="web-update-tooltip" class="update-tooltip"></div>
|
|
|
</div>
|
|
|
@@ -209,11 +209,13 @@
|
|
|
</a>
|
|
|
<button onclick="confirmSquidUpdate(); mobileMenuOpen = false" id="squid-update-btn-mobile" class="flex-1 flex items-center justify-center gap-2 px-3 py-3 rounded-lg font-semibold text-sm bg-gradient-to-r from-emerald-600 to-emerald-400 text-white shadow hover:from-emerald-700 hover:to-emerald-600 transition-all duration-300">
|
|
|
<i id="squid-update-icon-mobile" class="fas fa-sync-alt"></i>
|
|
|
- <span class="flex items-center gap-2">{{ _("Squid") }} <span id="squid-update-chip-mobile" class="update-chip update-chip--squid hidden">NEW</span></span>
|
|
|
+ <span id="squid-update-label-mobile" data-loading-label="{{ _('Actualizando...') }} Squid">{{ _("Squid") }}</span>
|
|
|
+ <span id="squid-update-chip-mobile" class="update-chip update-chip--squid hidden">NEW</span>
|
|
|
</button>
|
|
|
<button onclick="confirmWebUpdate(); mobileMenuOpen = false" id="web-update-btn-mobile" class="flex-1 flex items-center justify-center gap-2 px-3 py-3 rounded-lg font-semibold text-sm bg-gradient-to-r from-purple-600 to-purple-400 text-white shadow hover:from-purple-700 hover:to-purple-600 transition-all duration-300">
|
|
|
<i id="web-update-icon-mobile" class="fas fa-cloud-download-alt"></i>
|
|
|
- <span class="flex items-center gap-2">{{ _("Web") }} <span id="web-update-chip-mobile" class="update-chip update-chip--web hidden">NEW</span></span>
|
|
|
+ <span id="web-update-label-mobile" data-loading-label="{{ _('Actualizando...') }} SquidStats">{{ _("Web") }}</span>
|
|
|
+ <span id="web-update-chip-mobile" class="update-chip update-chip--web hidden">NEW</span>
|
|
|
</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -636,7 +638,7 @@
|
|
|
|
|
|
// Desktop icon attention
|
|
|
if (el.icon) {
|
|
|
- if (hasUpdate) {
|
|
|
+ if (hasUpdate && !el.btn.disabled) {
|
|
|
el.icon.classList.add('update-icon-attention');
|
|
|
} else {
|
|
|
el.icon.classList.remove('update-icon-attention');
|
|
|
@@ -668,7 +670,7 @@
|
|
|
|
|
|
// Mobile icon attention
|
|
|
if (el.mobileIcon) {
|
|
|
- if (hasUpdate) {
|
|
|
+ if (hasUpdate && !el.mobileBtn.disabled) {
|
|
|
el.mobileIcon.classList.add('update-icon-attention');
|
|
|
} else {
|
|
|
el.mobileIcon.classList.remove('update-icon-attention');
|
|
|
@@ -773,11 +775,53 @@
|
|
|
return metaTag ? metaTag.getAttribute('content') : '';
|
|
|
}
|
|
|
|
|
|
+ function setUpdateButtonLoading(type, isLoading) {
|
|
|
+ const config = {
|
|
|
+ squid: {
|
|
|
+ buttonIds: ['squid-update-btn', 'squid-update-btn-mobile'],
|
|
|
+ iconIds: ['squid-update-icon', 'squid-update-icon-mobile'],
|
|
|
+ labelIds: ['squid-update-label', 'squid-update-label-mobile'],
|
|
|
+ idleIcon: 'fa-sync-alt'
|
|
|
+ },
|
|
|
+ web: {
|
|
|
+ buttonIds: ['web-update-btn', 'web-update-btn-mobile'],
|
|
|
+ iconIds: ['web-update-icon', 'web-update-icon-mobile'],
|
|
|
+ labelIds: ['web-update-label', 'web-update-label-mobile'],
|
|
|
+ idleIcon: 'fa-cloud-download-alt'
|
|
|
+ }
|
|
|
+ }[type];
|
|
|
+
|
|
|
+ config.buttonIds.forEach((id) => {
|
|
|
+ const button = document.getElementById(id);
|
|
|
+ if (button) {
|
|
|
+ button.disabled = isLoading;
|
|
|
+ button.setAttribute('aria-busy', String(isLoading));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ config.iconIds.forEach((id) => {
|
|
|
+ const icon = document.getElementById(id);
|
|
|
+ if (!icon) return;
|
|
|
+ icon.classList.remove('fa-spin', 'fa-spinner', 'fa-sync-alt', 'fa-cloud-download-alt', 'update-icon-attention');
|
|
|
+ icon.classList.add(isLoading ? 'fa-spinner' : config.idleIcon);
|
|
|
+ if (isLoading) icon.classList.add('fa-spin');
|
|
|
+ else if (icon.closest('button')?.classList.contains('update-available')) icon.classList.add('update-icon-attention');
|
|
|
+ });
|
|
|
+
|
|
|
+ config.labelIds.forEach((id) => {
|
|
|
+ const label = document.getElementById(id);
|
|
|
+ if (!label) return;
|
|
|
+ if (!label.dataset.idleLabel) label.dataset.idleLabel = label.textContent;
|
|
|
+ label.textContent = isLoading ? label.dataset.loadingLabel : label.dataset.idleLabel;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
// Funciones de confirmación para actualizaciones
|
|
|
function confirmSquidUpdate() {
|
|
|
showCustomConfirm(
|
|
|
{{ _('¿Estás seguro de que deseas actualizar el servicio Squid? Guarda tu configuración antes de continuar, el servicio se reiniciará automáticamente.')|tojson }},
|
|
|
async () => {
|
|
|
+ setUpdateButtonLoading('squid', true);
|
|
|
try {
|
|
|
const response = await fetch('/install', {
|
|
|
method: 'POST',
|
|
|
@@ -793,6 +837,7 @@
|
|
|
window.location.reload();
|
|
|
} else {
|
|
|
const message = data.message || {{ _('Error al actualizar Squid')|tojson }};
|
|
|
+ setUpdateButtonLoading('squid', false);
|
|
|
if (window.toastr) {
|
|
|
toastr.error(message, {{ _('Error al actualizar Squid')|tojson }});
|
|
|
} else {
|
|
|
@@ -800,6 +845,7 @@
|
|
|
}
|
|
|
}
|
|
|
} catch (error) {
|
|
|
+ setUpdateButtonLoading('squid', false);
|
|
|
alert({{ _('Error de conexión')|tojson }});
|
|
|
}
|
|
|
}
|
|
|
@@ -818,6 +864,7 @@
|
|
|
showCustomConfirm(
|
|
|
{{ _('¿Estás seguro de que deseas actualizar SquidStats? Se actualizará la interfaz web, funcionalidades y correcciones de seguridad.')|tojson }},
|
|
|
async () => {
|
|
|
+ setUpdateButtonLoading('web', true);
|
|
|
try {
|
|
|
const response = await fetch('/update', {
|
|
|
method: 'POST',
|
|
|
@@ -830,6 +877,7 @@
|
|
|
if (response.ok) {
|
|
|
window.location.reload();
|
|
|
} else {
|
|
|
+ setUpdateButtonLoading('web', false);
|
|
|
alert({{ _('Error al actualizar la aplicación web')|tojson }});
|
|
|
}
|
|
|
} catch (error) {
|