wizardTabAdvanced.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. /**
  2. * Copyright (c) 2015, Arthur Schiwon <blizzz@owncloud.com>
  3. * This file is licensed under the Affero General Public License version 3 or later.
  4. * See the COPYING-README file.
  5. */
  6. OCA = OCA || {};
  7. (function() {
  8. /**
  9. * @classdesc This class represents the view belonging to the advanced tab
  10. * in the LDAP wizard.
  11. */
  12. var WizardTabAdvanced = OCA.LDAP.Wizard.WizardTabGeneric.subClass({
  13. /**
  14. * initializes the instance. Always call it after initialization.
  15. *
  16. * @param {any} tabIndex -
  17. * @param {any} tabID -
  18. */
  19. init: function (tabIndex, tabID) {
  20. this._super(tabIndex, tabID);
  21. var items = {
  22. // Connection settings
  23. ldap_configuration_active: {
  24. $element: $('#ldap_configuration_active'),
  25. setMethod: 'setConfigurationState'
  26. },
  27. ldap_backup_host: {
  28. $element: $('#ldap_backup_host'),
  29. setMethod: 'setBackupHost'
  30. },
  31. ldap_backup_port: {
  32. $element: $('#ldap_backup_port'),
  33. setMethod: 'setBackupPort'
  34. },
  35. ldap_override_main_server: {
  36. $element: $('#ldap_override_main_server'),
  37. setMethod: 'setOverrideMainServerState'
  38. },
  39. ldap_turn_off_cert_check: {
  40. $element: $('#ldap_turn_off_cert_check'),
  41. setMethod: 'setCertCheckDisabled'
  42. },
  43. ldap_cache_ttl: {
  44. $element: $('#ldap_cache_ttl'),
  45. setMethod: 'setCacheTTL'
  46. },
  47. //Directory Settings
  48. ldap_display_name: {
  49. $element: $('#ldap_display_name'),
  50. setMethod: 'setUserDisplayName'
  51. },
  52. ldap_user_display_name_2: {
  53. $element: $('#ldap_user_display_name_2'),
  54. setMethod: 'setUserDisplayName2'
  55. },
  56. ldap_base_users: {
  57. $element: $('#ldap_base_users'),
  58. setMethod: 'setBaseDNUsers'
  59. },
  60. ldap_attributes_for_user_search: {
  61. $element: $('#ldap_attributes_for_user_search'),
  62. setMethod: 'setSearchAttributesUsers'
  63. },
  64. ldap_group_display_name: {
  65. $element: $('#ldap_group_display_name'),
  66. setMethod: 'setGroupDisplayName'
  67. },
  68. ldap_base_groups: {
  69. $element: $('#ldap_base_groups'),
  70. setMethod: 'setBaseDNGroups'
  71. },
  72. ldap_attributes_for_group_search: {
  73. $element: $('#ldap_attributes_for_group_search'),
  74. setMethod: 'setSearchAttributesGroups'
  75. },
  76. ldap_group_member_assoc_attribute: {
  77. $element: $('#ldap_group_member_assoc_attribute'),
  78. setMethod: 'setGroupMemberAssociationAttribute'
  79. },
  80. ldap_dynamic_group_member_url: {
  81. $element: $('#ldap_dynamic_group_member_url'),
  82. setMethod: 'setDynamicGroupMemberURL'
  83. },
  84. ldap_nested_groups: {
  85. $element: $('#ldap_nested_groups'),
  86. setMethod: 'setUseNestedGroups'
  87. },
  88. ldap_paging_size: {
  89. $element: $('#ldap_paging_size'),
  90. setMethod: 'setPagingSize'
  91. },
  92. ldap_turn_on_pwd_change: {
  93. $element: $('#ldap_turn_on_pwd_change'),
  94. setMethod: 'setPasswordChangeEnabled'
  95. },
  96. ldap_default_ppolicy_dn: {
  97. $element: $('#ldap_default_ppolicy_dn'),
  98. setMethod: 'setDefaultPPolicyDN'
  99. },
  100. //Special Attributes
  101. ldap_quota_attr: {
  102. $element: $('#ldap_quota_attr'),
  103. setMethod: 'setQuotaAttribute'
  104. },
  105. ldap_quota_def: {
  106. $element: $('#ldap_quota_def'),
  107. setMethod: 'setQuotaDefault'
  108. },
  109. ldap_email_attr: {
  110. $element: $('#ldap_email_attr'),
  111. setMethod: 'setEmailAttribute'
  112. },
  113. home_folder_naming_rule: {
  114. $element: $('#home_folder_naming_rule'),
  115. setMethod: 'setHomeFolderAttribute'
  116. },
  117. ldap_ext_storage_home_attribute: {
  118. $element: $('#ldap_ext_storage_home_attribute'),
  119. setMethod: 'setExternalStorageHomeAttribute'
  120. },
  121. };
  122. this.setManagedItems(items);
  123. },
  124. /**
  125. * Sets the config model for this view and subscribes to some events.
  126. * Also binds the config chooser to the model
  127. *
  128. * @param {OCA.LDAP.Wizard.ConfigModel} configModel
  129. */
  130. setModel: function(configModel) {
  131. this._super(configModel);
  132. this.configModel.on('configLoaded', this.onConfigLoaded, this);
  133. this.configModel.on('receivedLdapFeature', this.onResultReceived, this);
  134. },
  135. /**
  136. * updates the experienced admin check box
  137. *
  138. * @param {string} isConfigActive contains an int
  139. */
  140. setConfigurationState: function(isConfigActive) {
  141. this.setElementValue(
  142. this.managedItems.ldap_configuration_active.$element, isConfigActive
  143. );
  144. },
  145. /**
  146. * updates the backup host configuration text field
  147. *
  148. * @param {string} host
  149. */
  150. setBackupHost: function(host) {
  151. this.setElementValue(this.managedItems.ldap_backup_host.$element, host);
  152. },
  153. /**
  154. * updates the backup port configuration text field
  155. *
  156. * @param {string} port
  157. */
  158. setBackupPort: function(port) {
  159. this.setElementValue(this.managedItems.ldap_backup_port.$element, port);
  160. },
  161. /**
  162. * sets whether the main server should be overridden or not
  163. *
  164. * @param {string} doOverride contains an int
  165. */
  166. setOverrideMainServerState: function(doOverride) {
  167. this.setElementValue(
  168. this.managedItems.ldap_override_main_server.$element, doOverride
  169. );
  170. },
  171. /**
  172. * sets whether the SSL/TLS certification check shout be disabled
  173. *
  174. * @param {string} doCertCheck contains an int
  175. */
  176. setCertCheckDisabled: function(doCertCheck) {
  177. this.setElementValue(
  178. this.managedItems.ldap_turn_off_cert_check.$element, doCertCheck
  179. );
  180. },
  181. /**
  182. * sets the time-to-live of the LDAP cache (in seconds)
  183. *
  184. * @param {string} cacheTTL contains an int
  185. */
  186. setCacheTTL: function(cacheTTL) {
  187. this.setElementValue(this.managedItems.ldap_cache_ttl.$element, cacheTTL);
  188. },
  189. /**
  190. * sets the user display name attribute
  191. *
  192. * @param {string} attribute
  193. */
  194. setUserDisplayName: function(attribute) {
  195. this.setElementValue(this.managedItems.ldap_display_name.$element, attribute);
  196. },
  197. /**
  198. * sets the additional user display name attribute
  199. *
  200. * @param {string} attribute
  201. */
  202. setUserDisplayName2: function(attribute) {
  203. this.setElementValue(this.managedItems.ldap_user_display_name_2.$element, attribute);
  204. },
  205. /**
  206. * sets the Base DN for users
  207. *
  208. * @param {string} base
  209. */
  210. setBaseDNUsers: function(base) {
  211. this.setElementValue(this.managedItems.ldap_base_users.$element, base);
  212. },
  213. /**
  214. * sets the attributes for user searches
  215. *
  216. * @param {string} attributes
  217. */
  218. setSearchAttributesUsers: function(attributes) {
  219. this.setElementValue(this.managedItems.ldap_attributes_for_user_search.$element, attributes);
  220. },
  221. /**
  222. * sets the display name attribute for groups
  223. *
  224. * @param {string} attribute
  225. */
  226. setGroupDisplayName: function(attribute) {
  227. this.setElementValue(this.managedItems.ldap_group_display_name.$element, attribute);
  228. },
  229. /**
  230. * sets the Base DN for groups
  231. *
  232. * @param {string} base
  233. */
  234. setBaseDNGroups: function(base) {
  235. this.setElementValue(this.managedItems.ldap_base_groups.$element, base);
  236. },
  237. /**
  238. * sets the attributes for group search
  239. *
  240. * @param {string} attributes
  241. */
  242. setSearchAttributesGroups: function(attributes) {
  243. this.setElementValue(this.managedItems.ldap_attributes_for_group_search.$element, attributes);
  244. },
  245. /**
  246. * sets the attribute for the association of users and groups
  247. *
  248. * @param {string} attribute
  249. */
  250. setGroupMemberAssociationAttribute: function(attribute) {
  251. this.setElementValue(this.managedItems.ldap_group_member_assoc_attribute.$element, attribute);
  252. },
  253. /**
  254. * sets the dynamic group member url attribute
  255. *
  256. * @param {string} attribute
  257. */
  258. setDynamicGroupMemberURL: function(attribute) {
  259. this.setElementValue(this.managedItems.ldap_dynamic_group_member_url.$element, attribute);
  260. },
  261. /**
  262. * enabled or disables the use of nested groups (groups in groups in
  263. * groups…)
  264. *
  265. * @param {string} useNestedGroups contains an int
  266. */
  267. setUseNestedGroups: function(useNestedGroups) {
  268. this.setElementValue(this.managedItems.ldap_nested_groups.$element, useNestedGroups);
  269. },
  270. /**
  271. * sets the size of pages for paged search
  272. *
  273. * @param {string} size contains an int
  274. */
  275. setPagingSize: function(size) {
  276. this.setElementValue(this.managedItems.ldap_paging_size.$element, size);
  277. },
  278. /**
  279. * sets whether the password changes per user should be enabled
  280. *
  281. * @param {string} doPasswordChange contains an int
  282. */
  283. setPasswordChangeEnabled: function(doPasswordChange) {
  284. this.setElementValue(
  285. this.managedItems.ldap_turn_on_pwd_change.$element, doPasswordChange
  286. );
  287. },
  288. /**
  289. * sets the default ppolicy attribute
  290. *
  291. * @param {string} attribute
  292. */
  293. setDefaultPPolicyDN: function(attribute) {
  294. this.setElementValue(this.managedItems.ldap_default_ppolicy_dn.$element, attribute);
  295. },
  296. /**
  297. * sets the email attribute
  298. *
  299. * @param {string} attribute
  300. */
  301. setEmailAttribute: function(attribute) {
  302. this.setElementValue(this.managedItems.ldap_email_attr.$element, attribute);
  303. },
  304. /**
  305. * sets the external storage home attribute
  306. *
  307. * @param {string} attribute
  308. */
  309. setExternalStorageHomeAttribute: function(attribute) {
  310. this.setElementValue(this.managedItems.ldap_ext_storage_home_attribute.$element, attribute);
  311. },
  312. /**
  313. * sets the quota attribute
  314. *
  315. * @param {string} attribute
  316. */
  317. setQuotaAttribute: function(attribute) {
  318. this.setElementValue(this.managedItems.ldap_quota_attr.$element, attribute);
  319. },
  320. /**
  321. * sets the default quota for LDAP users
  322. *
  323. * @param {string} quota contains an int
  324. */
  325. setQuotaDefault: function(quota) {
  326. this.setElementValue(this.managedItems.ldap_quota_def.$element, quota);
  327. },
  328. /**
  329. * sets the attribute for the Nextcloud user specific home folder location
  330. *
  331. * @param {string} attribute
  332. */
  333. setHomeFolderAttribute: function(attribute) {
  334. this.setElementValue(this.managedItems.home_folder_naming_rule.$element, attribute);
  335. },
  336. /**
  337. * deals with the result of the Test Connection test
  338. *
  339. * @param {WizardTabAdvanced} view
  340. * @param {FeaturePayload} payload
  341. */
  342. onResultReceived: function(view, payload) {
  343. if(payload.feature === 'TestConfiguration') {
  344. OC.Notification.showTemporary(payload.data.message);
  345. }
  346. }
  347. });
  348. OCA.LDAP.Wizard.WizardTabAdvanced = WizardTabAdvanced;
  349. })();