settings.js 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394
  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" checked="checked"/>' +
  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>';
  35. /* TODO the current l10n extrator can't handle JS functions within handlebar
  36. templates therefore they are duplicated here
  37. t("files_external", "Enable encryption")
  38. t("files_external", "Enable previews")
  39. t("files_external", "Enable sharing")
  40. t("files_external", "Check for changes")
  41. t("files_external", "Never")
  42. t("files_external", "Once every direct access")
  43. */
  44. /**
  45. * Returns the selection of applicable users in the given configuration row
  46. *
  47. * @param $row configuration row
  48. * @return array array of user names
  49. */
  50. function getSelection($row) {
  51. var values = $row.find('.applicableUsers').select2('val');
  52. if (!values || values.length === 0) {
  53. values = [];
  54. }
  55. return values;
  56. }
  57. function highlightBorder($element, highlight) {
  58. $element.toggleClass('warning-input', highlight);
  59. return highlight;
  60. }
  61. function isInputValid($input) {
  62. var optional = $input.hasClass('optional');
  63. switch ($input.attr('type')) {
  64. case 'text':
  65. case 'password':
  66. if ($input.val() === '' && !optional) {
  67. return false;
  68. }
  69. break;
  70. }
  71. return true;
  72. }
  73. function highlightInput($input) {
  74. switch ($input.attr('type')) {
  75. case 'text':
  76. case 'password':
  77. return highlightBorder($input, !isInputValid($input));
  78. }
  79. }
  80. /**
  81. * Initialize select2 plugin on the given elements
  82. *
  83. * @param {Array<Object>} array of jQuery elements
  84. * @param {int} userListLimit page size for result list
  85. */
  86. function addSelect2 ($elements, userListLimit) {
  87. if (!$elements.length) {
  88. return;
  89. }
  90. $elements.select2({
  91. placeholder: t('files_external', 'All users. Type to select user or group.'),
  92. allowClear: true,
  93. multiple: true,
  94. //minimumInputLength: 1,
  95. ajax: {
  96. url: OC.generateUrl('apps/files_external/applicable'),
  97. dataType: 'json',
  98. quietMillis: 100,
  99. data: function (term, page) { // page is the one-based page number tracked by Select2
  100. return {
  101. pattern: term, //search term
  102. limit: userListLimit, // page size
  103. offset: userListLimit*(page-1) // page number starts with 0
  104. };
  105. },
  106. results: function (data) {
  107. if (data.status === 'success') {
  108. var results = [];
  109. var userCount = 0; // users is an object
  110. // add groups
  111. $.each(data.groups, function(i, group) {
  112. results.push({name:group+'(group)', displayname:group, type:'group' });
  113. });
  114. // add users
  115. $.each(data.users, function(id, user) {
  116. userCount++;
  117. results.push({name:id, displayname:user, type:'user' });
  118. });
  119. var more = (userCount >= userListLimit) || (data.groups.length >= userListLimit);
  120. return {results: results, more: more};
  121. } else {
  122. //FIXME add error handling
  123. }
  124. }
  125. },
  126. initSelection: function(element, callback) {
  127. var users = {};
  128. users['users'] = [];
  129. var toSplit = element.val().split(",");
  130. for (var i = 0; i < toSplit.length; i++) {
  131. users['users'].push(toSplit[i]);
  132. }
  133. $.ajax(OC.generateUrl('displaynames'), {
  134. type: 'POST',
  135. contentType: 'application/json',
  136. data: JSON.stringify(users),
  137. dataType: 'json'
  138. }).done(function(data) {
  139. var results = [];
  140. if (data.status === 'success') {
  141. $.each(data.users, function(user, displayname) {
  142. if (displayname !== false) {
  143. results.push({name:user, displayname:displayname, type:'user'});
  144. }
  145. });
  146. callback(results);
  147. } else {
  148. //FIXME add error handling
  149. }
  150. });
  151. },
  152. id: function(element) {
  153. return element.name;
  154. },
  155. formatResult: function (element) {
  156. var $result = $('<span><div class="avatardiv"/><span>'+escapeHTML(element.displayname)+'</span></span>');
  157. var $div = $result.find('.avatardiv')
  158. .attr('data-type', element.type)
  159. .attr('data-name', element.name)
  160. .attr('data-displayname', element.displayname);
  161. if (element.type === 'group') {
  162. var url = OC.imagePath('core','places/contacts-dark'); // TODO better group icon
  163. $div.html('<img width="32" height="32" src="'+url+'">');
  164. }
  165. return $result.get(0).outerHTML;
  166. },
  167. formatSelection: function (element) {
  168. if (element.type === 'group') {
  169. return '<span title="'+escapeHTML(element.name)+'" class="group">'+escapeHTML(element.displayname+' '+t('files_external', '(group)'))+'</span>';
  170. } else {
  171. return '<span title="'+escapeHTML(element.name)+'" class="user">'+escapeHTML(element.displayname)+'</span>';
  172. }
  173. },
  174. escapeMarkup: function (m) { return m; } // we escape the markup in formatResult and formatSelection
  175. }).on('select2-loaded', function() {
  176. $.each($('.avatardiv'), function(i, div) {
  177. var $div = $(div);
  178. if ($div.data('type') === 'user') {
  179. $div.avatar($div.data('name'),32);
  180. }
  181. });
  182. });
  183. }
  184. /**
  185. * @class OCA.External.Settings.StorageConfig
  186. *
  187. * @classdesc External storage config
  188. */
  189. var StorageConfig = function(id) {
  190. this.id = id;
  191. this.backendOptions = {};
  192. };
  193. // Keep this in sync with \OC_Mount_Config::STATUS_*
  194. StorageConfig.Status = {
  195. IN_PROGRESS: -1,
  196. SUCCESS: 0,
  197. ERROR: 1,
  198. INDETERMINATE: 2
  199. };
  200. StorageConfig.Visibility = {
  201. NONE: 0,
  202. PERSONAL: 1,
  203. ADMIN: 2,
  204. DEFAULT: 3
  205. };
  206. /**
  207. * @memberof OCA.External.Settings
  208. */
  209. StorageConfig.prototype = {
  210. _url: null,
  211. /**
  212. * Storage id
  213. *
  214. * @type int
  215. */
  216. id: null,
  217. /**
  218. * Mount point
  219. *
  220. * @type string
  221. */
  222. mountPoint: '',
  223. /**
  224. * Backend
  225. *
  226. * @type string
  227. */
  228. backend: null,
  229. /**
  230. * Authentication mechanism
  231. *
  232. * @type string
  233. */
  234. authMechanism: null,
  235. /**
  236. * Backend-specific configuration
  237. *
  238. * @type Object.<string,object>
  239. */
  240. backendOptions: null,
  241. /**
  242. * Mount-specific options
  243. *
  244. * @type Object.<string,object>
  245. */
  246. mountOptions: null,
  247. /**
  248. * Creates or saves the storage.
  249. *
  250. * @param {Function} [options.success] success callback, receives result as argument
  251. * @param {Function} [options.error] error callback
  252. */
  253. save: function(options) {
  254. var self = this;
  255. var url = OC.generateUrl(this._url);
  256. var method = 'POST';
  257. if (_.isNumber(this.id)) {
  258. method = 'PUT';
  259. url = OC.generateUrl(this._url + '/{id}', {id: this.id});
  260. }
  261. $.ajax({
  262. type: method,
  263. url: url,
  264. contentType: 'application/json',
  265. data: JSON.stringify(this.getData()),
  266. success: function(result) {
  267. self.id = result.id;
  268. if (_.isFunction(options.success)) {
  269. options.success(result);
  270. }
  271. },
  272. error: options.error
  273. });
  274. },
  275. /**
  276. * Returns the data from this object
  277. *
  278. * @return {Array} JSON array of the data
  279. */
  280. getData: function() {
  281. var data = {
  282. mountPoint: this.mountPoint,
  283. backend: this.backend,
  284. authMechanism: this.authMechanism,
  285. backendOptions: this.backendOptions
  286. };
  287. if (this.id) {
  288. data.id = this.id;
  289. }
  290. if (this.mountOptions) {
  291. data.mountOptions = this.mountOptions;
  292. }
  293. return data;
  294. },
  295. /**
  296. * Recheck the storage
  297. *
  298. * @param {Function} [options.success] success callback, receives result as argument
  299. * @param {Function} [options.error] error callback
  300. */
  301. recheck: function(options) {
  302. if (!_.isNumber(this.id)) {
  303. if (_.isFunction(options.error)) {
  304. options.error();
  305. }
  306. return;
  307. }
  308. $.ajax({
  309. type: 'GET',
  310. url: OC.generateUrl(this._url + '/{id}', {id: this.id}),
  311. success: options.success,
  312. error: options.error
  313. });
  314. },
  315. /**
  316. * Deletes the storage
  317. *
  318. * @param {Function} [options.success] success callback
  319. * @param {Function} [options.error] error callback
  320. */
  321. destroy: function(options) {
  322. if (!_.isNumber(this.id)) {
  323. // the storage hasn't even been created => success
  324. if (_.isFunction(options.success)) {
  325. options.success();
  326. }
  327. return;
  328. }
  329. $.ajax({
  330. type: 'DELETE',
  331. url: OC.generateUrl(this._url + '/{id}', {id: this.id}),
  332. success: options.success,
  333. error: options.error
  334. });
  335. },
  336. /**
  337. * Validate this model
  338. *
  339. * @return {boolean} false if errors exist, true otherwise
  340. */
  341. validate: function() {
  342. if (this.mountPoint === '') {
  343. return false;
  344. }
  345. if (!this.backend) {
  346. return false;
  347. }
  348. if (this.errors) {
  349. return false;
  350. }
  351. return true;
  352. }
  353. };
  354. /**
  355. * @class OCA.External.Settings.GlobalStorageConfig
  356. * @augments OCA.External.Settings.StorageConfig
  357. *
  358. * @classdesc Global external storage config
  359. */
  360. var GlobalStorageConfig = function(id) {
  361. this.id = id;
  362. this.applicableUsers = [];
  363. this.applicableGroups = [];
  364. };
  365. /**
  366. * @memberOf OCA.External.Settings
  367. */
  368. GlobalStorageConfig.prototype = _.extend({}, StorageConfig.prototype,
  369. /** @lends OCA.External.Settings.GlobalStorageConfig.prototype */ {
  370. _url: 'apps/files_external/globalstorages',
  371. /**
  372. * Applicable users
  373. *
  374. * @type Array.<string>
  375. */
  376. applicableUsers: null,
  377. /**
  378. * Applicable groups
  379. *
  380. * @type Array.<string>
  381. */
  382. applicableGroups: null,
  383. /**
  384. * Storage priority
  385. *
  386. * @type int
  387. */
  388. priority: null,
  389. /**
  390. * Returns the data from this object
  391. *
  392. * @return {Array} JSON array of the data
  393. */
  394. getData: function() {
  395. var data = StorageConfig.prototype.getData.apply(this, arguments);
  396. return _.extend(data, {
  397. applicableUsers: this.applicableUsers,
  398. applicableGroups: this.applicableGroups,
  399. priority: this.priority,
  400. });
  401. }
  402. });
  403. /**
  404. * @class OCA.External.Settings.UserStorageConfig
  405. * @augments OCA.External.Settings.StorageConfig
  406. *
  407. * @classdesc User external storage config
  408. */
  409. var UserStorageConfig = function(id) {
  410. this.id = id;
  411. };
  412. UserStorageConfig.prototype = _.extend({}, StorageConfig.prototype,
  413. /** @lends OCA.External.Settings.UserStorageConfig.prototype */ {
  414. _url: 'apps/files_external/userstorages'
  415. });
  416. /**
  417. * @class OCA.External.Settings.UserGlobalStorageConfig
  418. * @augments OCA.External.Settings.StorageConfig
  419. *
  420. * @classdesc User external storage config
  421. */
  422. var UserGlobalStorageConfig = function (id) {
  423. this.id = id;
  424. };
  425. UserGlobalStorageConfig.prototype = _.extend({}, StorageConfig.prototype,
  426. /** @lends OCA.External.Settings.UserStorageConfig.prototype */ {
  427. _url: 'apps/files_external/userglobalstorages'
  428. });
  429. /**
  430. * @class OCA.External.Settings.MountOptionsDropdown
  431. *
  432. * @classdesc Dropdown for mount options
  433. *
  434. * @param {Object} $container container DOM object
  435. */
  436. var MountOptionsDropdown = function() {
  437. };
  438. /**
  439. * @memberof OCA.External.Settings
  440. */
  441. MountOptionsDropdown.prototype = {
  442. /**
  443. * Dropdown element
  444. *
  445. * @var Object
  446. */
  447. $el: null,
  448. /**
  449. * Show dropdown
  450. *
  451. * @param {Object} $container container
  452. * @param {Object} mountOptions mount options
  453. * @param {Array} enabledOptions enabled mount options
  454. */
  455. show: function($container, mountOptions, enabledOptions) {
  456. if (MountOptionsDropdown._last) {
  457. MountOptionsDropdown._last.hide();
  458. }
  459. var template = MountOptionsDropdown._template;
  460. if (!template) {
  461. template = Handlebars.compile(MOUNT_OPTIONS_DROPDOWN_TEMPLATE);
  462. MountOptionsDropdown._template = template;
  463. }
  464. var $el = $(template());
  465. this.$el = $el;
  466. this.setOptions(mountOptions, enabledOptions);
  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} enabledOptions enabled mount options
  507. */
  508. setOptions: function(options, enabledOptions) {
  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 (enabledOptions.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.find('td').last().attr('class', 'remove');
  734. $tr.find('td.mountOptionsToggle').removeClass('hidden');
  735. $tr.find('td').last().removeAttr('style');
  736. $tr.removeAttr('id');
  737. $tr.find('select#selectBackend');
  738. addSelect2($tr.find('.applicableUsers'), this._userListLimit);
  739. if (storageConfig.id) {
  740. $tr.data('id', storageConfig.id);
  741. }
  742. $tr.find('.backend').text(backend.name);
  743. if (mountPoint === '') {
  744. mountPoint = this._suggestMountPoint(backend.name);
  745. }
  746. $tr.find('.mountPoint input').val(mountPoint);
  747. $tr.addClass(backend.identifier);
  748. $tr.find('.backend').data('identifier', backend.identifier);
  749. var selectAuthMechanism = $('<select class="selectAuthMechanism"></select>');
  750. var neededVisibility = (this._isPersonal) ? StorageConfig.Visibility.PERSONAL : StorageConfig.Visibility.ADMIN;
  751. $.each(this._allAuthMechanisms, function(authIdentifier, authMechanism) {
  752. if (backend.authSchemes[authMechanism.scheme] && (authMechanism.visibility & neededVisibility)) {
  753. selectAuthMechanism.append(
  754. $('<option value="'+authMechanism.identifier+'" data-scheme="'+authMechanism.scheme+'">'+authMechanism.name+'</option>')
  755. );
  756. }
  757. });
  758. if (storageConfig.authMechanism) {
  759. selectAuthMechanism.val(storageConfig.authMechanism);
  760. } else {
  761. storageConfig.authMechanism = selectAuthMechanism.val();
  762. }
  763. $tr.find('td.authentication').append(selectAuthMechanism);
  764. var $td = $tr.find('td.configuration');
  765. $.each(backend.configuration, _.partial(this.writeParameterInput, $td).bind(this));
  766. this.trigger('selectBackend', $tr, backend.identifier, onCompletion);
  767. this.configureAuthMechanism($tr, storageConfig.authMechanism, onCompletion);
  768. if (storageConfig.backendOptions) {
  769. $td.children().each(function() {
  770. var input = $(this);
  771. var val = storageConfig.backendOptions[input.data('parameter')];
  772. if (val !== undefined) {
  773. input.val(storageConfig.backendOptions[input.data('parameter')]);
  774. highlightInput(input);
  775. }
  776. });
  777. }
  778. var applicable = [];
  779. if (storageConfig.applicableUsers) {
  780. applicable = applicable.concat(storageConfig.applicableUsers);
  781. }
  782. if (storageConfig.applicableGroups) {
  783. applicable = applicable.concat(
  784. _.map(storageConfig.applicableGroups, function(group) {
  785. return group+'(group)';
  786. })
  787. );
  788. }
  789. $tr.find('.applicableUsers').val(applicable).trigger('change');
  790. var priorityEl = $('<input type="hidden" class="priority" value="' + backend.priority + '" />');
  791. $tr.append(priorityEl);
  792. if (storageConfig.mountOptions) {
  793. $tr.find('input.mountOptions').val(JSON.stringify(storageConfig.mountOptions));
  794. } else {
  795. // FIXME default backend mount options
  796. $tr.find('input.mountOptions').val(JSON.stringify({
  797. 'encrypt': true,
  798. 'previews': true,
  799. 'enable_sharing': true,
  800. 'filesystem_check_changes': 1
  801. }));
  802. }
  803. return $tr;
  804. },
  805. /**
  806. * Load storages into config rows
  807. */
  808. loadStorages: function() {
  809. var self = this;
  810. if (this._isPersonal) {
  811. // load userglobal storages
  812. $.ajax({
  813. type: 'GET',
  814. url: OC.generateUrl('apps/files_external/userglobalstorages'),
  815. contentType: 'application/json',
  816. success: function(result) {
  817. var onCompletion = jQuery.Deferred();
  818. $.each(result, function(i, storageParams) {
  819. var storageConfig;
  820. var isUserGlobal = storageParams.type === 'system' && self._isPersonal;
  821. storageParams.mountPoint = storageParams.mountPoint.substr(1); // trim leading slash
  822. if (isUserGlobal) {
  823. storageConfig = new UserGlobalStorageConfig();
  824. } else {
  825. storageConfig = new self._storageConfigClass();
  826. }
  827. _.extend(storageConfig, storageParams);
  828. var $tr = self.newStorage(storageConfig, onCompletion);
  829. // userglobal storages must be at the top of the list
  830. $tr.detach();
  831. self.$el.prepend($tr);
  832. var $authentication = $tr.find('.authentication');
  833. $authentication.text($authentication.find('select option:selected').text());
  834. // disable any other inputs
  835. $tr.find('.mountOptionsToggle, .remove').empty();
  836. $tr.find('input:not(.user_provided), select:not(.user_provided)').attr('disabled', 'disabled');
  837. if (isUserGlobal) {
  838. $tr.find('.configuration').find(':not(.user_provided)').remove();
  839. } else {
  840. // userglobal storages do not expose configuration data
  841. $tr.find('.configuration').text(t('files_external', 'Admin defined'));
  842. }
  843. });
  844. onCompletion.resolve();
  845. }
  846. });
  847. }
  848. var url = this._storageConfigClass.prototype._url;
  849. $.ajax({
  850. type: 'GET',
  851. url: OC.generateUrl(url),
  852. contentType: 'application/json',
  853. success: function(result) {
  854. var onCompletion = jQuery.Deferred();
  855. $.each(result, function(i, storageParams) {
  856. storageParams.mountPoint = storageParams.mountPoint.substr(1); // trim leading slash
  857. var storageConfig = new self._storageConfigClass();
  858. _.extend(storageConfig, storageParams);
  859. var $tr = self.newStorage(storageConfig, onCompletion);
  860. self.recheckStorageConfig($tr);
  861. });
  862. onCompletion.resolve();
  863. }
  864. });
  865. },
  866. /**
  867. * @param {jQuery} $td
  868. * @param {string} parameter
  869. * @param {string} placeholder
  870. * @param {Array} classes
  871. * @return {jQuery} newly created input
  872. */
  873. writeParameterInput: function($td, parameter, placeholder, classes) {
  874. var hasFlag = function(flag) {
  875. return (placeholder.flags & flag) === flag;
  876. };
  877. classes = $.isArray(classes) ? classes : [];
  878. classes.push('added');
  879. if (hasFlag(MountConfigListView.ParameterFlags.OPTIONAL)) {
  880. classes.push('optional');
  881. }
  882. if (hasFlag(MountConfigListView.ParameterFlags.USER_PROVIDED)) {
  883. if (this._isPersonal) {
  884. classes.push('user_provided');
  885. } else {
  886. return;
  887. }
  888. }
  889. var newElement;
  890. var trimmedPlaceholder = placeholder.value;
  891. if (placeholder.type === MountConfigListView.ParameterTypes.PASSWORD) {
  892. newElement = $('<input type="password" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" />');
  893. } else if (placeholder.type === MountConfigListView.ParameterTypes.BOOLEAN) {
  894. var checkboxId = _.uniqueId('checkbox_');
  895. newElement = $('<input type="checkbox" id="'+checkboxId+'" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" /><label for="'+checkboxId+'">'+ trimmedPlaceholder+'</label>');
  896. } else if (placeholder.type === MountConfigListView.ParameterTypes.HIDDEN) {
  897. newElement = $('<input type="hidden" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" />');
  898. } else {
  899. newElement = $('<input type="text" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" />');
  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.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. this.updateStatus($tr, StorageConfig.Status.IN_PROGRESS);
  997. storage.destroy({
  998. success: function() {
  999. $tr.remove();
  1000. },
  1001. error: function() {
  1002. self.updateStatus($tr, StorageConfig.Status.ERROR);
  1003. }
  1004. });
  1005. },
  1006. /**
  1007. * Saves the storage from the given tr
  1008. *
  1009. * @param $tr storage row
  1010. * @param Function callback callback to call after save
  1011. * @param concurrentTimer only update if the timer matches this
  1012. */
  1013. saveStorageConfig:function($tr, callback, concurrentTimer) {
  1014. var self = this;
  1015. var storage = this.getStorageConfig($tr);
  1016. if (!storage || !storage.validate()) {
  1017. return false;
  1018. }
  1019. this.updateStatus($tr, StorageConfig.Status.IN_PROGRESS);
  1020. storage.save({
  1021. success: function(result) {
  1022. if (concurrentTimer === undefined
  1023. || $tr.data('save-timer') === concurrentTimer
  1024. ) {
  1025. self.updateStatus($tr, result.status);
  1026. $tr.data('id', result.id);
  1027. if (_.isFunction(callback)) {
  1028. callback(storage);
  1029. }
  1030. }
  1031. },
  1032. error: function() {
  1033. if (concurrentTimer === undefined
  1034. || $tr.data('save-timer') === concurrentTimer
  1035. ) {
  1036. self.updateStatus($tr, StorageConfig.Status.ERROR);
  1037. }
  1038. }
  1039. });
  1040. },
  1041. /**
  1042. * Recheck storage availability
  1043. *
  1044. * @param {jQuery} $tr storage row
  1045. * @return {boolean} success
  1046. */
  1047. recheckStorageConfig: function($tr) {
  1048. var self = this;
  1049. var storage = this.getStorageConfig($tr);
  1050. if (!storage.validate()) {
  1051. return false;
  1052. }
  1053. this.updateStatus($tr, StorageConfig.Status.IN_PROGRESS);
  1054. storage.recheck({
  1055. success: function(result) {
  1056. self.updateStatus($tr, result.status, result.statusMessage);
  1057. },
  1058. error: function() {
  1059. self.updateStatus($tr, StorageConfig.Status.ERROR);
  1060. }
  1061. });
  1062. },
  1063. /**
  1064. * Update status display
  1065. *
  1066. * @param {jQuery} $tr
  1067. * @param {int} status
  1068. * @param {string} message
  1069. */
  1070. updateStatus: function($tr, status, message) {
  1071. var $statusSpan = $tr.find('.status span');
  1072. $statusSpan.removeClass('loading-small success indeterminate error');
  1073. switch (status) {
  1074. case null:
  1075. // remove status
  1076. break;
  1077. case StorageConfig.Status.IN_PROGRESS:
  1078. $statusSpan.addClass('loading-small');
  1079. break;
  1080. case StorageConfig.Status.SUCCESS:
  1081. $statusSpan.addClass('success');
  1082. break;
  1083. case StorageConfig.Status.INDETERMINATE:
  1084. $statusSpan.addClass('indeterminate');
  1085. break;
  1086. default:
  1087. $statusSpan.addClass('error');
  1088. }
  1089. $statusSpan.attr('data-original-title', (typeof message === 'string') ? message : '');
  1090. },
  1091. /**
  1092. * Suggest mount point name that doesn't conflict with the existing names in the list
  1093. *
  1094. * @param {string} defaultMountPoint default name
  1095. */
  1096. _suggestMountPoint: function(defaultMountPoint) {
  1097. var $el = this.$el;
  1098. var pos = defaultMountPoint.indexOf('/');
  1099. if (pos !== -1) {
  1100. defaultMountPoint = defaultMountPoint.substring(0, pos);
  1101. }
  1102. defaultMountPoint = defaultMountPoint.replace(/\s+/g, '');
  1103. var i = 1;
  1104. var append = '';
  1105. var match = true;
  1106. while (match && i < 20) {
  1107. match = false;
  1108. $el.find('tbody td.mountPoint input').each(function(index, mountPoint) {
  1109. if ($(mountPoint).val() === defaultMountPoint+append) {
  1110. match = true;
  1111. return false;
  1112. }
  1113. });
  1114. if (match) {
  1115. append = i;
  1116. i++;
  1117. } else {
  1118. break;
  1119. }
  1120. }
  1121. return defaultMountPoint + append;
  1122. },
  1123. /**
  1124. * Toggles the mount options dropdown
  1125. *
  1126. * @param {Object} $tr configuration row
  1127. */
  1128. _showMountOptionsDropdown: function($tr) {
  1129. if (this._preventNextDropdown) {
  1130. // prevented because the click was on the toggle
  1131. this._preventNextDropdown = false;
  1132. return;
  1133. }
  1134. var self = this;
  1135. var storage = this.getStorageConfig($tr);
  1136. var $toggle = $tr.find('.mountOptionsToggle');
  1137. var dropDown = new MountOptionsDropdown();
  1138. var enabledOptions = ['previews', 'filesystem_check_changes', 'enable_sharing'];
  1139. if (this._encryptionEnabled) {
  1140. enabledOptions.push('encrypt');
  1141. }
  1142. dropDown.show($toggle, storage.mountOptions || [], enabledOptions);
  1143. $('body').on('mouseup.mountOptionsDropdown', function(event) {
  1144. var $target = $(event.target);
  1145. if ($toggle.has($target).length) {
  1146. // why is it always so hard to make dropdowns behave ?
  1147. // this prevents the click on the toggle to cause
  1148. // the dropdown to reopen itself
  1149. // (preventDefault doesn't work here because the click
  1150. // event is already in the queue and cannot be cancelled)
  1151. self._preventNextDropdown = true;
  1152. }
  1153. if ($target.closest('.dropdown').length) {
  1154. return;
  1155. }
  1156. dropDown.hide();
  1157. });
  1158. dropDown.$el.on('hide', function() {
  1159. var mountOptions = dropDown.getOptions();
  1160. $('body').off('mouseup.mountOptionsDropdown');
  1161. $tr.find('input.mountOptions').val(JSON.stringify(mountOptions));
  1162. self.saveStorageConfig($tr);
  1163. });
  1164. }
  1165. }, OC.Backbone.Events);
  1166. $(document).ready(function() {
  1167. var enabled = $('#files_external').attr('data-encryption-enabled');
  1168. var encryptionEnabled = (enabled ==='true')? true: false;
  1169. var mountConfigListView = new MountConfigListView($('#externalStorage'), {
  1170. encryptionEnabled: encryptionEnabled
  1171. });
  1172. mountConfigListView.loadStorages();
  1173. // TODO: move this into its own View class
  1174. var $allowUserMounting = $('#allowUserMounting');
  1175. $allowUserMounting.bind('change', function() {
  1176. OC.msg.startSaving('#userMountingMsg');
  1177. if (this.checked) {
  1178. OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'yes');
  1179. $('input[name="allowUserMountingBackends\\[\\]"]').prop('checked', true);
  1180. $('#userMountingBackends').removeClass('hidden');
  1181. $('input[name="allowUserMountingBackends\\[\\]"]').eq(0).trigger('change');
  1182. } else {
  1183. OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'no');
  1184. $('#userMountingBackends').addClass('hidden');
  1185. }
  1186. OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('files_external', 'Saved')}});
  1187. });
  1188. $('input[name="allowUserMountingBackends\\[\\]"]').bind('change', function() {
  1189. OC.msg.startSaving('#userMountingMsg');
  1190. var userMountingBackends = $('input[name="allowUserMountingBackends\\[\\]"]:checked').map(function(){
  1191. return $(this).val();
  1192. }).get();
  1193. var deprecatedBackends = $('input[name="allowUserMountingBackends\\[\\]"][data-deprecate-to]').map(function(){
  1194. if ($.inArray($(this).data('deprecate-to'), userMountingBackends) !== -1) {
  1195. return $(this).val();
  1196. }
  1197. return null;
  1198. }).get();
  1199. userMountingBackends = userMountingBackends.concat(deprecatedBackends);
  1200. OC.AppConfig.setValue('files_external', 'user_mounting_backends', userMountingBackends.join());
  1201. OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('files_external', 'Saved')}});
  1202. // disable allowUserMounting
  1203. if(userMountingBackends.length === 0) {
  1204. $allowUserMounting.prop('checked', false);
  1205. $allowUserMounting.trigger('change');
  1206. }
  1207. });
  1208. $('#global_credentials').on('submit', function() {
  1209. var $form = $(this);
  1210. var uid = $form.find('[name=uid]').val();
  1211. var user = $form.find('[name=username]').val();
  1212. var password = $form.find('[name=password]').val();
  1213. var $submit = $form.find('[type=submit]');
  1214. $submit.val(t('files_external', 'Saving...'));
  1215. $.ajax({
  1216. type: 'POST',
  1217. contentType: 'application/json',
  1218. data: JSON.stringify({
  1219. uid: uid,
  1220. user: user,
  1221. password: password
  1222. }),
  1223. url: OC.generateUrl('apps/files_external/globalcredentials'),
  1224. dataType: 'json',
  1225. success: function() {
  1226. $submit.val(t('files_external', 'Saved'));
  1227. setTimeout(function(){
  1228. $submit.val(t('files_external', 'Save'));
  1229. }, 2500);
  1230. }
  1231. });
  1232. return false;
  1233. });
  1234. // global instance
  1235. OCA.External.Settings.mountConfig = mountConfigListView;
  1236. /**
  1237. * Legacy
  1238. *
  1239. * @namespace
  1240. * @deprecated use OCA.External.Settings.mountConfig instead
  1241. */
  1242. OC.MountConfig = {
  1243. saveStorage: _.bind(mountConfigListView.saveStorageConfig, mountConfigListView)
  1244. };
  1245. });
  1246. // export
  1247. OCA.External = OCA.External || {};
  1248. /**
  1249. * @namespace
  1250. */
  1251. OCA.External.Settings = OCA.External.Settings || {};
  1252. OCA.External.Settings.GlobalStorageConfig = GlobalStorageConfig;
  1253. OCA.External.Settings.UserStorageConfig = UserStorageConfig;
  1254. OCA.External.Settings.MountConfigListView = MountConfigListView;
  1255. })();