فهرست منبع

Added toggle to use friendly name in stats

Henry Whitaker 5 سال پیش
والد
کامیت
f1e8c6b7ff
3فایلهای تغییر یافته به همراه22 افزوده شده و 8 حذف شده
  1. 1 0
      api/config/default.php
  2. 13 5
      api/homepage/tautulli.php
  3. 8 3
      js/functions.js

+ 1 - 0
api/config/default.php

@@ -341,6 +341,7 @@ return array(
 	'tautulliPopularTV' => true,
 	'tautulliHeader' => 'Tautulli',
 	'tautulliHeaderToggle' => true,
+	'tautulliFriendlyName' => true,
 	'homepagePiholeEnabled' => false,
 	'homepagePiholeAuth' => '1',
 	'homepagePiholeRefresh' => '10000',

+ 13 - 5
api/homepage/tautulli.php

@@ -139,6 +139,13 @@ trait TautulliHomepageItem
 						'value' => $this->config['homepageTautulliMiscAuth'],
 						'options' => $this->groupOptions
 					),
+					array(
+						'type' => 'switch',
+						'name' => 'tautulliFriendlyName',
+						'label' => 'Use Friendly Name',
+						'value' => $this->config['tautulliFriendlyName'],
+						'help' => 'Use the friendly name set in tautulli for users.',
+					),
 				),
 				'Test Connection' => array(
 					array(
@@ -157,7 +164,7 @@ trait TautulliHomepageItem
 			)
 		);
 	}
-	
+
 	public function testConnectionTautulli()
 	{
 		if (empty($this->config['tautulliURL'])) {
@@ -186,7 +193,7 @@ trait TautulliHomepageItem
 			return false;
 		}
 	}
-	
+
 	public function tautulliHomepagePermissions($key = null)
 	{
 		$permissions = [
@@ -211,7 +218,7 @@ trait TautulliHomepageItem
 			return [];
 		}
 	}
-	
+
 	public function homepageOrdertautulli()
 	{
 		if ($this->homepageItemPermissions($this->tautulliHomepagePermissions('main'))) {
@@ -227,7 +234,7 @@ trait TautulliHomepageItem
 				';
 		}
 	}
-	
+
 	public function getTautulliHomepageData()
 	{
 		if (!$this->homepageItemPermissions($this->tautulliHomepagePermissions('main'), true)) {
@@ -283,6 +290,7 @@ trait TautulliHomepageItem
 				'popularMovies' => $this->config['tautulliPopularMovies'],
 				'popularTV' => $this->config['tautulliPopularTV'],
 				'title' => $this->config['tautulliHeaderToggle'],
+				'friendlyName' => $this->config['tautulliFriendlyName'],
 			];
 			$ids = []; // Array of stat_ids to remove from the returned array
 			if (!$this->qualifyRequest($this->config['homepageTautulliLibraryAuth'])) {
@@ -319,4 +327,4 @@ trait TautulliHomepageItem
 		$this->setAPIResponse('success', null, 200, $api);
 		return $api;
 	}
-}
+}

+ 8 - 3
js/functions.js

@@ -6936,6 +6936,7 @@ function buildTautulliItem(array){
     var homestats = array.homestats.data;
     var libstats = array.libstats;
     var options = array.options;
+    var friendlyName = array.options.friendlyName;
     var buildLibraries = function(data){
         var libs = data.data;
         var movies = [];
@@ -7026,7 +7027,7 @@ function buildTautulliItem(array){
         card += (audio.length > 0) ? buildCard('artist', audio) : '';
         return card;
     };
-    var buildStats = function(data, stat){
+    var buildStats = function(data, stat, friendlyName = true){
         var card = '';
         data.forEach(e => {
             let classes = '';
@@ -7074,7 +7075,11 @@ function buildTautulliItem(array){
                                             var rowNameValue = '';
                                             var rowValue = '';
                                             if(stat == 'top_users') {
-                                                rowNameValue = item['user'];
+                                                if(friendlyName) {
+                                                    rowNameValue = item['friendly_name'];
+                                                } else {
+                                                    rowNameValue = item['user'];
+                                                }
                                                 rowValue = item['total_plays'];
                                             } else if(stat == 'top_platforms') {
                                                 rowNameValue = item['platform'];
@@ -7112,7 +7117,7 @@ function buildTautulliItem(array){
     cards += (options['popularTV']) ? buildStats(homestats, 'popular_tv') : '';
     cards += (options['topMovies']) ? buildStats(homestats, 'top_movies') : '';
     cards += (options['topTV']) ? buildStats(homestats, 'top_tv') : '';
-    cards += (options['topUsers']) ? buildStats(homestats, 'top_users') : '';
+    cards += (options['topUsers']) ? buildStats(homestats, 'top_users', friendlyName) : '';
     cards += (options['topPlatforms']) ? buildStats(homestats, 'top_platforms') : '';
     cards += '</div>';
     cards += '<div class="row tautulliLibraries">'