wizardDetectorAvailableAttributes.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 an Attributes Detector. It executes the auto-detection of
  10. * available attributes by the ownCloud server, if requirements are met.
  11. *
  12. * @constructor
  13. */
  14. var WizardDetectorAvailableAttributes = OCA.LDAP.Wizard.WizardDetectorGeneric.subClass({
  15. /** @inheritdoc */
  16. init: function() {
  17. // given, it is not a configuration key
  18. this.setTargetKey('ldap_loginfilter_attributes');
  19. this.runsOnRequest = true;
  20. },
  21. /**
  22. * runs the detector, if port is not set.
  23. *
  24. * @param {OCA.LDAP.Wizard.ConfigModel} model
  25. * @param {string} configID - the configuration prefix
  26. * @returns {boolean|jqXHR}
  27. * @abstract
  28. */
  29. run: function(model, configID) {
  30. model.notifyAboutDetectionStart(this.getTargetKey());
  31. var params = OC.buildQueryString({
  32. action: 'determineAttributes',
  33. ldap_serverconfig_chooser: configID
  34. });
  35. return model.callWizard(params, this.processResult, this);
  36. },
  37. /**
  38. * @inheritdoc
  39. */
  40. processResult: function(model, detector, result) {
  41. if(result.status === 'success') {
  42. var payload = {
  43. feature: 'AvailableAttributes',
  44. data: result.options[detector.getTargetKey()]
  45. };
  46. model.inform(payload);
  47. }
  48. this._super(model, detector, result);
  49. }
  50. });
  51. OCA.LDAP.Wizard.WizardDetectorAvailableAttributes = WizardDetectorAvailableAttributes;
  52. })();