wizardDetectorTestAbstract.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-FileCopyrightText: 2015 ownCloud, Inc.
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. OCA = OCA || {};
  7. (function() {
  8. /**
  9. * @classdesc a Port Detector. It executes the auto-detection of the port
  10. * by the Nextcloud server, if requirements are met.
  11. *
  12. * @constructor
  13. */
  14. var WizardDetectorTestAbstract = OCA.LDAP.Wizard.WizardDetectorGeneric.subClass({
  15. isLegacy: false,
  16. /**
  17. * runs the test
  18. *
  19. * @param {OCA.LDAP.Wizard.ConfigModel} model
  20. * @param {string} configID - the configuration prefix
  21. * @param {Object} params - additional parameters needed to send to the
  22. * wizard
  23. * @returns {boolean|jqXHR}
  24. * @abstract
  25. */
  26. run: function(model, configID, params) {
  27. if(_.isUndefined(this.wizardMethod) && !this.isLegacy) {
  28. console.warn('wizardMethod not set! ' + this.constructor);
  29. return false;
  30. }
  31. model.notifyAboutDetectionStart(this.getTargetKey());
  32. params = params || {};
  33. params = OC.buildQueryString($.extend({
  34. action: this.wizardMethod,
  35. ldap_serverconfig_chooser: configID
  36. }, params));
  37. if(!this.isLegacy) {
  38. return model.callWizard(params, this.processResult, this);
  39. } else {
  40. return model.callAjax(this.legacyDestination, params, this.processResult, this);
  41. }
  42. },
  43. /**
  44. * @inheritdoc
  45. */
  46. processResult: function(model, detector, result) {
  47. model['notifyAboutDetectionCompletion'](detector.getTargetKey());
  48. var payload = {
  49. feature: detector.testName,
  50. data: result
  51. };
  52. model.inform(payload);
  53. }
  54. });
  55. OCA.LDAP.Wizard.WizardDetectorTestAbstract = WizardDetectorTestAbstract;
  56. })();