1
0

wizardTabAdvanced.js 14 KB

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