Skip to content

Commit

Permalink
Settings: VFS Mounting now has templates
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Nov 20, 2016
1 parent 78960f4 commit 489c61a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/packages/default/Settings/module-vfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
(function(Application, Window, Utils, API, VFS, GUI) {
'use strict';

var TEMPLATES = {
WebDAV: {
MountName: 'owncloud',
MountDescription: 'OwnCloud',
MountHost: 'http://localhost/remote.php/webdav/',
MountNamespace: 'DAV:',
MountUsername: function() {
return OSjs.Core.getHandler().getUserData().username;
}
}
};

function createMountWindow(win, scheme, selected, ondone) {

var nwin = new Window('SettingsMountWindow', {
Expand Down Expand Up @@ -61,6 +73,19 @@
return true;
}

function setTemplate(name) {
var tpl = TEMPLATES[name];
if ( tpl ) {
Object.keys(tpl).forEach(function(k) {
var val = tpl[k];
if ( typeof val === 'function' ) {
val = val();
}
scheme.find(self, k).set('value', val);
});
}
}

function done() {
var conn = {
transport: scheme.find(self, 'MountType').get('value'),
Expand Down Expand Up @@ -103,13 +128,19 @@
scheme.find(self, 'MountType').set('value', selected.transport);
scheme.find(self, 'MountName').set('value', selected.name);
scheme.find(self, 'MountDescription').set('value', selected.description);

if ( selected.options ) {
scheme.find(self, 'MountHost').set('value', selected.options.host);
scheme.find(self, 'MountNamespace').set('value', selected.options.ns);
scheme.find(self, 'MountUsername').set('value', selected.options.username);
scheme.find(self, 'MountPassword').set('value', selected.options.password);
scheme.find(self, 'MountCORS').set('value', selected.options.cors);
}
} else {
setTemplate(scheme.find(this, 'MountType').get('value'));
scheme.find(this, 'MountType').on('change', function(ev) {
setTemplate(ev.detail);
});
}

scheme.find(this, 'ButtonClose').on('click', function() {
Expand Down

0 comments on commit 489c61a

Please sign in to comment.