updates: fixes for imdb manual add and manual add dates
Local Docker Build (Dev) / build-dev (push) Successful in 5s
Local Docker Build (Dev) / build-dev (push) Successful in 5s
This commit is contained in:
@@ -1065,7 +1065,7 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
|||||||
const modal = document.getElementById('edit-modal');
|
const modal = document.getElementById('edit-modal');
|
||||||
const title = document.getElementById('modal-title');
|
const title = document.getElementById('modal-title');
|
||||||
const modalBody = document.querySelector('#edit-modal .modal-body');
|
const modalBody = document.querySelector('#edit-modal .modal-body');
|
||||||
|
|
||||||
if (mediaType === 'movie') {
|
if (mediaType === 'movie') {
|
||||||
title.textContent = `Edit Movie: ${options.imdb_id}`;
|
title.textContent = `Edit Movie: ${options.imdb_id}`;
|
||||||
} else {
|
} else {
|
||||||
@@ -1074,9 +1074,10 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
|||||||
const episode = options.episode || 0;
|
const episode = options.episode || 0;
|
||||||
title.textContent = `Edit Episode: ${options.imdb_id} S${season.toString().padStart(2, '0')}E${episode.toString().padStart(2, '0')}`;
|
title.textContent = `Edit Episode: ${options.imdb_id} S${season.toString().padStart(2, '0')}E${episode.toString().padStart(2, '0')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build enhanced edit form with date options
|
// Build enhanced edit form with date options
|
||||||
let formHtml = `
|
let formHtml = `
|
||||||
|
<form id="edit-form-enhanced" onsubmit="handleEnhancedEditSubmit(event); return false;">
|
||||||
<input type="hidden" id="edit-imdb-id" value="${options.imdb_id}">
|
<input type="hidden" id="edit-imdb-id" value="${options.imdb_id}">
|
||||||
<input type="hidden" id="edit-media-type" value="${mediaType}">
|
<input type="hidden" id="edit-media-type" value="${mediaType}">
|
||||||
${mediaType === 'episode' ? `
|
${mediaType === 'episode' ? `
|
||||||
@@ -1086,21 +1087,21 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
|||||||
<input type="hidden" id="edit-season" value="">
|
<input type="hidden" id="edit-season" value="">
|
||||||
<input type="hidden" id="edit-episode" value="">
|
<input type="hidden" id="edit-episode" value="">
|
||||||
`}
|
`}
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Choose Date Source:</label>
|
<label>Choose Date Source:</label>
|
||||||
<div class="date-options">
|
<div class="date-options">
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Add available date options
|
// Add available date options
|
||||||
options.options.forEach((option, index) => {
|
options.options.forEach((option, index) => {
|
||||||
const isSelected = option.source === currentSource ? 'checked' : '';
|
const isSelected = option.source === currentSource ? 'checked' : '';
|
||||||
const optionId = `date-option-${index}`;
|
const optionId = `date-option-${index}`;
|
||||||
|
|
||||||
formHtml += `
|
formHtml += `
|
||||||
<div class="date-option-card">
|
<div class="date-option-card">
|
||||||
<label class="date-option-label">
|
<label class="date-option-label">
|
||||||
<input type="radio" name="edit-date-option" value="${index}" ${isSelected}
|
<input type="radio" name="edit-date-option" value="${index}" ${isSelected}
|
||||||
onchange="updateEditDateFromOption(${index}, ${JSON.stringify(option).replace(/"/g, '"')})">
|
onchange="updateEditDateFromOption(${index}, ${JSON.stringify(option).replace(/"/g, '"')})">
|
||||||
<div class="date-option-content">
|
<div class="date-option-content">
|
||||||
<h4>${option.label}</h4>
|
<h4>${option.label}</h4>
|
||||||
@@ -1111,17 +1112,17 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
});
|
});
|
||||||
|
|
||||||
formHtml += `
|
formHtml += `
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="edit-dateadded">Date Added:</label>
|
<label for="edit-dateadded">Date Added:</label>
|
||||||
<input type="datetime-local" id="edit-dateadded" required>
|
<input type="datetime-local" id="edit-dateadded" required>
|
||||||
<small>Adjust the date/time as needed</small>
|
<small>Adjust the date/time as needed</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="edit-source">Source:</label>
|
<label for="edit-source">Source:</label>
|
||||||
<select id="edit-source" required>
|
<select id="edit-source" required>
|
||||||
@@ -1133,16 +1134,17 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
|||||||
<option value="no_valid_date_source">No Valid Source</option>
|
<option value="no_valid_date_source">No Valid Source</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="button" class="btn btn-secondary" onclick="closeModal()">Cancel</button>
|
<button type="button" class="btn btn-secondary" onclick="closeModal()">Cancel</button>
|
||||||
<button type="submit" class="btn btn-primary" onclick="handleEnhancedEditSubmit(event)">Save Changes</button>
|
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
modalBody.innerHTML = formHtml;
|
modalBody.innerHTML = formHtml;
|
||||||
|
|
||||||
|
|
||||||
// Set current values
|
// Set current values
|
||||||
if (currentDateadded && currentDateadded !== '-') {
|
if (currentDateadded && currentDateadded !== '-') {
|
||||||
try {
|
try {
|
||||||
@@ -1152,12 +1154,12 @@ function showEnhancedEditModal(mediaType, options, currentDateadded, currentSour
|
|||||||
document.getElementById('edit-dateadded').value = '';
|
document.getElementById('edit-dateadded').value = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('edit-source').value = currentSource || 'manual';
|
document.getElementById('edit-source').value = currentSource || 'manual';
|
||||||
|
|
||||||
// Store options for later use
|
// Store options for later use
|
||||||
modal.dataset.options = JSON.stringify(options);
|
modal.dataset.options = JSON.stringify(options);
|
||||||
|
|
||||||
modal.classList.add('active');
|
modal.classList.add('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1219,35 +1221,51 @@ function updateEditDateFromOption(optionIndex, option) {
|
|||||||
|
|
||||||
async function handleEnhancedEditSubmit(event) {
|
async function handleEnhancedEditSubmit(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
console.log('🔍 Enhanced Edit Submit called');
|
||||||
|
|
||||||
const modal = document.getElementById('edit-modal');
|
const modal = document.getElementById('edit-modal');
|
||||||
const options = JSON.parse(modal.dataset.options);
|
const options = JSON.parse(modal.dataset.options);
|
||||||
const imdbId = options.imdb_id;
|
const imdbId = options.imdb_id;
|
||||||
const mediaType = document.getElementById('edit-media-type').value;
|
const mediaType = document.getElementById('edit-media-type').value;
|
||||||
const dateadded = document.getElementById('edit-dateadded').value;
|
const dateadded = document.getElementById('edit-dateadded').value;
|
||||||
const source = document.getElementById('edit-source').value;
|
const source = document.getElementById('edit-source').value;
|
||||||
|
|
||||||
|
console.log('🔍 Form values:', {
|
||||||
|
imdbId,
|
||||||
|
mediaType,
|
||||||
|
dateadded,
|
||||||
|
dateaddedType: typeof dateadded,
|
||||||
|
dateaddedLength: dateadded ? dateadded.length : 0,
|
||||||
|
source
|
||||||
|
});
|
||||||
|
|
||||||
if (!dateadded) {
|
if (!dateadded) {
|
||||||
|
console.log('❌ Date field is empty!');
|
||||||
showToast('Please enter a date', 'warning');
|
showToast('Please enter a date', 'warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert datetime-local to ISO string with error handling
|
// Convert datetime-local to ISO string with error handling
|
||||||
let isoDateadded = null;
|
let isoDateadded = null;
|
||||||
try {
|
try {
|
||||||
isoDateadded = new Date(dateadded).toISOString();
|
isoDateadded = new Date(dateadded).toISOString();
|
||||||
|
console.log('✅ Converted to ISO:', isoDateadded);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.error('❌ Date conversion error:', e);
|
||||||
showToast('Invalid date format', 'error');
|
showToast('Invalid date format', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mediaType === 'movie') {
|
if (mediaType === 'movie') {
|
||||||
|
console.log('📤 Calling updateMovieDate with:', { imdbId, isoDateadded, source });
|
||||||
await updateMovieDate(imdbId, isoDateadded, source);
|
await updateMovieDate(imdbId, isoDateadded, source);
|
||||||
} else {
|
} else {
|
||||||
|
console.log('📤 Calling updateEpisodeDate with:', { imdbId, season: options.season, episode: options.episode, isoDateadded, source });
|
||||||
await updateEpisodeDate(imdbId, options.season, options.episode, isoDateadded, source);
|
await updateEpisodeDate(imdbId, options.season, options.episode, isoDateadded, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
closeModal();
|
closeModal();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Enhanced edit failed:', error);
|
console.error('Enhanced edit failed:', error);
|
||||||
@@ -1280,24 +1298,39 @@ function closeModal() {
|
|||||||
|
|
||||||
async function handleEditSubmit(event) {
|
async function handleEditSubmit(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
console.log('🔍 Basic Edit Submit called (OLD HANDLER)');
|
||||||
|
|
||||||
const imdbId = document.getElementById('edit-imdb-id').value;
|
const imdbId = document.getElementById('edit-imdb-id').value;
|
||||||
const mediaType = document.getElementById('edit-media-type').value;
|
const mediaType = document.getElementById('edit-media-type').value;
|
||||||
const season = document.getElementById('edit-season').value;
|
const season = document.getElementById('edit-season').value;
|
||||||
const episode = document.getElementById('edit-episode').value;
|
const episode = document.getElementById('edit-episode').value;
|
||||||
const dateadded = document.getElementById('edit-dateadded').value;
|
const dateadded = document.getElementById('edit-dateadded').value;
|
||||||
const source = document.getElementById('edit-source').value;
|
const source = document.getElementById('edit-source').value;
|
||||||
|
|
||||||
|
console.log('🔍 OLD Form values:', {
|
||||||
|
imdbId,
|
||||||
|
mediaType,
|
||||||
|
dateadded,
|
||||||
|
dateaddedType: typeof dateadded,
|
||||||
|
dateaddedLength: dateadded ? dateadded.length : 0,
|
||||||
|
source
|
||||||
|
});
|
||||||
|
|
||||||
// Convert datetime-local to ISO string
|
// Convert datetime-local to ISO string
|
||||||
const isoDateadded = dateadded ? new Date(dateadded).toISOString() : null;
|
const isoDateadded = dateadded ? new Date(dateadded).toISOString() : null;
|
||||||
|
|
||||||
|
console.log('🔍 OLD isoDateadded:', isoDateadded);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mediaType === 'movie') {
|
if (mediaType === 'movie') {
|
||||||
|
console.log('📤 OLD calling updateMovieDate with:', { imdbId, isoDateadded, source });
|
||||||
await updateMovieDate(imdbId, isoDateadded, source);
|
await updateMovieDate(imdbId, isoDateadded, source);
|
||||||
} else {
|
} else {
|
||||||
|
console.log('📤 OLD calling updateEpisodeDate');
|
||||||
await updateEpisodeDate(imdbId, parseInt(season), parseInt(episode), isoDateadded, source);
|
await updateEpisodeDate(imdbId, parseInt(season), parseInt(episode), isoDateadded, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
closeModal();
|
closeModal();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Update failed:', error);
|
console.error('Update failed:', error);
|
||||||
@@ -1306,22 +1339,36 @@ async function handleEditSubmit(event) {
|
|||||||
|
|
||||||
// Update functions
|
// Update functions
|
||||||
async function updateMovieDate(imdbId, dateadded, source) {
|
async function updateMovieDate(imdbId, dateadded, source) {
|
||||||
|
console.log('🔍 updateMovieDate called with:', {
|
||||||
|
imdbId,
|
||||||
|
dateadded,
|
||||||
|
dateaddedType: typeof dateadded,
|
||||||
|
dateaddedValue: dateadded,
|
||||||
|
source
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const payload = {
|
||||||
|
dateadded: dateadded,
|
||||||
|
source: source
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('📤 Sending API request with payload:', JSON.stringify(payload));
|
||||||
|
|
||||||
const result = await apiCall(`/api/movies/${imdbId}`, {
|
const result = await apiCall(`/api/movies/${imdbId}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify(payload)
|
||||||
dateadded: dateadded,
|
|
||||||
source: source
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('✅ API response:', result);
|
||||||
|
|
||||||
showToast(result.message, 'success');
|
showToast(result.message, 'success');
|
||||||
|
|
||||||
// Refresh current view
|
// Refresh current view
|
||||||
if (currentTab === 'movies') loadMovies(currentMoviesPage);
|
if (currentTab === 'movies') loadMovies(currentMoviesPage);
|
||||||
if (currentTab === 'reports') loadReport();
|
if (currentTab === 'reports') loadReport();
|
||||||
if (currentTab === 'dashboard') loadDashboard();
|
if (currentTab === 'dashboard') loadDashboard();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Movie update failed:', error);
|
console.error('Movie update failed:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user