2.0
Juraj Nyíri 3 years ago
parent a7c8ba1916
commit 7d918fa53c

@ -19453,6 +19453,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.port = document.createElement('paper-input'); this.port = document.createElement('paper-input');
this.maxCount = document.createElement('paper-input'); this.maxCount = document.createElement('paper-input');
this.libraryName = document.createElement('paper-dropdown-menu'); this.libraryName = document.createElement('paper-dropdown-menu');
this.protocol = document.createElement('paper-dropdown-menu');
this.tabs = document.createElement('paper-tabs'); this.tabs = document.createElement('paper-tabs');
this.devicesTabs = 0; this.devicesTabs = 0;
this.entities = []; this.entities = [];
@ -19473,10 +19474,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
}; };
this.valueUpdated = () => { this.valueUpdated = () => {
if (!lodash.isEmpty(this.libraryName.value)) { if (!lodash.isEmpty(this.libraryName.value)) {
const originalConfig = lodash.clone(this.config);
this.config.ip = this.ip.value; this.config.ip = this.ip.value;
this.config.token = this.token.value; this.config.token = this.token.value;
this.config.port = this.port.value; this.config.port = this.port.value;
this.config.libraryName = this.libraryName.value; this.config.libraryName = this.libraryName.value;
this.config.protocol = this.protocol.value;
if (lodash.isEmpty(this.maxCount.value)) { if (lodash.isEmpty(this.maxCount.value)) {
this.config.maxCount = ''; this.config.maxCount = '';
} }
@ -19491,7 +19494,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
} }
}); });
} }
this.fireEvent(this, 'config-changed', { config: this.config }); if (!lodash.isEqual(this.config, originalConfig)) {
console.log(this.config);
console.log(originalConfig);
console.log('event');
this.fireEvent(this, 'config-changed', { config: this.config });
}
} }
}; };
this.render = async () => { this.render = async () => {
@ -19536,6 +19544,22 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
plexTitle.style.margin = '0px'; plexTitle.style.margin = '0px';
plexTitle.style.padding = '0px'; plexTitle.style.padding = '0px';
this.content.appendChild(plexTitle); this.content.appendChild(plexTitle);
this.protocol.innerHTML = '';
const protocolItems = document.createElement('paper-listbox');
protocolItems.appendChild(addDropdownItem('http'));
protocolItems.appendChild(addDropdownItem('https'));
protocolItems.slot = 'dropdown-content';
this.protocol.label = 'Plex Protocol';
this.protocol.appendChild(protocolItems);
this.protocol.style.width = '100%';
this.protocol.addEventListener('value-changed', this.valueUpdated);
if (lodash.isEmpty(this.config.protocol)) {
this.protocol.value = 'http';
}
else {
this.protocol.value = this.config.protocol;
}
this.content.appendChild(this.protocol);
this.ip.label = 'Plex IP Address'; this.ip.label = 'Plex IP Address';
this.ip.value = this.config.ip; this.ip.value = this.config.ip;
this.ip.addEventListener('change', this.valueUpdated); this.ip.addEventListener('change', this.valueUpdated);
@ -19629,6 +19653,9 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
if (config.protocol) { if (config.protocol) {
this.plexProtocol = config.protocol; this.plexProtocol = config.protocol;
} }
else {
this.config.protocol = 'http';
}
this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort); this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort);
this.render(); this.render();
}; };
@ -21661,6 +21688,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort); this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort);
this.data = {}; this.data = {};
this.error = '';
this.renderInitialData(); this.renderInitialData();
}; };
this.getCardSize = () => { this.getCardSize = () => {

@ -26,6 +26,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
libraryName: any = document.createElement('paper-dropdown-menu'); libraryName: any = document.createElement('paper-dropdown-menu');
protocol: any = document.createElement('paper-dropdown-menu');
tabs: any = document.createElement('paper-tabs'); tabs: any = document.createElement('paper-tabs');
devicesTabs = 0; devicesTabs = 0;
@ -60,10 +62,13 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
valueUpdated = (): void => { valueUpdated = (): void => {
if (!_.isEmpty(this.libraryName.value)) { if (!_.isEmpty(this.libraryName.value)) {
const originalConfig = _.clone(this.config);
this.config.ip = this.ip.value; this.config.ip = this.ip.value;
this.config.token = this.token.value; this.config.token = this.token.value;
this.config.port = this.port.value; this.config.port = this.port.value;
this.config.libraryName = this.libraryName.value; this.config.libraryName = this.libraryName.value;
this.config.protocol = this.protocol.value;
if (_.isEmpty(this.maxCount.value)) { if (_.isEmpty(this.maxCount.value)) {
this.config.maxCount = ''; this.config.maxCount = '';
} else { } else {
@ -78,7 +83,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
} }
}); });
} }
this.fireEvent(this, 'config-changed', { config: this.config }); if (!_.isEqual(this.config, originalConfig)) {
console.log(this.config);
console.log(originalConfig);
console.log('event');
this.fireEvent(this, 'config-changed', { config: this.config });
}
} }
}; };
@ -129,6 +139,22 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
plexTitle.style.padding = '0px'; plexTitle.style.padding = '0px';
this.content.appendChild(plexTitle); this.content.appendChild(plexTitle);
this.protocol.innerHTML = '';
const protocolItems: any = document.createElement('paper-listbox');
protocolItems.appendChild(addDropdownItem('http'));
protocolItems.appendChild(addDropdownItem('https'));
protocolItems.slot = 'dropdown-content';
this.protocol.label = 'Plex Protocol';
this.protocol.appendChild(protocolItems);
this.protocol.style.width = '100%';
this.protocol.addEventListener('value-changed', this.valueUpdated);
if (_.isEmpty(this.config.protocol)) {
this.protocol.value = 'http';
} else {
this.protocol.value = this.config.protocol;
}
this.content.appendChild(this.protocol);
this.ip.label = 'Plex IP Address'; this.ip.label = 'Plex IP Address';
this.ip.value = this.config.ip; this.ip.value = this.config.ip;
this.ip.addEventListener('change', this.valueUpdated); this.ip.addEventListener('change', this.valueUpdated);
@ -232,6 +258,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
if (config.protocol) { if (config.protocol) {
this.plexProtocol = config.protocol; this.plexProtocol = config.protocol;
} else {
this.config.protocol = 'http';
} }
this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort); this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort);

@ -1542,6 +1542,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort); this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort);
this.data = {}; this.data = {};
this.error = '';
this.renderInitialData(); this.renderInitialData();
}; };

Loading…
Cancel
Save