fixed file naming thingy
This commit is contained in:
@@ -57,6 +57,13 @@ class BDFRApp {
|
||||
this.authStateInput = document.getElementById('authState');
|
||||
this.userAuthStateInput = document.getElementById('userAuthState');
|
||||
|
||||
// User downloads section
|
||||
this.userDownloadsSection = document.getElementById('userDownloadsSection');
|
||||
this.downloadLikesBtn = document.getElementById('downloadLikesBtn');
|
||||
this.downloadSavedBtn = document.getElementById('downloadSavedBtn');
|
||||
this.userScheduleOptions = document.getElementById('userScheduleOptions');
|
||||
this.userRunTimeInput = document.getElementById('userRunTime');
|
||||
|
||||
// Scheduled task form elements
|
||||
this.runDailyCheckbox = document.getElementById('runDaily');
|
||||
this.scheduleOptions = document.getElementById('scheduleOptions');
|
||||
@@ -105,6 +112,20 @@ class BDFRApp {
|
||||
if (this.logoutBtn) {
|
||||
this.logoutBtn.addEventListener('click', () => this.handleLogout());
|
||||
}
|
||||
|
||||
// User downloads events
|
||||
if (this.downloadLikesBtn) {
|
||||
this.downloadLikesBtn.addEventListener('click', () => this.handleDownloadLikes());
|
||||
}
|
||||
if (this.downloadSavedBtn) {
|
||||
this.downloadSavedBtn.addEventListener('click', () => this.handleDownloadSaved());
|
||||
}
|
||||
|
||||
// User schedule toggle
|
||||
const userScheduleRadios = document.querySelectorAll('input[name="user_schedule_type"]');
|
||||
userScheduleRadios.forEach(radio => {
|
||||
radio.addEventListener('change', (e) => this.updateUserScheduleUI(e.target.value));
|
||||
});
|
||||
// Real-time input validation
|
||||
['subreddit', 'username', 'sourceName'].forEach(id => {
|
||||
const input = document.getElementById(id);
|
||||
@@ -886,6 +907,11 @@ class BDFRApp {
|
||||
if (this.authStateInput) this.authStateInput.value = this.authState || '';
|
||||
if (this.userAuthStateInput) this.userAuthStateInput.value = this.authState || '';
|
||||
|
||||
// Show user downloads section
|
||||
if (this.userDownloadsSection) {
|
||||
this.userDownloadsSection.style.display = 'block';
|
||||
}
|
||||
|
||||
} else {
|
||||
this.authSection.style.display = 'block';
|
||||
this.authStatus.textContent = '🔴 Not Connected';
|
||||
@@ -899,6 +925,11 @@ class BDFRApp {
|
||||
// Clear auth state from forms
|
||||
if (this.authStateInput) this.authStateInput.value = '';
|
||||
if (this.userAuthStateInput) this.userAuthStateInput.value = '';
|
||||
|
||||
// Hide user downloads section
|
||||
if (this.userDownloadsSection) {
|
||||
this.userDownloadsSection.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -975,6 +1006,68 @@ class BDFRApp {
|
||||
}
|
||||
}
|
||||
|
||||
updateUserScheduleUI(scheduleType) {
|
||||
if (this.userScheduleOptions) {
|
||||
this.userScheduleOptions.style.display = scheduleType === 'scheduled' ? 'block' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
async handleDownloadLikes() {
|
||||
await this.handleUserDownload('likes');
|
||||
}
|
||||
|
||||
async handleDownloadSaved() {
|
||||
await this.handleUserDownload('saved');
|
||||
}
|
||||
|
||||
async handleUserDownload(type) {
|
||||
const downloadMode = document.querySelector('input[name="user_download_mode"]:checked').value;
|
||||
const scheduleType = document.querySelector('input[name="user_schedule_type"]:checked').value;
|
||||
const runNow = scheduleType === 'now';
|
||||
const runTime = this.userRunTimeInput ? this.userRunTimeInput.value : '02:00';
|
||||
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
|
||||
const params = {
|
||||
limit: 25,
|
||||
sort: 'hot',
|
||||
download_mode: downloadMode,
|
||||
run_now: runNow,
|
||||
run_time: runTime,
|
||||
timezone: timezone,
|
||||
auth_state: this.authState
|
||||
};
|
||||
|
||||
const endpoint = type === 'likes' ? '/api/scheduled-tasks/create-likes' : '/api/scheduled-tasks/create-saved';
|
||||
|
||||
try {
|
||||
this.showLoading(this[`download${type.charAt(0).toUpperCase() + type.slice(1)}Btn`]);
|
||||
|
||||
const response = await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(params)
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
const action = runNow ? 'started' : 'scheduled';
|
||||
this.showSuccess(`Your ${type} download has been ${action}!`);
|
||||
await this.loadScheduledTasks();
|
||||
} else {
|
||||
this.showError(result.detail || `Failed to ${runNow ? 'start' : 'schedule'} ${type} download`);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
this.showError(`Network error occurred while ${runNow ? 'starting' : 'scheduling'} ${type} download`);
|
||||
} finally {
|
||||
this.hideLoading(this[`download${type.charAt(0).toUpperCase() + type.slice(1)}Btn`]);
|
||||
}
|
||||
}
|
||||
|
||||
async completeOAuth2Flow(code, state) {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
|
||||
Reference in New Issue
Block a user