wizardTabAdvanced.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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. //User Profile Attributes
  122. ldap_attr_phone: {
  123. $element: $('#ldap_attr_phone'),
  124. setMethod: 'setPhoneAttribute'
  125. },
  126. ldap_attr_website: {
  127. $element: $('#ldap_attr_website'),
  128. setMethod: 'setWebsiteAttribute'
  129. },
  130. ldap_attr_address: {
  131. $element: $('#ldap_attr_address'),
  132. setMethod: 'setAddressAttribute'
  133. },
  134. ldap_attr_twitter: {
  135. $element: $('#ldap_attr_twitter'),
  136. setMethod: 'setTwitterAttribute'
  137. },
  138. ldap_attr_fediverse: {
  139. $element: $('#ldap_attr_fediverse'),
  140. setMethod: 'setFediverseAttribute'
  141. },
  142. ldap_attr_organisation: {
  143. $element: $('#ldap_attr_organisation'),
  144. setMethod: 'setOrganisationAttribute'
  145. },
  146. ldap_attr_role: {
  147. $element: $('#ldap_attr_role'),
  148. setMethod: 'setRoleAttribute'
  149. },
  150. ldap_attr_headline: {
  151. $element: $('#ldap_attr_headline'),
  152. setMethod: 'setHeadlineAttribute'
  153. },
  154. ldap_attr_biography: {
  155. $element: $('#ldap_attr_biography'),
  156. setMethod: 'setBiographyAttribute'
  157. },
  158. };
  159. this.setManagedItems(items);
  160. },
  161. /**
  162. * Sets the config model for this view and subscribes to some events.
  163. * Also binds the config chooser to the model
  164. *
  165. * @param {OCA.LDAP.Wizard.ConfigModel} configModel
  166. */
  167. setModel: function(configModel) {
  168. this._super(configModel);
  169. this.configModel.on('configLoaded', this.onConfigLoaded, this);
  170. this.configModel.on('receivedLdapFeature', this.onResultReceived, this);
  171. },
  172. /**
  173. * updates the experienced admin check box
  174. *
  175. * @param {string} isConfigActive contains an int
  176. */
  177. setConfigurationState: function(isConfigActive) {
  178. this.setElementValue(
  179. this.managedItems.ldap_configuration_active.$element, isConfigActive
  180. );
  181. },
  182. /**
  183. * updates the backup host configuration text field
  184. *
  185. * @param {string} host
  186. */
  187. setBackupHost: function(host) {
  188. this.setElementValue(this.managedItems.ldap_backup_host.$element, host);
  189. },
  190. /**
  191. * updates the backup port configuration text field
  192. *
  193. * @param {string} port
  194. */
  195. setBackupPort: function(port) {
  196. this.setElementValue(this.managedItems.ldap_backup_port.$element, port);
  197. },
  198. /**
  199. * sets whether the main server should be overridden or not
  200. *
  201. * @param {string} doOverride contains an int
  202. */
  203. setOverrideMainServerState: function(doOverride) {
  204. this.setElementValue(
  205. this.managedItems.ldap_override_main_server.$element, doOverride
  206. );
  207. },
  208. /**
  209. * sets whether the SSL/TLS certification check shout be disabled
  210. *
  211. * @param {string} doCertCheck contains an int
  212. */
  213. setCertCheckDisabled: function(doCertCheck) {
  214. this.setElementValue(
  215. this.managedItems.ldap_turn_off_cert_check.$element, doCertCheck
  216. );
  217. },
  218. /**
  219. * sets the time-to-live of the LDAP cache (in seconds)
  220. *
  221. * @param {string} cacheTTL contains an int
  222. */
  223. setCacheTTL: function(cacheTTL) {
  224. this.setElementValue(this.managedItems.ldap_cache_ttl.$element, cacheTTL);
  225. },
  226. /**
  227. * sets the user display name attribute
  228. *
  229. * @param {string} attribute
  230. */
  231. setUserDisplayName: function(attribute) {
  232. this.setElementValue(this.managedItems.ldap_display_name.$element, attribute);
  233. },
  234. /**
  235. * sets the additional user display name attribute
  236. *
  237. * @param {string} attribute
  238. */
  239. setUserDisplayName2: function(attribute) {
  240. this.setElementValue(this.managedItems.ldap_user_display_name_2.$element, attribute);
  241. },
  242. /**
  243. * sets the Base DN for users
  244. *
  245. * @param {string} base
  246. */
  247. setBaseDNUsers: function(base) {
  248. this.setElementValue(this.managedItems.ldap_base_users.$element, base);
  249. },
  250. /**
  251. * sets the attributes for user searches
  252. *
  253. * @param {string} attributes
  254. */
  255. setSearchAttributesUsers: function(attributes) {
  256. this.setElementValue(this.managedItems.ldap_attributes_for_user_search.$element, attributes);
  257. },
  258. /**
  259. * sets the display name attribute for groups
  260. *
  261. * @param {string} attribute
  262. */
  263. setGroupDisplayName: function(attribute) {
  264. this.setElementValue(this.managedItems.ldap_group_display_name.$element, attribute);
  265. },
  266. /**
  267. * sets the Base DN for groups
  268. *
  269. * @param {string} base
  270. */
  271. setBaseDNGroups: function(base) {
  272. this.setElementValue(this.managedItems.ldap_base_groups.$element, base);
  273. },
  274. /**
  275. * sets the attributes for group search
  276. *
  277. * @param {string} attributes
  278. */
  279. setSearchAttributesGroups: function(attributes) {
  280. this.setElementValue(this.managedItems.ldap_attributes_for_group_search.$element, attributes);
  281. },
  282. /**
  283. * sets the attribute for the association of users and groups
  284. *
  285. * @param {string} attribute
  286. */
  287. setGroupMemberAssociationAttribute: function(attribute) {
  288. this.setElementValue(this.managedItems.ldap_group_member_assoc_attribute.$element, attribute);
  289. },
  290. /**
  291. * sets the dynamic group member url attribute
  292. *
  293. * @param {string} attribute
  294. */
  295. setDynamicGroupMemberURL: function(attribute) {
  296. this.setElementValue(this.managedItems.ldap_dynamic_group_member_url.$element, attribute);
  297. },
  298. /**
  299. * enabled or disables the use of nested groups (groups in groups in
  300. * groups…)
  301. *
  302. * @param {string} useNestedGroups contains an int
  303. */
  304. setUseNestedGroups: function(useNestedGroups) {
  305. this.setElementValue(this.managedItems.ldap_nested_groups.$element, useNestedGroups);
  306. },
  307. /**
  308. * sets the size of pages for paged search
  309. *
  310. * @param {string} size contains an int
  311. */
  312. setPagingSize: function(size) {
  313. this.setElementValue(this.managedItems.ldap_paging_size.$element, size);
  314. },
  315. /**
  316. * sets whether the password changes per user should be enabled
  317. *
  318. * @param {string} doPasswordChange contains an int
  319. */
  320. setPasswordChangeEnabled: function(doPasswordChange) {
  321. this.setElementValue(
  322. this.managedItems.ldap_turn_on_pwd_change.$element, doPasswordChange
  323. );
  324. },
  325. /**
  326. * sets the default ppolicy attribute
  327. *
  328. * @param {string} attribute
  329. */
  330. setDefaultPPolicyDN: function(attribute) {
  331. this.setElementValue(this.managedItems.ldap_default_ppolicy_dn.$element, attribute);
  332. },
  333. /**
  334. * sets the email attribute
  335. *
  336. * @param {string} attribute
  337. */
  338. setEmailAttribute: function(attribute) {
  339. this.setElementValue(this.managedItems.ldap_email_attr.$element, attribute);
  340. },
  341. /**
  342. * sets the external storage home attribute
  343. *
  344. * @param {string} attribute
  345. */
  346. setExternalStorageHomeAttribute: function(attribute) {
  347. this.setElementValue(this.managedItems.ldap_ext_storage_home_attribute.$element, attribute);
  348. },
  349. /**
  350. * sets the quota attribute
  351. *
  352. * @param {string} attribute
  353. */
  354. setQuotaAttribute: function(attribute) {
  355. this.setElementValue(this.managedItems.ldap_quota_attr.$element, attribute);
  356. },
  357. /**
  358. * sets the default quota for LDAP users
  359. *
  360. * @param {string} quota contains an int
  361. */
  362. setQuotaDefault: function(quota) {
  363. this.setElementValue(this.managedItems.ldap_quota_def.$element, quota);
  364. },
  365. /**
  366. * sets the attribute for the Nextcloud user specific home folder location
  367. *
  368. * @param {string} attribute
  369. */
  370. setHomeFolderAttribute: function(attribute) {
  371. this.setElementValue(this.managedItems.home_folder_naming_rule.$element, attribute);
  372. },
  373. /**
  374. * sets the attribute for the Nextcloud user profile phone Number
  375. *
  376. * @param {string} attribute
  377. */
  378. setPhoneAttribute: function(attribute) {
  379. this.setElementValue(this.managedItems.ldap_attr_phone.$element, attribute);
  380. },
  381. /**
  382. * sets the attribute for the Nextcloud user profile website
  383. *
  384. * @param {string} attribute
  385. */
  386. setWebsiteAttribute: function(attribute) {
  387. this.setElementValue(this.managedItems.ldap_attr_website.$element, attribute);
  388. },
  389. /**
  390. * sets the attribute for the Nextcloud user profile postal address
  391. *
  392. * @param {string} attribute
  393. */
  394. setAddressAttribute: function(attribute) {
  395. this.setElementValue(this.managedItems.ldap_attr_address.$element, attribute);
  396. },
  397. /**
  398. * sets the attribute for the Nextcloud user profile twitter
  399. *
  400. * @param {string} attribute
  401. */
  402. setTwitterAttribute: function(attribute) {
  403. this.setElementValue(this.managedItems.ldap_attr_twitter.$element, attribute);
  404. },
  405. /**
  406. * sets the attribute for the Nextcloud user profile fediverse
  407. *
  408. * @param {string} attribute
  409. */
  410. setFediverseAttribute: function(attribute) {
  411. this.setElementValue(this.managedItems.ldap_attr_fediverse.$element, attribute);
  412. },
  413. /**
  414. * sets the attribute for the Nextcloud user profile organisation
  415. *
  416. * @param {string} attribute
  417. */
  418. setOrganisationAttribute: function(attribute) {
  419. this.setElementValue(this.managedItems.ldap_attr_organisation.$element, attribute);
  420. },
  421. /**
  422. * sets the attribute for the Nextcloud user profile role
  423. *
  424. * @param {string} attribute
  425. */
  426. setRoleAttribute: function(attribute) {
  427. this.setElementValue(this.managedItems.ldap_attr_role.$element, attribute);
  428. },
  429. /**
  430. * sets the attribute for the Nextcloud user profile headline
  431. *
  432. * @param {string} attribute
  433. */
  434. setHeadlineAttribute: function(attribute) {
  435. this.setElementValue(this.managedItems.ldap_attr_headline.$element, attribute);
  436. },
  437. /**
  438. * sets the attribute for the Nextcloud user profile biography
  439. *
  440. * @param {string} attribute
  441. */
  442. setBiographyAttribute: function(attribute) {
  443. this.setElementValue(this.managedItems.ldap_attr_biography.$element, attribute);
  444. },
  445. /**
  446. * deals with the result of the Test Connection test
  447. *
  448. * @param {WizardTabAdvanced} view
  449. * @param {FeaturePayload} payload
  450. */
  451. onResultReceived: function(view, payload) {
  452. if(payload.feature === 'TestConfiguration') {
  453. OC.Notification.showTemporary(payload.data.message);
  454. }
  455. }
  456. });
  457. OCA.LDAP.Wizard.WizardTabAdvanced = WizardTabAdvanced;
  458. })();