Răsfoiți Sursa

small fixes

causefx 8 ani în urmă
părinte
comite
ab4a24c36d

+ 33 - 32
api/functions/homepage-connect-functions.php

@@ -554,41 +554,42 @@ function transmissionConnect() {
 			$options = (localURL($GLOBALS['transmissionURL'])) ? array('verify' => false ) : array();
 			$response = Requests::get($url, array(), $options);
 			if($response->headers['x-transmission-session-id']){
-				$session_id = $response->headers['x-transmission-session-id'];
-			}
-            $headers = array(
-        		'X-Transmission-Session-Id' => $session_id,
-        		'Content-Type' => 'application/json'
-        	);
-        	$data = array(
-        		'method' => 'torrent-get',
-        		'arguments' => array(
-        			'fields' => array(
-        				"id", "name", "totalSize", "eta", "isFinished", "isStalled", "percentDone", "rateDownload", "status", "downloadDir","errorString"
-        			),
-        		),
-        		'tags' => ''
-        	);
-            $response = Requests::post($url, $headers, json_encode($data), $options);
-            if($response->success){
-                $torrentList = json_decode($response->body, true)['arguments']['torrents'];
-                if($GLOBALS['transmissionHideSeeding'] || $GLOBALS['transmissionHideCompleted']){
-                    $filter = array();
-                    $torrents['arguments']['torrents'] = array();
-                    if($GLOBALS['transmissionHideSeeding']){ array_push($filter, 6, 5); }
-                    if($GLOBALS['transmissionHideCompleted']){ array_push($filter, 0); }
-                    foreach ($torrentList as $key => $value) {
-                        if(!in_array($value['status'], $filter)){
-                            $torrents['arguments']['torrents'][] = $value;
+                $headers = array(
+            		'X-Transmission-Session-Id' => $response->headers['x-transmission-session-id'],
+            		'Content-Type' => 'application/json'
+            	);
+            	$data = array(
+            		'method' => 'torrent-get',
+            		'arguments' => array(
+            			'fields' => array(
+            				"id", "name", "totalSize", "eta", "isFinished", "isStalled", "percentDone", "rateDownload", "status", "downloadDir","errorString"
+            			),
+            		),
+            		'tags' => ''
+            	);
+                $response = Requests::post($url, $headers, json_encode($data), $options);
+                if($response->success){
+                    $torrentList = json_decode($response->body, true)['arguments']['torrents'];
+                    if($GLOBALS['transmissionHideSeeding'] || $GLOBALS['transmissionHideCompleted']){
+                        $filter = array();
+                        $torrents['arguments']['torrents'] = array();
+                        if($GLOBALS['transmissionHideSeeding']){ array_push($filter, 6, 5); }
+                        if($GLOBALS['transmissionHideCompleted']){ array_push($filter, 0); }
+                        foreach ($torrentList as $key => $value) {
+                            if(!in_array($value['status'], $filter)){
+                                $torrents['arguments']['torrents'][] = $value;
+                            }
                         }
+                    }else{
+                        $torrents = json_decode($response->body, true);
                     }
-                }else{
-                    $torrents = json_decode($response->body, true);
-                }
 
-				$api['content']['queueItems'] = $torrents;
-                $api['content']['historyItems'] = false;
-			}
+    				$api['content']['queueItems'] = $torrents;
+                    $api['content']['historyItems'] = false;
+    			}
+			}else{
+                writeLog('error', 'Transmission Connect Function - Error: Could not get session ID', 'SYSTEM');
+            }
 		}catch( Requests_Exception $e ) {
 			writeLog('error', 'Transmission Connect Function - Error: '.$e->getMessage(), 'SYSTEM');
 		};

+ 3 - 1
api/pages/settings-settings-logs.php

@@ -10,10 +10,12 @@ $(document).on("click", ".swapLog", function(e) {
 	$(this).addClass(\'active\');
 });
 </script>
-<div class="btn-group m-b-20">
+<div class="btn-group m-b-20 pull-left">
     <button type="button" class="btn btn-default btn-outline waves-effect bg-org swapLog active" data-name="loginLog" lang="en">Login Log</button>
     <button type="button" class="btn btn-default btn-outline waves-effect bg-org swapLog" data-name="orgLog" lang="en">Organizr Log</button>
 </div>
+<button class="btn btn-danger btn-sm waves-effect waves-light pull-right purgeLog" type="button"><span class="btn-label"><i class="fa fa-trash"></i></span>Purge Log</button>
+<div class="clearfix"></div>
 <div class="white-box bg-org logTable loginLogDiv">
     <h3 class="box-title m-b-0" lang="en">Login Logs</h3>
     <div class="table-responsive">

+ 5 - 0
js/custom.js

@@ -1651,6 +1651,11 @@ $(document).on("click", ".downloader", function(e) {
 	});
 	ajaxloader();
 
+});
+// purge log
+$(document).on("click", ".purgeLog", function () {
+var log = $('.swapLog.active').attr('data-name');
+alert('This action is not set yet - but this would have purged the '+log+' log');
 });
 /* ===== Open-Close Right Sidebar ===== */