You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

settings.js 37KB

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