Added channel update functionality

This commit is contained in:
2025-03-28 13:21:22 -03:00
parent e8fae1a14b
commit 2300fd8685
7 changed files with 153 additions and 6 deletions

View File

@@ -471,6 +471,9 @@
<button id="resolution-btn" class="control-button" onclick="toggleResolution()">
%RESOLUTION_LABEL%: <span id="resolution-state">%RESOLUTION%</span>
</button>
<button id="refresh-ch-btn" class="control-button" onclick="refreshChannels()">
%REFRESH_CH_LABEL%
</button>
</div>
<div class="section">
@@ -672,6 +675,34 @@
.then(() => window.location.reload())
}
function refreshChannels() {
const refreshBtn = document.getElementById('refresh-ch-btn');
const originalText = refreshBtn.textContent;
refreshBtn.textContent = "Updating...";
refreshBtn.disabled = true;
fetch('/update_channels')
.then(response => response.json())
.then(data => {
refreshBtn.textContent = originalText;
refreshBtn.disabled = false;
if (data.success) {
showToast(`%JS_CH_UPDATE_P1% ${data.channel_count} %JS_CH_UPDATE_P2%`);
// Reload the page to show updated channel list
setTimeout(() => window.location.reload(), 2000);
} else {
showToast("%JS_CH_UPDATE_FAIL%");
}
})
.catch(error => {
refreshBtn.textContent = originalText;
refreshBtn.disabled = false;
showToast("Error updating channels. Please try again.");
});
}
// Mobile-friendly toast notification
function showToast(message) {
const toast = document.createElement('div');