From 4dda13c2dc8528ad7033b659050689509dd17dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Wed, 1 Sep 2021 01:02:10 +0200 Subject: [PATCH] Add: Live tv into editor UI --- dist/plex-meets-homeassistant.js | 8 ++++++++ src/editor.ts | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 2ff3a0f..7f2711b 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19646,6 +19646,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.entitiesRegistry = false; this.plexValidSection = document.createElement('div'); this.loaded = false; + this.livetv = {}; this.fireEvent = (node, type, detail, options = {}) => { // eslint-disable-next-line no-param-reassign detail = detail === null || detail === undefined ? {} : detail; @@ -19859,6 +19860,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.appendChild(this.content); this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort); this.sections = await this.plex.getSections(); + this.livetv = await this.plex.getLiveTV(); this.collections = await this.plex.getCollections(); this.playlists = await this.plex.getPlaylists(); this.clients = await this.plex.getClients(); @@ -20068,6 +20070,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.runAfter.addEventListener('value-changed', this.valueUpdated); this.runAfter.value = this.config.runAfter; this.plexValidSection.appendChild(this.runAfter); + if (!lodash.isEmpty(this.livetv)) { + libraryItems.appendChild(addDropdownItem('Live TV', true)); + lodash.forEach(lodash.keys(this.livetv), (livetv) => { + libraryItems.appendChild(addDropdownItem(livetv)); + }); + } if (!lodash.isEmpty(this.sections)) { libraryItems.appendChild(addDropdownItem('Libraries', true)); lodash.forEach(this.sections, (section) => { diff --git a/src/editor.ts b/src/editor.ts index b25f844..3ff32ad 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -72,6 +72,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { loaded = false; + livetv: Record = {}; + fireEvent = ( node: HTMLElement, type: string, @@ -300,6 +302,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort); this.sections = await this.plex.getSections(); + this.livetv = await this.plex.getLiveTV(); this.collections = await this.plex.getCollections(); this.playlists = await this.plex.getPlaylists(); this.clients = await this.plex.getClients(); @@ -519,6 +522,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.runAfter.value = this.config.runAfter; this.plexValidSection.appendChild(this.runAfter); + if (!_.isEmpty(this.livetv)) { + libraryItems.appendChild(addDropdownItem('Live TV', true)); + _.forEach(_.keys(this.livetv), (livetv: string) => { + libraryItems.appendChild(addDropdownItem(livetv)); + }); + } if (!_.isEmpty(this.sections)) { libraryItems.appendChild(addDropdownItem('Libraries', true)); _.forEach(this.sections, (section: Record) => {