Merge branch 'main' into ui_configuration

2.0
Juraj Nyíri 3 years ago
commit f76c4c054b

@ -21088,15 +21088,21 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.detailElem.style.transition = '0s'; this.detailElem.style.transition = '0s';
this.detailElem.style.top = `${top - 1000}px`; this.detailElem.style.top = `${top - 1000}px`;
clearInterval(this.showDetailsTimeout); clearInterval(this.showDetailsTimeout);
this.showDetailsTimeout = setTimeout(() => { // eslint-disable-next-line @typescript-eslint/no-misused-promises
if (this.detailElem) { this.showDetailsTimeout = setTimeout(async () => {
if (this.detailElem && this.plex) {
this.detailElem.style.visibility = 'visible'; this.detailElem.style.visibility = 'visible';
this.detailElem.style.transition = '0.7s'; this.detailElem.style.transition = '0.7s';
this.detailElem.style.top = `${top}px`; this.detailElem.style.top = `${top}px`;
let mainData = data;
if (lodash.isEqual(data.type, 'season')) {
mainData = await this.plex.getDetails(data.parentKey.split('/')[3]);
mainData.title = `${mainData.title} - ${data.title}`;
}
const directorElem = this.getElementsByClassName('metaInfoDetailsData')[0]; const directorElem = this.getElementsByClassName('metaInfoDetailsData')[0];
if (directorElem.parentElement) { if (directorElem.parentElement) {
if (data.Director && data.Director.length > 0) { if (mainData.Director && mainData.Director.length > 0) {
directorElem.innerHTML = escapeHtml(data.Director[0].tag); directorElem.innerHTML = escapeHtml(mainData.Director[0].tag);
directorElem.parentElement.style.display = 'table-row'; directorElem.parentElement.style.display = 'table-row';
} }
else { else {
@ -21105,8 +21111,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
const writerElem = this.getElementsByClassName('metaInfoDetailsData')[1]; const writerElem = this.getElementsByClassName('metaInfoDetailsData')[1];
if (writerElem.parentElement) { if (writerElem.parentElement) {
if (data.Writer && data.Writer.length > 0) { if (mainData.Writer && mainData.Writer.length > 0) {
writerElem.innerHTML = escapeHtml(data.Writer[0].tag); writerElem.innerHTML = escapeHtml(mainData.Writer[0].tag);
writerElem.parentElement.style.display = 'table-row'; writerElem.parentElement.style.display = 'table-row';
} }
else { else {
@ -21115,8 +21121,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
const studioElem = this.getElementsByClassName('metaInfoDetailsData')[2]; const studioElem = this.getElementsByClassName('metaInfoDetailsData')[2];
if (studioElem.parentElement) { if (studioElem.parentElement) {
if (data.studio) { if (mainData.studio) {
studioElem.innerHTML = escapeHtml(data.studio); studioElem.innerHTML = escapeHtml(mainData.studio);
studioElem.parentElement.style.display = 'table-row'; studioElem.parentElement.style.display = 'table-row';
} }
else { else {
@ -21125,9 +21131,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
const genreElem = this.getElementsByClassName('metaInfoDetailsData')[3]; const genreElem = this.getElementsByClassName('metaInfoDetailsData')[3];
if (genreElem.parentElement) { if (genreElem.parentElement) {
if (data.Genre && data.Genre.length > 0) { if (mainData.Genre && mainData.Genre.length > 0) {
let genre = ''; let genre = '';
lodash.forEach(data.Genre, tag => { lodash.forEach(mainData.Genre, tag => {
genre += `${tag.tag}, `; genre += `${tag.tag}, `;
}); });
genreElem.innerHTML = escapeHtml(genre.slice(0, -2)); genreElem.innerHTML = escapeHtml(genre.slice(0, -2));
@ -21137,18 +21143,18 @@ class PlexMeetsHomeAssistant extends HTMLElement {
genreElem.parentElement.style.display = 'none'; genreElem.parentElement.style.display = 'none';
} }
} }
this.getElementsByClassName('detailsTitle')[0].innerHTML = escapeHtml(data.title); this.getElementsByClassName('detailsTitle')[0].innerHTML = escapeHtml(mainData.title);
this.getElementsByClassName('detailsYear')[0].innerHTML = escapeHtml(data.year); this.getElementsByClassName('detailsYear')[0].innerHTML = escapeHtml(mainData.year);
this.getElementsByClassName('metaInfo')[0].innerHTML = `${(data.duration !== undefined this.getElementsByClassName('metaInfo')[0].innerHTML = `${(mainData.duration !== undefined
? `<span class='minutesDetail'>${Math.round(parseInt(escapeHtml(data.duration), 10) / 60 / 1000)} min</span>` ? `<span class='minutesDetail'>${Math.round(parseInt(escapeHtml(mainData.duration), 10) / 60 / 1000)} min</span>`
: '') + : '') +
(data.contentRating !== undefined (mainData.contentRating !== undefined
? `<span class='contentRatingDetail'>${escapeHtml(data.contentRating)}</span>` ? `<span class='contentRatingDetail'>${escapeHtml(mainData.contentRating)}</span>`
: '') + : '') +
(data.rating !== undefined (mainData.rating !== undefined
? `<span class='ratingDetail'>${data.rating < 5 ? '&#128465;' : '&#11088;'}&nbsp;${Math.round(parseFloat(escapeHtml(data.rating)) * 10) / 10}</span>` ? `<span class='ratingDetail'>${mainData.rating < 5 ? '&#128465;' : '&#11088;'}&nbsp;${Math.round(parseFloat(escapeHtml(mainData.rating)) * 10) / 10}</span>`
: '')}<div class='clear'></div>`; : '')}<div class='clear'></div>`;
this.getElementsByClassName('detailDesc')[0].innerHTML = escapeHtml(data.summary); this.getElementsByClassName('detailDesc')[0].innerHTML = escapeHtml(mainData.summary);
/* todo temp disabled /* todo temp disabled
if (data.type === 'movie') { if (data.type === 'movie') {
(this.detailElem.children[5] as HTMLElement).style.visibility = 'visible'; (this.detailElem.children[5] as HTMLElement).style.visibility = 'visible';

@ -871,16 +871,22 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.detailElem.style.transition = '0s'; this.detailElem.style.transition = '0s';
this.detailElem.style.top = `${top - 1000}px`; this.detailElem.style.top = `${top - 1000}px`;
clearInterval(this.showDetailsTimeout); clearInterval(this.showDetailsTimeout);
this.showDetailsTimeout = setTimeout(() => { // eslint-disable-next-line @typescript-eslint/no-misused-promises
if (this.detailElem) { this.showDetailsTimeout = setTimeout(async () => {
if (this.detailElem && this.plex) {
this.detailElem.style.visibility = 'visible'; this.detailElem.style.visibility = 'visible';
this.detailElem.style.transition = '0.7s'; this.detailElem.style.transition = '0.7s';
this.detailElem.style.top = `${top}px`; this.detailElem.style.top = `${top}px`;
let mainData = data;
if (_.isEqual(data.type, 'season')) {
mainData = await this.plex.getDetails(data.parentKey.split('/')[3]);
mainData.title = `${mainData.title} - ${data.title}`;
}
const directorElem = this.getElementsByClassName('metaInfoDetailsData')[0] as HTMLElement; const directorElem = this.getElementsByClassName('metaInfoDetailsData')[0] as HTMLElement;
if (directorElem.parentElement) { if (directorElem.parentElement) {
if (data.Director && data.Director.length > 0) { if (mainData.Director && mainData.Director.length > 0) {
directorElem.innerHTML = escapeHtml(data.Director[0].tag); directorElem.innerHTML = escapeHtml(mainData.Director[0].tag);
directorElem.parentElement.style.display = 'table-row'; directorElem.parentElement.style.display = 'table-row';
} else { } else {
directorElem.parentElement.style.display = 'none'; directorElem.parentElement.style.display = 'none';
@ -889,8 +895,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
const writerElem = this.getElementsByClassName('metaInfoDetailsData')[1] as HTMLElement; const writerElem = this.getElementsByClassName('metaInfoDetailsData')[1] as HTMLElement;
if (writerElem.parentElement) { if (writerElem.parentElement) {
if (data.Writer && data.Writer.length > 0) { if (mainData.Writer && mainData.Writer.length > 0) {
writerElem.innerHTML = escapeHtml(data.Writer[0].tag); writerElem.innerHTML = escapeHtml(mainData.Writer[0].tag);
writerElem.parentElement.style.display = 'table-row'; writerElem.parentElement.style.display = 'table-row';
} else { } else {
writerElem.parentElement.style.display = 'none'; writerElem.parentElement.style.display = 'none';
@ -898,8 +904,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
const studioElem = this.getElementsByClassName('metaInfoDetailsData')[2] as HTMLElement; const studioElem = this.getElementsByClassName('metaInfoDetailsData')[2] as HTMLElement;
if (studioElem.parentElement) { if (studioElem.parentElement) {
if (data.studio) { if (mainData.studio) {
studioElem.innerHTML = escapeHtml(data.studio); studioElem.innerHTML = escapeHtml(mainData.studio);
studioElem.parentElement.style.display = 'table-row'; studioElem.parentElement.style.display = 'table-row';
} else { } else {
studioElem.parentElement.style.display = 'none'; studioElem.parentElement.style.display = 'none';
@ -907,9 +913,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
const genreElem = this.getElementsByClassName('metaInfoDetailsData')[3] as HTMLElement; const genreElem = this.getElementsByClassName('metaInfoDetailsData')[3] as HTMLElement;
if (genreElem.parentElement) { if (genreElem.parentElement) {
if (data.Genre && data.Genre.length > 0) { if (mainData.Genre && mainData.Genre.length > 0) {
let genre = ''; let genre = '';
_.forEach(data.Genre, tag => { _.forEach(mainData.Genre, tag => {
genre += `${tag.tag}, `; genre += `${tag.tag}, `;
}); });
genreElem.innerHTML = escapeHtml(genre.slice(0, -2)); genreElem.innerHTML = escapeHtml(genre.slice(0, -2));
@ -918,22 +924,22 @@ class PlexMeetsHomeAssistant extends HTMLElement {
genreElem.parentElement.style.display = 'none'; genreElem.parentElement.style.display = 'none';
} }
} }
(this.getElementsByClassName('detailsTitle')[0] as HTMLElement).innerHTML = escapeHtml(data.title); (this.getElementsByClassName('detailsTitle')[0] as HTMLElement).innerHTML = escapeHtml(mainData.title);
(this.getElementsByClassName('detailsYear')[0] as HTMLElement).innerHTML = escapeHtml(data.year); (this.getElementsByClassName('detailsYear')[0] as HTMLElement).innerHTML = escapeHtml(mainData.year);
(this.getElementsByClassName('metaInfo')[0] as HTMLElement).innerHTML = `${(data.duration !== undefined (this.getElementsByClassName('metaInfo')[0] as HTMLElement).innerHTML = `${(mainData.duration !== undefined
? `<span class='minutesDetail'>${Math.round( ? `<span class='minutesDetail'>${Math.round(
parseInt(escapeHtml(data.duration), 10) / 60 / 1000 parseInt(escapeHtml(mainData.duration), 10) / 60 / 1000
)} min</span>` )} min</span>`
: '') + : '') +
(data.contentRating !== undefined (mainData.contentRating !== undefined
? `<span class='contentRatingDetail'>${escapeHtml(data.contentRating)}</span>` ? `<span class='contentRatingDetail'>${escapeHtml(mainData.contentRating)}</span>`
: '') + : '') +
(data.rating !== undefined (mainData.rating !== undefined
? `<span class='ratingDetail'>${data.rating < 5 ? '&#128465;' : '&#11088;'}&nbsp;${Math.round( ? `<span class='ratingDetail'>${mainData.rating < 5 ? '&#128465;' : '&#11088;'}&nbsp;${Math.round(
parseFloat(escapeHtml(data.rating)) * 10 parseFloat(escapeHtml(mainData.rating)) * 10
) / 10}</span>` ) / 10}</span>`
: '')}<div class='clear'></div>`; : '')}<div class='clear'></div>`;
(this.getElementsByClassName('detailDesc')[0] as HTMLElement).innerHTML = escapeHtml(data.summary); (this.getElementsByClassName('detailDesc')[0] as HTMLElement).innerHTML = escapeHtml(mainData.summary);
/* todo temp disabled /* todo temp disabled
if (data.type === 'movie') { if (data.type === 'movie') {

Loading…
Cancel
Save