wizardDetectorTestAbstract.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 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. })();