feat: implement frontend renderer, styling, and localization support for download management
This commit is contained in:
+50
-1
@@ -34,6 +34,9 @@ const overallPercent = document.getElementById('overall-percent');
|
|||||||
const overallProgressBar = document.getElementById('overall-progress-bar');
|
const overallProgressBar = document.getElementById('overall-progress-bar');
|
||||||
const overallCountText = document.getElementById('overall-count-text');
|
const overallCountText = document.getElementById('overall-count-text');
|
||||||
const overallRemainingText = document.getElementById('overall-remaining-text');
|
const overallRemainingText = document.getElementById('overall-remaining-text');
|
||||||
|
const dlPauseBtn = document.getElementById('dl-pause-btn');
|
||||||
|
const dlResumeBtn = document.getElementById('dl-resume-btn');
|
||||||
|
const dlStopBtn = document.getElementById('dl-stop-btn');
|
||||||
|
|
||||||
const languageSelect = document.getElementById('language-select');
|
const languageSelect = document.getElementById('language-select');
|
||||||
|
|
||||||
@@ -189,6 +192,30 @@ window.addEventListener('DOMContentLoaded', async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bind Pause, Resume, and Stop Control Buttons
|
||||||
|
if (dlPauseBtn) {
|
||||||
|
dlPauseBtn.addEventListener('click', async () => {
|
||||||
|
await window.api.pauseDownload();
|
||||||
|
dlPauseBtn.style.display = 'none';
|
||||||
|
dlResumeBtn.style.display = 'inline-flex';
|
||||||
|
downloadStatus.textContent = currentLang === 'tr' ? 'Duraklatıldı' : 'Paused';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dlResumeBtn) {
|
||||||
|
dlResumeBtn.addEventListener('click', async () => {
|
||||||
|
await window.api.resumeDownload();
|
||||||
|
dlResumeBtn.style.display = 'none';
|
||||||
|
dlPauseBtn.style.display = 'inline-flex';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dlStopBtn) {
|
||||||
|
dlStopBtn.addEventListener('click', async () => {
|
||||||
|
await window.api.stopDownload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Get and load persisted or default language
|
// Get and load persisted or default language
|
||||||
const savedLang = localStorage.getItem('vibe_lang') || 'tr';
|
const savedLang = localStorage.getItem('vibe_lang') || 'tr';
|
||||||
languageSelect.value = savedLang;
|
languageSelect.value = savedLang;
|
||||||
@@ -566,6 +593,7 @@ function renderTrackList(info) {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
track.checked = checkbox.checked;
|
track.checked = checkbox.checked;
|
||||||
updateSelectAllCheckboxState();
|
updateSelectAllCheckboxState();
|
||||||
|
updateSummaryStats();
|
||||||
});
|
});
|
||||||
|
|
||||||
checkboxWrapper.appendChild(checkbox);
|
checkboxWrapper.appendChild(checkbox);
|
||||||
@@ -651,8 +679,14 @@ function renderTrackList(info) {
|
|||||||
statusEl.appendChild(statusBadge);
|
statusEl.appendChild(statusBadge);
|
||||||
itemEl.appendChild(statusEl);
|
itemEl.appendChild(statusEl);
|
||||||
|
|
||||||
itemEl.addEventListener('click', () => {
|
itemEl.addEventListener('click', (e) => {
|
||||||
|
if (e.target.closest('.track-checkbox') || e.target.closest('.format-badge-btn')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
focusedTrackId = track.id;
|
focusedTrackId = track.id;
|
||||||
|
track.checked = !track.checked;
|
||||||
|
updateSelectAllCheckboxState();
|
||||||
|
updateSummaryStats();
|
||||||
syncBottomPanelWithTrack(track);
|
syncBottomPanelWithTrack(track);
|
||||||
renderTrackList(currentVideoData);
|
renderTrackList(currentVideoData);
|
||||||
});
|
});
|
||||||
@@ -809,6 +843,10 @@ downloadBtn.addEventListener('click', async () => {
|
|||||||
try {
|
try {
|
||||||
const browser = useCookiesCheckbox.checked ? cookieBrowserSelect.value : null;
|
const browser = useCookiesCheckbox.checked ? cookieBrowserSelect.value : null;
|
||||||
|
|
||||||
|
// Ensure initial button visibility states on start
|
||||||
|
if (dlPauseBtn) dlPauseBtn.style.display = 'inline-flex';
|
||||||
|
if (dlResumeBtn) dlResumeBtn.style.display = 'none';
|
||||||
|
|
||||||
// Map selected items into a simplified API task schema
|
// Map selected items into a simplified API task schema
|
||||||
const downloadTasks = selectedItems.map(t => ({
|
const downloadTasks = selectedItems.map(t => ({
|
||||||
id: t.id,
|
id: t.id,
|
||||||
@@ -876,6 +914,17 @@ downloadBtn.addEventListener('click', async () => {
|
|||||||
downloadProgressPanel.style.display = 'none';
|
downloadProgressPanel.style.display = 'none';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (result.stopped) {
|
||||||
|
// User aborted queue
|
||||||
|
downloadProgressPanel.style.display = 'none';
|
||||||
|
Swal.fire({
|
||||||
|
title: currentLang === 'tr' ? 'İndirme Durduruldu' : 'Download Stopped',
|
||||||
|
text: currentLang === 'tr' ? 'İndirme işlemi kullanıcı tarafından durduruldu.' : 'The download process was stopped by the user.',
|
||||||
|
icon: 'info',
|
||||||
|
background: 'rgba(23, 20, 38, 0.95)',
|
||||||
|
color: '#fff',
|
||||||
|
confirmButtonColor: '#7000ff'
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
showError(result.error);
|
showError(result.error);
|
||||||
downloadProgressPanel.style.display = 'none';
|
downloadProgressPanel.style.display = 'none';
|
||||||
|
|||||||
@@ -1130,5 +1130,20 @@ html[dir="rtl"] .summary-speed-select {
|
|||||||
background-position: left 6px center;
|
background-position: left 6px center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Control Buttons styling */
|
||||||
|
.dl-ctrl-btn {
|
||||||
|
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dl-ctrl-btn:hover {
|
||||||
|
transform: translateY(-1px);
|
||||||
|
filter: brightness(1.2);
|
||||||
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dl-ctrl-btn:active {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user