Add hostname at the end of the calendar row

This commit is contained in:
Alex Thomassen 2022-08-25 16:12:34 +02:00
parent 46483202ca
commit 8be820b711

View File

@ -40,6 +40,7 @@ async function fetchIcs(url, name)
const status = item.getFirstPropertyValue('status');
const start = item.getFirstPropertyValue('dtstart').toJSDate();
const end = item.getFirstPropertyValue('dtend').toJSDate();
const publisher = item.getFirstPropertyValue('categories');
let isAdded = false;
if (status.toLowerCase() === 'confirmed') {
@ -71,13 +72,14 @@ async function fetchIcs(url, name)
// console.log(status);
// }
title = `${title} [${name}]`;
title = `${title} (${publisher})`;
return {
title: title,
start,
end,
display: 'list-item',
classNames: [name],
};
});
@ -151,6 +153,24 @@ const toggleButton = {
},
};
function appendSonarrHostnames()
{
const names = icsUrls.map(item => item.name);
for (const name of names) {
const rows = document.querySelectorAll(`.${name}`);
for (const row of rows) {
const lastCell = row.querySelector('td:last-child');
const hostname = document.createElement('span');
hostname.className = 'float-end';
hostname.textContent = name;
lastCell.insertAdjacentElement('beforeend', hostname);
}
}
}
async function loadSonarrCalendar(shouldScroll = false)
{
const calendarElement = document.querySelector('#sonarr-calendar');
@ -189,6 +209,8 @@ async function loadSonarrCalendar(shouldScroll = false)
const message = document.querySelector('#status-message');
try {
calendar.render();
appendSonarrHostnames();
if (message) {
message.remove();