From fbc7890247b8460b09565c75b259714216a7894e Mon Sep 17 00:00:00 2001 From: cmatute7712 <130001712+cmatute7712@users.noreply.github.com> Date: Sat, 1 Jun 2024 12:54:12 -0700 Subject: [PATCH] Imeplements multi selector for library type for Emby/Jellyfin. Allows for multiselect using array style notation in yaml. Also updated docs to reflect change Fixes #681 --- docs/customservices.md | 4 +++- src/components/services/Emby.vue | 35 ++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/docs/customservices.md b/docs/customservices.md index fbd25d32c..6bb99f51c 100644 --- a/docs/customservices.md +++ b/docs/customservices.md @@ -203,7 +203,9 @@ You need to set the type to Emby, provide an api key and choose which stats to s url: "http://192.168.0.151/" type: "Emby" apikey: "<---insert-api-key-here--->" - libraryType: "music" #Choose which stats to show. Can be one of: music, series or movies. + libraryType: #Choose which stats to show. Can be of value: "music", "series" or "movies". + - "music" + - "movies" ``` ## Uptime Kuma diff --git a/src/components/services/Emby.vue b/src/components/services/Emby.vue index d2411f067..8f6a2d807 100644 --- a/src/components/services/Emby.vue +++ b/src/components/services/Emby.vue @@ -40,15 +40,34 @@ export default { seriesCount: 0, episodeCount: 0, }), - computed: { + computed: { embyCount: function () { - if (this.item.libraryType === "music") - return `${this.songCount} songs, ${this.albumCount} albums`; - else if (this.item.libraryType === "movies") - return `${this.movieCount} movies`; - else if (this.item.libraryType === "series") - return `${this.episodeCount} eps, ${this.seriesCount} series`; - else return `wrong library type 💀`; + const libraryType = this.item.libraryType; + const counts = []; + + libraryType.forEach((type, index) => { + if (type === "music") { + counts.push(`${this.songCount} songs`); + counts.push(`${this.albumCount} albums`); + } else if (type === "movies") { + counts.push(`${this.movieCount} movies`); + } else if (type === "series") { + counts.push(`${this.episodeCount} episodes`); + counts.push(`${this.seriesCount} series`); + } else { + return `wrong library type 💀`; + } + }); + + const allowedParams = this.item.embyCountParams || ""; + const params = allowedParams.split(",").map((param) => param.trim()); + + const filteredCounts = counts.filter((count, index) => { + const countType = count.split(" ")[1]; + return params.some((param) => countType.includes(param)); + }); + + return filteredCounts.join(", "); }, }, created() {