2.0
Juraj Nyíri 3 years ago
parent a59dcb845f
commit a7c8ba1916

@ -19451,6 +19451,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.ip = document.createElement('paper-input');
this.token = document.createElement('paper-input');
this.port = document.createElement('paper-input');
this.maxCount = document.createElement('paper-input');
this.libraryName = document.createElement('paper-dropdown-menu');
this.tabs = document.createElement('paper-tabs');
this.devicesTabs = 0;
@ -19476,6 +19477,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.config.token = this.token.value;
this.config.port = this.port.value;
this.config.libraryName = this.libraryName.value;
if (lodash.isEmpty(this.maxCount.value)) {
this.config.maxCount = '';
}
else {
this.config.maxCount = parseInt(this.maxCount.value, 10);
}
if (!lodash.isEmpty(this.entities)) {
this.config.entity = [];
lodash.forEach(this.entities, entity => {
@ -19542,6 +19549,11 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.port.type = 'number';
this.port.addEventListener('change', this.valueUpdated);
this.content.appendChild(this.port);
this.maxCount.label = 'Maximum number of items to display';
this.maxCount.value = this.config.maxCount;
this.maxCount.type = 'number';
this.maxCount.addEventListener('change', this.valueUpdated);
this.content.appendChild(this.maxCount);
this.libraryName.innerHTML = '';
const libraryItems = document.createElement('paper-listbox');
libraryItems.appendChild(addDropdownItem('Continue Watching'));
@ -20376,6 +20388,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.maxCount = false;
this.error = '';
this.contentBGHeight = 0;
this.initialDataLoaded = false;
this.renderNewElementsIfNeeded = () => {
const loadAdditionalRowsCount = 2; // todo: make this configurable
const height = getHeight(this.content);
@ -20453,8 +20466,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.card) {
this.previousPageWidth = this.card.offsetWidth;
}
this.renderInitialData();
this.resizeBackground();
this.initialDataLoaded = true;
};
this.renderInitialData = async () => {
let { entity } = JSON.parse(JSON.stringify(this.config));
@ -21595,7 +21608,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
return playButton;
};
this.setConfig = (config) => {
console.log('setConfig from main');
this.plexProtocol = 'http';
if (!config.entity || config.entity.length === 0) {
throw new Error('You need to define at least one entity');
@ -21632,7 +21644,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (config.port) {
this.plexPort = config.port;
}
if (config.maxCount) {
if (config.maxCount && config.maxCount !== '') {
this.maxCount = config.maxCount;
}
if (config.runBefore) {
@ -21657,11 +21669,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
}
set hass(hass) {
this.hassObj = hass;
if (!this.content) {
this.error = '';
if (!this.loading) {
this.loadInitialData();
}
if (!this.initialDataLoaded) {
this.loadInitialData();
}
}
static getConfigElement() {

@ -22,6 +22,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
port: any = document.createElement('paper-input');
maxCount: any = document.createElement('paper-input');
libraryName: any = document.createElement('paper-dropdown-menu');
tabs: any = document.createElement('paper-tabs');
@ -62,6 +64,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.config.token = this.token.value;
this.config.port = this.port.value;
this.config.libraryName = this.libraryName.value;
if (_.isEmpty(this.maxCount.value)) {
this.config.maxCount = '';
} else {
this.config.maxCount = parseInt(this.maxCount.value, 10);
}
if (!_.isEmpty(this.entities)) {
this.config.entity = [];
_.forEach(this.entities, entity => {
@ -137,6 +145,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.port.addEventListener('change', this.valueUpdated);
this.content.appendChild(this.port);
this.maxCount.label = 'Maximum number of items to display';
this.maxCount.value = this.config.maxCount;
this.maxCount.type = 'number';
this.maxCount.addEventListener('change', this.valueUpdated);
this.content.appendChild(this.maxCount);
this.libraryName.innerHTML = '';
const libraryItems: any = document.createElement('paper-listbox');
libraryItems.appendChild(addDropdownItem('Continue Watching'));

@ -125,14 +125,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
card: HTMLElement | undefined;
initialDataLoaded = false;
set hass(hass: HomeAssistant) {
this.hassObj = hass;
if (!this.content) {
this.error = '';
if (!this.loading) {
this.loadInitialData();
}
if (!this.initialDataLoaded) {
this.loadInitialData();
}
}
@ -224,8 +223,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.card) {
this.previousPageWidth = this.card.offsetWidth;
}
this.renderInitialData();
this.resizeBackground();
this.initialDataLoaded = true;
};
renderInitialData = async (): Promise<void> => {
@ -1490,7 +1489,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
};
setConfig = (config: any): void => {
console.log('setConfig from main');
this.plexProtocol = 'http';
if (!config.entity || config.entity.length === 0) {
throw new Error('You need to define at least one entity');
@ -1526,7 +1524,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (config.port) {
this.plexPort = config.port;
}
if (config.maxCount) {
if (config.maxCount && config.maxCount !== '') {
this.maxCount = config.maxCount;
}
if (config.runBefore) {

Loading…
Cancel
Save