settings.js 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409
  1. /*
  2. * Copyright (c) 2014
  3. *
  4. * This file is licensed under the Affero General Public License version 3
  5. * or later.
  6. *
  7. * See the COPYING-README file.
  8. *
  9. */
  10. (function(){
  11. // TODO: move to a separate file
  12. var MOUNT_OPTIONS_DROPDOWN_TEMPLATE =
  13. '<div class="drop dropdown mountOptionsDropdown">' +
  14. // FIXME: options are hard-coded for now
  15. ' <div class="optionRow">' +
  16. ' <input id="mountOptionsEncrypt" name="encrypt" type="checkbox" value="true" checked="checked"/>' +
  17. ' <label for="mountOptionsEncrypt">{{t "files_external" "Enable encryption"}}</label>' +
  18. ' </div>' +
  19. ' <div class="optionRow">' +
  20. ' <input id="mountOptionsPreviews" name="previews" type="checkbox" value="true" checked="checked"/>' +
  21. ' <label for="mountOptionsPreviews">{{t "files_external" "Enable previews"}}</label>' +
  22. ' </div>' +
  23. ' <div class="optionRow">' +
  24. ' <input id="mountOptionsSharing" name="enable_sharing" type="checkbox" value="true"/>' +
  25. ' <label for="mountOptionsSharing">{{t "files_external" "Enable sharing"}}</label>' +
  26. ' </div>' +
  27. ' <div class="optionRow">' +
  28. ' <label for="mountOptionsFilesystemCheck">{{t "files_external" "Check for changes"}}</label>' +
  29. ' <select id="mountOptionsFilesystemCheck" name="filesystem_check_changes" data-type="int">' +
  30. ' <option value="0">{{t "files_external" "Never"}}</option>' +
  31. ' <option value="1" selected="selected">{{t "files_external" "Once every direct access"}}</option>' +
  32. ' </select>' +
  33. ' </div>' +
  34. ' <div class="optionRow">' +
  35. ' <input id="mountOptionsEncoding" name="encoding_compatibility" type="checkbox" value="true"/>' +
  36. ' <label for="mountOptionsEncoding">{{mountOptionsEncodingLabel}}</label>' +
  37. ' </div>' +
  38. '</div>';
  39. /**
  40. * Returns the selection of applicable users in the given configuration row
  41. *
  42. * @param $row configuration row
  43. * @return array array of user names
  44. */
  45. function getSelection($row) {
  46. var values = $row.find('.applicableUsers').select2('val');
  47. if (!values || values.length === 0) {
  48. values = [];
  49. }
  50. return values;
  51. }
  52. function highlightBorder($element, highlight) {
  53. $element.toggleClass('warning-input', highlight);
  54. return highlight;
  55. }
  56. function isInputValid($input) {
  57. var optional = $input.hasClass('optional');
  58. switch ($input.attr('type')) {
  59. case 'text':
  60. case 'password':
  61. if ($input.val() === '' && !optional) {
  62. return false;
  63. }
  64. break;
  65. }
  66. return true;
  67. }
  68. function highlightInput($input) {
  69. switch ($input.attr('type')) {
  70. case 'text':
  71. case 'password':
  72. return highlightBorder($input, !isInputValid($input));
  73. }
  74. }
  75. /**
  76. * Initialize select2 plugin on the given elements
  77. *
  78. * @param {Array<Object>} array of jQuery elements
  79. * @param {int} userListLimit page size for result list
  80. */
  81. function addSelect2 ($elements, userListLimit) {
  82. if (!$elements.length) {
  83. return;
  84. }
  85. $elements.select2({
  86. placeholder: t('files_external', 'All users. Type to select user or group.'),
  87. allowClear: true,
  88. multiple: true,
  89. dropdownCssClass: 'files-external-select2',
  90. //minimumInputLength: 1,
  91. ajax: {
  92. url: OC.generateUrl('apps/files_external/applicable'),
  93. dataType: 'json',
  94. quietMillis: 100,
  95. data: function (term, page) { // page is the one-based page number tracked by Select2
  96. return {
  97. pattern: term, //search term
  98. limit: userListLimit, // page size
  99. offset: userListLimit*(page-1) // page number starts with 0
  100. };
  101. },
  102. results: function (data) {
  103. if (data.status === 'success') {
  104. var results = [];
  105. var userCount = 0; // users is an object
  106. // add groups
  107. $.each(data.groups, function(i, group) {
  108. results.push({name:group+'(group)', displayname:group, type:'group' });
  109. });
  110. // add users
  111. $.each(data.users, function(id, user) {
  112. userCount++;
  113. results.push({name:id, displayname:user, type:'user' });
  114. });
  115. var more = (userCount >= userListLimit) || (data.groups.length >= userListLimit);
  116. return {results: results, more: more};
  117. } else {
  118. //FIXME add error handling
  119. }
  120. }
  121. },
  122. initSelection: function(element, callback) {
  123. var users = {};
  124. users['users'] = [];
  125. var toSplit = element.val().split(",");
  126. for (var i = 0; i < toSplit.length; i++) {
  127. users['users'].push(toSplit[i]);
  128. }
  129. $.ajax(OC.generateUrl('displaynames'), {
  130. type: 'POST',
  131. contentType: 'application/json',
  132. data: JSON.stringify(users),
  133. dataType: 'json'
  134. }).done(function(data) {
  135. var results = [];
  136. if (data.status === 'success') {
  137. $.each(data.users, function(user, displayname) {
  138. if (displayname !== false) {
  139. results.push({name:user, displayname:displayname, type:'user'});
  140. }
  141. });
  142. callback(results);
  143. } else {
  144. //FIXME add error handling
  145. }
  146. });
  147. },
  148. id: function(element) {
  149. return element.name;
  150. },
  151. formatResult: function (element) {
  152. var $result = $('<span><div class="avatardiv"/><span>'+escapeHTML(element.displayname)+'</span></span>');
  153. var $div = $result.find('.avatardiv')
  154. .attr('data-type', element.type)
  155. .attr('data-name', element.name)
  156. .attr('data-displayname', element.displayname);
  157. if (element.type === 'group') {
  158. var url = OC.imagePath('core','places/contacts-dark'); // TODO better group icon
  159. $div.html('<img width="32" height="32" src="'+url+'">');
  160. }
  161. return $result.get(0).outerHTML;
  162. },
  163. formatSelection: function (element) {
  164. if (element.type === 'group') {
  165. return '<span title="'+escapeHTML(element.name)+'" class="group">'+escapeHTML(element.displayname+' '+t('files_external', '(group)'))+'</span>';
  166. } else {
  167. return '<span title="'+escapeHTML(element.name)+'" class="user">'+escapeHTML(element.displayname)+'</span>';
  168. }
  169. },
  170. escapeMarkup: function (m) { return m; } // we escape the markup in formatResult and formatSelection
  171. }).on('select2-loaded', function() {
  172. $.each($('.avatardiv'), function(i, div) {
  173. var $div = $(div);
  174. if ($div.data('type') === 'user') {
  175. $div.avatar($div.data('name'),32);
  176. }
  177. });
  178. });
  179. }
  180. /**
  181. * @class OCA.External.Settings.StorageConfig
  182. *
  183. * @classdesc External storage config
  184. */
  185. var StorageConfig = function(id) {
  186. this.id = id;
  187. this.backendOptions = {};
  188. };
  189. // Keep this in sync with \OC_Mount_Config::STATUS_*
  190. StorageConfig.Status = {
  191. IN_PROGRESS: -1,
  192. SUCCESS: 0,
  193. ERROR: 1,
  194. INDETERMINATE: 2
  195. };
  196. StorageConfig.Visibility = {
  197. NONE: 0,
  198. PERSONAL: 1,
  199. ADMIN: 2,
  200. DEFAULT: 3
  201. };
  202. /**
  203. * @memberof OCA.External.Settings
  204. */
  205. StorageConfig.prototype = {
  206. _url: null,
  207. /**
  208. * Storage id
  209. *
  210. * @type int
  211. */
  212. id: null,
  213. /**
  214. * Mount point
  215. *
  216. * @type string
  217. */
  218. mountPoint: '',
  219. /**
  220. * Backend
  221. *
  222. * @type string
  223. */
  224. backend: null,
  225. /**
  226. * Authentication mechanism
  227. *
  228. * @type string
  229. */
  230. authMechanism: null,
  231. /**
  232. * Backend-specific configuration
  233. *
  234. * @type Object.<string,object>
  235. */
  236. backendOptions: null,
  237. /**
  238. * Mount-specific options
  239. *
  240. * @type Object.<string,object>
  241. */
  242. mountOptions: null,
  243. /**
  244. * Creates or saves the storage.
  245. *
  246. * @param {Function} [options.success] success callback, receives result as argument
  247. * @param {Function} [options.error] error callback
  248. */
  249. save: function(options) {
  250. var self = this;
  251. var url = OC.generateUrl(this._url);
  252. var method = 'POST';
  253. if (_.isNumber(this.id)) {
  254. method = 'PUT';
  255. url = OC.generateUrl(this._url + '/{id}', {id: this.id});
  256. }
  257. $.ajax({
  258. type: method,
  259. url: url,
  260. contentType: 'application/json',
  261. data: JSON.stringify(this.getData()),
  262. success: function(result) {
  263. self.id = result.id;
  264. if (_.isFunction(options.success)) {
  265. options.success(result);
  266. }
  267. },
  268. error: options.error
  269. });
  270. },
  271. /**
  272. * Returns the data from this object
  273. *
  274. * @return {Array} JSON array of the data
  275. */
  276. getData: function() {
  277. var data = {
  278. mountPoint: this.mountPoint,
  279. backend: this.backend,
  280. authMechanism: this.authMechanism,
  281. backendOptions: this.backendOptions,
  282. testOnly: true
  283. };
  284. if (this.id) {
  285. data.id = this.id;
  286. }
  287. if (this.mountOptions) {
  288. data.mountOptions = this.mountOptions;
  289. }
  290. return data;
  291. },
  292. /**
  293. * Recheck the storage
  294. *
  295. * @param {Function} [options.success] success callback, receives result as argument
  296. * @param {Function} [options.error] error callback
  297. */
  298. recheck: function(options) {
  299. if (!_.isNumber(this.id)) {
  300. if (_.isFunction(options.error)) {
  301. options.error();
  302. }
  303. return;
  304. }
  305. $.ajax({
  306. type: 'GET',
  307. url: OC.generateUrl(this._url + '/{id}', {id: this.id}),
  308. data: {'testOnly': true},
  309. success: options.success,
  310. error: options.error
  311. });
  312. },
  313. /**
  314. * Deletes the storage
  315. *
  316. * @param {Function} [options.success] success callback
  317. * @param {Function} [options.error] error callback
  318. */
  319. destroy: function(options) {
  320. if (!_.isNumber(this.id)) {
  321. // the storage hasn't even been created => success
  322. if (_.isFunction(options.success)) {
  323. options.success();
  324. }
  325. return;
  326. }
  327. $.ajax({
  328. type: 'DELETE',
  329. url: OC.generateUrl(this._url + '/{id}', {id: this.id}),
  330. success: options.success,
  331. error: options.error
  332. });
  333. },
  334. /**
  335. * Validate this model
  336. *
  337. * @return {boolean} false if errors exist, true otherwise
  338. */
  339. validate: function() {
  340. if (this.mountPoint === '') {
  341. return false;
  342. }
  343. if (!this.backend) {
  344. return false;
  345. }
  346. if (this.errors) {
  347. return false;
  348. }
  349. return true;
  350. }
  351. };
  352. /**
  353. * @class OCA.External.Settings.GlobalStorageConfig
  354. * @augments OCA.External.Settings.StorageConfig
  355. *
  356. * @classdesc Global external storage config
  357. */
  358. var GlobalStorageConfig = function(id) {
  359. this.id = id;
  360. this.applicableUsers = [];
  361. this.applicableGroups = [];
  362. };
  363. /**
  364. * @memberOf OCA.External.Settings
  365. */
  366. GlobalStorageConfig.prototype = _.extend({}, StorageConfig.prototype,
  367. /** @lends OCA.External.Settings.GlobalStorageConfig.prototype */ {
  368. _url: 'apps/files_external/globalstorages',
  369. /**
  370. * Applicable users
  371. *
  372. * @type Array.<string>
  373. */
  374. applicableUsers: null,
  375. /**
  376. * Applicable groups
  377. *
  378. * @type Array.<string>
  379. */
  380. applicableGroups: null,
  381. /**
  382. * Storage priority
  383. *
  384. * @type int
  385. */
  386. priority: null,
  387. /**
  388. * Returns the data from this object
  389. *
  390. * @return {Array} JSON array of the data
  391. */
  392. getData: function() {
  393. var data = StorageConfig.prototype.getData.apply(this, arguments);
  394. return _.extend(data, {
  395. applicableUsers: this.applicableUsers,
  396. applicableGroups: this.applicableGroups,
  397. priority: this.priority,
  398. });
  399. }
  400. });
  401. /**
  402. * @class OCA.External.Settings.UserStorageConfig
  403. * @augments OCA.External.Settings.StorageConfig
  404. *
  405. * @classdesc User external storage config
  406. */
  407. var UserStorageConfig = function(id) {
  408. this.id = id;
  409. };
  410. UserStorageConfig.prototype = _.extend({}, StorageConfig.prototype,
  411. /** @lends OCA.External.Settings.UserStorageConfig.prototype */ {
  412. _url: 'apps/files_external/userstorages'
  413. });
  414. /**
  415. * @class OCA.External.Settings.UserGlobalStorageConfig
  416. * @augments OCA.External.Settings.StorageConfig
  417. *
  418. * @classdesc User external storage config
  419. */
  420. var UserGlobalStorageConfig = function (id) {
  421. this.id = id;
  422. };
  423. UserGlobalStorageConfig.prototype = _.extend({}, StorageConfig.prototype,
  424. /** @lends OCA.External.Settings.UserStorageConfig.prototype */ {
  425. _url: 'apps/files_external/userglobalstorages'
  426. });
  427. /**
  428. * @class OCA.External.Settings.MountOptionsDropdown
  429. *
  430. * @classdesc Dropdown for mount options
  431. *
  432. * @param {Object} $container container DOM object
  433. */
  434. var MountOptionsDropdown = function() {
  435. };
  436. /**
  437. * @memberof OCA.External.Settings
  438. */
  439. MountOptionsDropdown.prototype = {
  440. /**
  441. * Dropdown element
  442. *
  443. * @var Object
  444. */
  445. $el: null,
  446. /**
  447. * Show dropdown
  448. *
  449. * @param {Object} $container container
  450. * @param {Object} mountOptions mount options
  451. * @param {Array} visibleOptions enabled mount options
  452. */
  453. show: function($container, mountOptions, visibleOptions) {
  454. if (MountOptionsDropdown._last) {
  455. MountOptionsDropdown._last.hide();
  456. }
  457. var template = MountOptionsDropdown._template;
  458. if (!template) {
  459. template = Handlebars.compile(MOUNT_OPTIONS_DROPDOWN_TEMPLATE);
  460. MountOptionsDropdown._template = template;
  461. }
  462. var $el = $(template({
  463. mountOptionsEncodingLabel: t('files_external', 'Compatibility with Mac NFD encoding (slow)')
  464. }));
  465. this.$el = $el;
  466. this.setOptions(mountOptions, visibleOptions);
  467. this.$el.appendTo($container);
  468. MountOptionsDropdown._last = this;
  469. this.$el.trigger('show');
  470. },
  471. hide: function() {
  472. if (this.$el) {
  473. this.$el.trigger('hide');
  474. this.$el.remove();
  475. this.$el = null;
  476. MountOptionsDropdown._last = null;
  477. }
  478. },
  479. /**
  480. * Returns the mount options from the dropdown controls
  481. *
  482. * @return {Object} options mount options
  483. */
  484. getOptions: function() {
  485. var options = {};
  486. this.$el.find('input, select').each(function() {
  487. var $this = $(this);
  488. var key = $this.attr('name');
  489. var value = null;
  490. if ($this.attr('type') === 'checkbox') {
  491. value = $this.prop('checked');
  492. } else {
  493. value = $this.val();
  494. }
  495. if ($this.attr('data-type') === 'int') {
  496. value = parseInt(value, 10);
  497. }
  498. options[key] = value;
  499. });
  500. return options;
  501. },
  502. /**
  503. * Sets the mount options to the dropdown controls
  504. *
  505. * @param {Object} options mount options
  506. * @param {Array} visibleOptions enabled mount options
  507. */
  508. setOptions: function(options, visibleOptions) {
  509. var $el = this.$el;
  510. _.each(options, function(value, key) {
  511. var $optionEl = $el.find('input, select').filterAttr('name', key);
  512. if ($optionEl.attr('type') === 'checkbox') {
  513. if (_.isString(value)) {
  514. value = (value === 'true');
  515. }
  516. $optionEl.prop('checked', !!value);
  517. } else {
  518. $optionEl.val(value);
  519. }
  520. });
  521. $el.find('.optionRow').each(function(i, row){
  522. var $row = $(row);
  523. var optionId = $row.find('input, select').attr('name');
  524. if (visibleOptions.indexOf(optionId) === -1) {
  525. $row.hide();
  526. } else {
  527. $row.show();
  528. }
  529. });
  530. }
  531. };
  532. /**
  533. * @class OCA.External.Settings.MountConfigListView
  534. *
  535. * @classdesc Mount configuration list view
  536. *
  537. * @param {Object} $el DOM object containing the list
  538. * @param {Object} [options]
  539. * @param {int} [options.userListLimit] page size in applicable users dropdown
  540. */
  541. var MountConfigListView = function($el, options) {
  542. this.initialize($el, options);
  543. };
  544. MountConfigListView.ParameterFlags = {
  545. OPTIONAL: 1,
  546. USER_PROVIDED: 2
  547. };
  548. MountConfigListView.ParameterTypes = {
  549. TEXT: 0,
  550. BOOLEAN: 1,
  551. PASSWORD: 2,
  552. HIDDEN: 3
  553. };
  554. /**
  555. * @memberOf OCA.External.Settings
  556. */
  557. MountConfigListView.prototype = _.extend({
  558. /**
  559. * jQuery element containing the config list
  560. *
  561. * @type Object
  562. */
  563. $el: null,
  564. /**
  565. * Storage config class
  566. *
  567. * @type Class
  568. */
  569. _storageConfigClass: null,
  570. /**
  571. * Flag whether the list is about user storage configs (true)
  572. * or global storage configs (false)
  573. *
  574. * @type bool
  575. */
  576. _isPersonal: false,
  577. /**
  578. * Page size in applicable users dropdown
  579. *
  580. * @type int
  581. */
  582. _userListLimit: 30,
  583. /**
  584. * List of supported backends
  585. *
  586. * @type Object.<string,Object>
  587. */
  588. _allBackends: null,
  589. /**
  590. * List of all supported authentication mechanisms
  591. *
  592. * @type Object.<string,Object>
  593. */
  594. _allAuthMechanisms: null,
  595. _encryptionEnabled: false,
  596. /**
  597. * @param {Object} $el DOM object containing the list
  598. * @param {Object} [options]
  599. * @param {int} [options.userListLimit] page size in applicable users dropdown
  600. */
  601. initialize: function($el, options) {
  602. var self = this;
  603. this.$el = $el;
  604. this._isPersonal = ($el.data('admin') !== true);
  605. if (this._isPersonal) {
  606. this._storageConfigClass = OCA.External.Settings.UserStorageConfig;
  607. } else {
  608. this._storageConfigClass = OCA.External.Settings.GlobalStorageConfig;
  609. }
  610. if (options && !_.isUndefined(options.userListLimit)) {
  611. this._userListLimit = options.userListLimit;
  612. }
  613. this._encryptionEnabled = options.encryptionEnabled;
  614. // read the backend config that was carefully crammed
  615. // into the data-configurations attribute of the select
  616. this._allBackends = this.$el.find('.selectBackend').data('configurations');
  617. this._allAuthMechanisms = this.$el.find('#addMountPoint .authentication').data('mechanisms');
  618. this._initEvents();
  619. },
  620. /**
  621. * Custom JS event handlers
  622. * Trigger callback for all existing configurations
  623. */
  624. whenSelectBackend: function(callback) {
  625. this.$el.find('tbody tr:not(#addMountPoint)').each(function(i, tr) {
  626. var backend = $(tr).find('.backend').data('identifier');
  627. callback($(tr), backend);
  628. });
  629. this.on('selectBackend', callback);
  630. },
  631. whenSelectAuthMechanism: function(callback) {
  632. var self = this;
  633. this.$el.find('tbody tr:not(#addMountPoint)').each(function(i, tr) {
  634. var authMechanism = $(tr).find('.selectAuthMechanism').val();
  635. callback($(tr), authMechanism, self._allAuthMechanisms[authMechanism]['scheme']);
  636. });
  637. this.on('selectAuthMechanism', callback);
  638. },
  639. /**
  640. * Initialize DOM event handlers
  641. */
  642. _initEvents: function() {
  643. var self = this;
  644. var onChangeHandler = _.bind(this._onChange, this);
  645. //this.$el.on('input', 'td input', onChangeHandler);
  646. this.$el.on('keyup', 'td input', onChangeHandler);
  647. this.$el.on('paste', 'td input', onChangeHandler);
  648. this.$el.on('change', 'td input:checkbox', onChangeHandler);
  649. this.$el.on('change', '.applicable', onChangeHandler);
  650. this.$el.on('click', '.status>span', function() {
  651. self.recheckStorageConfig($(this).closest('tr'));
  652. });
  653. this.$el.on('click', 'td.remove>img', function() {
  654. self.deleteStorageConfig($(this).closest('tr'));
  655. });
  656. this.$el.on('click', 'td.mountOptionsToggle>img', function() {
  657. self._showMountOptionsDropdown($(this).closest('tr'));
  658. });
  659. this.$el.on('change', '.selectBackend', _.bind(this._onSelectBackend, this));
  660. this.$el.on('change', '.selectAuthMechanism', _.bind(this._onSelectAuthMechanism, this));
  661. },
  662. _onChange: function(event) {
  663. var self = this;
  664. var $target = $(event.target);
  665. if ($target.closest('.dropdown').length) {
  666. // ignore dropdown events
  667. return;
  668. }
  669. highlightInput($target);
  670. var $tr = $target.closest('tr');
  671. this.updateStatus($tr, null);
  672. var timer = $tr.data('save-timer');
  673. clearTimeout(timer);
  674. timer = setTimeout(function() {
  675. self.saveStorageConfig($tr, null, timer);
  676. }, 2000);
  677. $tr.data('save-timer', timer);
  678. },
  679. _onSelectBackend: function(event) {
  680. var $target = $(event.target);
  681. var $tr = $target.closest('tr');
  682. var storageConfig = new this._storageConfigClass();
  683. storageConfig.mountPoint = $tr.find('.mountPoint input').val();
  684. storageConfig.backend = $target.val();
  685. $tr.find('.mountPoint input').val('');
  686. var onCompletion = jQuery.Deferred();
  687. $tr = this.newStorage(storageConfig, onCompletion);
  688. onCompletion.resolve();
  689. $tr.find('td.configuration').children().not('[type=hidden]').first().focus();
  690. this.saveStorageConfig($tr);
  691. },
  692. _onSelectAuthMechanism: function(event) {
  693. var $target = $(event.target);
  694. var $tr = $target.closest('tr');
  695. var authMechanism = $target.val();
  696. var onCompletion = jQuery.Deferred();
  697. this.configureAuthMechanism($tr, authMechanism, onCompletion);
  698. onCompletion.resolve();
  699. this.saveStorageConfig($tr);
  700. },
  701. /**
  702. * Configure the storage config with a new authentication mechanism
  703. *
  704. * @param {jQuery} $tr config row
  705. * @param {string} authMechanism
  706. * @param {jQuery.Deferred} onCompletion
  707. */
  708. configureAuthMechanism: function($tr, authMechanism, onCompletion) {
  709. var authMechanismConfiguration = this._allAuthMechanisms[authMechanism];
  710. var $td = $tr.find('td.configuration');
  711. $td.find('.auth-param').remove();
  712. $.each(authMechanismConfiguration['configuration'], _.partial(
  713. this.writeParameterInput, $td, _, _, ['auth-param']
  714. ).bind(this));
  715. this.trigger('selectAuthMechanism',
  716. $tr, authMechanism, authMechanismConfiguration['scheme'], onCompletion
  717. );
  718. },
  719. /**
  720. * Create a config row for a new storage
  721. *
  722. * @param {StorageConfig} storageConfig storage config to pull values from
  723. * @param {jQuery.Deferred} onCompletion
  724. * @return {jQuery} created row
  725. */
  726. newStorage: function(storageConfig, onCompletion) {
  727. var mountPoint = storageConfig.mountPoint;
  728. var backend = this._allBackends[storageConfig.backend];
  729. // FIXME: Replace with a proper Handlebar template
  730. var $tr = this.$el.find('tr#addMountPoint');
  731. this.$el.find('tbody').append($tr.clone());
  732. $tr.data('storageConfig', storageConfig);
  733. $tr.show();
  734. $tr.find('td').last().attr('class', 'remove');
  735. $tr.find('td.mountOptionsToggle').removeClass('hidden');
  736. $tr.find('td').last().removeAttr('style');
  737. $tr.removeAttr('id');
  738. $tr.find('select#selectBackend');
  739. addSelect2($tr.find('.applicableUsers'), this._userListLimit);
  740. if (storageConfig.id) {
  741. $tr.data('id', storageConfig.id);
  742. }
  743. $tr.find('.backend').text(backend.name);
  744. if (mountPoint === '') {
  745. mountPoint = this._suggestMountPoint(backend.name);
  746. }
  747. $tr.find('.mountPoint input').val(mountPoint);
  748. $tr.addClass(backend.identifier);
  749. $tr.find('.backend').data('identifier', backend.identifier);
  750. var selectAuthMechanism = $('<select class="selectAuthMechanism"></select>');
  751. var neededVisibility = (this._isPersonal) ? StorageConfig.Visibility.PERSONAL : StorageConfig.Visibility.ADMIN;
  752. $.each(this._allAuthMechanisms, function(authIdentifier, authMechanism) {
  753. if (backend.authSchemes[authMechanism.scheme] && (authMechanism.visibility & neededVisibility)) {
  754. selectAuthMechanism.append(
  755. $('<option value="'+authMechanism.identifier+'" data-scheme="'+authMechanism.scheme+'">'+authMechanism.name+'</option>')
  756. );
  757. }
  758. });
  759. if (storageConfig.authMechanism) {
  760. selectAuthMechanism.val(storageConfig.authMechanism);
  761. } else {
  762. storageConfig.authMechanism = selectAuthMechanism.val();
  763. }
  764. $tr.find('td.authentication').append(selectAuthMechanism);
  765. var $td = $tr.find('td.configuration');
  766. $.each(backend.configuration, _.partial(this.writeParameterInput, $td).bind(this));
  767. this.trigger('selectBackend', $tr, backend.identifier, onCompletion);
  768. this.configureAuthMechanism($tr, storageConfig.authMechanism, onCompletion);
  769. if (storageConfig.backendOptions) {
  770. $td.find('input, select').each(function() {
  771. var input = $(this);
  772. var val = storageConfig.backendOptions[input.data('parameter')];
  773. if (val !== undefined) {
  774. if(input.is('input:checkbox')) {
  775. input.prop('checked', val);
  776. }
  777. input.val(storageConfig.backendOptions[input.data('parameter')]);
  778. highlightInput(input);
  779. }
  780. });
  781. }
  782. var applicable = [];
  783. if (storageConfig.applicableUsers) {
  784. applicable = applicable.concat(storageConfig.applicableUsers);
  785. }
  786. if (storageConfig.applicableGroups) {
  787. applicable = applicable.concat(
  788. _.map(storageConfig.applicableGroups, function(group) {
  789. return group+'(group)';
  790. })
  791. );
  792. }
  793. $tr.find('.applicableUsers').val(applicable).trigger('change');
  794. var priorityEl = $('<input type="hidden" class="priority" value="' + backend.priority + '" />');
  795. $tr.append(priorityEl);
  796. if (storageConfig.mountOptions) {
  797. $tr.find('input.mountOptions').val(JSON.stringify(storageConfig.mountOptions));
  798. } else {
  799. // FIXME default backend mount options
  800. $tr.find('input.mountOptions').val(JSON.stringify({
  801. 'encrypt': true,
  802. 'previews': true,
  803. 'enable_sharing': false,
  804. 'filesystem_check_changes': 1,
  805. 'encoding_compatibility': false
  806. }));
  807. }
  808. return $tr;
  809. },
  810. /**
  811. * Load storages into config rows
  812. */
  813. loadStorages: function() {
  814. var self = this;
  815. if (this._isPersonal) {
  816. // load userglobal storages
  817. $.ajax({
  818. type: 'GET',
  819. url: OC.generateUrl('apps/files_external/userglobalstorages'),
  820. data: {'testOnly' : true},
  821. contentType: 'application/json',
  822. success: function(result) {
  823. var onCompletion = jQuery.Deferred();
  824. $.each(result, function(i, storageParams) {
  825. var storageConfig;
  826. var isUserGlobal = storageParams.type === 'system' && self._isPersonal;
  827. storageParams.mountPoint = storageParams.mountPoint.substr(1); // trim leading slash
  828. if (isUserGlobal) {
  829. storageConfig = new UserGlobalStorageConfig();
  830. } else {
  831. storageConfig = new self._storageConfigClass();
  832. }
  833. _.extend(storageConfig, storageParams);
  834. var $tr = self.newStorage(storageConfig, onCompletion);
  835. // userglobal storages must be at the top of the list
  836. $tr.detach();
  837. self.$el.prepend($tr);
  838. var $authentication = $tr.find('.authentication');
  839. $authentication.text($authentication.find('select option:selected').text());
  840. // disable any other inputs
  841. $tr.find('.mountOptionsToggle, .remove').empty();
  842. $tr.find('input:not(.user_provided), select:not(.user_provided)').attr('disabled', 'disabled');
  843. if (isUserGlobal) {
  844. $tr.find('.configuration').find(':not(.user_provided)').remove();
  845. } else {
  846. // userglobal storages do not expose configuration data
  847. $tr.find('.configuration').text(t('files_external', 'Admin defined'));
  848. }
  849. });
  850. var mainForm = $('#files_external');
  851. if (result.length === 0 && mainForm.attr('data-can-create') === 'false') {
  852. mainForm.hide();
  853. $('a[href="#external-storage"]').parent().hide();
  854. }
  855. onCompletion.resolve();
  856. }
  857. });
  858. }
  859. var url = this._storageConfigClass.prototype._url;
  860. $.ajax({
  861. type: 'GET',
  862. url: OC.generateUrl(url),
  863. contentType: 'application/json',
  864. success: function(result) {
  865. var onCompletion = jQuery.Deferred();
  866. $.each(result, function(i, storageParams) {
  867. storageParams.mountPoint = storageParams.mountPoint.substr(1); // trim leading slash
  868. var storageConfig = new self._storageConfigClass();
  869. _.extend(storageConfig, storageParams);
  870. var $tr = self.newStorage(storageConfig, onCompletion);
  871. self.recheckStorageConfig($tr);
  872. });
  873. onCompletion.resolve();
  874. }
  875. });
  876. },
  877. /**
  878. * @param {jQuery} $td
  879. * @param {string} parameter
  880. * @param {string} placeholder
  881. * @param {Array} classes
  882. * @return {jQuery} newly created input
  883. */
  884. writeParameterInput: function($td, parameter, placeholder, classes) {
  885. var hasFlag = function(flag) {
  886. return (placeholder.flags & flag) === flag;
  887. };
  888. classes = $.isArray(classes) ? classes : [];
  889. classes.push('added');
  890. if (hasFlag(MountConfigListView.ParameterFlags.OPTIONAL)) {
  891. classes.push('optional');
  892. }
  893. if (hasFlag(MountConfigListView.ParameterFlags.USER_PROVIDED)) {
  894. if (this._isPersonal) {
  895. classes.push('user_provided');
  896. } else {
  897. return;
  898. }
  899. }
  900. var newElement;
  901. var trimmedPlaceholder = placeholder.value;
  902. if (placeholder.type === MountConfigListView.ParameterTypes.PASSWORD) {
  903. newElement = $('<input type="password" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" />');
  904. } else if (placeholder.type === MountConfigListView.ParameterTypes.BOOLEAN) {
  905. var checkboxId = _.uniqueId('checkbox_');
  906. newElement = $('<div><label><input type="checkbox" id="'+checkboxId+'" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" />'+ trimmedPlaceholder+'</label></div>');
  907. } else if (placeholder.type === MountConfigListView.ParameterTypes.HIDDEN) {
  908. newElement = $('<input type="hidden" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" />');
  909. } else {
  910. newElement = $('<input type="text" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" />');
  911. }
  912. highlightInput(newElement);
  913. $td.append(newElement);
  914. return newElement;
  915. },
  916. /**
  917. * Gets the storage model from the given row
  918. *
  919. * @param $tr row element
  920. * @return {OCA.External.StorageConfig} storage model instance
  921. */
  922. getStorageConfig: function($tr) {
  923. var storageId = $tr.data('id');
  924. if (!storageId) {
  925. // new entry
  926. storageId = null;
  927. }
  928. var storage = $tr.data('storageConfig');
  929. if (!storage) {
  930. storage = new this._storageConfigClass(storageId);
  931. }
  932. storage.errors = null;
  933. storage.mountPoint = $tr.find('.mountPoint input').val();
  934. storage.backend = $tr.find('.backend').data('identifier');
  935. storage.authMechanism = $tr.find('.selectAuthMechanism').val();
  936. var classOptions = {};
  937. var configuration = $tr.find('.configuration input');
  938. var missingOptions = [];
  939. $.each(configuration, function(index, input) {
  940. var $input = $(input);
  941. var parameter = $input.data('parameter');
  942. if ($input.attr('type') === 'button') {
  943. return;
  944. }
  945. if (!isInputValid($input) && !$input.hasClass('optional')) {
  946. missingOptions.push(parameter);
  947. return;
  948. }
  949. if ($(input).is(':checkbox')) {
  950. if ($(input).is(':checked')) {
  951. classOptions[parameter] = true;
  952. } else {
  953. classOptions[parameter] = false;
  954. }
  955. } else {
  956. classOptions[parameter] = $(input).val();
  957. }
  958. });
  959. storage.backendOptions = classOptions;
  960. if (missingOptions.length) {
  961. storage.errors = {
  962. backendOptions: missingOptions
  963. };
  964. }
  965. // gather selected users and groups
  966. if (!this._isPersonal) {
  967. var groups = [];
  968. var users = [];
  969. var multiselect = getSelection($tr);
  970. $.each(multiselect, function(index, value) {
  971. var pos = (value.indexOf)?value.indexOf('(group)'): -1;
  972. if (pos !== -1) {
  973. groups.push(value.substr(0, pos));
  974. } else {
  975. users.push(value);
  976. }
  977. });
  978. // FIXME: this should be done in the multiselect change event instead
  979. $tr.find('.applicable')
  980. .data('applicable-groups', groups)
  981. .data('applicable-users', users);
  982. storage.applicableUsers = users;
  983. storage.applicableGroups = groups;
  984. storage.priority = parseInt($tr.find('input.priority').val() || '100', 10);
  985. }
  986. var mountOptions = $tr.find('input.mountOptions').val();
  987. if (mountOptions) {
  988. storage.mountOptions = JSON.parse(mountOptions);
  989. }
  990. return storage;
  991. },
  992. /**
  993. * Deletes the storage from the given tr
  994. *
  995. * @param $tr storage row
  996. * @param Function callback callback to call after save
  997. */
  998. deleteStorageConfig: function($tr) {
  999. var self = this;
  1000. var configId = $tr.data('id');
  1001. if (!_.isNumber(configId)) {
  1002. // deleting unsaved storage
  1003. $tr.remove();
  1004. return;
  1005. }
  1006. var storage = new this._storageConfigClass(configId);
  1007. this.updateStatus($tr, StorageConfig.Status.IN_PROGRESS);
  1008. storage.destroy({
  1009. success: function() {
  1010. $tr.remove();
  1011. },
  1012. error: function() {
  1013. self.updateStatus($tr, StorageConfig.Status.ERROR);
  1014. }
  1015. });
  1016. },
  1017. /**
  1018. * Saves the storage from the given tr
  1019. *
  1020. * @param $tr storage row
  1021. * @param Function callback callback to call after save
  1022. * @param concurrentTimer only update if the timer matches this
  1023. */
  1024. saveStorageConfig:function($tr, callback, concurrentTimer) {
  1025. var self = this;
  1026. var storage = this.getStorageConfig($tr);
  1027. if (!storage || !storage.validate()) {
  1028. return false;
  1029. }
  1030. this.updateStatus($tr, StorageConfig.Status.IN_PROGRESS);
  1031. storage.save({
  1032. success: function(result) {
  1033. if (concurrentTimer === undefined
  1034. || $tr.data('save-timer') === concurrentTimer
  1035. ) {
  1036. self.updateStatus($tr, result.status);
  1037. $tr.data('id', result.id);
  1038. if (_.isFunction(callback)) {
  1039. callback(storage);
  1040. }
  1041. }
  1042. },
  1043. error: function() {
  1044. if (concurrentTimer === undefined
  1045. || $tr.data('save-timer') === concurrentTimer
  1046. ) {
  1047. self.updateStatus($tr, StorageConfig.Status.ERROR);
  1048. }
  1049. }
  1050. });
  1051. },
  1052. /**
  1053. * Recheck storage availability
  1054. *
  1055. * @param {jQuery} $tr storage row
  1056. * @return {boolean} success
  1057. */
  1058. recheckStorageConfig: function($tr) {
  1059. var self = this;
  1060. var storage = this.getStorageConfig($tr);
  1061. if (!storage.validate()) {
  1062. return false;
  1063. }
  1064. this.updateStatus($tr, StorageConfig.Status.IN_PROGRESS);
  1065. storage.recheck({
  1066. success: function(result) {
  1067. self.updateStatus($tr, result.status, result.statusMessage);
  1068. },
  1069. error: function() {
  1070. self.updateStatus($tr, StorageConfig.Status.ERROR);
  1071. }
  1072. });
  1073. },
  1074. /**
  1075. * Update status display
  1076. *
  1077. * @param {jQuery} $tr
  1078. * @param {int} status
  1079. * @param {string} message
  1080. */
  1081. updateStatus: function($tr, status, message) {
  1082. var $statusSpan = $tr.find('.status span');
  1083. $statusSpan.removeClass('loading-small success indeterminate error');
  1084. switch (status) {
  1085. case null:
  1086. // remove status
  1087. break;
  1088. case StorageConfig.Status.IN_PROGRESS:
  1089. $statusSpan.addClass('loading-small');
  1090. break;
  1091. case StorageConfig.Status.SUCCESS:
  1092. $statusSpan.addClass('success');
  1093. break;
  1094. case StorageConfig.Status.INDETERMINATE:
  1095. $statusSpan.addClass('indeterminate');
  1096. break;
  1097. default:
  1098. $statusSpan.addClass('error');
  1099. }
  1100. $statusSpan.attr('data-original-title', (typeof message === 'string') ? message : '');
  1101. },
  1102. /**
  1103. * Suggest mount point name that doesn't conflict with the existing names in the list
  1104. *
  1105. * @param {string} defaultMountPoint default name
  1106. */
  1107. _suggestMountPoint: function(defaultMountPoint) {
  1108. var $el = this.$el;
  1109. var pos = defaultMountPoint.indexOf('/');
  1110. if (pos !== -1) {
  1111. defaultMountPoint = defaultMountPoint.substring(0, pos);
  1112. }
  1113. defaultMountPoint = defaultMountPoint.replace(/\s+/g, '');
  1114. var i = 1;
  1115. var append = '';
  1116. var match = true;
  1117. while (match && i < 20) {
  1118. match = false;
  1119. $el.find('tbody td.mountPoint input').each(function(index, mountPoint) {
  1120. if ($(mountPoint).val() === defaultMountPoint+append) {
  1121. match = true;
  1122. return false;
  1123. }
  1124. });
  1125. if (match) {
  1126. append = i;
  1127. i++;
  1128. } else {
  1129. break;
  1130. }
  1131. }
  1132. return defaultMountPoint + append;
  1133. },
  1134. /**
  1135. * Toggles the mount options dropdown
  1136. *
  1137. * @param {Object} $tr configuration row
  1138. */
  1139. _showMountOptionsDropdown: function($tr) {
  1140. if (this._preventNextDropdown) {
  1141. // prevented because the click was on the toggle
  1142. this._preventNextDropdown = false;
  1143. return;
  1144. }
  1145. var self = this;
  1146. var storage = this.getStorageConfig($tr);
  1147. var $toggle = $tr.find('.mountOptionsToggle');
  1148. var dropDown = new MountOptionsDropdown();
  1149. var visibleOptions = [
  1150. 'previews',
  1151. 'filesystem_check_changes',
  1152. 'enable_sharing',
  1153. 'encoding_compatibility'
  1154. ];
  1155. if (this._encryptionEnabled) {
  1156. visibleOptions.push('encrypt');
  1157. }
  1158. dropDown.show($toggle, storage.mountOptions || [], visibleOptions);
  1159. $('body').on('mouseup.mountOptionsDropdown', function(event) {
  1160. var $target = $(event.target);
  1161. if ($toggle.has($target).length) {
  1162. // why is it always so hard to make dropdowns behave ?
  1163. // this prevents the click on the toggle to cause
  1164. // the dropdown to reopen itself
  1165. // (preventDefault doesn't work here because the click
  1166. // event is already in the queue and cannot be cancelled)
  1167. self._preventNextDropdown = true;
  1168. }
  1169. if ($target.closest('.dropdown').length) {
  1170. return;
  1171. }
  1172. dropDown.hide();
  1173. });
  1174. dropDown.$el.on('hide', function() {
  1175. var mountOptions = dropDown.getOptions();
  1176. $('body').off('mouseup.mountOptionsDropdown');
  1177. $tr.find('input.mountOptions').val(JSON.stringify(mountOptions));
  1178. self.saveStorageConfig($tr);
  1179. });
  1180. }
  1181. }, OC.Backbone.Events);
  1182. $(document).ready(function() {
  1183. var enabled = $('#files_external').attr('data-encryption-enabled');
  1184. var encryptionEnabled = (enabled ==='true')? true: false;
  1185. var mountConfigListView = new MountConfigListView($('#externalStorage'), {
  1186. encryptionEnabled: encryptionEnabled
  1187. });
  1188. mountConfigListView.loadStorages();
  1189. // TODO: move this into its own View class
  1190. var $allowUserMounting = $('#allowUserMounting');
  1191. $allowUserMounting.bind('change', function() {
  1192. OC.msg.startSaving('#userMountingMsg');
  1193. if (this.checked) {
  1194. OCP.AppConfig.setValue('files_external', 'allow_user_mounting', 'yes');
  1195. $('input[name="allowUserMountingBackends\\[\\]"]').prop('checked', true);
  1196. $('#userMountingBackends').removeClass('hidden');
  1197. $('input[name="allowUserMountingBackends\\[\\]"]').eq(0).trigger('change');
  1198. } else {
  1199. OCP.AppConfig.setValue('files_external', 'allow_user_mounting', 'no');
  1200. $('#userMountingBackends').addClass('hidden');
  1201. }
  1202. OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('files_external', 'Saved')}});
  1203. });
  1204. $('input[name="allowUserMountingBackends\\[\\]"]').bind('change', function() {
  1205. OC.msg.startSaving('#userMountingMsg');
  1206. var userMountingBackends = $('input[name="allowUserMountingBackends\\[\\]"]:checked').map(function(){
  1207. return $(this).val();
  1208. }).get();
  1209. var deprecatedBackends = $('input[name="allowUserMountingBackends\\[\\]"][data-deprecate-to]').map(function(){
  1210. if ($.inArray($(this).data('deprecate-to'), userMountingBackends) !== -1) {
  1211. return $(this).val();
  1212. }
  1213. return null;
  1214. }).get();
  1215. userMountingBackends = userMountingBackends.concat(deprecatedBackends);
  1216. OCP.AppConfig.setValue('files_external', 'user_mounting_backends', userMountingBackends.join());
  1217. OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('files_external', 'Saved')}});
  1218. // disable allowUserMounting
  1219. if(userMountingBackends.length === 0) {
  1220. $allowUserMounting.prop('checked', false);
  1221. $allowUserMounting.trigger('change');
  1222. }
  1223. });
  1224. $('#global_credentials').on('submit', function() {
  1225. var $form = $(this);
  1226. var uid = $form.find('[name=uid]').val();
  1227. var user = $form.find('[name=username]').val();
  1228. var password = $form.find('[name=password]').val();
  1229. var $submit = $form.find('[type=submit]');
  1230. $submit.val(t('files_external', 'Saving...'));
  1231. $.ajax({
  1232. type: 'POST',
  1233. contentType: 'application/json',
  1234. data: JSON.stringify({
  1235. uid: uid,
  1236. user: user,
  1237. password: password
  1238. }),
  1239. url: OC.generateUrl('apps/files_external/globalcredentials'),
  1240. dataType: 'json',
  1241. success: function() {
  1242. $submit.val(t('files_external', 'Saved'));
  1243. setTimeout(function(){
  1244. $submit.val(t('files_external', 'Save'));
  1245. }, 2500);
  1246. }
  1247. });
  1248. return false;
  1249. });
  1250. // global instance
  1251. OCA.External.Settings.mountConfig = mountConfigListView;
  1252. /**
  1253. * Legacy
  1254. *
  1255. * @namespace
  1256. * @deprecated use OCA.External.Settings.mountConfig instead
  1257. */
  1258. OC.MountConfig = {
  1259. saveStorage: _.bind(mountConfigListView.saveStorageConfig, mountConfigListView)
  1260. };
  1261. });
  1262. // export
  1263. OCA.External = OCA.External || {};
  1264. /**
  1265. * @namespace
  1266. */
  1267. OCA.External.Settings = OCA.External.Settings || {};
  1268. OCA.External.Settings.GlobalStorageConfig = GlobalStorageConfig;
  1269. OCA.External.Settings.UserStorageConfig = UserStorageConfig;
  1270. OCA.External.Settings.MountConfigListView = MountConfigListView;
  1271. })();