Use Checkboxes to select libraries (#287)
Co-authored-by: rlauu <46294892+rlauu@users.noreply.github.com>
This commit is contained in:
parent
2438ba79f2
commit
72e59f273a
@ -77,15 +77,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="inputContainer">
|
<div class="folderAccessListContainer">
|
||||||
<label class="inputLabel inputLabelUnfocused" for="SelectedLibraries">
|
<div class="folderAccess">
|
||||||
Limit analysis to the following libraries
|
<h3 class="checkboxListLabel">Limit analysis to the following libraries</h3>
|
||||||
</label>
|
<div class="checkboxList paperList" style="padding: 0.5em 1em;" id="libraryCheckboxes">
|
||||||
<input id="SelectedLibraries" type="text" is="emby-input" />
|
</div>
|
||||||
<div class="fieldDescription">
|
|
||||||
Enter the names of libraries to analyze, separated by commas. If this field is left
|
|
||||||
blank, all libraries on the server containing television episodes will be analyzed.
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="fieldDescription">
|
||||||
|
Select the libraries you want to include in the analysis. If no libraries are selected, all TV show libraries will be analyzed.
|
||||||
|
</div>
|
||||||
|
<label class="inputLabel" for="SelectedLibraries"></label>
|
||||||
|
<input id="SelectedLibraries" type="hidden" is="emby-input" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<details id="intro_reqs">
|
<details id="intro_reqs">
|
||||||
@ -401,7 +403,7 @@
|
|||||||
<details id="AutoSkipClientList" style="padding-bottom: 1em;">
|
<details id="AutoSkipClientList" style="padding-bottom: 1em;">
|
||||||
<summary>Auto Skip Client List</summary>
|
<summary>Auto Skip Client List</summary>
|
||||||
<br />
|
<br />
|
||||||
<div class="checkboxList paperList" style="padding:.5em 1em"></div>
|
<div class="checkboxList paperList" style="padding:.5em 1em" id="autoSkipCheckboxes"></div>
|
||||||
<label class="inputLabel" for="ClientList"></label>
|
<label class="inputLabel" for="ClientList"></label>
|
||||||
<input id="ClientList" type="hidden" is="emby-input" />
|
<input id="ClientList" type="hidden" is="emby-input" />
|
||||||
</details>
|
</details>
|
||||||
@ -810,41 +812,43 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDeviceList() {
|
function updateList(textField, container) {
|
||||||
const response = await getJson("Devices");
|
textField.value = Array.from(container.querySelectorAll('input[type="checkbox"]:checked'))
|
||||||
const devices = [...new Set(response.Items.map(item => item.AppName))];
|
.map(checkbox => checkbox.nextElementSibling.textContent)
|
||||||
return devices;
|
.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateClientList() {
|
function generateCheckboxList(items, containerId, textFieldId) {
|
||||||
document.getElementById('ClientList').value = Array.from(
|
const container = document.getElementById(containerId);
|
||||||
autoSkipClientList.querySelectorAll('input[type="checkbox"]:checked')
|
const textField = document.getElementById(textFieldId);
|
||||||
).map(checkbox => checkbox.nextElementSibling.textContent).join(', ');
|
const checkedItems = textField.value ? textField.value.split(', ') : [];
|
||||||
}
|
|
||||||
|
|
||||||
async function generateAutoSkipClientList() {
|
container.innerHTML = items.map(item => {
|
||||||
var devices = await getDeviceList();
|
const isChecked = checkedItems.includes(item) ? 'checked' : '';
|
||||||
var deviceList = document.getElementById('ClientList').value;
|
|
||||||
var checkedDevices = deviceList ? deviceList.split(', ') : [];
|
|
||||||
|
|
||||||
var checkboxListHtml = devices.map(function(device) {
|
|
||||||
var id = 'chk' + device.replace(/\s+/g, '');
|
|
||||||
var isChecked = checkedDevices.includes(device) ? 'checked' : '';
|
|
||||||
return '<label class="emby-checkbox-label">' +
|
return '<label class="emby-checkbox-label">' +
|
||||||
'<input type="checkbox" is="emby-checkbox" id="' + id + '" ' + isChecked + '>' +
|
'<input type="checkbox" is="emby-checkbox" ' + isChecked + '>' +
|
||||||
'<span class="checkboxLabel">' + device + '</span>' +
|
'<span class="checkboxLabel">' + item + '</span>' +
|
||||||
'</label>';
|
'</label>';
|
||||||
}).join('');
|
}).join('');
|
||||||
|
|
||||||
var checkboxList = autoSkipClientList.querySelector('.checkboxList.paperList');
|
container.addEventListener('change', event => {
|
||||||
checkboxList.innerHTML = checkboxListHtml;
|
if (event.target.type === 'checkbox') {
|
||||||
|
updateList(textField, container);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var checkboxes = checkboxList.querySelectorAll('input[type="checkbox"]');
|
async function generateAutoSkipClientList() {
|
||||||
for (var i = 0; i < checkboxes.length; i++) {
|
const response = await getJson("Devices");
|
||||||
checkboxes[i].addEventListener('change', function() {
|
const devices = [...new Set(response.Items.map(item => item.AppName))];
|
||||||
updateClientList();
|
generateCheckboxList(devices, 'autoSkipCheckboxes', 'ClientList');
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
async function populateLibraries() {
|
||||||
|
const response = await getJson("Library/MediaFolders");
|
||||||
|
const tvLibraries = response.Items.filter(item => item.CollectionType === "tvshows");
|
||||||
|
const libraryNames = tvLibraries.map(lib => lib.Name || 'Unnamed Library');
|
||||||
|
generateCheckboxList(libraryNames, 'libraryCheckboxes', 'SelectedLibraries');
|
||||||
}
|
}
|
||||||
|
|
||||||
var persistSkip = document.querySelector("input#PersistSkipButton");
|
var persistSkip = document.querySelector("input#PersistSkipButton");
|
||||||
@ -1197,6 +1201,7 @@
|
|||||||
document.querySelector("#" + field).checked = config[field];
|
document.querySelector("#" + field).checked = config[field];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
populateLibraries();
|
||||||
autoSkipChanged();
|
autoSkipChanged();
|
||||||
autoSkipCreditsChanged();
|
autoSkipCreditsChanged();
|
||||||
persistSkipChanged();
|
persistSkipChanged();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user