From 0a2d122c3d09a8257795953faef1821c72386980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Tue, 31 Aug 2021 18:35:02 +0200 Subject: [PATCH] Add: Title option to UI editor --- dist/plex-meets-homeassistant.js | 14 ++++++++++++++ src/editor.ts | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 006669f..e0dea04 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19571,6 +19571,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.token = document.createElement('paper-input'); this.port = document.createElement('paper-input'); this.maxCount = document.createElement('paper-input'); + this.cardTitle = document.createElement('paper-input'); this.libraryName = document.createElement('paper-dropdown-menu'); this.protocol = document.createElement('paper-dropdown-menu'); this.tabs = document.createElement('paper-tabs'); @@ -19635,6 +19636,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { else { this.config.maxCount = this.maxCount.value; } + if (lodash.isEmpty(this.cardTitle.value)) { + this.config.title = ''; + } + else { + this.config.title = this.cardTitle.value; + } if (!lodash.isEmpty(this.entities)) { this.config.entity = []; lodash.forEach(this.entities, entity => { @@ -19880,6 +19887,10 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { viewTitle.style.marginBottom = '0px'; viewTitle.style.marginTop = '20px'; this.plexValidSection.appendChild(viewTitle); + this.cardTitle.label = 'Card title'; + this.cardTitle.value = this.config.title; + this.cardTitle.addEventListener('change', this.valueUpdated); + this.plexValidSection.appendChild(this.cardTitle); this.maxCount.label = 'Maximum number of items to display'; this.maxCount.value = this.config.maxCount; this.maxCount.type = 'number'; @@ -20127,6 +20138,9 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { if (!lodash.isNil(config.runAfter)) { this.config.runAfter = config.runAfter; } + if (!lodash.isNil(config.title)) { + this.config.title = config.title; + } if (lodash.isNumber(this.config.maxCount)) { this.config.maxCount = `${this.config.maxCount}`; } diff --git a/src/editor.ts b/src/editor.ts index ceb1ae9..23b855d 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -24,6 +24,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { maxCount: any = document.createElement('paper-input'); + cardTitle: any = document.createElement('paper-input'); + libraryName: any = document.createElement('paper-dropdown-menu'); protocol: any = document.createElement('paper-dropdown-menu'); @@ -117,6 +119,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.config.maxCount = this.maxCount.value; } + if (_.isEmpty(this.cardTitle.value)) { + this.config.title = ''; + } else { + this.config.title = this.cardTitle.value; + } + if (!_.isEmpty(this.entities)) { this.config.entity = []; _.forEach(this.entities, entity => { @@ -374,6 +382,11 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { viewTitle.style.marginTop = '20px'; this.plexValidSection.appendChild(viewTitle); + this.cardTitle.label = 'Card title'; + this.cardTitle.value = this.config.title; + this.cardTitle.addEventListener('change', this.valueUpdated); + this.plexValidSection.appendChild(this.cardTitle); + this.maxCount.label = 'Maximum number of items to display'; this.maxCount.value = this.config.maxCount; this.maxCount.type = 'number'; @@ -629,6 +642,10 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.config.runAfter = config.runAfter; } + if (!_.isNil(config.title)) { + this.config.title = config.title; + } + if (_.isNumber(this.config.maxCount)) { this.config.maxCount = `${this.config.maxCount}`; }