|
|
@ -3,7 +3,7 @@
|
|
|
|
import _ from 'lodash';
|
|
|
|
import _ from 'lodash';
|
|
|
|
import { HomeAssistant } from 'custom-card-helpers';
|
|
|
|
import { HomeAssistant } from 'custom-card-helpers';
|
|
|
|
import Plex from './modules/Plex';
|
|
|
|
import Plex from './modules/Plex';
|
|
|
|
import { fetchEntityRegistry, createTextElement } from './modules/utils';
|
|
|
|
import { fetchEntityRegistry, createTextElement, setTextElementValue } from './modules/utils';
|
|
|
|
|
|
|
|
|
|
|
|
class PlexMeetsHomeAssistantEditor extends HTMLElement {
|
|
|
|
class PlexMeetsHomeAssistantEditor extends HTMLElement {
|
|
|
|
content: any;
|
|
|
|
content: any;
|
|
|
@ -394,25 +394,24 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
|
|
|
|
this.ip.style.width = '100%';
|
|
|
|
this.ip.style.width = '100%';
|
|
|
|
this.ip.style.marginTop = '10px';
|
|
|
|
this.ip.style.marginTop = '10px';
|
|
|
|
this.ip.style.marginBottom = '10px';
|
|
|
|
this.ip.style.marginBottom = '10px';
|
|
|
|
|
|
|
|
|
|
|
|
this.ip.label = 'Plex IP Address / Hostname';
|
|
|
|
this.ip.label = 'Plex IP Address / Hostname';
|
|
|
|
if (this.config.ip) {
|
|
|
|
if (this.config.ip) {
|
|
|
|
this.ip.value = this.config.ip.replace(/^https?:\/\//i, '').replace(/\/$/, '');
|
|
|
|
setTextElementValue(this.ip, this.config.ip.replace(/^https?:\/\//i, '').replace(/\/$/, ''));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.ip.value = this.config.ip;
|
|
|
|
setTextElementValue(this.ip, this.config.ip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.ip.addEventListener('change', this.valueUpdated);
|
|
|
|
this.ip.addEventListener('change', this.valueUpdated);
|
|
|
|
this.content.appendChild(this.ip);
|
|
|
|
this.content.appendChild(this.ip);
|
|
|
|
|
|
|
|
|
|
|
|
this.port.label = 'Plex Port (Optional)';
|
|
|
|
this.port.label = 'Plex Port (Optional)';
|
|
|
|
this.port.value = this.config.port;
|
|
|
|
setTextElementValue(this.port, this.config.port);
|
|
|
|
this.port.type = 'number';
|
|
|
|
this.port.type = 'number';
|
|
|
|
this.port.addEventListener('change', this.valueUpdated);
|
|
|
|
this.port.addEventListener('change', this.valueUpdated);
|
|
|
|
this.content.appendChild(this.port);
|
|
|
|
this.content.appendChild(this.port);
|
|
|
|
|
|
|
|
|
|
|
|
this.token.label = 'Plex Token';
|
|
|
|
this.token.label = 'Plex Token';
|
|
|
|
this.token.value = this.config.token;
|
|
|
|
setTextElementValue(this.token, this.token.value);
|
|
|
|
this.token.addEventListener('change', this.valueUpdated);
|
|
|
|
this.token.addEventListener('change', this.valueUpdated);
|
|
|
|
this.content.appendChild(this.token);
|
|
|
|
this.content.appendChild(this.token);
|
|
|
|
|
|
|
|
|
|
|
@ -565,12 +564,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
|
|
|
|
this.plexValidSection.appendChild(this.displayType);
|
|
|
|
this.plexValidSection.appendChild(this.displayType);
|
|
|
|
|
|
|
|
|
|
|
|
this.cardTitle.label = 'Card title (Optional)';
|
|
|
|
this.cardTitle.label = 'Card title (Optional)';
|
|
|
|
this.cardTitle.value = this.config.title;
|
|
|
|
setTextElementValue(this.cardTitle, this.config.title);
|
|
|
|
this.cardTitle.addEventListener('change', this.valueUpdated);
|
|
|
|
this.cardTitle.addEventListener('change', this.valueUpdated);
|
|
|
|
this.plexValidSection.appendChild(this.cardTitle);
|
|
|
|
this.plexValidSection.appendChild(this.cardTitle);
|
|
|
|
|
|
|
|
|
|
|
|
this.maxCount.label = 'Maximum number of items to display (Optional)';
|
|
|
|
this.maxCount.label = 'Maximum number of items to display (Optional)';
|
|
|
|
this.maxCount.value = this.config.maxCount;
|
|
|
|
setTextElementValue(this.maxCount, this.config.maxCount);
|
|
|
|
this.maxCount.type = 'number';
|
|
|
|
this.maxCount.type = 'number';
|
|
|
|
this.maxCount.addEventListener('change', this.valueUpdated);
|
|
|
|
this.maxCount.addEventListener('change', this.valueUpdated);
|
|
|
|
this.plexValidSection.appendChild(this.maxCount);
|
|
|
|
this.plexValidSection.appendChild(this.maxCount);
|
|
|
@ -590,7 +589,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
|
|
|
|
this.plexValidSection.appendChild(this.useHorizontalScroll);
|
|
|
|
this.plexValidSection.appendChild(this.useHorizontalScroll);
|
|
|
|
|
|
|
|
|
|
|
|
this.maxRows.label = 'Maximum number of rows to display (Optional)';
|
|
|
|
this.maxRows.label = 'Maximum number of rows to display (Optional)';
|
|
|
|
this.maxRows.value = this.config.maxRows;
|
|
|
|
setTextElementValue(this.maxRows, this.config.maxRows);
|
|
|
|
this.maxRows.type = 'number';
|
|
|
|
this.maxRows.type = 'number';
|
|
|
|
this.maxRows.addEventListener('change', this.valueUpdated);
|
|
|
|
this.maxRows.addEventListener('change', this.valueUpdated);
|
|
|
|
this.plexValidSection.appendChild(this.maxRows);
|
|
|
|
this.plexValidSection.appendChild(this.maxRows);
|
|
|
@ -678,7 +677,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
|
|
|
|
this.runBefore.style.width = '100%';
|
|
|
|
this.runBefore.style.width = '100%';
|
|
|
|
this.runBefore.style.height = '40px';
|
|
|
|
this.runBefore.style.height = '40px';
|
|
|
|
this.runBefore.addEventListener('change', this.valueUpdated);
|
|
|
|
this.runBefore.addEventListener('change', this.valueUpdated);
|
|
|
|
this.runBefore.value = this.config.runBefore;
|
|
|
|
setTextElementValue(this.runBefore, this.config.runBefore);
|
|
|
|
this.plexValidSection.appendChild(this.runBefore);
|
|
|
|
this.plexValidSection.appendChild(this.runBefore);
|
|
|
|
|
|
|
|
|
|
|
|
this.runAfter.innerHTML = '';
|
|
|
|
this.runAfter.innerHTML = '';
|
|
|
@ -690,7 +689,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
|
|
|
|
this.runAfter.style.width = '100%';
|
|
|
|
this.runAfter.style.width = '100%';
|
|
|
|
this.runAfter.style.height = '40px';
|
|
|
|
this.runAfter.style.height = '40px';
|
|
|
|
this.runAfter.addEventListener('change', this.valueUpdated);
|
|
|
|
this.runAfter.addEventListener('change', this.valueUpdated);
|
|
|
|
this.runAfter.value = this.config.runAfter;
|
|
|
|
setTextElementValue(this.runAfter, this.config.runAfter);
|
|
|
|
this.plexValidSection.appendChild(this.runAfter);
|
|
|
|
this.plexValidSection.appendChild(this.runAfter);
|
|
|
|
|
|
|
|
|
|
|
|
const styleTitle = document.createElement('h2');
|
|
|
|
const styleTitle = document.createElement('h2');
|
|
|
@ -701,25 +700,25 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
|
|
|
|
this.plexValidSection.appendChild(styleTitle);
|
|
|
|
this.plexValidSection.appendChild(styleTitle);
|
|
|
|
|
|
|
|
|
|
|
|
this.minWidth.label = 'Minimum width of the card (Optional)';
|
|
|
|
this.minWidth.label = 'Minimum width of the card (Optional)';
|
|
|
|
this.minWidth.value = this.config.minWidth;
|
|
|
|
setTextElementValue(this.minWidth, this.config.minWidth);
|
|
|
|
this.minWidth.type = 'number';
|
|
|
|
this.minWidth.type = 'number';
|
|
|
|
this.minWidth.addEventListener('change', this.valueUpdated);
|
|
|
|
this.minWidth.addEventListener('change', this.valueUpdated);
|
|
|
|
this.plexValidSection.appendChild(this.minWidth);
|
|
|
|
this.plexValidSection.appendChild(this.minWidth);
|
|
|
|
|
|
|
|
|
|
|
|
this.minExpandedWidth.label = 'Expanded width of the card (Optional)';
|
|
|
|
this.minExpandedWidth.label = 'Expanded width of the card (Optional)';
|
|
|
|
this.minExpandedWidth.value = this.config.minExpandedWidth;
|
|
|
|
setTextElementValue(this.minExpandedWidth, this.config.minExpandedWidth);
|
|
|
|
this.minExpandedWidth.type = 'number';
|
|
|
|
this.minExpandedWidth.type = 'number';
|
|
|
|
this.minExpandedWidth.addEventListener('change', this.valueUpdated);
|
|
|
|
this.minExpandedWidth.addEventListener('change', this.valueUpdated);
|
|
|
|
this.plexValidSection.appendChild(this.minExpandedWidth);
|
|
|
|
this.plexValidSection.appendChild(this.minExpandedWidth);
|
|
|
|
|
|
|
|
|
|
|
|
this.minExpandedHeight.label = 'Expanded height of the card (Optional)';
|
|
|
|
this.minExpandedHeight.label = 'Expanded height of the card (Optional)';
|
|
|
|
this.minExpandedHeight.value = this.config.minExpandedHeight;
|
|
|
|
setTextElementValue(this.minExpandedHeight, this.config.minExpandedHeight);
|
|
|
|
this.minExpandedHeight.type = 'number';
|
|
|
|
this.minExpandedHeight.type = 'number';
|
|
|
|
this.minExpandedHeight.addEventListener('change', this.valueUpdated);
|
|
|
|
this.minExpandedHeight.addEventListener('change', this.valueUpdated);
|
|
|
|
this.plexValidSection.appendChild(this.minExpandedHeight);
|
|
|
|
this.plexValidSection.appendChild(this.minExpandedHeight);
|
|
|
|
|
|
|
|
|
|
|
|
this.minEpisodeWidth.label = 'Minimum width of the episode card (Optional)';
|
|
|
|
this.minEpisodeWidth.label = 'Minimum width of the episode card (Optional)';
|
|
|
|
this.minEpisodeWidth.value = this.config.minEpisodeWidth;
|
|
|
|
setTextElementValue(this.minEpisodeWidth, this.config.minEpisodeWidth);
|
|
|
|
this.minEpisodeWidth.type = 'number';
|
|
|
|
this.minEpisodeWidth.type = 'number';
|
|
|
|
this.minEpisodeWidth.addEventListener('change', this.valueUpdated);
|
|
|
|
this.minEpisodeWidth.addEventListener('change', this.valueUpdated);
|
|
|
|
this.plexValidSection.appendChild(this.minEpisodeWidth);
|
|
|
|
this.plexValidSection.appendChild(this.minEpisodeWidth);
|
|
|
@ -734,12 +733,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
|
|
|
|
if (_.isEmpty(this.config.displayTitleMain)) {
|
|
|
|
if (_.isEmpty(this.config.displayTitleMain)) {
|
|
|
|
this.displayTitleMain.value = 'Yes';
|
|
|
|
this.displayTitleMain.value = 'Yes';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.displayTitleMain.value = this.config.displayTitleMain;
|
|
|
|
setTextElementValue(this.displayTitleMain, this.config.displayTitleMain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.plexValidSection.appendChild(this.displayTitleMain);
|
|
|
|
this.plexValidSection.appendChild(this.displayTitleMain);
|
|
|
|
|
|
|
|
|
|
|
|
this.fontSize1.label = 'Font size used in titles under cards (Optional)';
|
|
|
|
this.fontSize1.label = 'Font size used in titles under cards (Optional)';
|
|
|
|
this.fontSize1.value = this.config.fontSize1;
|
|
|
|
setTextElementValue(this.fontSize1, this.config.fontSize1);
|
|
|
|
this.fontSize1.type = 'number';
|
|
|
|
this.fontSize1.type = 'number';
|
|
|
|
this.fontSize1.addEventListener('change', this.valueUpdated);
|
|
|
|
this.fontSize1.addEventListener('change', this.valueUpdated);
|
|
|
|
this.plexValidSection.appendChild(this.fontSize1);
|
|
|
|
this.plexValidSection.appendChild(this.fontSize1);
|
|
|
@ -754,25 +753,25 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
|
|
|
|
if (_.isEmpty(this.config.displaySubtitleMain)) {
|
|
|
|
if (_.isEmpty(this.config.displaySubtitleMain)) {
|
|
|
|
this.displaySubtitleMain.value = 'Yes';
|
|
|
|
this.displaySubtitleMain.value = 'Yes';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.displaySubtitleMain.value = this.config.displaySubtitleMain;
|
|
|
|
setTextElementValue(this.displaySubtitleMain, this.config.displaySubtitleMain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.plexValidSection.appendChild(this.displaySubtitleMain);
|
|
|
|
this.plexValidSection.appendChild(this.displaySubtitleMain);
|
|
|
|
|
|
|
|
|
|
|
|
this.fontSize2.label = 'Font size used in sub-titles under cards (Optional)';
|
|
|
|
this.fontSize2.label = 'Font size used in sub-titles under cards (Optional)';
|
|
|
|
this.fontSize2.value = this.config.fontSize2;
|
|
|
|
setTextElementValue(this.fontSize2, this.config.fontSize2);
|
|
|
|
this.fontSize2.type = 'number';
|
|
|
|
this.fontSize2.type = 'number';
|
|
|
|
this.fontSize2.addEventListener('change', this.valueUpdated);
|
|
|
|
this.fontSize2.addEventListener('change', this.valueUpdated);
|
|
|
|
this.plexValidSection.appendChild(this.fontSize2);
|
|
|
|
this.plexValidSection.appendChild(this.fontSize2);
|
|
|
|
|
|
|
|
|
|
|
|
this.fontSize3.label = 'Font size used in title of the opened content (Optional)';
|
|
|
|
this.fontSize3.label = 'Font size used in title of the opened content (Optional)';
|
|
|
|
this.fontSize3.value = this.config.fontSize3;
|
|
|
|
setTextElementValue(this.fontSize3, this.config.fontSize3);
|
|
|
|
this.fontSize3.type = 'number';
|
|
|
|
this.fontSize3.type = 'number';
|
|
|
|
this.fontSize3.addEventListener('change', this.valueUpdated);
|
|
|
|
this.fontSize3.addEventListener('change', this.valueUpdated);
|
|
|
|
this.plexValidSection.appendChild(this.fontSize3);
|
|
|
|
this.plexValidSection.appendChild(this.fontSize3);
|
|
|
|
|
|
|
|
|
|
|
|
this.fontSize4.label =
|
|
|
|
this.fontSize4.label =
|
|
|
|
'Font size used in sub-titles, to-view count and description of the opened content (Optional)';
|
|
|
|
'Font size used in sub-titles, to-view count and description of the opened content (Optional)';
|
|
|
|
this.fontSize4.value = this.config.fontSize4;
|
|
|
|
setTextElementValue(this.fontSize4, this.config.fontSize4);
|
|
|
|
this.fontSize4.type = 'number';
|
|
|
|
this.fontSize4.type = 'number';
|
|
|
|
this.fontSize4.addEventListener('change', this.valueUpdated);
|
|
|
|
this.fontSize4.addEventListener('change', this.valueUpdated);
|
|
|
|
this.plexValidSection.appendChild(this.fontSize4);
|
|
|
|
this.plexValidSection.appendChild(this.fontSize4);
|
|
|
|