causefx 8 лет назад
Родитель
Сommit
ad96129044
4 измененных файлов с 67 добавлено и 22 удалено
  1. 2 2
      api/config/default.php
  2. 22 19
      api/functions/organizr-functions.php
  3. 4 0
      js/custom.js
  4. 39 1
      js/functions.js

+ 2 - 2
api/config/default.php

@@ -4,8 +4,6 @@ return array(
 	'authType' => 'internal',
     'authBackend' => '',
 	'authBackendHost' => '',
-	'authUsername' => '',
-	'authPassword' => '',
 	'authBaseDN' => '',
 	'authBackendDomain' => '',
     'logo' => 'plugins/images/organizr/logo-wide.png',
@@ -19,6 +17,8 @@ return array(
     'style'=>'dark',
     'plexURL' => '',
     'plexToken' => '',
+    'embyURL' => '',
+    'embyToken' => '',
     'plexID' => '',
     'tautulliURL' => '',
     'ombiURL' => '',

+ 22 - 19
api/functions/organizr-functions.php

@@ -155,6 +155,7 @@ function getSettingsMain(){
 		array(
 			'type' => 'select',
 			'name' => 'authType',
+            'id' => 'authSelect',
 			'label' => 'Authentication Type',
 			'value' => $GLOBALS['authType'],
 			'options' => getAuthTypes()
@@ -162,14 +163,16 @@ function getSettingsMain(){
         array(
 			'type' => 'select',
 			'name' => 'authBackend',
+            'id' => 'authBackendSelect',
 			'label' => 'Authentication Backend',
+            'class' => 'backendAuth switchAuth',
 			'value' => $GLOBALS['authBackend'],
 			'options' => getAuthBackends()
 		),
         array(
 			'type' => 'input',
 			'name' => 'plexToken',
-            'class' => 'plexAuth',
+            'class' => 'plexAuth switchAuth',
 			'label' => 'Plex Token',
 			'value' => $GLOBALS['plexToken'],
 			'placeholder' => 'Use Get Token Button'
@@ -177,7 +180,7 @@ function getSettingsMain(){
 		array(
 			'type' => 'button',
 			'label' => 'Get Plex Token',
-			'class' => 'popup-with-form getPlexTokenAuth plexAuth',
+			'class' => 'popup-with-form getPlexTokenAuth plexAuth switchAuth',
 			'icon' => 'fa fa-paper-plane',
 			'text' => 'Retrieve',
 			'href' => '#auth-plex-token-form',
@@ -186,7 +189,7 @@ function getSettingsMain(){
 		array(
 			'type' => 'input',
 			'name' => 'plexID',
-            'class' => 'plexAuth',
+            'class' => 'plexAuth switchAuth',
 			'label' => 'Plex Machine',
 			'value' => $GLOBALS['plexID'],
 			'placeholder' => 'Use Get Plex Machine Button'
@@ -194,7 +197,7 @@ function getSettingsMain(){
 		array(
 			'type' => 'button',
 			'label' => 'Get Plex Machine',
-			'class' => 'popup-with-form getPlexMachineAuth plexAuth',
+			'class' => 'popup-with-form getPlexMachineAuth plexAuth switchAuth',
 			'icon' => 'fa fa-paper-plane',
 			'text' => 'Retrieve',
 			'href' => '#auth-plex-machine-form',
@@ -203,35 +206,35 @@ function getSettingsMain(){
         array(
 			'type' => 'input',
 			'name' => 'authBackendHost',
-            'class' => 'temp',
+            'class' => 'ldapAuth ftpAuth switchAuth',
 			'label' => 'Host Address',
 			'value' => $GLOBALS['authBackendHost'],
-			'placeholder' => 'http{s) | ftp(s) | ldap(s) ://hostname:port'
+			'placeholder' => 'http{s) | ftp(s) | ldap(s)://hostname:port'
 		),
         array(
 			'type' => 'input',
 			'name' => 'authBaseDN',
-            'class' => 'temp',
+            'class' => 'ldapAuth switchAuth',
 			'label' => 'Host Base DN',
 			'value' => $GLOBALS['authBaseDN'],
 			'placeholder' => 'cn=%s,dc=sub,dc=domain,dc=com'
 		),
         array(
 			'type' => 'input',
-			'name' => 'authUsername',
-            'class' => 'temp',
-			'label' => 'Host Username',
-			'value' => $GLOBALS['authUsername'],
-			'placeholder' => 'Username if required'
+			'name' => 'embyURL',
+            'class' => 'embyAuth switchAuth',
+			'label' => 'Emby URL',
+			'value' => $GLOBALS['embyURL'],
+			'placeholder' => ''
 		),
         array(
-			'type' => 'password',
-			'name' => 'authPassword',
-            'class' => 'temp',
-			'label' => 'Host Password',
-			'value' => $GLOBALS['authPassword'],
-			'placeholder' => 'Password if required'
-		),
+			'type' => 'input',
+			'name' => 'embyToken',
+            'class' => 'embyAuth switchAuth',
+			'label' => 'Emby Token',
+			'value' => $GLOBALS['embyToken'],
+			'placeholder' => ''
+		)
 		/*array(
 			'type' => 'button',
 			'label' => 'Send Test',

+ 4 - 0
js/custom.js

@@ -1157,6 +1157,10 @@ $(document).on('change asColorPicker::close', '#settings-main-form :input', func
         2000
     );
 });
+// AUTH BACKEND HIDE SHOW
+$(document).on('change', '#authSelect, #authBackendSelect', function(e) {
+    changeAuth();
+});
 $(document).on("click", ".getSSOPlexToken", function () {
     $('.ssoPlexTokenMessage').text("Grabbing Token");
     $('.ssoPlexTokenHeader').addClass('panel-info').removeClass('panel-warning').removeClass('panel-danger');

+ 39 - 1
js/functions.js

@@ -498,7 +498,7 @@ function selectOptions(options, active){
 }
 function buildFormItem(item){
 	var placeholder = (item.placeholder) ? ' placeholder="'+item.placeholder+'"' : '';
-	var id = (item.id) ? ' id="'+item.placeholder+'"' : '';
+	var id = (item.id) ? ' id="'+item.id+'"' : '';
 	var type = (item.type) ? ' data-type="'+item.type+'"' : '';
 	var value = (item.value) ? ' value="'+item.value+'"' : '';
 	var name = (item.name) ? ' name="'+item.name+'"' : '';
@@ -796,6 +796,7 @@ function buildSettingsMain(){
 		var response = JSON.parse(data);
 		console.log(response)
 		$('#settings-main-form').html(buildSettingsMainItem(response.data));
+		changeAuth();
 		;
 	}).fail(function(xhr) {
 		console.error("Organizr Function: API Connection Failed");
@@ -1818,6 +1819,43 @@ function generateCode() {
         code += possible.charAt(Math.floor(Math.random() * possible.length));
     return code;
 }
+//Settings change auth
+function changeAuth(){
+    var type = $('#authSelect').val();
+    var service = $('#authBackendSelect').val();
+    switch (service) {
+        case 'plex':
+            $('.switchAuth').parent().parent().parent().hide();
+            $('.backendAuth').parent().parent().parent().show();
+            $('.plexAuth').parent().parent().parent().show();
+            console.log(service);
+            break;
+        case 'emby_local':
+        case 'emby2':
+        case 'emby3':
+            $('.switchAuth').parent().parent().parent().hide();
+            $('.backendAuth').parent().parent().parent().show();
+            $('.embyAuth').parent().parent().parent().show();
+            console.log(service);
+            break;
+        case 'ftp':
+            $('.switchAuth').parent().parent().parent().hide();
+            $('.backendAuth').parent().parent().parent().show();
+            $('.ftpAuth').parent().parent().parent().show();
+            console.log(service);
+            break;
+        case 'ldap':
+            $('.switchAuth').parent().parent().parent().hide();
+            $('.backendAuth').parent().parent().parent().show();
+            $('.ldapAuth').parent().parent().parent().show();
+            console.log(service);
+            break;
+        default:
+            $('.switchAuth').parent().parent().parent().hide();
+            $('.backendAuth').parent().parent().parent().show();
+    }
+    if(type == 'internal') { $('.switchAuth').parent().parent().parent().hide(); }
+}
 function launch(){
 	organizrConnect('api/?v1/launch_organizr').success(function (data) {
 		var json = JSON.parse(data);