Radarr-Sonarr-Integration #12
@@ -62,6 +62,28 @@ const getMediaCleanerMoviesTitle = async () => {
|
|||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectedMovies = new Set();
|
||||||
|
const selectedTvShows = new Set();
|
||||||
|
|
||||||
|
const createCheckbox = (mediaInfo = {}, state = []) => {
|
||||||
|
const checkbox = document.createElement('input');
|
||||||
|
checkbox.type = 'checkbox';
|
||||||
|
checkbox.dataset.mediaInfo = JSON.stringify(mediaInfo) || '';
|
||||||
|
|
||||||
|
checkbox.addEventListener('change', (e) => {
|
||||||
|
const mediaInfo = checkbox.dataset.mediaInfo || '(no info)';
|
||||||
|
if (checkbox.checked) {
|
||||||
|
state.add(mediaInfo);
|
||||||
|
} else {
|
||||||
|
state.delete(mediaInfo);
|
||||||
|
}
|
||||||
|
// Update UI or state — use console.log for debugging
|
||||||
|
console.log('selected:', Array.from(state));
|
||||||
|
});
|
||||||
|
|
||||||
|
return checkbox;
|
||||||
|
};
|
||||||
|
|
||||||
const populateTables = async () => {
|
const populateTables = async () => {
|
||||||
var moviesInfo = await getMediaCleanerMovieInfo();
|
var moviesInfo = await getMediaCleanerMovieInfo();
|
||||||
var seriesInfo = await getMediaCleanerSeriesInfo();
|
var seriesInfo = await getMediaCleanerSeriesInfo();
|
||||||
@@ -78,9 +100,7 @@ const populateTables = async () => {
|
|||||||
var cell1 = row.insertCell(0);
|
var cell1 = row.insertCell(0);
|
||||||
var cell2 = row.insertCell(1);
|
var cell2 = row.insertCell(1);
|
||||||
cell1.innerHTML = moviesInfo[i].Name;
|
cell1.innerHTML = moviesInfo[i].Name;
|
||||||
// Will need to be enabled once radarr and sonarr integration is enabled.
|
cell2.appendChild(createCheckbox(moviesInfo[i], selectedMovies));
|
||||||
// Maybe change this to an element to remove hard coding.
|
|
||||||
cell2.innerHTML = "<input type=\"checkbox\" disabled />";
|
|
||||||
cell2.className = "actions-cell";
|
cell2.className = "actions-cell";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,9 +120,7 @@ const populateTables = async () => {
|
|||||||
var cell3 = row.insertCell(2);
|
var cell3 = row.insertCell(2);
|
||||||
cell1.innerHTML = seriesInfo[i].Name;
|
cell1.innerHTML = seriesInfo[i].Name;
|
||||||
cell2.innerHTML = seriesInfo[i].Seasons.map(season => season.replace("Season ", "")).join(", ");
|
cell2.innerHTML = seriesInfo[i].Seasons.map(season => season.replace("Season ", "")).join(", ");
|
||||||
// Will need to be enabled once radarr and sonarr integration is enabled.
|
cell3.appendChild(createCheckbox(seriesInfo[i], selectedTvShows));
|
||||||
// Maybe change this to an element to remove hard coding.
|
|
||||||
cell3.innerHTML = "<input type=\"checkbox\" disabled />";
|
|
||||||
cell3.className = "actions-cell";
|
cell3.className = "actions-cell";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user