From bee724c53e243bda82c9490154fcd13079e41082 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Thu, 24 May 2012 11:06:03 -0400 Subject: [PATCH] Initial work on UI for mounting external storage --- apps/files_external/appinfo/app.php | 1 + apps/files_external/appinfo/info.xml | 2 +- apps/files_external/css/settings.css | 6 ++ apps/files_external/js/settings.js | 59 +++++++++++++++++ apps/files_external/settings.php | 35 ++++++++++ apps/files_external/templates/settings.php | 74 ++++++++++++++++++++++ 6 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 apps/files_external/css/settings.css create mode 100644 apps/files_external/js/settings.js create mode 100644 apps/files_external/settings.php create mode 100644 apps/files_external/templates/settings.php diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php index 784ed032d4..2940a07025 100644 --- a/apps/files_external/appinfo/app.php +++ b/apps/files_external/appinfo/app.php @@ -10,3 +10,4 @@ OC::$CLASSPATH['OC_Filestorage_FTP']='apps/files_external/lib/ftp.php'; OC::$CLASSPATH['OC_Filestorage_DAV']='apps/files_external/lib/webdav.php'; OC::$CLASSPATH['OC_Filestorage_Google']='apps/files_external/lib/google.php'; OC::$CLASSPATH['OC_Filestorage_SWIFT']='apps/files_external/lib/swift.php'; +OCP\App::registerAdmin('files_external', 'settings'); diff --git a/apps/files_external/appinfo/info.xml b/apps/files_external/appinfo/info.xml index c324730593..e0301365d1 100644 --- a/apps/files_external/appinfo/info.xml +++ b/apps/files_external/appinfo/info.xml @@ -4,7 +4,7 @@ External storage support Mount external storage sources AGPL - Robin Appelman + Robin Appelman, Michael Gapczynski 4 true diff --git a/apps/files_external/css/settings.css b/apps/files_external/css/settings.css new file mode 100644 index 0000000000..b11af752ec --- /dev/null +++ b/apps/files_external/css/settings.css @@ -0,0 +1,6 @@ +.error { color: #FF3B3B; } +td.type { width:8em; } +td.mount, td.options, td.applicable { width:10em; } +#addStorage>td { border:none; } +#addStorage>td:not(.selectStorage) { visibility:hidden; } +#selectStorage { margin-left:-10px; } \ No newline at end of file diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js new file mode 100644 index 0000000000..9a558ad6e4 --- /dev/null +++ b/apps/files_external/js/settings.js @@ -0,0 +1,59 @@ +$(document).ready(function(){ + + function applicableChange(applicable) { + if (applicable == 'Global') { + + } + console.log(applicable); + } + + $('#selectStorage').live('change', function() { + var tr = $(this).parent().parent(); + $('#externalStorage tbody').last().append($(tr).clone()); + var selected = $(this).val(); + $(this).parent().text(selected); + var backends = $(this).data('configurations').split(';'); + var configuration = []; + // Find selected backend configuration parameters + $.each(backends, function(index, backend) { + if (backend.split(':')[0] == selected) { + configuration = backend.split(':')[1].split(','); + // break; + } + }); + var td = $(tr).find('td.configuration'); + $.each(configuration, function(index, config) { + if (config.indexOf('*') != -1) { + td.append(''); + } else { + td.append(''); + } + }); + $(tr).find('td').last().attr('class', 'remove'); + $(tr).removeAttr('id'); + $(this).remove(); + }); + + $('td.remove>img').live('click', function() { + $(this).parent().parent().remove(); + // TODO remove storage + }); + + $('#externalStorage select[multiple]').each(function(index,element){ + applyMultiplySelect($(element)); + }); + + function applyMultiplySelect(element) { + var checkHandeler=false; + element.multiSelect({ + oncheck:applicableChange, + onuncheck:applicableChange, + minWidth: 120, + }); + } + + $('#allowUserMounting').bind('change', function() { + // TODO save setting + }); + +}); \ No newline at end of file diff --git a/apps/files_external/settings.php b/apps/files_external/settings.php new file mode 100644 index 0000000000..ce1b308d75 --- /dev/null +++ b/apps/files_external/settings.php @@ -0,0 +1,35 @@ +. +*/ + +OCP\Util::addscript('files_external', 'settings'); +OCP\Util::addstyle('files_external', 'settings'); +$tmpl = new OCP\Template('files_external', 'settings'); +$tmpl->assign('allowUserMounting', 'yes'); +$tmpl->assign('isAdminPage', true); +$tmpl->assign('storage', array()); +$tmpl->assign('groups', OC_Group::getGroups()); +$tmpl->assign('backends', array('Amazon S3', 'FTP', 'Google Drive', 'SWIFT', 'WebDAV')); +$tmpl->assign('configurations', ''); +$tmpl->assign('options', array('Encrypt', 'Version control', 'Allow sharing')); +return $tmpl->fetchPage(); + +?> \ No newline at end of file diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php new file mode 100644 index 0000000000..e34c032239 --- /dev/null +++ b/apps/files_external/templates/settings.php @@ -0,0 +1,74 @@ +
+
+ t('External Storage'); ?> + + + + + + + + + '.$l->t('Applicable').''; ?> + + + + + 'addStorage', 'mount' => ''))); ?> + + data-storage-id=""> + + + + + + + + + + + + + + + +
t('Type'); ?>t('Configuration'); ?>t('Mount Location'); ?>t('Options'); ?> 
+ + > + + $value): ?> + + + + + + + + + + + + ><?php echo $l->t('Delete'); ?>
+ + +
+ /> +
+ t('Allow users to mount their own external storage'); ?> + +
+
\ No newline at end of file