Selaa lähdekoodia

Merge pull request #1 from causefx/v2-develop

Updates
Rob Gökemeijer 8 vuotta sitten
vanhempi
commit
d3e8853263

+ 18 - 1
api/config/default.php

@@ -31,6 +31,22 @@ return array(
     'ssoPlex' => false,
     'ssoOmbi' => false,
     'ssoTautulli' => false,
+	'sabnzbdURL' => '',
+    'sabnzbdToken' => '',
+    'nzbgetURL' => '',
+    'nzbgetUsername' => '',
+    'nzbgetPassword' => '',
+	'transmissionURL' => '',
+    'transmissionUsername' => '',
+    'transmissionPassword' => '',
+    'transmissionHideSeeding' => false,
+    'transmissionHideCompleted' => false,
+    'homepageSabnzbdEnabled' => false,
+    'homepageSabnzbdAuth' => '1',
+    'homepageTransmissionEnabled' => false,
+    'homepageTransmissionAuth' => '1',
+    'homepageNzbgetEnabled' => false,
+    'homepageNzbgetAuth' => '1',
     'homepagePlexEnabled' => false,
     'homepagePlexAuth' => '1',
     'homepageEmbyEnabled' => false,
@@ -49,11 +65,12 @@ return array(
 	'homepageOrderombi' => '12',
 	'homepageOrdercalendar' => '13',
 	'homepageOrdernoticeguest' => '14',
-	'homepageOrdertransmisson' => '15',
+	'homepageOrdertransmission' => '15',
     'homepageShowStreamNames' => false,
     'homepageShowStreamNamesAuth' => '1',
     'homepageStreamRefresh' => '60000',
     'homepageRecentRefresh' => '60000',
+    'homepageDownloadRefresh' => '60000',
     'homepagePlexStreams' => false,
     'homepagePlexStreamsAuth' => '1',
     'homepagePlexRecent' => false,

+ 175 - 27
api/functions/homepage-functions.php

@@ -16,7 +16,7 @@ function homepageOrder(){
 		"homepageOrderombi" => $GLOBALS['homepageOrderombi'],
 		"homepageOrdercalendar" => $GLOBALS['homepageOrdercalendar'],
 		"homepageOrdernoticeguest" => $GLOBALS['homepageOrdernoticeguest'],
-		"homepageOrdertransmisson" => $GLOBALS['homepageOrdertransmisson'],
+		"homepageOrdertransmission" => $GLOBALS['homepageOrdertransmission'],
 	);
 	asort($homepageOrder);
 	return $homepageOrder;
@@ -47,14 +47,47 @@ function buildHomepageItem($homepageItem){
 		case 'homepageOrderspeedtest':
 
 			break;
-		case 'homepageOrdertransmisson':
-
+		case 'homepageOrdertransmission':
+			if($GLOBALS['homepageTransmissionEnabled']){
+				$item .= '
+				<script>
+				// Transmission
+				homepageDownloader("transmission");
+				setInterval(function() {
+					homepageDownloader("transmission");
+				}, '.$GLOBALS['homepageDownloadRefresh'].');
+				// End Transmission
+				</script>
+				';
+			}
 			break;
 		case 'homepageOrdernzbget':
-
+			if($GLOBALS['homepageNzbgetEnabled']){
+				$item .= '
+				<script>
+				// NZBGet
+				homepageDownloader("nzbget");
+				setInterval(function() {
+					homepageDownloader("nzbget");
+				}, '.$GLOBALS['homepageDownloadRefresh'].');
+				// End NZBGet
+				</script>
+				';
+			}
 			break;
 		case 'homepageOrdersabnzbd':
-
+			if($GLOBALS['homepageSabnzbdEnabled']){
+				$item .= '
+				<script>
+				// SabNZBd
+				homepageDownloader("sabnzbd");
+				setInterval(function() {
+					homepageDownloader("sabnzbd");
+				}, '.$GLOBALS['homepageDownloadRefresh'].');
+				// End SabNZBd
+				</script>
+				';
+			}
 			break;
 		case 'homepageOrderplexnowplaying':
 			if($GLOBALS['homepagePlexStreams']){
@@ -397,52 +430,167 @@ function getHomepageList(){
             )
         ),
         array(
-            'name' => 'Sonarr',
+            'name' => 'SabNZBD',
             'enabled' => false,
-            'image' => 'plugins/images/tabs/sonarr.png',
-            'category' => 'PVR',
+            'image' => 'plugins/images/tabs/sabnzbd.png',
+            'category' => 'Downloader',
             'settings' => array(
                 'Enable' => array(
                     array(
             			'type' => 'switch',
-            			'name' => 'homepagePlexEnabled',
+            			'name' => 'homepageSabnzbdEnabled',
             			'label' => 'Enable',
-            			'value' => $GLOBALS['homepagePlexEnabled']
+            			'value' => $GLOBALS['homepageSabnzbdEnabled']
+            		),
+					array(
+            			'type' => 'select',
+            			'name' => 'homepageSabnzbdAuth',
+            			'label' => 'Minimum Authentication',
+            			'value' => $GLOBALS['homepageSabnzbdAuth'],
+                        'options' => $groups
             		)
                 ),
-                'Connection' => array(
+				'Connection' => array(
                     array(
                         'type' => 'input',
-                        'name' => 'plexURL',
+                        'name' => 'sabnzbdURL',
                         'label' => 'URL',
-                        'value' => $GLOBALS['plexURL']
+                        'value' => $GLOBALS['sabnzbdURL'],
+						'placeholder' => 'http(s)://hostname:port'
                     ),
                     array(
                         'type' => 'input',
-                        'name' => 'plexToken',
+                        'name' => 'sabnzbdToken',
                         'label' => 'Token',
-                        'value' => $GLOBALS['plexToken']
+                        'value' => $GLOBALS['sabnzbdToken']
                     )
                 ),
-                'Authentication' => array(
+				'Misc Options' => array(
+					array(
+						'type' => 'select',
+						'name' => 'homepageDownloadRefresh',
+						'label' => 'Refresh Seconds',
+						'value' => $GLOBALS['homepageDownloadRefresh'],
+						'options' => $time
+					)
+				)
+            )
+        ),
+		array(
+            'name' => 'NZBGet',
+            'enabled' => false,
+            'image' => 'plugins/images/tabs/nzbget.png',
+            'category' => 'Downloader',
+            'settings' => array(
+                'Enable' => array(
                     array(
+            			'type' => 'switch',
+            			'name' => 'homepageNzbgetEnabled',
+            			'label' => 'Enable',
+            			'value' => $GLOBALS['homepageNzbgetEnabled']
+            		),
+					array(
             			'type' => 'select',
-            			'name' => 'homepagePlexAuth',
+            			'name' => 'homepageNzbgetAuth',
             			'label' => 'Minimum Authentication',
-            			'value' => $GLOBALS['homepagePlexAuth'],
+            			'value' => $GLOBALS['homepageNzbgetAuth'],
                         'options' => $groups
             		)
                 ),
-                'Options' => array(
+				'Connection' => array(
                     array(
-    					'type' => 'select',
-    					'name' => 'style',
-    					'label' => 'Style',
-    					'class' => 'styleChanger',
-    					'value' => $GLOBALS['style'],
-    					'options' => $groups
-    				)
-                )
+                        'type' => 'input',
+                        'name' => 'nzbgetURL',
+                        'label' => 'URL',
+                        'value' => $GLOBALS['nzbgetURL'],
+						'placeholder' => 'http(s)://hostname:port'
+                    ),
+                    array(
+                        'type' => 'input',
+                        'name' => 'nzbgetUsername',
+                        'label' => 'Username',
+                        'value' => $GLOBALS['nzbgetUsername']
+                    ),
+					array(
+                        'type' => 'password',
+                        'name' => 'nzbgetPassword',
+                        'label' => 'Password',
+                        'value' => $GLOBALS['nzbgetPassword']
+                    )
+                ),
+				'Misc Options' => array(
+					array(
+						'type' => 'select',
+						'name' => 'homepageDownloadRefresh',
+						'label' => 'Refresh Seconds',
+						'value' => $GLOBALS['homepageDownloadRefresh'],
+						'options' => $time
+					)
+				)
+            )
+        ),
+		array(
+            'name' => 'Transmission',
+            'enabled' => false,
+            'image' => 'plugins/images/tabs/transmission.png',
+            'category' => 'Downloader',
+            'settings' => array(
+                'Enable' => array(
+                    array(
+            			'type' => 'switch',
+            			'name' => 'homepageTransmissionEnabled',
+            			'label' => 'Enable',
+            			'value' => $GLOBALS['homepageTransmissionEnabled']
+            		),
+					array(
+            			'type' => 'select',
+            			'name' => 'homepageTransmissionAuth',
+            			'label' => 'Minimum Authentication',
+            			'value' => $GLOBALS['homepageTransmissionAuth'],
+                        'options' => $groups
+            		)
+                ),
+				'Connection' => array(
+                    array(
+                        'type' => 'input',
+                        'name' => 'transmissionURL',
+                        'label' => 'URL',
+                        'value' => $GLOBALS['transmissionURL'],
+						'placeholder' => 'http(s)://hostname:port'
+                    ),
+                    array(
+                        'type' => 'input',
+                        'name' => 'transmissionUsername',
+                        'label' => 'Username',
+                        'value' => $GLOBALS['transmissionUsername']
+                    ),
+					array(
+                        'type' => 'password',
+                        'name' => 'transmissionPassword',
+                        'label' => 'Password',
+                        'value' => $GLOBALS['transmissionPassword']
+                    )
+                ),
+				'Misc Options' => array(
+					array(
+            			'type' => 'switch',
+            			'name' => 'transmissionHideSeeding',
+            			'label' => 'Hide Seeding',
+            			'value' => $GLOBALS['transmissionHideSeeding']
+            		),array(
+            			'type' => 'switch',
+            			'name' => 'transmissionHideCompleted',
+            			'label' => 'Hide Completed',
+            			'value' => $GLOBALS['transmissionHideCompleted']
+            		),
+					array(
+						'type' => 'select',
+						'name' => 'homepageDownloadRefresh',
+						'label' => 'Refresh Seconds',
+						'value' => $GLOBALS['homepageDownloadRefresh'],
+						'options' => $time
+					)
+				)
             )
         )
     );

+ 9 - 2
api/functions/normal-functions.php

@@ -111,6 +111,7 @@ function encrypt($password, $key = null) {
     return openssl_encrypt($password, 'AES-256-CBC', $key, 0, fillString($key,16));
 }
 function decrypt($password, $key = null) {
+	if(empty($password)){ return ''; }
     $key = (isset($GLOBALS['organizrHash'])) ? $GLOBALS['organizrHash'] : $key;
     return openssl_decrypt($password, 'AES-256-CBC', $key, 0, fillString($key,16));
 }
@@ -263,7 +264,7 @@ function array_filter_key(array $array, $callback){
 	return array_intersect_key($array, array_flip($matchedKeys));
 }
 // Qualify URL
-function qualifyURL($url) {
+function qualifyURL($url, $return=false) {
 	//local address?
 	if(substr($url, 0,1) == "/"){
 		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
@@ -292,7 +293,13 @@ function qualifyURL($url) {
 	// Path
 	$path = (isset($digest['path']) && $digest['path'] !== '/'?$digest['path']:'');
 	// Output
-	return $scheme.'://'.$host.$port.$path;
+	$array = array(
+		'scheme' => $scheme,
+		'host' => $host,
+		'port' => $port,
+		'path' => $path
+	);
+	return ($return) ? $array : $scheme.'://'.$host.$port.$path;
 }
 function getServerPath() {
 	if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){

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

@@ -754,6 +754,59 @@ function getImage() {
 		die("Invalid Request");
 	}
 }
+function downloader($array){
+	switch ($array['data']['source']) {
+        case 'sabnzbd':
+			switch ($array['data']['action']) {
+                case 'resume':
+                case 'pause':
+                    sabnzbdAction($array['data']['action'],$array['data']['target']);
+                    break;
+
+                default:
+                    # code...
+                    break;
+            }
+            break;
+		case 'nzbget':
+
+			break;
+        default:
+            # code...
+            break;
+    }
+}
+function sabnzbdAction($action=null, $target=null) {
+    if($GLOBALS['homepageSabnzbdEnabled'] && !empty($GLOBALS['sabnzbdURL']) && !empty($GLOBALS['sabnzbdToken']) && qualifyRequest($GLOBALS['homepageSabnzbdAuth'])){
+        $url = qualifyURL($GLOBALS['sabnzbdURL']);
+        switch ($action) {
+            case 'pause':
+                $id = ($target !== '' && $target !== 'main' && isset($target)) ? 'mode=queue&name=pause&value='.$target.'&' : 'mode=pause';
+                $url = $url.'/api?'.$id.'&output=json&apikey='.$GLOBALS['sabnzbdToken'];
+                break;
+            case 'resume':
+                $id = ($target !== '' && $target !== 'main' && isset($target)) ? 'mode=queue&name=resume&value='.$target.'&' : 'mode=resume';
+                $url = $url.'/api?'.$id.'&output=json&apikey='.$GLOBALS['sabnzbdToken'];
+                break;
+            default:
+                # code...
+                break;
+        }
+
+        try{
+			$options = (localURL($url)) ? array('verify' => false ) : array();
+			$response = Requests::get($url, array(), $options);
+			if($response->success){
+				$api['content'] = json_decode($response->body, true);
+			}
+		}catch( Requests_Exception $e ) {
+			writeLog('error', 'SabNZBd Connect Function - Error: '.$e->getMessage(), 'SYSTEM');
+		};
+        $api['content'] = isset($api['content']) ? $api['content'] : false;
+        return $api;
+    }
+}
+
 /*
 function sendEmail($email = null, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null){
 	try {

+ 1 - 1
api/functions/static-globals.php

@@ -2,7 +2,7 @@
 
 // ===================================
 // Organizr Version
-$GLOBALS['installedVersion'] = '2.0.0-alpha.130';
+$GLOBALS['installedVersion'] = '2.0.0-alpha.250';
 // ===================================
 // Set GLOBALS from config file
 $GLOBALS['userConfigPath'] = dirname(__DIR__,1).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php';

+ 13 - 0
api/index.php

@@ -815,6 +815,19 @@ switch ($function) {
                 break;
         }
         break;
+	case 'v1_downloader':
+		switch ($method) {
+			case 'POST':
+                $result['status'] = 'success';
+                $result['statusText'] = 'success';
+                $result['data'] = downloader($_POST);
+				break;
+			default:
+				$result['status'] = 'error';
+				$result['statusText'] = 'The function requested is not defined for method: '.$method;
+				break;
+		}
+		break;
     default:
         //No Function Available
         $result['status'] = 'error';

+ 2 - 2
api/pages/settings-tab-editor-tabs.php

@@ -17,7 +17,7 @@ $( \'#tabEditorTable\' ).sortable({
 <div class="panel bg-org panel-info">
     <div class="panel-heading">
         <span lang="en">Tab Editor</span>
-        <button type="button" class="btn btn-success btn-circle pull-right popup-with-form m-r-5" href="#new-tab-form" data-effect="mfp-3d-unfold"><i class="fa fa-plus"></i> </button>
+        <button type="button" class="btn btn-info btn-circle pull-right popup-with-form m-r-5" href="#new-tab-form" data-effect="mfp-3d-unfold"><i class="fa fa-plus"></i> </button>
     </div>
     <div class="table-responsive">
         <form id="submit-tabs-form" onsubmit="return false;">
@@ -77,7 +77,7 @@ $( \'#tabEditorTable\' ).sortable({
             <input type="text" class="form-control" id="edit-tab-form-inputImage" name="tabImage"  required="">
         </div>
     </fieldset>
-    <button class="btn btn-sm btn-info btn-rounded waves-effect waves-light pull-right row b-none editTab" type="button"><span class="btn-label"><i class="fa fa-plus"></i></span><span lang="en">Edit Group</span></button>
+    <button class="btn btn-sm btn-info btn-rounded waves-effect waves-light pull-right row b-none editTab" type="button"><span class="btn-label"><i class="fa fa-check"></i></span><span lang="en">Edit Tab</span></button>
     <div class="clearfix"></div>
 </form>
 ';

+ 27 - 0
css/organizr.css

@@ -153,6 +153,7 @@ object-fit: contain;
   bottom: 0px;
   background: rgba(31, 31, 31, 0.73);
   width: inherit;
+  color: white;
 }
 .nowPlayingHover{
   margin-bottom: 14px;
@@ -178,6 +179,7 @@ object-fit: contain;
 h2.m-b-0.font-medium.pull-right {
   -webkit-filter: drop-shadow(1px 1px 0px #1f1f1f);
   filter: drop-shadow(1px 1px 0px #1f1f1f);
+  color: white;
 }
 .text-plex {
   color: #E5A00D;
@@ -209,3 +211,28 @@ h2.m-b-0.font-medium.pull-right {
   overflow: hidden;
   filter: blur(0px) grayscale(1)
 }
+.mailbox-widget .customtab li.active a, .mailbox-widget .customtab li.active, .mailbox-widget .customtab li.active a:focus {
+    background: 0 0;
+    color: #fff;
+    border-color: #53e69d;
+}
+.nav-tabs.pull-right>li>a:hover {
+    background: transparent;
+    border-radius: 0px;
+}
+.homepageImageTitle {
+  height: 40px;
+  margin-top: -7px;
+}
+.grayscale {
+  -webkit-filter: grayscale(100%); /* Safari 6.0 - 9.0 */
+  filter: grayscale(100%);
+}
+td span.label.label-info {
+  min-width: 80px !important;
+  display: inline-block !important;
+}
+.inbox-center.table-responsive {
+max-height: 300px;
+overflow-y: auto;
+}

+ 28 - 7
js/custom.js

@@ -309,12 +309,14 @@ function pageLoad(){
         size: "6px",
         color: 'rgba(0,0,0,0.5)'
     });
-    $('.chat-list').slimScroll({
-        height: '100%',
-        position: 'right',
-        size: "0px",
-        color: '#dcdcdc'
-    });
+    if(bowser.mobile !== true){
+        $('.inbox-center').slimScroll({
+            height: '100%',
+            position: 'right',
+            size: "5px",
+            color: '#dcdcdc'
+        });
+    }
     /* ===== Resize all elements ===== */
 
 
@@ -462,7 +464,7 @@ function pageLoad(){
     $('.inline-popups').magnificPopup({
       removalDelay: 500, //delay removal by X to allow out-animation
       closeOnBgClick: true,
-      closeOnContentClick: true,
+      //closeOnContentClick: true,
       callbacks: {
         beforeOpen: function() {
            this.st.mainClass = this.st.el.attr('data-effect');
@@ -1630,6 +1632,25 @@ $(document).on("click", ".metadata-get", function(e) {
 	});
 	ajaxloader();
 
+});
+// sad play/resume
+$(document).on("click", ".downloader", function(e) {
+    var action = $(this).attr('data-action');
+    var source = $(this).attr('data-source');
+    var target = $(this).attr('data-target');
+    console.log(action);
+    console.log(source);
+    console.log(target);
+    ajaxloader(".content-wrap","in");
+	organizrAPI('POST','api/?v1/downloader',{action:action, source:source, target:target}).success(function(data) {
+		var response = JSON.parse(data);
+        console.log(response);
+		homepageDownloader(source);
+	}).fail(function(xhr) {
+		console.error("Organizr Function: API Connection Failed");
+	});
+	ajaxloader();
+
 });
 /* ===== Open-Close Right Sidebar ===== */
 

+ 14 - 0
js/version.json

@@ -40,5 +40,19 @@
         "new": "Plugin Framework nearly complete|Added Mail Plugin",
         "fixed": "",
         "notes": "This is alpha - expect bugs|Please report bugs in GitHub issues page"
+    },
+	"2.0.0-alpha.200": {
+        "date":"2018-02-04 21:00",
+        "title": "Homepage Work Started",
+        "new": "Plex Streams on homepage|Plex Recent Added on homepage|Emby Streams on homepage|Emby Recent Added on homepage|SabNZBd on homepage",
+        "fixed": "Multiple things for performace",
+        "notes": "This is alpha - expect bugs|Please report bugs in GitHub issues page"
+    },
+	"2.0.0-alpha.250": {
+        "date":"2018-02-05 21:00",
+        "title": "NZBGet Homepage",
+        "new": "NZBGet on homepage - please check for bugs",
+        "fixed": "",
+        "notes": "This is alpha - expect bugs|Please report bugs in GitHub issues page"
     }
 }

BIN
plugins/images/tabs/nzbget.png