Răsfoiți Sursa

Grab monitorr icons in Org

Should allow viewing icons outside of LAN when not using RP url
Henry Whitaker 6 ani în urmă
părinte
comite
e38bb1b3e7
2 a modificat fișierele cu 17 adăugiri și 2 ștergeri
  1. 16 1
      api/functions/homepage-connect-functions.php
  2. 1 1
      js/functions.js

+ 16 - 1
api/functions/homepage-connect-functions.php

@@ -2572,7 +2572,22 @@ function getMonitorr()
 							$image = $match;
 						}
 					}
-					$statuses[$service]['image'] = $url . '/assets' . $image;
+					$ext = explode('.', $image);
+					$ext = $ext[key(array_slice($ext, -1, 1, true))];
+
+					$imageUrl = $url . '/assets' . $image;
+
+					$cacheDirectory = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;
+					$cacheImage = $cacheDirectory . 'monitorr-' . $image;
+
+					$img = Requests::get($imageUrl, [ 'Token' => $GLOBALS['organizrAPI'] ], []);
+					if($img->success) {
+						$base64 = 'data:image/' . $ext . ';base64,' . base64_encode($img->body);
+						// $statuses[$service]['image'] = '/plugins/images/cache/monitorr-' . $service . '.' . $ext;
+						$statuses[$service]['image'] = $base64;
+					} else {
+						$statuses[$service]['image'] = $cacheDirectory . 'no-list.png';
+					}
 				}
 
 				ksort($statuses);

+ 1 - 1
js/functions.js

@@ -6752,7 +6752,7 @@ function buildMonitorrItem(array){
 
     .monitorr-card img {
         max-height: 100px;
-        max-width: 100%;]
+        max-width: 100%;
     }
 
     .monitorr-card .indicator {