Browse Source

fix deluge hide seed/completed

causefx 8 years ago
parent
commit
aae3aee1b9
3 changed files with 54 additions and 3 deletions
  1. 20 3
      api/functions/homepage-connect-functions.php
  2. 33 0
      api/functions/organizr-functions.php
  3. 1 0
      js/custom.js

+ 20 - 3
api/functions/homepage-connect-functions.php

@@ -773,11 +773,28 @@ function qBittorrentConnect()
 }
 function delugeConnect()
 {
-    if ($GLOBALS['homepageDelugeEnabled'] && !empty($GLOBALS['delugeURL']) && qualifyRequest($GLOBALS['homepageDelugeAuth'])) {
+    if ($GLOBALS['homepageDelugeEnabled'] && !empty($GLOBALS['delugeURL']) && !empty($GLOBALS['delugePassword']) && qualifyRequest($GLOBALS['homepageDelugeAuth'])) {
         try {
             $deluge = new deluge($GLOBALS['delugeURL'], decrypt($GLOBALS['delugePassword']));
-            $torrents = $deluge->getTorrents(null, 'comment, download_payload_rate, eta, is_finished, is_seed, message, name, paused, progress, queue, state, total_size, upload_payload_rate');
-            $api['content']['queueItems'] = $torrents;
+            $torrents = $deluge->getTorrents(null, 'comment, download_payload_rate, eta, hash, is_finished, is_seed, message, name, paused, progress, queue, state, total_size, upload_payload_rate');
+	        if ($GLOBALS['delugeHideSeeding'] || $GLOBALS['delugeHideCompleted']) {
+		        $filter = array();
+		        if ($GLOBALS['delugeHideSeeding']) {
+			        array_push($filter, 'Seeding', 'Uploading', 'queuedUP');
+		        }
+		        if ($GLOBALS['delugeHideCompleted']) {
+			        array_push($filter, 'Seeding', 'Completed');
+		        }
+		        //prettyPrint($torrents);
+		        foreach ($torrents as $key => $value) {
+			        if (!in_array($value->state, $filter)) {
+				        $api['content']['queueItems'][] = $value;
+			        }
+		        }
+	        } else {
+		        $api['content']['queueItems'] = $torrents;
+	        }
+            //$api['content']['queueItems'] = $torrents;
             $api['content']['historyItems'] = false;
         } catch (Excecption $e) {
             writeLog('error', 'Deluge Connect Function - Error: '.$e->getMessage(), 'SYSTEM');

+ 33 - 0
api/functions/organizr-functions.php

@@ -1092,6 +1092,39 @@ function sabnzbdAction($action=null, $target=null)
         return $api;
     }
 }
+// Deluge API isn't working ATM - will get with dev.
+function delugeAction($action=null, $target=null)
+{
+	if ($GLOBALS['homepageDelugeEnabled'] && !empty($GLOBALS['delugeURL']) && !empty($GLOBALS['delugePassword']) && qualifyRequest($GLOBALS['homepageDelugeAuth'])) {
+		$url = qualifyURL($GLOBALS['delugeURL']);
+		try {
+			$deluge = new deluge($GLOBALS['delugeURL'], decrypt($GLOBALS['delugePassword']));
+			switch ($action) {
+				case 'pause':
+					$torrents = $deluge->pauseTorrent($target);
+					break;
+				case 'pauseAll':
+					$torrents = $deluge->pauseAllTorrents();
+					break;
+				case 'resume':
+					$torrents = $deluge->resumeTorrent($target);
+					break;
+				case 'resumeAll':
+					$torrents = $deluge->resumeAllTorrents();
+					break;
+				default:
+					# code...
+					break;
+			}
+			$api['content'] = $torrents;
+		} catch (Excecption $e) {
+			writeLog('error', 'Deluge Connect Function - Error: '.$e->getMessage(), 'SYSTEM');
+		}
+		$api['content'] = isset($api['content']) ? $api['content'] : false;
+		return $api;
+	}
+	return false;
+}
 function getOrgUsers()
 {
     $result = allUsers();

+ 1 - 0
js/custom.js

@@ -966,6 +966,7 @@ $(document).on('focusout', 'input.pick-a-color', function(e) {
 });
 $(document).on('change colorPicker::close', '#customize-appearance-form :input', function(e) {
     $(this).attr('data-changed', true);
+    //$(this).addClass('has-success');
     switch ($(this).attr('type')) {
         case 'switch':
         case 'checkbox':