Răsfoiți Sursa

Merge pull request #1342 from henrywhitaker3/homepage-item-titles

Added toggle to display title on Pi-hole and Tautulli homepage items
causefx 6 ani în urmă
părinte
comite
87037aa4db

+ 2 - 0
api/config/default.php

@@ -280,9 +280,11 @@ return array(
 	'tautulliPopularMovies' => true,
 	'tautulliPopularTV' => true,
 	'tautulliHeader' => 'Tautulli',
+	'tautulliHeaderToggle' => true,
 	'homepagePiholeEnabled' => false,
 	'homepagePiholeAuth' => '1',
 	'homepagePiholeRefresh' => '10000',
 	'homepagePiholeCombine' => false,
+	'piholeHeaderToggle' => true,
 	'piholeURL' => ''
 );

+ 2 - 0
api/functions/homepage-connect-functions.php

@@ -137,6 +137,7 @@ function getPihole()
 			};
 		}
 		$api['options']['combine'] = $GLOBALS['homepagePiholeCombine'];
+		$api['options']['title'] = $GLOBALS['piholeHeaderToggle'];
 		$api = isset($api) ? $api : false;
 		return $api;
 	}
@@ -2473,6 +2474,7 @@ function getTautulli()
 				'topPlatforms' => $GLOBALS['tautulliTopPlatforms'],
 				'popularMovies' => $GLOBALS['tautulliPopularMovies'],
 				'popularTV' => $GLOBALS['tautulliPopularTV'],
+				'title' => $GLOBALS['tautulliHeaderToggle'],
 			];
 			$ids = []; // Array of stat_ids to remove from the returned array
 			if (!qualifyRequest($GLOBALS['homepageTautulliLibraryAuth'])) {

+ 14 - 0
api/functions/homepage-functions.php

@@ -2546,6 +2546,13 @@ function getHomepageList()
 					),
 				),
 				'Misc' => array(
+					array(
+						'type' => 'switch',
+						'name' => 'piholeHeaderToggle',
+						'label' => 'Toggle Title',
+						'value' => $GLOBALS['piholeHeaderToggle'],
+						'help' => 'Shows/hides the title of this homepage module'
+					),
 					array(
 						'type' => 'switch',
 						'name' => 'homepagePiholeCombine',
@@ -2584,6 +2591,13 @@ function getHomepageList()
 						'label' => 'Title',
 						'value' => $GLOBALS['tautulliHeader'],
 						'help' => 'Sets the title of this homepage module'
+					),
+					array(
+						'type' => 'switch',
+						'name' => 'tautulliHeaderToggle',
+						'label' => 'Toggle Title',
+						'value' => $GLOBALS['tautulliHeaderToggle'],
+						'help' => 'Shows/hides the title of this homepage module'
 					)
 				),
 				'Connection' => array(

+ 28 - 16
js/functions.js

@@ -5680,20 +5680,26 @@ function buildHealthChecks(array){
 }
 function buildPihole(array){
     if(array === false){ return ''; }
-    return (array) ? `
+    var html = `
     <div id="allPihole">
-		<div class="el-element-overlay row">
-		    <div class="col-md-12">
-		        <h4 class="pull-left homepage-element-title"><span lang="en">Pi-hole</span> : </h4><h4 class="pull-left">&nbsp;</h4>
-		        <hr class="hidden-xs ml-2">
-		    </div>
-			<div class="clearfix"></div>
+        <div class="el-element-overlay row">`;
+    if(array['options']['title']) {
+        html += `
+            <div class="col-md-12">
+                <h4 class="pull-left homepage-element-title"><span lang="en">Pi-hole</span> : </h4><h4 class="pull-left">&nbsp;</h4>
+                <hr class="hidden-xs ml-2">
+            </div>
+            <div class="clearfix"></div>
+        `;
+    }
+    html += `
 		    <div class="piholeCards col-sm-12 my-3">
 			    `+buildPiholeItem(array)+`
 			</div>
 		</div>
 	</div>
-    ` : 'hello';
+    `;
+    return (array) ? html : '';
 }
 function buildUnifi(array){
     if(array === false){ return ''; }
@@ -6653,20 +6659,26 @@ function buildTautulliItem(array){
 }
 function buildTautulli(array){
     if(array === false){ return ''; }
-    return (array) ? `
+    var html = `
     <div id="allTautulli">
-		<div class="el-element-overlay row">
-		    <div class="col-md-12">
-		        <h4 class="pull-left homepage-element-title"><span>`+activeInfo.settings.homepage.options.titles.tautulli+`</span> : </h4><h4 class="pull-left">&nbsp;</h4>
-		        <hr class="hidden-xs ml-2">
-		    </div>
-			<div class="clearfix"></div>
+		<div class="el-element-overlay row">`
+    if(array['options']['title']) {
+        html += `
+            <div class="col-md-12">
+                <h4 class="pull-left homepage-element-title"><span>`+activeInfo.settings.homepage.options.titles.tautulli+`</span> : </h4><h4 class="pull-left">&nbsp;</h4>
+                <hr class="hidden-xs ml-2">
+            </div>
+            <div class="clearfix"></div>
+        `;
+    }
+    html += `
             <div class="tautulliCards col-sm-12 my-3">
                 `+buildTautulliItem(array)+`
 			</div>
 		</div>
 	</div>
-    ` : '';
+    `;
+    return (array) ? html : '';
 }
 function homepageTautulli(timeout){
     var timeout = (typeof timeout !== 'undefined') ? timeout : activeInfo.settings.homepage.refresh.homepageTautulliRefresh;