From 7d918fa53c3ef19307df5159235b79540bc7c822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Sat, 10 Jul 2021 23:07:13 +0200 Subject: [PATCH] no message --- dist/plex-meets-homeassistant.js | 30 +++++++++++++++++++++++++++++- src/editor.ts | 30 +++++++++++++++++++++++++++++- src/plex-meets-homeassistant.ts | 1 + 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index f97a39a..e28b562 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19453,6 +19453,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.port = document.createElement('paper-input'); this.maxCount = document.createElement('paper-input'); this.libraryName = document.createElement('paper-dropdown-menu'); + this.protocol = document.createElement('paper-dropdown-menu'); this.tabs = document.createElement('paper-tabs'); this.devicesTabs = 0; this.entities = []; @@ -19473,10 +19474,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { }; this.valueUpdated = () => { if (!lodash.isEmpty(this.libraryName.value)) { + const originalConfig = lodash.clone(this.config); this.config.ip = this.ip.value; this.config.token = this.token.value; this.config.port = this.port.value; this.config.libraryName = this.libraryName.value; + this.config.protocol = this.protocol.value; if (lodash.isEmpty(this.maxCount.value)) { 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 () => { @@ -19536,6 +19544,22 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { plexTitle.style.margin = '0px'; plexTitle.style.padding = '0px'; 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.value = this.config.ip; this.ip.addEventListener('change', this.valueUpdated); @@ -19629,6 +19653,9 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { if (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.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.data = {}; + this.error = ''; this.renderInitialData(); }; this.getCardSize = () => { diff --git a/src/editor.ts b/src/editor.ts index 622d44c..4812109 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -26,6 +26,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { libraryName: any = document.createElement('paper-dropdown-menu'); + protocol: any = document.createElement('paper-dropdown-menu'); + tabs: any = document.createElement('paper-tabs'); devicesTabs = 0; @@ -60,10 +62,13 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { valueUpdated = (): void => { if (!_.isEmpty(this.libraryName.value)) { + const originalConfig = _.clone(this.config); this.config.ip = this.ip.value; this.config.token = this.token.value; this.config.port = this.port.value; this.config.libraryName = this.libraryName.value; + + this.config.protocol = this.protocol.value; if (_.isEmpty(this.maxCount.value)) { this.config.maxCount = ''; } 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'; 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.value = this.config.ip; this.ip.addEventListener('change', this.valueUpdated); @@ -232,6 +258,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { if (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); diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 6b87299..3f9726a 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -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.data = {}; + this.error = ''; this.renderInitialData(); };